From 2466bb68976d078cc36ccddd98e2e3f1e55147b8 Mon Sep 17 00:00:00 2001 From: Per Persson Date: Wed, 21 Sep 2011 14:02:43 +0200 Subject: HDMIservice: Improve error handling CEC received message with invalid length is handled. Plug and unplug is filtered to avoid duplicate events. ST-Ericsson ID: 363062 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10177 Change-Id: I989fab8e6b5504a5c4652aaac4f36d18fe8faa37 Signed-off-by: Per Persson Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/31658 Reviewed-by: QATOOLS Reviewed-by: QABUILD Reviewed-by: QATEST Reviewed-by: Jimmy RUBIN Reviewed-by: Robert FEKETE --- src/cec.c | 3 +++ src/hdmi_service.c | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/cec.c b/src/cec.c index 30c95d8..4b6acf5 100644 --- a/src/cec.c +++ b/src/cec.c @@ -155,6 +155,9 @@ int cecrx(void) cecsize = read(cecreadfd, buf, sizeof(buf)); close(cecreadfd); + if (cecsize < 0) + return -1; + for (cnt = 0; cnt < cecsize; cnt++) LOGHDMILIB2("cecrx[%d]:%x", cnt, buf[cnt]); diff --git a/src/hdmi_service.c b/src/hdmi_service.c index ac10fee..fd2b174 100644 --- a/src/hdmi_service.c +++ b/src/hdmi_service.c @@ -340,9 +340,15 @@ static int hdmiplugged_handle(int *basic_audio_support) struct edid_latency edid_latency = {-1, -1, -1, -1}; int res; int ret = 0; + enum hdmi_plug_state plug_state; LOGHDMILIB("%s", "HDMIEVENT_HDMIPLUGGED"); + if ((plugstate_get(&plug_state) == 0) && (plug_state == HDMI_PLUGGED)) { + LOGHDMILIB("%s", "Already plugged, ignore"); + return -1; + } + plugstate_set(HDMI_PLUGGED); *basic_audio_support = 0; video_formats_clear(); @@ -466,7 +472,16 @@ hdmiplugged_handle_end: static int hdmiunplugged_handle(void) { + enum hdmi_plug_state plug_state; + LOGHDMILIB("%s", "HDMIEVENT_HDMIUNPLUGGED"); + + if ((plugstate_get(&plug_state) == 0) && + (plug_state == HDMI_UNPLUGGED)) { + LOGHDMILIB("%s", "Already unplugged, ignore"); + return -1; + } + plugstate_set(HDMI_UNPLUGGED); /* Allow early suspend */ @@ -870,8 +885,8 @@ static void thread_main_fn(void *arg) video_supported); } } else if (events & HDMIEVENT_HDMIUNPLUGGED) { - hdmiunplugged_handle(); - plugevent_send(HDMI_UNPLUGGED_EV, 0, 0, NULL); + if (hdmiunplugged_handle() == 0) + plugevent_send(HDMI_UNPLUGGED_EV, 0, 0, NULL); } if (events & HDMIEVENT_CEC) -- cgit v1.2.3