From 986aec1bc94434caf356dfc7f1ee83e1833c1885 Mon Sep 17 00:00:00 2001 From: Tao Zeng Date: Fri, 24 Jun 2016 06:34:27 +0000 Subject: PD#127058: get port status when boot to avoid double initialize Logical address will be initialized by hot-plug and boot. Change-Id: I0a7da0c108bd7d583fca01e3154e700d41751a38 --- diff --git a/hdmi_cec.c b/hdmi_cec.c index a8d292d..b87a8bd 100644 --- a/hdmi_cec.c +++ b/hdmi_cec.c @@ -528,6 +528,34 @@ static void cec_set_option(const struct hdmi_cec_device* dev, int flag, int valu } /* + * get connect status when boot + */ +static void get_boot_connect_status(struct aml_cec_hal *hal_info) +{ + unsigned int total; + int i, port, ret; + + ret = ioctl(hal_info->fd, CEC_IOC_GET_PORT_NUM, &total); + D("total port:%d, ret:%d\n", total, ret); + if (ret < 0) + return ; + + if (total > MAX_PORT) + total = MAX_PORT; + hal_info->con_status = 0; + for (i = 0; i < total; i++) { + port = i + 1; + ret = ioctl(hal_info->fd, CEC_IOC_GET_CONNECT_STATUS, &port); + if (ret) { + D("get port %d connected status failed, ret:%d\n", i, ret); + continue; + } + hal_info->con_status |= ((port ? 1 : 0) << i); + } + D("con_status:%x\n", hal_info->con_status); +} + +/* * (*set_audio_return_channel)() configures ARC circuit in the hardware logic * to start or stop the feature. Flag can be either 1 to start the feature * or 0 to stop it. @@ -665,6 +693,7 @@ static int open_cec( const struct hw_module_t* module, char const *name, return -EINVAL; } ret = ioctl(hal_info->fd, CEC_IOC_SET_DEV_TYPE, hal_info->device_type); + get_boot_connect_status(hal_info); pthread_create(&hal_info->ThreadId, NULL, cec_rx_loop, hal_info); pthread_setname_np(hal_info->ThreadId, "cec_rx_loop"); -- cgit