From 7c642b38362af69db86e4114e669d1aa209bfd50 Mon Sep 17 00:00:00 2001 From: hereticmaggot Date: Tue, 21 Jun 2016 11:52:40 +0200 Subject: [PATCH 01/10] Add latest commit from Raybuntu --- drivers/amlogic/cec/hdmi_ao_cec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/amlogic/cec/hdmi_ao_cec.c b/drivers/amlogic/cec/hdmi_ao_cec.c index 21ca8bbdf6c6a5..a21faf7b36c6bf 100644 --- a/drivers/amlogic/cec/hdmi_ao_cec.c +++ b/drivers/amlogic/cec/hdmi_ao_cec.c @@ -996,6 +996,9 @@ int cec_node_init(struct hdmitx_dev *hdmitx_device) if ((cec_dev->hal_flag & (1 << HDMI_OPTION_SYSTEM_CEC_CONTROL))) return -1; + if (!(hdmitx_device->cec_func_config & (1 << CEC_FUNC_MSAK))) + return -1; + CEC_INFO("cec_node_init started\n"); cec_phy_addr = ((a << 12) | (b << 8) | (c << 4) | (d << 0)); From 224e0753c1cfd2405fba084856e58cab13ce0f6e Mon Sep 17 00:00:00 2001 From: hereticmaggot Date: Tue, 21 Jun 2016 11:53:36 +0200 Subject: [PATCH 02/10] add latest commit from Raybuntu From a768b30431680046c8f6e430949bb6994660614b Mon Sep 17 00:00:00 2001 From: hereticmaggot Date: Tue, 21 Jun 2016 11:54:03 +0200 Subject: [PATCH 03/10] Add latest commit from Raybuntu From b7f80cee07f510173ee9bb3bff380614ba73f3cb Mon Sep 17 00:00:00 2001 From: hereticmaggot Date: Tue, 21 Jun 2016 19:23:55 +0200 Subject: [PATCH 04/10] [aocec] prevent unecessary node init's on Sony TVs --- drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_main.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_main.c b/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_main.c index 57105b62eda6e6..f05fe8f73a5a1b 100644 --- a/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_main.c +++ b/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_main.c @@ -495,11 +495,7 @@ static int set_disp_mode_auto(void) if ((vic_ready != HDMI_Unkown) && (vic_ready == vic)) { hdmi_print(IMP, SYS "[%s] ALREADY init VIC = %d\n", __func__, vic); -#if defined(CONFIG_ARCH_MESON64_ODROIDC2) - if (hdmitx_device.RXCap.IEEEOUI == 0 || odroidc_voutmode()) { -#else if (hdmitx_device.RXCap.IEEEOUI == 0) { -#endif /* DVI case judgement. In uboot, directly output HDMI * mode */ @@ -981,10 +977,6 @@ const char *disp_mode_t[] = { "1600x900p60hz", "1680x1050p60hz", "1920x1200p60hz", - "2560x1440p60hz", - "2560x1600p60hz", - "2560x1080p60hz", - "3440x1440p60hz", NULL }; @@ -1559,7 +1551,9 @@ void hdmitx_hpd_plugin_handler(struct work_struct *work) set_disp_mode_auto(); hdmitx_set_audio(hdev, &(hdev->cur_audio_param), hdmi_ch); switch_set_state(&sdev, 1); +#ifndef CONFIG_AML_AO_CEC cec_node_init(hdev); +#endif hdev->hdmitx_event &= ~HDMI_TX_HPD_PLUGIN; mutex_unlock(&setclk_mutex); } @@ -2471,9 +2465,6 @@ static int __init hdmitx_boot_para_setup(char *s) hdmitx_device.cec_func_config = list; hdmi_print(INF, CEC "HDMI hdmi_cec_func_config:0x%x\n", hdmitx_device.cec_func_config); - } else if (strcmp(token, "forcergb") == 0) { - hdmitx_output_rgb(); - hdmi_print(IMP, "Forced RGB colorspace output\n"); } } offset = token_offset; From e3dab09a63fbfa0ee3d70f9bf5f5b46a0d18348b Mon Sep 17 00:00:00 2001 From: hereticmaggot Date: Tue, 21 Jun 2016 19:24:40 +0200 Subject: [PATCH 05/10] [aocec] send inactive source before the switch --- drivers/amlogic/cec/hdmi_ao_cec.c | 36 +++++++++++++------------------ 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/amlogic/cec/hdmi_ao_cec.c b/drivers/amlogic/cec/hdmi_ao_cec.c index a21faf7b36c6bf..1e41f9e1588661 100644 --- a/drivers/amlogic/cec/hdmi_ao_cec.c +++ b/drivers/amlogic/cec/hdmi_ao_cec.c @@ -116,7 +116,7 @@ static int cec_tx_result; static unsigned char rx_msg[MAX_MSG]; static unsigned char rx_len; static unsigned int new_msg; -bool cec_msg_dbg_en = 0; +bool cec_msg_dbg_en = 1; #define CEC_ERR(format, args...) \ {if (cec_dev->dbg_dev) \ @@ -467,27 +467,19 @@ static int cec_ll_trigle_tx(const unsigned char *msg, int len) unsigned int j = 20; unsigned tx_stat; static int cec_timeout_cnt = 1; - int flag = 0; while (1) { tx_stat = aocec_rd_reg(CEC_TX_MSG_STATUS); if (tx_stat != TX_BUSY) break; - if (!flag && tx_stat == TX_BUSY) { - CEC_INFO("TX is busy. Sending TX_ABORT\n"); - aocec_wr_reg(CEC_TX_MSG_CMD, TX_ABORT); - flag = 1; - } - if (!(j--)) { - CEC_INFO("TX is still busy. Sending TX_NO_OP\n"); - aocec_wr_reg(CEC_TX_MSG_CMD, TX_NO_OP); + CEC_INFO("wating busy timeout\n"); + aocec_wr_reg(CEC_TX_MSG_CMD, TX_ABORT); cec_timeout_cnt++; - if (cec_timeout_cnt > 0x08) { + if (cec_timeout_cnt > 0x08) cec_hw_reset(); - break; - } + break; } msleep(20); } @@ -577,7 +569,7 @@ int cec_ll_tx(const unsigned char *msg, unsigned char len) cec_tx_result = 0; ret = wait_for_completion_timeout(&cec_dev->tx_ok, timeout); if (ret <= 0) { - /* timeout of interrupt */ + /* timeout or interrupt */ ret = CEC_FAIL_OTHER; CEC_INFO("tx timeout\n"); } else { @@ -996,9 +988,6 @@ int cec_node_init(struct hdmitx_dev *hdmitx_device) if ((cec_dev->hal_flag & (1 << HDMI_OPTION_SYSTEM_CEC_CONTROL))) return -1; - if (!(hdmitx_device->cec_func_config & (1 << CEC_FUNC_MSAK))) - return -1; - CEC_INFO("cec_node_init started\n"); cec_phy_addr = ((a << 12) | (b << 8) | (c << 4) | (d << 0)); @@ -1236,10 +1225,9 @@ static void cec_rx_process(void) cec_send_simplink_ack(); } break; - case CEC_OC_DEVICE_VENDOR_ID: - break; default: + CEC_ERR("unsupported command:%x\n", opcode); break; } new_msg = 0; @@ -1648,10 +1636,16 @@ static long hdmitx_cec_ioctl(struct file *f, case CEC_IOC_SET_OPTION_SYS_CTRL: tmp = (1 << HDMI_OPTION_SYSTEM_CEC_CONTROL); - if (arg) + if (arg){ + if (cec_dev->cec_info.log_addr[0] != 0) { + cec_inactive_source(CEC_BROADCAST_ADDR); + cec_menu_status_smp(CEC_TV_ADDR, DEVICE_MENU_INACTIVE); + } cec_dev->hal_flag |= tmp; - else + } + else { cec_dev->hal_flag &= ~(tmp); + } break; case CEC_IOC_SET_OPTION_SET_LANG: From 2414aba06cb9159336a478aadd6c0d5df75a6566 Mon Sep 17 00:00:00 2001 From: hereticmaggot Date: Thu, 23 Jun 2016 08:30:06 +0200 Subject: [PATCH 06/10] revert --- drivers/amlogic/cec/hdmi_ao_cec.c | 33 +++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/amlogic/cec/hdmi_ao_cec.c b/drivers/amlogic/cec/hdmi_ao_cec.c index 1e41f9e1588661..21ca8bbdf6c6a5 100644 --- a/drivers/amlogic/cec/hdmi_ao_cec.c +++ b/drivers/amlogic/cec/hdmi_ao_cec.c @@ -116,7 +116,7 @@ static int cec_tx_result; static unsigned char rx_msg[MAX_MSG]; static unsigned char rx_len; static unsigned int new_msg; -bool cec_msg_dbg_en = 1; +bool cec_msg_dbg_en = 0; #define CEC_ERR(format, args...) \ {if (cec_dev->dbg_dev) \ @@ -467,19 +467,27 @@ static int cec_ll_trigle_tx(const unsigned char *msg, int len) unsigned int j = 20; unsigned tx_stat; static int cec_timeout_cnt = 1; + int flag = 0; while (1) { tx_stat = aocec_rd_reg(CEC_TX_MSG_STATUS); if (tx_stat != TX_BUSY) break; + if (!flag && tx_stat == TX_BUSY) { + CEC_INFO("TX is busy. Sending TX_ABORT\n"); + aocec_wr_reg(CEC_TX_MSG_CMD, TX_ABORT); + flag = 1; + } + if (!(j--)) { - CEC_INFO("wating busy timeout\n"); - aocec_wr_reg(CEC_TX_MSG_CMD, TX_ABORT); + CEC_INFO("TX is still busy. Sending TX_NO_OP\n"); + aocec_wr_reg(CEC_TX_MSG_CMD, TX_NO_OP); cec_timeout_cnt++; - if (cec_timeout_cnt > 0x08) + if (cec_timeout_cnt > 0x08) { cec_hw_reset(); - break; + break; + } } msleep(20); } @@ -569,7 +577,7 @@ int cec_ll_tx(const unsigned char *msg, unsigned char len) cec_tx_result = 0; ret = wait_for_completion_timeout(&cec_dev->tx_ok, timeout); if (ret <= 0) { - /* timeout or interrupt */ + /* timeout of interrupt */ ret = CEC_FAIL_OTHER; CEC_INFO("tx timeout\n"); } else { @@ -1225,9 +1233,10 @@ static void cec_rx_process(void) cec_send_simplink_ack(); } break; + case CEC_OC_DEVICE_VENDOR_ID: + break; default: - CEC_ERR("unsupported command:%x\n", opcode); break; } new_msg = 0; @@ -1636,16 +1645,10 @@ static long hdmitx_cec_ioctl(struct file *f, case CEC_IOC_SET_OPTION_SYS_CTRL: tmp = (1 << HDMI_OPTION_SYSTEM_CEC_CONTROL); - if (arg){ - if (cec_dev->cec_info.log_addr[0] != 0) { - cec_inactive_source(CEC_BROADCAST_ADDR); - cec_menu_status_smp(CEC_TV_ADDR, DEVICE_MENU_INACTIVE); - } + if (arg) cec_dev->hal_flag |= tmp; - } - else { + else cec_dev->hal_flag &= ~(tmp); - } break; case CEC_IOC_SET_OPTION_SET_LANG: From 69156ccbe103644d50dd706b4d28230761746581 Mon Sep 17 00:00:00 2001 From: hereticmaggot Date: Sat, 25 Jun 2016 16:07:52 +0200 Subject: [PATCH 07/10] [aocec] wait for phys addr from edid --- drivers/amlogic/cec/hdmi_ao_cec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/amlogic/cec/hdmi_ao_cec.c b/drivers/amlogic/cec/hdmi_ao_cec.c index 21ca8bbdf6c6a5..ba457e8eea861b 100644 --- a/drivers/amlogic/cec/hdmi_ao_cec.c +++ b/drivers/amlogic/cec/hdmi_ao_cec.c @@ -996,6 +996,9 @@ int cec_node_init(struct hdmitx_dev *hdmitx_device) if ((cec_dev->hal_flag & (1 << HDMI_OPTION_SYSTEM_CEC_CONTROL))) return -1; + if (!(hdmitx_device->cec_func_config & (1 << CEC_FUNC_MSAK))) + return -1; + CEC_INFO("cec_node_init started\n"); cec_phy_addr = ((a << 12) | (b << 8) | (c << 4) | (d << 0)); @@ -1449,6 +1452,8 @@ static struct class_attribute aocec_class_attr[] = { /******************** cec hal interface ***************************/ static int hdmitx_cec_open(struct inode *inode, struct file *file) { + wait_event_interruptible(cec_dev->tx_dev->hdmi_info.vsdb_phy_addr.waitq, + cec_dev->tx_dev->hdmi_info.vsdb_phy_addr.valid == 1); cec_dev->cec_info.open_count++; if (cec_dev->cec_info.open_count) { cec_dev->cec_info.hal_ctl = 1; From c9fa423f231556130b00d4fec90bba196a8488c1 Mon Sep 17 00:00:00 2001 From: hereticmaggot Date: Sat, 25 Jun 2016 16:09:06 +0200 Subject: [PATCH 08/10] [aocec] wait for phys addr from edid --- drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_edid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_edid.c b/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_edid.c index 4787300678d136..0c50ead3f12645 100644 --- a/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_edid.c +++ b/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_edid.c @@ -313,6 +313,9 @@ void set_vsdb_phy_addr(struct vsdb_phyaddr *vsdb, vsdb->d = (edid_offset[5] >> 0) & 0xf; vsdb_local = *vsdb; vsdb->valid = 1; +#ifdef CONFIG_AML_AO_CEC + wake_up_interruptible(&vsdb->waitq); +#endif } int Edid_Parse_check_HDMI_VSDB(struct hdmitx_info *info, From 3412f2d100ec6e1d6c8be4148e214a5bc0370216 Mon Sep 17 00:00:00 2001 From: hereticmaggot Date: Sat, 25 Jun 2016 16:10:25 +0200 Subject: [PATCH 09/10] [aocec] wait for phys addr from edid --- drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_main.c b/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_main.c index f05fe8f73a5a1b..46fa16b506979e 100644 --- a/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_main.c +++ b/drivers/amlogic/hdmi/hdmi_tx_20/hdmi_tx_main.c @@ -495,7 +495,11 @@ static int set_disp_mode_auto(void) if ((vic_ready != HDMI_Unkown) && (vic_ready == vic)) { hdmi_print(IMP, SYS "[%s] ALREADY init VIC = %d\n", __func__, vic); +#if defined(CONFIG_ARCH_MESON64_ODROIDC2) + if (hdmitx_device.RXCap.IEEEOUI == 0 || odroidc_voutmode()) { +#else if (hdmitx_device.RXCap.IEEEOUI == 0) { +#endif /* DVI case judgement. In uboot, directly output HDMI * mode */ @@ -977,6 +981,10 @@ const char *disp_mode_t[] = { "1600x900p60hz", "1680x1050p60hz", "1920x1200p60hz", + "2560x1440p60hz", + "2560x1600p60hz", + "2560x1080p60hz", + "3440x1440p60hz", NULL }; @@ -2182,6 +2190,9 @@ static int amhdmitx_probe(struct platform_device *pdev) HDMITX_Meson_Init(&hdmitx_device); hdmitx_device.task = kthread_run(hdmi_task_handle, &hdmitx_device, "kthread_hdmi"); +#ifdef CONFIG_AML_AO_CEC + init_waitqueue_head(&hdmitx_device.hdmi_info.vsdb_phy_addr.waitq); +#endif if (r < 0) { hdmi_print(INF, SYS "register switch dev failed\n"); @@ -2465,6 +2476,9 @@ static int __init hdmitx_boot_para_setup(char *s) hdmitx_device.cec_func_config = list; hdmi_print(INF, CEC "HDMI hdmi_cec_func_config:0x%x\n", hdmitx_device.cec_func_config); + } else if (strcmp(token, "forcergb") == 0) { + hdmitx_output_rgb(); + hdmi_print(IMP, "Forced RGB colorspace output\n"); } } offset = token_offset; From acbd01a654221677e693e3b361639b3de0aafe45 Mon Sep 17 00:00:00 2001 From: hereticmaggot Date: Sat, 25 Jun 2016 16:11:59 +0200 Subject: [PATCH 10/10] [aocec] wait for phys addr from edid --- include/linux/amlogic/hdmi_tx/hdmi_info_global.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/amlogic/hdmi_tx/hdmi_info_global.h b/include/linux/amlogic/hdmi_tx/hdmi_info_global.h index 7002c4602ce1a3..c7502e9ef35bd6 100644 --- a/include/linux/amlogic/hdmi_tx/hdmi_info_global.h +++ b/include/linux/amlogic/hdmi_tx/hdmi_info_global.h @@ -19,6 +19,7 @@ #define _HDMI_INFO_GLOBAL_H #include "hdmi_common.h" +#include /* old definitions move to hdmi_common.h */ @@ -269,6 +270,9 @@ struct vsdb_phyaddr { unsigned char c:4; unsigned char d:4; unsigned char valid; +#ifdef CONFIG_AML_AO_CEC + wait_queue_head_t waitq; +#endif }; struct hdmitx_clk {