1
0
Fork 0

rockchip: minor fixes for hdmi_cec device module

Signed-off-by: hmz007 <hmz007@gmail.com>
master
hmz007 2 years ago
parent d7d5b8f256
commit 055661789d

@ -483,14 +483,14 @@ static int hdmi_cec_device_open(const struct hw_module_t* module, const char* na
dev->device.set_audio_return_channel = hdmi_cec_set_audio_return_channel; dev->device.set_audio_return_channel = hdmi_cec_set_audio_return_channel;
dev->device.is_connected = hdmi_cec_is_connected; dev->device.is_connected = hdmi_cec_is_connected;
dev->phy_addr = 0; dev->phy_addr = 0;
dev->fd = open(HDMI_DEV_PATH,O_RDWR,0); dev->fd = open(HDMI_DEV_PATH,O_RDWR,0);
ALOGE(HDMI_DEV_PATH);
ALOGE("\n");
if (dev->fd < 0) { if (dev->fd < 0) {
ALOGE("%s open error!", __func__); ALOGE("%s failed to open %s, %d", __func__, HDMI_DEV_PATH, errno);
ALOGE("cec %s\n", strerror(errno)); } else {
ALOGI("%s dev->fd = %d", __func__, dev->fd);
} }
ALOGI("%s dev->fd = %d", __func__, dev->fd);
property_set("vendor.sys.hdmicec.version",HDMI_CEC_HAL_VERSION); property_set("vendor.sys.hdmicec.version",HDMI_CEC_HAL_VERSION);
*device = &dev->device.common; *device = &dev->device.common;
init_uevent_thread(dev); init_uevent_thread(dev);

@ -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;
} }
} }

Loading…
Cancel
Save