123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688 |
- #include "drv_types.h"
- #include "sysreg.h"
- #include "hdmi.h"
- #include "hdmi_hw.h"
- #include "hdmi_hpd.h"
- #include "hdmi_dbg.h"
- #include "hdmi_processing.h"
- #include "hdmi_notice.h"
- #include "hdmi_switch.h"
- #include "hdmi_cfg.h"
- #include "cec.h"
- #include "debounce.h"
- #include "mhl/cbus_drv.h"
- #include "hdmi_time.h"
- //for ARC GPIO 5V
- #include "drv_gpio.h"
- #include "sysreg.h"
- #include <drv2kmf.h>
- #include <drv_event.h>
- extern GPIOPin_t geGpio5V_Pin;
- #ifndef HDMI_DDC5V_WORKAROUND
- static DEBOUNCE hpd_db;
- #endif
- static HDMI_SRC_T cur_src = HDMI_SRC_NULL;
- static HDMI_PORT_T cur_port = HDMI_PORT_NULL;
- static SWITCH_PORT_T cur_sw_port = SWITCH_PORT_NULL;
- static struct timer_list term_timer;
- static BOOL IsHDMISelected(void)
- {
- return cur_port != HDMI_PORT_NULL;
- }
- static BOOL IsHWPortSelected(void)
- {
- return IsHDMISelected() && (cur_sw_port == SWITCH_PORT_NULL);
- }
- void hdmi_set_termination(DRV_HDMI_PORT_e ePort, DRV_HPD_LEVEL_e eLevel)
- {
- UINT8 bCurTerm;
- bCurTerm = HDMI_RegisterRead(HDMIRX_PHY_RTT_EN_P_2_0_);
- if(eLevel == DRV_HPD_LEVEL_LOW)
- bCurTerm = bCurTerm & (~ePort);
- else if(eLevel == DRV_HPD_LEVEL_HIGH)
- bCurTerm = bCurTerm | ePort;
-
- HDMI_RegisterWrite(HDMIRX_PHY_RTT_EN_P_2_0_, bCurTerm);
-
- }
- static void set_reset_phy(void)
- {
- if (IsHWPortSelected() && hdmi_get_hpd_at_cur_src())
- {
- //UINT8 b = 0;
- HDMI_RegisterWrite(HDMIRX_R_rst_n, 0);
- HDMI_RegisterWrite(HDMIRX_R_rst_n, 1);
- /* Clear phy settings */
- //PD for CEC
- HDMI_PHY_Enable(FALSE);
- /* Wait */
- HDMI_DelayMs(10);
- //Init Phy for HDMI 75M port A
- HDMI_PHY_Enable(TRUE);
- }
- }
- static UINT32 hpd_status = 0x0;
- static UINT32 switch_hpd_status = 0x0;
- static UINT32 hdmi_status = 0;
- static UINT32 hpd_mask_hw = 0x0;
- static UINT32 hpd_mask_sw = 0x0;
- static BOOL bToggle = false;
- extern BOOL MHL_CABLE_IN;
- static BOOL bfToggle = false;
- static void hdmi_repot_hpd_status(void)
- {
- HDMI_SRC_T src;
- SWITCH_PORT_T sw_port;
- HDMI_PORT_T hw_port;
- UINT32 local_hdmi_status = 0;
- UINT32 change_hdmi_status = 0;
- for (src = HDMI_SRC_1; src < 8; src++)
- {
- UINT32 s = 0;
- sw_port = hdmi_sw_port(src);
- hw_port = hdmi_hw_port(src);
- if (sw_port == SWITCH_PORT_NULL)
- {
- /* Current HDMI source is a hw port */
- if (hw_port != HDMI_PORT_NULL)
- {
- s = ((hpd_status & (1 << hw_port)) ? 1 : 0);
- }
- }
- else
- {
- /* Current HDMI source is a switch port */
- s = ((switch_hpd_status & (1 << sw_port)) ? 1 : 0);
- }
- local_hdmi_status |= (s << src);
- }
- change_hdmi_status = local_hdmi_status ^ hdmi_status;
- hdmi_status = local_hdmi_status;
- /* Notice Flow Control the current hpd status */
- HDMI_NoticeHotPlug(((hdmi_status << 8) & 0xff00) | (change_hdmi_status & 0xff));
- hdmidbg("%s change_hdmi_status:%x hdmi_status:%x cur_port%x\n", __FUNCTION__,change_hdmi_status,hdmi_status,cur_port);
- }
- void hdmi_report_cur_hpd(void)
- {
- //if (hdmi_status)
- {
- /* Report current hpd status again */
- HDMI_NoticeHotPlug(((hdmi_status << 8) & 0xff00) | (hdmi_status & 0xff));
- }
- }
- BOOL hdmi_get_hpd_at_cur_src(void)
- {
- if (cur_sw_port == SWITCH_PORT_NULL)
- {
- /* Current hdmi channel is a hw port */
- return (hpd_status & (1 << cur_port)) ? true : false;
- }
- else if (cur_port != HDMI_PORT_NULL)
- {
- /* Current hdmi channel is a sw port */
- //return (switch_hpd_status & (1 << cur_sw_port)) ? true : false;
- return ((hdmi_switch_hpd_status() & hpd_mask_sw) & (1 << cur_sw_port)) ? true : false;
- }
- return false;
- }
- void hdmi_set_hpd(ULONG reg, DRV_HPD_LEVEL_e eLevel)
- {
- #ifdef HDMI_HPD_EXT_1K_TO_SOURCE_5V
- HDMI_PORT_T ePort;
- if(reg == CEC_R_hpd_val_0)
- {
- #ifdef CONFIG_HDMI_PORT_A_HAVE_EXT_1K
- ePort = HDMI_PORT_A;
- if(eLevel == DRV_HPD_LEVEL_HIGH)
- {
- eLevel = DRV_HPD_LEVEL_HIGH;
- HDMI_RegisterWrite(CEC_R_hpd_val_0, eLevel);
- sysset_HDMI_HPD_HIGH_Z_MODE(ePort,1);
- sysset_HDMI_HPD_1K_OnOff(ePort,TRUE);
- }
- else
- {
- eLevel = DRV_HPD_LEVEL_LOW;
- HDMI_RegisterWrite(CEC_R_hpd_val_0, eLevel);
- sysset_HDMI_HPD_HIGH_Z_MODE(ePort,0);
- sysset_HDMI_HPD_1K_OnOff(ePort,FALSE);
- }
- #else
- HDMI_RegisterWrite(reg, eLevel);
- #endif
- }
- if(reg == CEC_R_hpd_val_1)
- {
- #ifdef CONFIG_HDMI_PORT_B_HAVE_EXT_1K
- ePort = HDMI_PORT_B;
- if(eLevel == DRV_HPD_LEVEL_HIGH)
- {
- eLevel = DRV_HPD_LEVEL_HIGH;
- HDMI_RegisterWrite(CEC_R_hpd_val_1, eLevel);
- sysset_HDMI_HPD_HIGH_Z_MODE(ePort,1);
- sysset_HDMI_HPD_1K_OnOff(ePort,TRUE);
- }
- else
- {
- eLevel = DRV_HPD_LEVEL_LOW;
- HDMI_RegisterWrite(CEC_R_hpd_val_1, eLevel);
- sysset_HDMI_HPD_HIGH_Z_MODE(ePort,0);
- sysset_HDMI_HPD_1K_OnOff(ePort,FALSE);
- }
- #else
- HDMI_RegisterWrite(reg, eLevel);
- #endif
- }
- if(reg == CEC_R_hpd_val_2)
- {
- #ifdef CONFIG_HDMI_PORT_C_HAVE_EXT_1K
- ePort = HDMI_PORT_C;
- if(eLevel == DRV_HPD_LEVEL_HIGH)
- {
- eLevel = DRV_HPD_LEVEL_HIGH;
- HDMI_RegisterWrite(CEC_R_hpd_val_2, eLevel);
- sysset_HDMI_HPD_HIGH_Z_MODE(ePort,1);
- sysset_HDMI_HPD_1K_OnOff(ePort,TRUE);
- }
- else
- {
- eLevel = DRV_HPD_LEVEL_LOW;
- HDMI_RegisterWrite(CEC_R_hpd_val_2, eLevel);
- sysset_HDMI_HPD_HIGH_Z_MODE(ePort,0);
- sysset_HDMI_HPD_1K_OnOff(ePort,FALSE);
- }
- #else
- HDMI_RegisterWrite(reg, eLevel);
- #endif
- }
- #else
- HDMI_RegisterWrite(reg, eLevel);
- #endif
- }
- void hdmi_apply_hpd(DRV_HDMI_PORT_e ePort, DRV_HPD_LEVEL_e eLevel)
- {
- volatile CUSTIMIZATION_TABLEPTR pCst;
- #ifndef HDMI_DDC5V_WORKAROUND
- HDMI_PORT_T eArcPort = DRV_Get_GPIO5V_ARCPort();
- #endif
- pCst = (volatile CUSTIMIZATION_TABLEPTR)SPI_OPTIONDATA_SHADOWADDR;
- if (bfToggle == TRUE)
- {
- return;
- }
- hdmidbg("set HPD port:%d level:%d\n", ePort, eLevel);
- if(ePort & pCst->HDMIHPDInvertMap)
- {
- if(eLevel == DRV_HPD_LEVEL_HIGH)
- {
- eLevel = DRV_HPD_LEVEL_LOW;
- }
- else
- {
- eLevel = DRV_HPD_LEVEL_HIGH;
- }
- }
-
- #ifdef HDMI_DDC5V_WORKAROUND
- if(ePort & DRV_HDMI_PORT_A)
- {
- hdmi_set_hpd(CEC_R_hpd_val_0, eLevel);
- }
- if(ePort & DRV_HDMI_PORT_B)
- {
- hdmi_set_hpd(CEC_R_hpd_val_1, eLevel);
- }
- if(ePort & DRV_HDMI_PORT_C)
- {
- hdmi_set_hpd(CEC_R_hpd_val_2, eLevel);
- }
- #else
- if(ePort & DRV_HDMI_PORT_A)
- {
- #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_A
- hdmi_set_hpd(CEC_R_hpd_val_0, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #else
- if((eArcPort != HDMI_PORT_A)||(geGpio5V_Pin == GPIO_NOT_USE))
- hdmi_set_hpd(CEC_R_hpd_val_0, HDMI_RegisterRead(CEC_ddc5v_0) ? eLevel : DRV_HPD_LEVEL_LOW);
- else
- hdmi_set_hpd(CEC_R_hpd_val_0, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #endif
- }
- if(ePort & DRV_HDMI_PORT_B)
- {
- #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_B
- hdmi_set_hpd(CEC_R_hpd_val_1, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #else
- if((eArcPort != HDMI_PORT_B)||(geGpio5V_Pin == GPIO_NOT_USE))
- hdmi_set_hpd(CEC_R_hpd_val_1, HDMI_RegisterRead(CEC_ddc5v_1) ? eLevel : DRV_HPD_LEVEL_LOW);
- else
- hdmi_set_hpd(CEC_R_hpd_val_1, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #endif
- }
- if(ePort & DRV_HDMI_PORT_C)
- {
- #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_C
- hdmi_set_hpd(CEC_R_hpd_val_2, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #else
- if((eArcPort != HDMI_PORT_C)||(geGpio5V_Pin == GPIO_NOT_USE))
- hdmi_set_hpd(CEC_R_hpd_val_2, HDMI_RegisterRead(CEC_ddc5v_2) ? eLevel : DRV_HPD_LEVEL_LOW);
- else
- hdmi_set_hpd(CEC_R_hpd_val_2, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #endif
- }
- #endif
- hdmidbg("Port HPD A:%d B:%d C:%d(invert:%d)\n", HDMI_RegisterRead(CEC_R_hpd_val_0), HDMI_RegisterRead(CEC_R_hpd_val_1), HDMI_RegisterRead(CEC_R_hpd_val_2), pCst->HDMIHPDInvertMap);
- }
- void hdmi_apply_hpd_Toggle(DRV_HDMI_PORT_e ePort, DRV_HPD_LEVEL_e eLevel, BOOL SetToggle)
- {
- volatile CUSTIMIZATION_TABLEPTR pCst;
- #ifndef HDMI_DDC5V_WORKAROUND
- HDMI_PORT_T eArcPort = DRV_Get_GPIO5V_ARCPort();
- #endif
- pCst = (volatile CUSTIMIZATION_TABLEPTR)SPI_OPTIONDATA_SHADOWADDR;
- hdmidbg("set HPD port:%d level:%d\n", ePort, eLevel);
- bfToggle = SetToggle;
- if(ePort & pCst->HDMIHPDInvertMap)
- {
- if(eLevel == DRV_HPD_LEVEL_HIGH)
- {
- eLevel = DRV_HPD_LEVEL_LOW;
- }
- else
- {
- eLevel = DRV_HPD_LEVEL_HIGH;
- }
- }
-
- #ifdef HDMI_DDC5V_WORKAROUND
- if(ePort & DRV_HDMI_PORT_A)
- {
- hdmi_set_hpd(CEC_R_hpd_val_0, eLevel);
- }
- if(ePort & DRV_HDMI_PORT_B)
- {
- hdmi_set_hpd(CEC_R_hpd_val_1, eLevel);
- }
- if(ePort & DRV_HDMI_PORT_C)
- {
- hdmi_set_hpd(CEC_R_hpd_val_2, eLevel);
- }
- #else
- if(ePort & DRV_HDMI_PORT_A)
- {
- #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_A
- hdmi_set_hpd(CEC_R_hpd_val_0, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #else
- if((eArcPort != HDMI_PORT_A)||(geGpio5V_Pin == GPIO_NOT_USE))
- hdmi_set_hpd(CEC_R_hpd_val_0, HDMI_RegisterRead(CEC_ddc5v_0) ? eLevel : DRV_HPD_LEVEL_LOW);
- else
- hdmi_set_hpd(CEC_R_hpd_val_0, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #endif
- }
- if(ePort & DRV_HDMI_PORT_B)
- {
- #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_B
- hdmi_set_hpd(CEC_R_hpd_val_1, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #else
- if((eArcPort != HDMI_PORT_B)||(geGpio5V_Pin == GPIO_NOT_USE))
- hdmi_set_hpd(CEC_R_hpd_val_1, HDMI_RegisterRead(CEC_ddc5v_1) ? eLevel : DRV_HPD_LEVEL_LOW);
- else
- hdmi_set_hpd(CEC_R_hpd_val_1, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #endif
- }
- if(ePort & DRV_HDMI_PORT_C)
- {
- #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_C
- hdmi_set_hpd(CEC_R_hpd_val_2, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #else
- if((eArcPort != HDMI_PORT_C)||(geGpio5V_Pin == GPIO_NOT_USE))
- hdmi_set_hpd(CEC_R_hpd_val_2, HDMI_RegisterRead(CEC_ddc5v_2) ? eLevel : DRV_HPD_LEVEL_LOW);
- else
- hdmi_set_hpd(CEC_R_hpd_val_2, (DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? eLevel : DRV_HPD_LEVEL_LOW);
- #endif
- }
- #endif
- hdmidbg("Port HPD A:%d B:%d C:%d(invert:%d)\n", HDMI_RegisterRead(CEC_R_hpd_val_0), HDMI_RegisterRead(CEC_R_hpd_val_1), HDMI_RegisterRead(CEC_R_hpd_val_2), pCst->HDMIHPDInvertMap);
- }
- void hdmi_apply_hpd_by5V(DRV_HDMI_PORT_e ePort)
- {
- volatile CUSTIMIZATION_TABLEPTR pCst;
- //DRV_HPD_LEVEL_e eLevel=DRV_HPD_LEVEL_LOW;
- DRV_HPD_LEVEL_e ePortA_Level,ePortB_Level,ePortC_Level;
- HDMI_PORT_T eArcPort = DRV_Get_GPIO5V_ARCPort();
- pCst = (volatile CUSTIMIZATION_TABLEPTR)SPI_OPTIONDATA_SHADOWADDR;
- ePortA_Level = ePortB_Level = ePortC_Level = DRV_HPD_LEVEL_LOW;
- if(ePort & DRV_HDMI_PORT_A)
- {
- #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_A
- ePortA_Level = ((DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? DRV_HPD_LEVEL_HIGH : DRV_HPD_LEVEL_LOW);
- #else
- if((eArcPort != HDMI_PORT_A)||(geGpio5V_Pin == GPIO_NOT_USE))
- {
- ePortA_Level = HDMI_RegisterRead(CEC_ddc5v_0) ;
- }
- else
- {
- ePortA_Level = ((DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? DRV_HPD_LEVEL_HIGH : DRV_HPD_LEVEL_LOW);
- }
- #endif
- }
- if(ePort & DRV_HDMI_PORT_B)
- {
- #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_B
- ePortB_Level = ((DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? DRV_HPD_LEVEL_HIGH : DRV_HPD_LEVEL_LOW);
- #else
- if((eArcPort != HDMI_PORT_B)||(geGpio5V_Pin == GPIO_NOT_USE))
- {
- ePortB_Level = HDMI_RegisterRead(CEC_ddc5v_1) ;
- }
- else
- {
- ePortB_Level = ((DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? DRV_HPD_LEVEL_HIGH : DRV_HPD_LEVEL_LOW);
- }
- #endif
-
- }
- if(ePort & DRV_HDMI_PORT_C)
- {
- #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_C
- ePortC_Level = ((DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? DRV_HPD_LEVEL_HIGH : DRV_HPD_LEVEL_LOW);
- #else
- if((eArcPort != HDMI_PORT_C)||(geGpio5V_Pin == GPIO_NOT_USE))
- {
- ePortC_Level = HDMI_RegisterRead(CEC_ddc5v_2) ;
- }
- else
- {
- ePortC_Level = ((DRV_GPIO5V_GET_CABLE_CONNECT_STATE() == HDMI_CALBE_CONNECT)? DRV_HPD_LEVEL_HIGH : DRV_HPD_LEVEL_LOW);
- }
- #endif
- }
- if(ePort & pCst->HDMIHPDInvertMap)
- {
- if(ePortA_Level == DRV_HPD_LEVEL_HIGH)
- {
- ePortA_Level = DRV_HPD_LEVEL_LOW;
- }
- else
- {
- ePortA_Level = DRV_HPD_LEVEL_HIGH;
- }
- if(ePortB_Level == DRV_HPD_LEVEL_HIGH)
- {
- ePortB_Level = DRV_HPD_LEVEL_LOW;
- }
- else
- {
- ePortB_Level = DRV_HPD_LEVEL_HIGH;
- }
- if(ePortC_Level == DRV_HPD_LEVEL_HIGH)
- {
- ePortC_Level = DRV_HPD_LEVEL_LOW;
- }
- else
- {
- ePortC_Level = DRV_HPD_LEVEL_HIGH;
- }
- }
- {
- hdmidbg("%s set HPD portA level:%d, portB level:%d, portC level:%d\n", __FUNCTION__,ePortA_Level,ePortB_Level,ePortC_Level);
- }
-
- if(ePort & DRV_HDMI_PORT_A)
- {
- hdmi_set_hpd(CEC_R_hpd_val_0, ePortA_Level);
- }
- if(ePort & DRV_HDMI_PORT_B)
- {
- hdmi_set_hpd(CEC_R_hpd_val_1, ePortB_Level);
- }
- if(ePort & DRV_HDMI_PORT_C)
- {
- hdmi_set_hpd(CEC_R_hpd_val_2, ePortC_Level);
- }
- }
- UINT32 hdmi_get_hpd_status(void)
- {
- UINT32 local_hpd_status = 0;
- local_hpd_status |= (HDMI_RegisterRead(CEC_R_hpd_val_0) & 0x1);
- local_hpd_status |= ((HDMI_RegisterRead(CEC_R_hpd_val_1) & 0x1) << 1);
- local_hpd_status |= ((HDMI_RegisterRead(CEC_R_hpd_val_2) & 0x1) << 2);
- return local_hpd_status;
- }
- static void hpd_debounce(void *dummy)
- {
- UINT32 local_hpd_status = 0;
- UINT32 local_switch_hpd_status = 0;
- UINT32 diff_hpd_status = 0;
- UINT32 diff_switch_hpd_status = 0;
- #ifndef CONFIG_CHANGE_HOT_PLUG_ACTION
- UINT8 fInRange = HDMI_RegisterRead(HDMIRX_IN_RANGE);
- #endif
-
- /* Apply hdmi hpd according to ddc */
- #ifdef HDMI_DDC5V_WORKAROUND
- local_hpd_status = hdmi_get_hpd_status() & hpd_mask_hw;
- #else
- hdmi_apply_hpd(DRV_HDMI_PORT_ALL, DRV_HPD_LEVEL_HIGH);
- local_hpd_status = hdmi_get_hpd_status() & hpd_mask_hw;
- #endif
- diff_hpd_status = local_hpd_status ^ hpd_status;
- hpd_status = local_hpd_status;
- #ifndef CONFIG_CHANGE_HOT_PLUG_ACTION
- /* patch: When cable is plugged on current source and
- current source is not switch port,
- To pull low hpd for 500ms for better compatibility */
- if (IsHWPortSelected() &&
- (diff_hpd_status & hpd_status & (1 << cur_port))&& (fInRange == FALSE) )
- {
- HDMI_DelayMs(20);
- bToggle = true;
- }
- if (bToggle)
- {
- hdmi_apply_hpd((1 << cur_port), DRV_HPD_LEVEL_LOW);
- HDMI_DelayMs(HDMI_HPD_L2H_DELAY);
- hdmi_apply_hpd((1 << cur_port), DRV_HPD_LEVEL_HIGH);
- bToggle = false;
- }
- #endif
- /* Get switch hpd */
- local_switch_hpd_status = hdmi_switch_hpd_status() & hpd_mask_sw;
- diff_switch_hpd_status = local_switch_hpd_status ^ switch_hpd_status;
- switch_hpd_status = local_switch_hpd_status;
- /* Patch: For phy issue,
- Reset hw and phy when current hdmi channel is a hw port and plugged */
- if (IsHDMISelected() && (diff_hpd_status & (1 << cur_port)) &&( DrvHDMIPortSelectBitsGet()!=0x3))
- {
- set_reset_phy();
- }
- if (diff_hpd_status || diff_switch_hpd_status)
- {
- /* check no signal case when hdmi source is selected and hpd is changed. */
- if (IsHDMISelected() && (diff_hpd_status & (1 << cur_port)) &&( DrvHDMIPortSelectBitsGet()!=0x3))
- {
- //#ifdef CONFIG_HDMI_DELAY_START_5V_DETECTION
- hdmi_signal_check_stop();
- //#endif
- hdmi_signal_check_start();
- }
- if (IsHDMISelected() && (diff_hpd_status & (1 << cur_port)) &&( DrvHDMIPortSelectBitsGet()!=0x3))
- {
- if( hpd_status & (1 << cur_port))//Current Port HDMI 5V HIGH
- {
- HDMI_NoticeHandler(HDMINOTICE_PROCESSING_IN, "Current Port Plug In");
- }
- else
- {
- //After plug in S+8203r HDMI Tester Source,Box IBT 1073 NG
- HDMI_RegisterWrite(HDMIRX_R_sw_hdcp_rstn, 0);
- HDMI_RegisterWrite(HDMIRX_R_sw_hdcp_rstn, 1);
- HDMI_NoticeHandler(HDMINOTICE_PROCESSING_OUT, "Current Port Plug Out");
- #ifdef HDMI_HPD_USE_1K_OHM
- if(MHL_CABLE_IN == FALSE)
- {
- if( DrvHDMIPortSelectBitsGet()==0x0)
- {
- #ifdef CONFIG_HDMI_PORT_A_HAVE_EXT_1K
- #else
- sysset_HDMI_HPD_1K_OnOff(HDMI_PORT_A, TRUE);
- #endif
- }
- else if( DrvHDMIPortSelectBitsGet()==0x1)
- {
- #ifdef CONFIG_HDMI_PORT_B_HAVE_EXT_1K
- #else
- sysset_HDMI_HPD_1K_OnOff(HDMI_PORT_B, TRUE);
- #endif
- }
- else if( DrvHDMIPortSelectBitsGet()==0x2)
- {
- #ifdef CONFIG_HDMI_PORT_C_HAVE_EXT_1K
- #else
- sysset_HDMI_HPD_1K_OnOff(HDMI_PORT_C, TRUE);
- #endif
- }
- }
- #endif
- }
- }
- }
- /* Notice hdmi status */
- hdmi_repot_hpd_status();
- }
- void hdmi_hpd_update(void)
- {
- #ifdef HDMI_DDC5V_WORKAROUND
- hpd_debounce(NULL);
- #else
- /* Use 100 ms debounce to handle un-stable hpd interrupts */
- debounce_notice(&hpd_db, NULL, 100);
- #endif
- }
- void hdmi_5v_change_need_ChangeSrc(HDMI_PORT_T port)
- {
- hdmidbg("%s %d,current_port:%d\n", __FUNCTION__, port,hdmi_get_cur_port());
- if(port >= 3 && HDMI_PORT_NUM != port)//valid is : 0,1,2
- return;
- if(hdmi_get_cur_port() != port)
- noticekmf(KMF2UMF_EVID_DRV, KMF2UMF_EVTYPE_DRV_INFORM_HDMI_CHANGESRC, (UINT8 *)&port, 1);
- }
- HDMI_PORT_T hdmi_get_cur_port(void)
- {
- //hdmidbg("%s %d\n", __FUNCTION__, cur_port);
- return cur_port;
- }
- void hdmi_hpd_init(void)
- {
- INT32 i;
- init_timer(&term_timer);
- #ifndef HDMI_DDC5V_WORKAROUND
- debounce_init(&hpd_db, hpd_debounce);
- #endif
- hdmi_status = 0x0;
- hpd_status = 0x0;
- switch_hpd_status = 0x0;
- hpd_mask_hw = 0;
- hpd_mask_sw = 0;
- for (i = 0; i < 4; i++)
- {
- if (hdmi_get_channel_at_hw_port(i) != HDMI_SRC_NULL)
- {
- hpd_mask_hw |= (1 << i);
- }
- if (hdmi_get_channel_at_switch_port(i) != HDMI_SRC_NULL)
- {
- hpd_mask_sw |= (1 << i);
- }
- }
- }
- void hdmi_hpd_handler(HDMI_SRC_T src)
- {
- cur_src = src;
- cur_port = hdmi_hw_port(src);
- cur_sw_port = hdmi_sw_port(src);
- if (IsHDMISelected())
- {
- /* Enter hdmi source */
- /* Patch: Toggle hpd low for 500 ms */
- if (IsHWPortSelected() && (hpd_status & (1 << cur_port)))
- {
- bToggle = true;
- hdmi_hpd_update();
- }
- }
- else
- {
- /* Leave hdmi source */
- bToggle = false;
- }
- }
|