From 3cc112360c30494d1ecc8fa1bb3e6096a88c2dbc Mon Sep 17 00:00:00 2001 From: Yong Qin Date: Thu, 11 Jul 2019 18:51:44 +0800 Subject: [PATCH] cec: during resume received OTP msg again [1/1] PD#TV-7837 Problem: when tv power on by OTP, when during power on, tv received OTP again, then needn't send power key. and need send a event to android. Solution: when cec driver is power on, needn't send power event to android. Verify: tl1 Change-Id: I8807c5cbbcab831577fdc23062a78454c2106167 Signed-off-by: Yong Qin --- drivers/amlogic/cec/hdmi_ao_cec.c | 95 +++++++++---------- drivers/amlogic/cec/hdmi_ao_cec.h | 5 +- drivers/amlogic/cec/m8_ao_cec.c | 22 ++--- include/linux/amlogic/cec_common.h | 8 +- .../media/vout/hdmi_tx/hdmi_tx_cec_20.h | 8 +- 5 files changed, 66 insertions(+), 72 deletions(-) diff --git a/drivers/amlogic/cec/hdmi_ao_cec.c b/drivers/amlogic/cec/hdmi_ao_cec.c index 0ecbfcbbfe30..8d70d5ece795 100644 --- a/drivers/amlogic/cec/hdmi_ao_cec.c +++ b/drivers/amlogic/cec/hdmi_ao_cec.c @@ -63,11 +63,6 @@ #define CEC_FRAME_DELAY msecs_to_jiffies(400) #define CEC_DEV_NAME "cec" -#define CEC_POWER_ON (0 << 0) -#define CEC_EARLY_SUSPEND (1 << 0) -#define CEC_DEEP_SUSPEND (1 << 1) -#define CEC_POWER_RESUME (1 << 2) - #define HR_DELAY(n) (ktime_set(0, n * 1000 * 1000)) #define MAX_INT 0x7ffffff @@ -1873,10 +1868,7 @@ void cec_key_report(int suspend) input_sync(cec_dev->cec_info.remote_cec_dev); input_event(cec_dev->cec_info.remote_cec_dev, EV_KEY, KEY_POWER, 0); input_sync(cec_dev->cec_info.remote_cec_dev); - if (!suspend) - CEC_INFO("== WAKE UP BY CEC ==\n") - else - CEC_INFO("== SLEEP by CEC==\n") + CEC_INFO("event %s %d\n", __func__, suspend); } void cec_give_version(unsigned int dest) @@ -2053,25 +2045,24 @@ static void cec_rx_process(void) return; } opcode = msg[1]; + CEC_INFO("%s op 0x%x\n", __func__, opcode); switch (opcode) { case CEC_OC_ACTIVE_SOURCE: - /*if (wake_ok == 0) */ - { - int phy_addr = msg[2] << 8 | msg[3]; - - if (phy_addr == 0xffff) - break; - /*wake_ok = 1;*/ - phy_addr |= (initiator << 16); - writel(phy_addr, cec_dev->cec_reg + AO_RTI_STATUS_REG1); - CEC_INFO("found wake up source:%x", phy_addr); + dest_phy_addr = msg[2] << 8 | msg[3]; + if (dest_phy_addr == 0xffff) + break; + dest_phy_addr |= (initiator << 16); + if (cec_dev->cec_suspend == CEC_PW_STANDBY) { + writel(dest_phy_addr, + cec_dev->cec_reg + AO_RTI_STATUS_REG1); + CEC_INFO("found wake up source:%x", dest_phy_addr); } break; case CEC_OC_ROUTING_CHANGE: dest_phy_addr = msg[4] << 8 | msg[5]; if ((dest_phy_addr == cec_dev->phy_addr) && - (cec_dev->cec_suspend == CEC_EARLY_SUSPEND)) { + (cec_dev->cec_suspend == CEC_PW_STANDBY)) { CEC_INFO("wake up by ROUTING_CHANGE\n"); cec_key_report(0); } @@ -2105,36 +2096,32 @@ static void cec_rx_process(void) case CEC_OC_SET_STREAM_PATH: cec_set_stream_path(msg); /* wake up if in early suspend */ - if (cec_dev->cec_suspend != CEC_POWER_ON) + if (cec_dev->cec_suspend == CEC_PW_STANDBY) cec_key_report(0); break; case CEC_OC_REQUEST_ACTIVE_SOURCE: - if (cec_dev->cec_suspend == CEC_POWER_ON) + if (cec_dev->cec_suspend == CEC_PW_POWER_ON) cec_active_source_smp(); break; case CEC_OC_GIVE_DEVICE_POWER_STATUS: - if (cec_dev->cec_suspend == CEC_DEEP_SUSPEND) - cec_report_power_status(initiator, POWER_STANDBY); - else if (cec_dev->cec_suspend == CEC_EARLY_SUSPEND) - cec_report_power_status(initiator, POWER_STANDBY); - else if (cec_dev->cec_suspend == CEC_POWER_RESUME) - cec_report_power_status(initiator, POWER_ON); + if (cec_dev->cec_suspend == CEC_PW_POWER_ON) + cec_report_power_status(initiator, CEC_PW_POWER_ON); else - cec_report_power_status(initiator, POWER_ON); + cec_report_power_status(initiator, CEC_PW_STANDBY); break; case CEC_OC_USER_CONTROL_PRESSED: /* wake up by key function */ - if (cec_dev->cec_suspend != CEC_POWER_ON) { + if (cec_dev->cec_suspend == CEC_PW_STANDBY) { if (msg[2] == 0x40 || msg[2] == 0x6d) cec_key_report(0); } break; case CEC_OC_MENU_REQUEST: - if (cec_dev->cec_suspend != CEC_POWER_ON) + if (cec_dev->cec_suspend != CEC_PW_POWER_ON) cec_menu_status_smp(initiator, DEVICE_MENU_INACTIVE); else cec_menu_status_smp(initiator, DEVICE_MENU_ACTIVE); @@ -2146,8 +2133,10 @@ static void cec_rx_process(void) dest_phy_addr = 0xffff; dest_phy_addr = (dest_phy_addr << 0) | (initiator << 16); writel(dest_phy_addr, cec_dev->cec_reg + AO_RTI_STATUS_REG1); - CEC_INFO("weak up by otp\n"); - cec_key_report(0); + if (cec_dev->cec_suspend == CEC_PW_STANDBY) { + CEC_INFO("weak up by otp\n"); + cec_key_report(0); + } break; default: @@ -2563,7 +2552,7 @@ static ssize_t log_addr_store(struct class *cla, struct class_attribute *attr, cec_logicaddr_set(val); /* add by hal, to init some data structure */ cec_dev->cec_info.log_addr = val; - cec_dev->cec_info.power_status = POWER_ON; + cec_dev->cec_info.power_status = CEC_PW_POWER_ON; return count; } @@ -3176,7 +3165,7 @@ static long hdmitx_cec_ioctl(struct file *f, /* add by hal, to init some data structure */ cec_dev->cec_info.log_addr = tmp; - cec_dev->cec_info.power_status = POWER_ON; + cec_dev->cec_info.power_status = CEC_PW_POWER_ON; cec_dev->cec_info.vendor_id = cec_dev->v_data.vendor_id; strncpy(cec_dev->cec_info.osd_name, cec_dev->v_data.cec_osd_string, 14); @@ -3269,13 +3258,13 @@ static const struct file_operations hdmitx_cec_fops = { #ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND static void aocec_early_suspend(struct early_suspend *h) { - cec_dev->cec_suspend = CEC_EARLY_SUSPEND; + cec_dev->cec_suspend = CEC_PW_STANDBY; CEC_INFO("%s, suspend:%d\n", __func__, cec_dev->cec_suspend); } static void aocec_late_resume(struct early_suspend *h) { - cec_dev->cec_suspend = CEC_POWER_ON; + cec_dev->cec_suspend = CEC_PW_POWER_ON; CEC_INFO("%s, suspend:%d\n", __func__, cec_dev->cec_suspend); } @@ -3837,27 +3826,30 @@ static int aml_cec_remove(struct platform_device *pdev) #ifdef CONFIG_PM static int aml_cec_pm_prepare(struct device *dev) { - cec_dev->cec_suspend = CEC_DEEP_SUSPEND; - CEC_INFO("%s, cec_suspend:%d\n", __func__, cec_dev->cec_suspend); + //cec_dev->cec_suspend = CEC_DEEP_SUSPEND; + CEC_INFO("%s\n", __func__); return 0; } static void aml_cec_pm_complete(struct device *dev) { - int exit = 0; - - if (cec_dev->exit_reg) { - exit = readl(cec_dev->exit_reg); - CEC_INFO("wake up flag:%x\n", exit); - } - if (((exit >> 28) & 0xf) == CEC_WAKEUP) + if (get_resume_method() == CEC_WAKEUP) { cec_key_report(0); + + if (scpi_clr_wakeup_reason()) + CEC_ERR("clr wakeup reason fail\n"); + } + + CEC_INFO("%s\n", __func__); } static int aml_cec_suspend_noirq(struct device *dev) { int ret = 0; + cec_dev->cec_info.power_status = CEC_PW_TRANS_ON_TO_STANDBY; + cec_dev->cec_suspend = CEC_PW_TRANS_ON_TO_STANDBY; + CEC_INFO("cec suspend noirq\n"); if (cec_dev->cec_num > ENABLE_ONE_CEC) cec_clear_all_logical_addr(CEC_B); @@ -3868,6 +3860,9 @@ static int aml_cec_suspend_noirq(struct device *dev) ret = pinctrl_pm_select_sleep_state(cec_dev->dbg_dev); else CEC_ERR("pinctrl sleep_state error\n"); + + cec_dev->cec_info.power_status = CEC_PW_STANDBY; + cec_dev->cec_suspend = CEC_PW_STANDBY; return 0; } @@ -3878,7 +3873,8 @@ static int aml_cec_resume_noirq(struct device *dev) CEC_INFO("cec resume noirq!\n"); - cec_dev->cec_info.power_status = TRANS_STANDBY_TO_ON; + cec_dev->cec_info.power_status = CEC_PW_TRANS_STANDBY_TO_ON; + cec_dev->cec_suspend = CEC_PW_TRANS_STANDBY_TO_ON; scpi_get_wakeup_reason(&cec_dev->wakeup_reason); CEC_ERR("wakeup_reason:0x%x\n", cec_dev->wakeup_reason); @@ -3889,13 +3885,14 @@ static int aml_cec_resume_noirq(struct device *dev) CEC_ERR("cev val1: %#x;val2: %#x\n", *((unsigned int *)&cec_dev->wakup_data), temp); - cec_dev->cec_info.power_status = TRANS_STANDBY_TO_ON; - cec_dev->cec_suspend = CEC_POWER_RESUME; cec_pre_init(); if (!IS_ERR(cec_dev->dbg_dev->pins->default_state)) ret = pinctrl_pm_select_default_state(cec_dev->dbg_dev); else CEC_ERR("pinctrl default_state error\n"); + + cec_dev->cec_info.power_status = CEC_PW_POWER_ON; + cec_dev->cec_suspend = CEC_PW_POWER_ON; return 0; } diff --git a/drivers/amlogic/cec/hdmi_ao_cec.h b/drivers/amlogic/cec/hdmi_ao_cec.h index ee07c044797f..f66165b5e674 100644 --- a/drivers/amlogic/cec/hdmi_ao_cec.h +++ b/drivers/amlogic/cec/hdmi_ao_cec.h @@ -18,14 +18,11 @@ #ifndef __AO_CEC_H__ #define __AO_CEC_H__ - -#define CEC_DRIVER_VERSION "2019/7/12: add cec chip id\n" +#define CEC_DRIVER_VERSION "2019/7/11: pretect resume received OTP again msg\n" #define CEC_FRAME_DELAY msecs_to_jiffies(400) #define CEC_DEV_NAME "cec" -#define CEC_EARLY_SUSPEND (1 << 0) -#define CEC_DEEP_SUSPEND (1 << 1) #define CEC_PHY_PORT_NUM 4 #define HR_DELAY(n) (ktime_set(0, n * 1000 * 1000)) diff --git a/drivers/amlogic/cec/m8_ao_cec.c b/drivers/amlogic/cec/m8_ao_cec.c index 9b867e281bd7..d733530eee2c 100644 --- a/drivers/amlogic/cec/m8_ao_cec.c +++ b/drivers/amlogic/cec/m8_ao_cec.c @@ -979,32 +979,32 @@ static void cec_rx_process(void) case CEC_OC_SET_STREAM_PATH: cec_set_stream_path(msg); /* wake up if in early suspend */ - if (cec_dev->cec_suspend == CEC_EARLY_SUSPEND) + if (cec_dev->cec_suspend == CEC_PW_STANDBY) cec_key_report(0); break; case CEC_OC_REQUEST_ACTIVE_SOURCE: - if (!cec_dev->cec_suspend) + if (cec_dev->cec_suspend == CEC_PW_POWER_ON) cec_active_source_smp(); break; case CEC_OC_GIVE_DEVICE_POWER_STATUS: - if (cec_dev->cec_suspend) - cec_report_power_status(initiator, POWER_STANDBY); + if (cec_dev->cec_suspend == CEC_PW_STANDBY) + cec_report_power_status(initiator, CEC_PW_STANDBY); else - cec_report_power_status(initiator, POWER_ON); + cec_report_power_status(initiator, CEC_PW_POWER_ON); break; case CEC_OC_USER_CONTROL_PRESSED: /* wake up by key function */ - if (cec_dev->cec_suspend == CEC_EARLY_SUSPEND) { + if (cec_dev->cec_suspend == CEC_PW_STANDBY) { if (msg[2] == 0x40 || msg[2] == 0x6d) cec_key_report(0); } break; case CEC_OC_MENU_REQUEST: - if (cec_dev->cec_suspend) + if (cec_dev->cec_suspend == CEC_PW_STANDBY) cec_menu_status_smp(initiator, DEVICE_MENU_INACTIVE); else cec_menu_status_smp(initiator, DEVICE_MENU_ACTIVE); @@ -1353,7 +1353,7 @@ static ssize_t log_addr_store(struct class *cla, struct class_attribute *attr, cec_logicaddr_set(val); /* add by hal, to init some data structure */ cec_dev->my_log_addr = val; - cec_dev->power_status = POWER_ON; + cec_dev->power_status = CEC_PW_POWER_ON; return count; } @@ -1723,13 +1723,13 @@ static const struct file_operations hdmitx_cec_fops = { struct early_suspend aocec_suspend_handler; static void aocec_early_suspend(struct early_suspend *h) { - cec_dev->cec_suspend = CEC_EARLY_SUSPEND; + cec_dev->cec_suspend = CEC_PW_STANDBY; CEC_INFO("%s, suspend:%d\n", __func__, cec_dev->cec_suspend); } static void aocec_late_resume(struct early_suspend *h) { - cec_dev->cec_suspend = 0; + cec_dev->cec_suspend = CEC_PW_POWER_ON; CEC_INFO("%s, suspend:%d\n", __func__, cec_dev->cec_suspend); } @@ -1928,7 +1928,7 @@ static __exit int aml_cec_remove(struct platform_device *pdev) #ifdef CONFIG_PM static int aml_cec_pm_prepare(struct device *dev) { - cec_dev->cec_suspend = CEC_DEEP_SUSPEND; + cec_dev->cec_suspend = CEC_PW_STANDBY; CEC_INFO("%s, cec_suspend:%d\n", __func__, cec_dev->cec_suspend); return 0; } diff --git a/include/linux/amlogic/cec_common.h b/include/linux/amlogic/cec_common.h index e7ce80b5b163..76128483eda4 100644 --- a/include/linux/amlogic/cec_common.h +++ b/include/linux/amlogic/cec_common.h @@ -183,10 +183,10 @@ enum hdmi_port_type { }; enum cec_power_status_e { - POWER_ON = 0x00, - POWER_STANDBY, - TRANS_STANDBY_TO_ON, - TRANS_ON_TO_STANDBY, + CEC_PW_POWER_ON = 0x00, + CEC_PW_STANDBY, + CEC_PW_TRANS_STANDBY_TO_ON, + CEC_PW_TRANS_ON_TO_STANDBY, }; enum cec_version_e { diff --git a/include/linux/amlogic/media/vout/hdmi_tx/hdmi_tx_cec_20.h b/include/linux/amlogic/media/vout/hdmi_tx/hdmi_tx_cec_20.h index 2e46deb17d8e..0c218f6021c8 100644 --- a/include/linux/amlogic/media/vout/hdmi_tx/hdmi_tx_cec_20.h +++ b/include/linux/amlogic/media/vout/hdmi_tx/hdmi_tx_cec_20.h @@ -215,10 +215,10 @@ enum cec_node_status_e { }; enum cec_power_status_e { - POWER_ON = 0x00, - POWER_STANDBY, - TRANS_STANDBY_TO_ON, - TRANS_ON_TO_STANDBY, + CEC_PW_POWER_ON = 0x00, + CEC_PW_STANDBY, + CEC_PW_TRANS_STANDBY_TO_ON, + CEC_PW_TRANS_ON_TO_STANDBY, }; enum status_req_mode_e {