diff options
author | Naseer Ahmed <naseer@codeaurora.org> | 2014-10-10 12:53:13 -0400 |
---|---|---|
committer | Naseer Ahmed <naseer@codeaurora.org> | 2015-03-02 14:54:49 -0500 |
commit | 251c030307209b90621b10967560727ed8790bb2 (patch) | |
tree | 682e2c822027f7197f8376c8b4b9871a6f1dabfd /hdmi_cec | |
parent | 7a7b66d1f03997b19ddc0b630dc36850c7826d97 (diff) | |
download | display-251c030307209b90621b10967560727ed8790bb2.tar.gz |
qcom: display: CEC bugfixes
* Correctly read and pass physical address
* Handle system control
* Use Google Vendor ID
Change-Id: I964fb4b590a0b952d7c8290aef6365d62a2418f0
Diffstat (limited to 'hdmi_cec')
-rw-r--r-- | hdmi_cec/QHDMIClient.cpp | 3 | ||||
-rw-r--r-- | hdmi_cec/qhdmi_cec.cpp | 41 | ||||
-rw-r--r-- | hdmi_cec/qhdmi_cec.h | 1 |
3 files changed, 32 insertions, 13 deletions
diff --git a/hdmi_cec/QHDMIClient.cpp b/hdmi_cec/QHDMIClient.cpp index 176779a4..2b2b1e6f 100644 --- a/hdmi_cec/QHDMIClient.cpp +++ b/hdmi_cec/QHDMIClient.cpp @@ -27,6 +27,7 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define DEBUG 0 #include <QServiceUtils.h> #include "QHDMIClient.h" @@ -49,7 +50,7 @@ void QHDMIClient::onHdmiHotplug(int connected) void QHDMIClient::onCECMessageRecieved(char *msg, ssize_t len) { - ALOGD("%s: CEC message received len: %zd", __FUNCTION__, len); + ALOGD_IF(DEBUG, "%s: CEC message received len: %zd", __FUNCTION__, len); cec_receive_message(mCtx, msg, len); } diff --git a/hdmi_cec/qhdmi_cec.cpp b/hdmi_cec/qhdmi_cec.cpp index 056cea1e..a6fcee80 100644 --- a/hdmi_cec/qhdmi_cec.cpp +++ b/hdmi_cec/qhdmi_cec.cpp @@ -189,10 +189,17 @@ static int cec_get_physical_address(const struct hdmi_cec_device* dev, uint16_t* addr) { cec_context_t* ctx = (cec_context_t*)(dev); - //XXX: Not sure if this physical address is the same as the one in port info - *addr = ctx->port_info[0].physical_address; + char pa_path[MAX_PATH_LENGTH]; + char pa_data[MAX_SYSFS_DATA]; + snprintf (pa_path, sizeof(pa_path),"%s/pa", + ctx->fb_sysfs_path); + int err = (int) read_node(pa_path, pa_data); + *addr = (uint16_t) atoi(pa_data); ALOGD_IF(DEBUG, "%s: Physical Address: 0x%x", __FUNCTION__, *addr); - return 0; + if (err < 0) + return err; + else + return 0; } static int cec_send_message(const struct hdmi_cec_device* dev, @@ -268,6 +275,9 @@ static int cec_send_message(const struct hdmi_cec_device* dev, void cec_receive_message(cec_context_t *ctx, char *msg, ssize_t len) { + if(!ctx->system_control) + return; + char dump[128]; if(len > 0) { hex_to_string(msg, len, dump); @@ -290,6 +300,9 @@ void cec_receive_message(cec_context_t *ctx, char *msg, ssize_t len) void cec_hdmi_hotplug(cec_context_t *ctx, int connected) { + //Ignore unplug events when system control is disabled + if(!ctx->system_control && connected == 0) + return; hdmi_event_t event; event.type = HDMI_EVENT_HOT_PLUG; event.dev = (hdmi_cec_device *) ctx; @@ -334,16 +347,19 @@ static void cec_set_option(const struct hdmi_cec_device* dev, int flag, int value) { cec_context_t* ctx = (cec_context_t*)(dev); - ALOGD_IF(DEBUG, "%s: flag:%d value:%d", __FUNCTION__, flag, value); switch (flag) { case HDMI_OPTION_WAKEUP: + ALOGD_IF(DEBUG, "%s: Wakeup: value: %d", __FUNCTION__, value); //XXX break; case HDMI_OPTION_ENABLE_CEC: + ALOGD_IF(DEBUG, "%s: Enable CEC: value: %d", __FUNCTION__, value); cec_enable(ctx, value? 1 : 0); break; case HDMI_OPTION_SYSTEM_CEC_CONTROL: - //XXX + ALOGD_IF(DEBUG, "%s: system_control: value: %d", + __FUNCTION__, value); + ctx->system_control = !!value; break; } } @@ -370,7 +386,7 @@ static int cec_is_connected(const struct hdmi_cec_device* dev, int port_id) ALOGD_IF(DEBUG, "%s: HDMI at port %d is - %s", __FUNCTION__, port_id, connected ? "connected":"disconnected"); - if (err) + if (err < 0) return (int) err; else return connected; @@ -392,7 +408,10 @@ static int cec_device_close(struct hw_device_t *dev) static int cec_enable(cec_context_t *ctx, int enable) { ssize_t err; - err = write_int_to_node(ctx, "cec/enable", !!enable); + // Enable CEC + // TODO: Set to 0x3 to enable CEC wakeup once driver has support + int value = enable ? 0x1 : 0x0; + err = write_int_to_node(ctx, "cec/enable", value); if(err < 0) { ALOGE("%s: Failed to toggle CEC: enable: %d", __FUNCTION__, enable); @@ -410,17 +429,15 @@ static void cec_init_context(cec_context_t *ctx) //Initialize ports - We support only one output port ctx->port_info = new hdmi_port_info[NUM_HDMI_PORTS]; ctx->port_info[0].type = HDMI_OUTPUT; - //XXX: Updated l-dev has port_id field ctx->port_info[0].port_id = 1; ctx->port_info[0].cec_supported = 1; //XXX: Enable ARC if supported ctx->port_info[0].arc_supported = 0; - //XXX: Get physical address from driver - ctx->port_info[0].physical_address = 0x1000; + cec_get_physical_address((hdmi_cec_device *) ctx, + &ctx->port_info[0].physical_address ); ctx->version = 0x4; - //XXX: Get vendor ID from driver - this is currently a placeholder value - ctx->vendor_id = 0x4571; + ctx->vendor_id = 0xA47733; cec_clear_logical_address((hdmi_cec_device_t*)ctx); //Set up listener for HDMI events diff --git a/hdmi_cec/qhdmi_cec.h b/hdmi_cec/qhdmi_cec.h index 4afd07fb..aa97620a 100644 --- a/hdmi_cec/qhdmi_cec.h +++ b/hdmi_cec/qhdmi_cec.h @@ -54,6 +54,7 @@ struct cec_context_t { cec_callback_t callback; // Struct storing callback object bool enabled; bool arc_enabled; + bool system_control; // If true, HAL/driver handle CEC messages int fb_num; // Framebuffer node for HDMI char fb_sysfs_path[MAX_PATH_LENGTH]; hdmi_port_info *port_info; // HDMI port info |