From b0f8ecf939caf1724c64323e4115d4158075b5ed Mon Sep 17 00:00:00 2001 From: hongmin hua Date: Thu, 2 Aug 2018 20:33:23 +0800 Subject: [PATCH] cec: add the port info and connect status for audio system PD#170794: cec: add the port info and connect status for audio system Change-Id: I433788d4f5fcbb3164f894ebc0f6827dd47b0633 Signed-off-by: hongmin hua Signed-off-by: Xindong Xu --- arch/arm64/boot/dts/amlogic/atom.dts | 4 +- .../boot/dts/amlogic/txlx_t962e_r321.dts | 5 +- drivers/amlogic/cec/hdmi_ao_cec.c | 67 +++++++++---------- drivers/amlogic/cec/hdmi_ao_cec.h | 2 +- 4 files changed, 37 insertions(+), 41 deletions(-) diff --git a/arch/arm64/boot/dts/amlogic/atom.dts b/arch/arm64/boot/dts/amlogic/atom.dts index 2aef68325476..9645d2171e42 100644 --- a/arch/arm64/boot/dts/amlogic/atom.dts +++ b/arch/arm64/boot/dts/amlogic/atom.dts @@ -972,7 +972,8 @@ cec_osd_string = "AML_TV"; /* Max Chars: 14 */ port_num = <4>; ee_cec; - arc_port_mask = <0x2>; + output = <1>; + arc_port_mask = <0x8>; interrupts = <0 205 1 0 199 1>; interrupt-names = "hdmi_aocecb","hdmi_aocec"; @@ -982,6 +983,7 @@ pinctrl-2=<&hdmitx_aocecb>; reg = <0x0 0xFF80023c 0x0 0x4 0x0 0xFF800000 0x0 0x400>; + reg-names = "ao_exit","ao"; }; diff --git a/arch/arm64/boot/dts/amlogic/txlx_t962e_r321.dts b/arch/arm64/boot/dts/amlogic/txlx_t962e_r321.dts index af1c9842938b..aead155ab741 100644 --- a/arch/arm64/boot/dts/amlogic/txlx_t962e_r321.dts +++ b/arch/arm64/boot/dts/amlogic/txlx_t962e_r321.dts @@ -967,9 +967,10 @@ vendor_id = <0x000000>; product_desc = "TXLX"; /* Max Chars: 16 */ cec_osd_string = "AML_TV"; /* Max Chars: 14 */ - port_num = <3>; + port_num = <4>; ee_cec; - arc_port_mask = <0x2>; + output = <1>; + arc_port_mask = <0x8>; interrupts = <0 205 1 0 199 1>; interrupt-names = "hdmi_aocecb","hdmi_aocec"; diff --git a/drivers/amlogic/cec/hdmi_ao_cec.c b/drivers/amlogic/cec/hdmi_ao_cec.c index 373381d16db4..d2dced29a01a 100644 --- a/drivers/amlogic/cec/hdmi_ao_cec.c +++ b/drivers/amlogic/cec/hdmi_ao_cec.c @@ -104,6 +104,7 @@ struct ao_cec_dev { struct device_node *node; unsigned int port_num; unsigned int arc_port; + unsigned int output; unsigned int hal_flag; unsigned int phy_addr; unsigned int port_seq; @@ -2312,13 +2313,9 @@ static void init_cec_port_info(struct hdmi_port_info *port, } else break; } - if ((cec_dev->dev_type == DEV_TYPE_TUNER) || - (cec_dev->dev_type == DEV_TYPE_PLAYBACK) || - (cec_dev->dev_type == DEV_TYPE_AUDIO_SYSTEM)) - b = cec_dev->port_num - 1; - else - b = cec_dev->port_num; + b = cec_dev->port_num; + CEC_ERR("%s phy_addr:%x, port num:%x\n", __func__, phy_addr, b); /* init for port info */ for (a = 0; a < sizeof(cec_dev->port_seq) * 2; a++) { /* set port physical address according port sequence */ @@ -2327,36 +2324,33 @@ static void init_cec_port_info(struct hdmi_port_info *port, if (c == 0xf) { /* not used */ CEC_INFO("port %d is not used\n", a); continue; - } else if (!c) - break; + } port[e].physical_address = (c) * phy_app + phy_addr; - } else { + } else /* asending order if port_seq is not set */ - port[e].physical_address = (e + 1) * phy_app + phy_addr; + port[e].physical_address = (a + 1) * phy_app + phy_addr; + if ((e + cec_dev->output) == b) { + port[e].physical_address = phy_addr; + port[e].port_id = 0; + port[e].type = HDMI_OUTPUT; + } else { + port[e].type = HDMI_INPUT; + port[e].port_id = a + 1; } - port[e].type = HDMI_INPUT; - port[e].port_id = a + 1; port[e].cec_supported = 1; /* set ARC feature according mask */ - if (cec_dev->arc_port & (1 << a)) + if (cec_dev->arc_port & (1 << e)) port[e].arc_supported = 1; else port[e].arc_supported = 0; + CEC_ERR("%s port:%d arc:%d phy:%x,type:%d\n", __func__, + port[e].port_id, port[e].arc_supported, + port[e].physical_address, + port[e].type); e++; if (e >= b) break; } - - if ((cec_dev->dev_type == DEV_TYPE_TUNER) || - (cec_dev->dev_type == DEV_TYPE_PLAYBACK) || - (cec_dev->dev_type == DEV_TYPE_AUDIO_SYSTEM)) { - /* last port is for tx in mixed tx/rx */ - port[e].type = HDMI_OUTPUT; - port[e].port_id = 0; /* 0 for tx port id */ - port[e].cec_supported = 1; - port[e].arc_supported = 0; - port[e].physical_address = phy_addr; - } } static long hdmitx_cec_ioctl(struct file *f, @@ -2527,20 +2521,15 @@ static long hdmitx_cec_ioctl(struct file *f, mutex_unlock(&cec_dev->cec_ioctl_mutex); return -EINVAL; } - if (!a && cec_dev->dev_type == DEV_TYPE_TUNER) - tmp = tx_hpd; - else { /* mixed for rx */ + /* mixed for rx & tx */ + if (a != 0) { tmp = hdmirx_get_connect_info(); - if (a >= 1) { - if (tmp & (1 << (a - 1))) - tmp = 1; - else - tmp = 0; - } else { + if (tmp & (1 << (a - 1))) + tmp = 1; + else tmp = 0; - CEC_INFO("err port number %d\n", a); - } - } + } else + tmp = tx_hpd; } if (copy_to_user(argp, &tmp, _IOC_SIZE(cmd))) { mutex_unlock(&cec_dev->cec_ioctl_mutex); @@ -2917,7 +2906,11 @@ static int aml_cec_probe(struct platform_device *pdev) CEC_ERR("not find 'arc_port_mask'\n"); cec_dev->arc_port = 0; } - + r = of_property_read_u32(node, "output", &(cec_dev->output)); + if (r) { + CEC_ERR("not find 'output'\n"); + cec_dev->output = 0; + } vend = &cec_dev->v_data; r = of_property_read_string(node, "vendor_name", (const char **)&(vend->vendor_name)); diff --git a/drivers/amlogic/cec/hdmi_ao_cec.h b/drivers/amlogic/cec/hdmi_ao_cec.h index fb171ebc5677..36aefd844117 100644 --- a/drivers/amlogic/cec/hdmi_ao_cec.h +++ b/drivers/amlogic/cec/hdmi_ao_cec.h @@ -18,7 +18,7 @@ #ifndef __AO_CEC_H__ #define __AO_CEC_H__ -#define CEC_DRIVER_VERSION "Ver 2018/08/01\n" +#define CEC_DRIVER_VERSION "Ver 2018/08/06\n" #define CEC_FRAME_DELAY msecs_to_jiffies(400) #define CEC_DEV_NAME "cec" -- 2.20.1