|
|
@ -32,6 +32,7 @@
|
|
|
|
#include <hdmicec.h>
|
|
|
|
#include <hdmicec.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
#include <cutils/properties.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define HDMI_CEC_UEVENT_THREAD_NAME "HdmiCecThread"
|
|
|
|
#define HDMI_CEC_UEVENT_THREAD_NAME "HdmiCecThread"
|
|
|
|
|
|
|
|
|
|
|
@ -102,13 +103,14 @@ static void *uevent_loop(void *param)
|
|
|
|
struct pollfd pfd[2];
|
|
|
|
struct pollfd pfd[2];
|
|
|
|
int fd[2];
|
|
|
|
int fd[2];
|
|
|
|
int ret, i;
|
|
|
|
int ret, i;
|
|
|
|
|
|
|
|
bool cec_debug = property_get_bool("vendor.sys.hdmicec.debug", false);
|
|
|
|
|
|
|
|
|
|
|
|
prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0);
|
|
|
|
prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0);
|
|
|
|
setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
|
|
|
|
setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY);
|
|
|
|
|
|
|
|
|
|
|
|
fd[0] = ctx->fd;
|
|
|
|
fd[0] = ctx->fd;
|
|
|
|
if (fd[0] < 0) {
|
|
|
|
if (fd[0] < 0) {
|
|
|
|
ALOGE ("%s:not able to open cec state node", __func__);
|
|
|
|
ALOGE ("%s: unable to open cec state node", __func__);
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -117,20 +119,20 @@ static void *uevent_loop(void *param)
|
|
|
|
pfd[0].events = POLLIN | POLLRDNORM | POLLPRI;
|
|
|
|
pfd[0].events = POLLIN | POLLRDNORM | POLLPRI;
|
|
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
while (true) {
|
|
|
|
usleep(1000);
|
|
|
|
// usleep(1000);
|
|
|
|
int err = poll(&pfd[0], 1, 20);
|
|
|
|
int err = poll(&pfd[0], 1, -1);
|
|
|
|
|
|
|
|
|
|
|
|
if (!err) {
|
|
|
|
if (!err) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
} else if(err > 0) {
|
|
|
|
} else if (err > 0) {
|
|
|
|
if (!ctx->enable || !ctx->system_control)
|
|
|
|
if (!ctx->enable || !ctx->system_control)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
ALOGD("poll revent:%02x\n", pfd[0].revents);
|
|
|
|
if (cec_debug) ALOGD("poll revent:%02x\n", pfd[0].revents);
|
|
|
|
memset(&cec_event, 0, sizeof(hdmi_event_t));
|
|
|
|
memset(&cec_event, 0, sizeof(hdmi_event_t));
|
|
|
|
if (pfd[0].revents & (POLLIN)) {
|
|
|
|
if (pfd[0].revents & (POLLIN)) {
|
|
|
|
struct cec_msg cecframe;
|
|
|
|
struct cec_msg cecframe;
|
|
|
|
|
|
|
|
|
|
|
|
ALOGD("poll receive msg\n");
|
|
|
|
if (cec_debug) ALOGD("poll receive msg\n");
|
|
|
|
ret = ioctl(pfd[0].fd, CEC_RECEIVE, &cecframe);
|
|
|
|
ret = ioctl(pfd[0].fd, CEC_RECEIVE, &cecframe);
|
|
|
|
if (!ret) {
|
|
|
|
if (!ret) {
|
|
|
|
cec_event.type = HDMI_EVENT_CEC_MESSAGE;
|
|
|
|
cec_event.type = HDMI_EVENT_CEC_MESSAGE;
|
|
|
@ -142,8 +144,9 @@ static void *uevent_loop(void *param)
|
|
|
|
if (!validcecmessage(cec_event)) {
|
|
|
|
if (!validcecmessage(cec_event)) {
|
|
|
|
for (ret = 0; ret < cec_event.cec.length; ret++)
|
|
|
|
for (ret = 0; ret < cec_event.cec.length; ret++)
|
|
|
|
cec_event.cec.body [ret + 1] = cecframe.msg[ret + 2];
|
|
|
|
cec_event.cec.body [ret + 1] = cecframe.msg[ret + 2];
|
|
|
|
for (i = 0; i < cecframe.len; i++)
|
|
|
|
for (i = 0; i < cecframe.len; i++) {
|
|
|
|
ALOGD("poll receive msg[%d]:%02x\n", i, cecframe.msg[i]);
|
|
|
|
if (cec_debug) ALOGD("poll receive msg[%d]:%02x\n", i, cecframe.msg[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (ctx->event_callback)
|
|
|
|
if (ctx->event_callback)
|
|
|
|
ctx->event_callback(&cec_event, ctx->cec_arg);
|
|
|
|
ctx->event_callback(&cec_event, ctx->cec_arg);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -213,8 +216,7 @@ static void *uevent_loop(void *param)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ALOGE("%s: cec poll failed errno: %s", __FUNCTION__,
|
|
|
|
ALOGE("%s: cec poll failed errno: %s", __FUNCTION__, strerror(errno));
|
|
|
|
strerror(errno));
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|