hdmi_hpd.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. #include "drv_types.h"
  2. #include "sysreg.h"
  3. #include "hdmi.h"
  4. #include "hdmi_hw.h"
  5. #include "hdmi_hpd.h"
  6. #include "hdmi_dbg.h"
  7. #include "hdmi_processing.h"
  8. #include "hdmi_notice.h"
  9. #include "hdmi_switch.h"
  10. #include "hdmi_cfg.h"
  11. #include "cec.h"
  12. #include "debounce.h"
  13. #include "mhl/cbus_drv.h"
  14. #include "hdmi_time.h"
  15. //for ARC GPIO 5V
  16. #include "drv_gpio.h"
  17. extern GPIOPin_t geGpio5V_Pin;
  18. #ifndef HDMI_DDC5V_WORKAROUND
  19. static DEBOUNCE hpd_db;
  20. #endif
  21. static HDMI_SRC_T cur_src = HDMI_SRC_NULL;
  22. static HDMI_PORT_T cur_port = HDMI_PORT_NULL;
  23. static SWITCH_PORT_T cur_sw_port = SWITCH_PORT_NULL;
  24. static struct timer_list term_timer;
  25. static BOOL IsHDMISelected(void)
  26. {
  27. return cur_port != HDMI_PORT_NULL;
  28. }
  29. static BOOL IsHWPortSelected(void)
  30. {
  31. return IsHDMISelected() && (cur_sw_port == SWITCH_PORT_NULL);
  32. }
  33. void hdmi_set_termination(DRV_HDMI_PORT_e ePort, DRV_HPD_LEVEL_e eLevel)
  34. {
  35. UINT8 bCurTerm;
  36. bCurTerm = HDMI_RegisterRead(HDMIRX_PHY_RTT_EN_P_2_0_);
  37. if(eLevel == DRV_HPD_LEVEL_LOW)
  38. bCurTerm = bCurTerm & (~ePort);
  39. else if(eLevel == DRV_HPD_LEVEL_HIGH)
  40. bCurTerm = bCurTerm | ePort;
  41. HDMI_RegisterWrite(HDMIRX_PHY_RTT_EN_P_2_0_, bCurTerm);
  42. }
  43. static void set_reset_phy(void)
  44. {
  45. if (IsHWPortSelected() && hdmi_get_hpd_at_cur_src())
  46. {
  47. //UINT8 b = 0;
  48. HDMI_RegisterWrite(HDMIRX_R_rst_n, 0);
  49. HDMI_RegisterWrite(HDMIRX_R_rst_n, 1);
  50. /* Clear phy settings */
  51. //PD for CEC
  52. HDMI_PHY_Enable(FALSE);
  53. /* Wait */
  54. HDMI_DelayMs(10);
  55. //Init Phy for HDMI 75M port A
  56. HDMI_PHY_Enable(TRUE);
  57. }
  58. }
  59. static UINT32 hpd_status = 0x0;
  60. static UINT32 switch_hpd_status = 0x0;
  61. static UINT32 hdmi_status = 0;
  62. static UINT32 hpd_mask_hw = 0x0;
  63. static UINT32 hpd_mask_sw = 0x0;
  64. static BOOL bToggle = false;
  65. extern BOOL MHL_CABLE_IN;
  66. static BOOL bfToggle = false;
  67. static void hdmi_repot_hpd_status(void)
  68. {
  69. HDMI_SRC_T src;
  70. SWITCH_PORT_T sw_port;
  71. HDMI_PORT_T hw_port;
  72. UINT32 local_hdmi_status = 0;
  73. UINT32 change_hdmi_status = 0;
  74. for (src = HDMI_SRC_1; src < 8; src++)
  75. {
  76. UINT32 s = 0;
  77. sw_port = hdmi_sw_port(src);
  78. hw_port = hdmi_hw_port(src);
  79. if (sw_port == SWITCH_PORT_NULL)
  80. {
  81. /* Current HDMI source is a hw port */
  82. if (hw_port != HDMI_PORT_NULL)
  83. {
  84. s = ((hpd_status & (1 << hw_port)) ? 1 : 0);
  85. }
  86. }
  87. else
  88. {
  89. /* Current HDMI source is a switch port */
  90. s = ((switch_hpd_status & (1 << sw_port)) ? 1 : 0);
  91. }
  92. local_hdmi_status |= (s << src);
  93. }
  94. change_hdmi_status = local_hdmi_status ^ hdmi_status;
  95. hdmi_status = local_hdmi_status;
  96. /* Notice Flow Control the current hpd status */
  97. HDMI_NoticeHotPlug(((hdmi_status << 8) & 0xff00) | (change_hdmi_status & 0xff));
  98. hdmidbg("%s change_hdmi_status:%x hdmi_status:%x cur_port%x\n", __FUNCTION__,change_hdmi_status,hdmi_status,cur_port);
  99. }
  100. void hdmi_report_cur_hpd(void)
  101. {
  102. //if (hdmi_status)
  103. {
  104. /* Report current hpd status again */
  105. HDMI_NoticeHotPlug(((hdmi_status << 8) & 0xff00) | (hdmi_status & 0xff));
  106. }
  107. }
  108. BOOL hdmi_get_hpd_at_cur_src(void)
  109. {
  110. if (cur_sw_port == SWITCH_PORT_NULL)
  111. {
  112. /* Current hdmi channel is a hw port */
  113. return (hpd_status & (1 << cur_port)) ? true : false;
  114. }
  115. else if (cur_port != HDMI_PORT_NULL)
  116. {
  117. /* Current hdmi channel is a sw port */
  118. //return (switch_hpd_status & (1 << cur_sw_port)) ? true : false;
  119. return ((hdmi_switch_hpd_status() & hpd_mask_sw) & (1 << cur_sw_port)) ? true : false;
  120. }
  121. return false;
  122. }
  123. void hdmi_apply_hpd(DRV_HDMI_PORT_e ePort, DRV_HPD_LEVEL_e eLevel)
  124. {
  125. volatile CUSTIMIZATION_TABLEPTR pCst;
  126. #ifndef HDMI_DDC5V_WORKAROUND
  127. HDMI_PORT_T eArcPort = DRV_Get_GPIO5V_ARCPort();
  128. #endif
  129. pCst = (volatile CUSTIMIZATION_TABLEPTR)SPI_OPTIONDATA_SHADOWADDR;
  130. if (bfToggle == TRUE)
  131. {
  132. return;
  133. }
  134. hdmidbg("set HPD port:%d level:%d\n", ePort, eLevel);
  135. if(ePort & pCst->HDMIHPDInvertMap)
  136. {
  137. if(eLevel == DRV_HPD_LEVEL_HIGH)
  138. {
  139. eLevel = DRV_HPD_LEVEL_LOW;
  140. }
  141. else
  142. {
  143. eLevel = DRV_HPD_LEVEL_HIGH;
  144. }
  145. }
  146. #ifdef HDMI_DDC5V_WORKAROUND
  147. if(ePort & DRV_HDMI_PORT_A)
  148. {
  149. HDMI_RegisterWrite(CEC_R_hpd_val_0, eLevel);
  150. }
  151. if(ePort & DRV_HDMI_PORT_B)
  152. {
  153. HDMI_RegisterWrite(CEC_R_hpd_val_1, eLevel);
  154. }
  155. if(ePort & DRV_HDMI_PORT_C)
  156. {
  157. HDMI_RegisterWrite(CEC_R_hpd_val_2, eLevel);
  158. }
  159. #else
  160. if(ePort & DRV_HDMI_PORT_A)
  161. {
  162. if(eArcPort != HDMI_PORT_A)
  163. HDMI_RegisterWrite(CEC_R_hpd_val_0, HDMI_RegisterRead(CEC_ddc5v_0) ? eLevel : DRV_HPD_LEVEL_LOW);
  164. else
  165. HDMI_RegisterWrite(CEC_R_hpd_val_0, GPIOTryRead(geGpio5V_Pin) ? eLevel : DRV_HPD_LEVEL_LOW);
  166. }
  167. if(ePort & DRV_HDMI_PORT_B)
  168. {
  169. if(eArcPort != HDMI_PORT_B)
  170. HDMI_RegisterWrite(CEC_R_hpd_val_1, HDMI_RegisterRead(CEC_ddc5v_1) ? eLevel : DRV_HPD_LEVEL_LOW);
  171. else
  172. HDMI_RegisterWrite(CEC_R_hpd_val_1, GPIOTryRead(geGpio5V_Pin) ? eLevel : DRV_HPD_LEVEL_LOW);
  173. }
  174. if(ePort & DRV_HDMI_PORT_C)
  175. {
  176. if(eArcPort != HDMI_PORT_C)
  177. HDMI_RegisterWrite(CEC_R_hpd_val_2, HDMI_RegisterRead(CEC_ddc5v_2) ? eLevel : DRV_HPD_LEVEL_LOW);
  178. else
  179. HDMI_RegisterWrite(CEC_R_hpd_val_2, GPIOTryRead(geGpio5V_Pin) ? eLevel : DRV_HPD_LEVEL_LOW);
  180. }
  181. #endif
  182. 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);
  183. }
  184. void hdmi_apply_hpd_Toggle(DRV_HDMI_PORT_e ePort, DRV_HPD_LEVEL_e eLevel, BOOL SetToggle)
  185. {
  186. volatile CUSTIMIZATION_TABLEPTR pCst;
  187. #ifndef HDMI_DDC5V_WORKAROUND
  188. HDMI_PORT_T eArcPort = DRV_Get_GPIO5V_ARCPort();
  189. #endif
  190. pCst = (volatile CUSTIMIZATION_TABLEPTR)SPI_OPTIONDATA_SHADOWADDR;
  191. hdmidbg("set HPD port:%d level:%d\n", ePort, eLevel);
  192. bfToggle = SetToggle;
  193. if(ePort & pCst->HDMIHPDInvertMap)
  194. {
  195. if(eLevel == DRV_HPD_LEVEL_HIGH)
  196. {
  197. eLevel = DRV_HPD_LEVEL_LOW;
  198. }
  199. else
  200. {
  201. eLevel = DRV_HPD_LEVEL_HIGH;
  202. }
  203. }
  204. #ifdef HDMI_DDC5V_WORKAROUND
  205. if(ePort & DRV_HDMI_PORT_A)
  206. {
  207. HDMI_RegisterWrite(CEC_R_hpd_val_0, eLevel);
  208. }
  209. if(ePort & DRV_HDMI_PORT_B)
  210. {
  211. HDMI_RegisterWrite(CEC_R_hpd_val_1, eLevel);
  212. }
  213. if(ePort & DRV_HDMI_PORT_C)
  214. {
  215. HDMI_RegisterWrite(CEC_R_hpd_val_2, eLevel);
  216. }
  217. #else
  218. if(ePort & DRV_HDMI_PORT_A)
  219. {
  220. if(eArcPort != HDMI_PORT_A)
  221. HDMI_RegisterWrite(CEC_R_hpd_val_0, HDMI_RegisterRead(CEC_ddc5v_0) ? eLevel : DRV_HPD_LEVEL_LOW);
  222. else
  223. HDMI_RegisterWrite(CEC_R_hpd_val_0, GPIOTryRead(geGpio5V_Pin) ? eLevel : DRV_HPD_LEVEL_LOW);
  224. }
  225. if(ePort & DRV_HDMI_PORT_B)
  226. {
  227. if(eArcPort != HDMI_PORT_B)
  228. HDMI_RegisterWrite(CEC_R_hpd_val_1, HDMI_RegisterRead(CEC_ddc5v_1) ? eLevel : DRV_HPD_LEVEL_LOW);
  229. else
  230. HDMI_RegisterWrite(CEC_R_hpd_val_1, GPIOTryRead(geGpio5V_Pin) ? eLevel : DRV_HPD_LEVEL_LOW);
  231. }
  232. if(ePort & DRV_HDMI_PORT_C)
  233. {
  234. if(eArcPort != HDMI_PORT_C)
  235. HDMI_RegisterWrite(CEC_R_hpd_val_2, HDMI_RegisterRead(CEC_ddc5v_2) ? eLevel : DRV_HPD_LEVEL_LOW);
  236. else
  237. HDMI_RegisterWrite(CEC_R_hpd_val_2, GPIOTryRead(geGpio5V_Pin) ? eLevel : DRV_HPD_LEVEL_LOW);
  238. }
  239. #endif
  240. 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);
  241. }
  242. void hdmi_apply_hpd_by5V(DRV_HDMI_PORT_e ePort)
  243. {
  244. volatile CUSTIMIZATION_TABLEPTR pCst;
  245. //DRV_HPD_LEVEL_e eLevel=DRV_HPD_LEVEL_LOW;
  246. DRV_HPD_LEVEL_e ePortA_Level,ePortB_Level,ePortC_Level;
  247. HDMI_PORT_T eArcPort = DRV_Get_GPIO5V_ARCPort();
  248. pCst = (volatile CUSTIMIZATION_TABLEPTR)SPI_OPTIONDATA_SHADOWADDR;
  249. ePortA_Level = ePortB_Level = ePortC_Level = DRV_HPD_LEVEL_LOW;
  250. if(ePort & DRV_HDMI_PORT_A)
  251. {
  252. if((eArcPort != HDMI_PORT_A)||(geGpio5V_Pin == GPIO_NOT_USE))
  253. {
  254. ePortA_Level = HDMI_RegisterRead(CEC_ddc5v_0) ;
  255. }
  256. else
  257. {
  258. ePortA_Level = GPIOTryRead(geGpio5V_Pin) ;
  259. }
  260. }
  261. if(ePort & DRV_HDMI_PORT_B)
  262. {
  263. if((eArcPort != HDMI_PORT_B)||(geGpio5V_Pin == GPIO_NOT_USE))
  264. {
  265. ePortB_Level = HDMI_RegisterRead(CEC_ddc5v_1) ;
  266. }
  267. else
  268. {
  269. ePortB_Level = GPIOTryRead(geGpio5V_Pin) ;
  270. }
  271. }
  272. if(ePort & DRV_HDMI_PORT_C)
  273. {
  274. if((eArcPort != HDMI_PORT_C)||(geGpio5V_Pin == GPIO_NOT_USE))
  275. {
  276. ePortC_Level = HDMI_RegisterRead(CEC_ddc5v_2) ;
  277. }
  278. else
  279. {
  280. ePortC_Level = GPIOTryRead(geGpio5V_Pin) ;
  281. }
  282. }
  283. if(ePort & pCst->HDMIHPDInvertMap)
  284. {
  285. if(ePortA_Level == DRV_HPD_LEVEL_HIGH)
  286. {
  287. ePortA_Level = DRV_HPD_LEVEL_LOW;
  288. }
  289. else
  290. {
  291. ePortA_Level = DRV_HPD_LEVEL_HIGH;
  292. }
  293. if(ePortB_Level == DRV_HPD_LEVEL_HIGH)
  294. {
  295. ePortB_Level = DRV_HPD_LEVEL_LOW;
  296. }
  297. else
  298. {
  299. ePortB_Level = DRV_HPD_LEVEL_HIGH;
  300. }
  301. if(ePortC_Level == DRV_HPD_LEVEL_HIGH)
  302. {
  303. ePortC_Level = DRV_HPD_LEVEL_LOW;
  304. }
  305. else
  306. {
  307. ePortC_Level = DRV_HPD_LEVEL_HIGH;
  308. }
  309. }
  310. if(ePort == DRV_HDMI_PORT_ALL)
  311. {
  312. hdmidbg("%s set HPD portA level:%d, portB level:%d, portC level:%d\n", __FUNCTION__,ePortA_Level,ePortB_Level,ePortC_Level);
  313. }
  314. else if(ePort == DRV_HDMI_PORT_A)
  315. {
  316. hdmidbg("%s set HPD portA level:%d\n",__FUNCTION__, ePortA_Level);
  317. }
  318. else if(ePort == DRV_HDMI_PORT_B)
  319. {
  320. hdmidbg("%s set HPD portB level:%d\n",__FUNCTION__, ePortB_Level);
  321. }
  322. else if(ePort == DRV_HDMI_PORT_C)
  323. {
  324. hdmidbg("%s set HPD portC level:%d\n",__FUNCTION__, ePortC_Level);
  325. }
  326. if(ePort & DRV_HDMI_PORT_A)
  327. {
  328. HDMI_RegisterWrite(CEC_R_hpd_val_0, ePortA_Level);
  329. }
  330. if(ePort & DRV_HDMI_PORT_B)
  331. {
  332. HDMI_RegisterWrite(CEC_R_hpd_val_1, ePortB_Level);
  333. }
  334. if(ePort & DRV_HDMI_PORT_C)
  335. {
  336. HDMI_RegisterWrite(CEC_R_hpd_val_2, ePortC_Level);
  337. }
  338. }
  339. UINT32 hdmi_get_hpd_status(void)
  340. {
  341. UINT32 local_hpd_status = 0;
  342. local_hpd_status |= (HDMI_RegisterRead(CEC_R_hpd_val_0) & 0x1);
  343. local_hpd_status |= ((HDMI_RegisterRead(CEC_R_hpd_val_1) & 0x1) << 1);
  344. local_hpd_status |= ((HDMI_RegisterRead(CEC_R_hpd_val_2) & 0x1) << 2);
  345. return local_hpd_status;
  346. }
  347. static void hpd_debounce(void *dummy)
  348. {
  349. UINT32 local_hpd_status = 0;
  350. UINT32 local_switch_hpd_status = 0;
  351. UINT32 diff_hpd_status = 0;
  352. UINT32 diff_switch_hpd_status = 0;
  353. #ifndef CONFIG_CHANGE_HOT_PLUG_ACTION
  354. UINT8 fInRange = HDMI_RegisterRead(HDMIRX_IN_RANGE);
  355. #endif
  356. /* Apply hdmi hpd according to ddc */
  357. #ifdef HDMI_DDC5V_WORKAROUND
  358. local_hpd_status = hdmi_get_hpd_status() & hpd_mask_hw;
  359. #else
  360. hdmi_apply_hpd(DRV_HDMI_PORT_ALL, DRV_HPD_LEVEL_HIGH);
  361. local_hpd_status = hdmi_get_hpd_status() & hpd_mask_hw;
  362. #endif
  363. diff_hpd_status = local_hpd_status ^ hpd_status;
  364. hpd_status = local_hpd_status;
  365. #ifndef CONFIG_CHANGE_HOT_PLUG_ACTION
  366. /* patch: When cable is plugged on current source and
  367. current source is not switch port,
  368. To pull low hpd for 500ms for better compatibility */
  369. if (IsHWPortSelected() &&
  370. (diff_hpd_status & hpd_status & (1 << cur_port))&& (fInRange == FALSE) )
  371. {
  372. HDMI_DelayMs(20);
  373. bToggle = true;
  374. }
  375. if (bToggle)
  376. {
  377. hdmi_apply_hpd((1 << cur_port), DRV_HPD_LEVEL_LOW);
  378. HDMI_DelayMs(HDMI_HPD_L2H_DELAY);
  379. hdmi_apply_hpd((1 << cur_port), DRV_HPD_LEVEL_HIGH);
  380. bToggle = false;
  381. }
  382. #endif
  383. /* Get switch hpd */
  384. local_switch_hpd_status = hdmi_switch_hpd_status() & hpd_mask_sw;
  385. diff_switch_hpd_status = local_switch_hpd_status ^ switch_hpd_status;
  386. switch_hpd_status = local_switch_hpd_status;
  387. /* Patch: For phy issue,
  388. Reset hw and phy when current hdmi channel is a hw port and plugged */
  389. if (IsHDMISelected() && (diff_hpd_status & (1 << cur_port)) &&( DrvHDMIPortSelectBitsGet()!=0x3))
  390. {
  391. set_reset_phy();
  392. }
  393. if (diff_hpd_status || diff_switch_hpd_status)
  394. {
  395. /* check no signal case when hdmi source is selected and hpd is changed. */
  396. if (IsHDMISelected() && (diff_hpd_status & (1 << cur_port)) &&( DrvHDMIPortSelectBitsGet()!=0x3))
  397. {
  398. hdmi_signal_check_start();
  399. }
  400. if (IsHDMISelected() && (diff_hpd_status & (1 << cur_port)) &&( DrvHDMIPortSelectBitsGet()!=0x3))
  401. {
  402. if( hpd_status & (1 << cur_port))//Current Port HDMI 5V HIGH
  403. {
  404. HDMI_NoticeHandler(HDMINOTICE_PROCESSING_IN, "Current Port Plug In");
  405. }
  406. else
  407. {
  408. //After plug in S+8203r HDMI Tester Source,Box IBT 1073 NG
  409. HDMI_RegisterWrite(HDMIRX_R_sw_hdcp_rstn, 0);
  410. HDMI_RegisterWrite(HDMIRX_R_sw_hdcp_rstn, 1);
  411. HDMI_NoticeHandler(HDMINOTICE_PROCESSING_OUT, "Current Port Plug Out");
  412. #ifdef HDMI_HPD_USE_1K_OHM
  413. if(MHL_CABLE_IN == FALSE)
  414. {
  415. if( DrvHDMIPortSelectBitsGet()==0x0)
  416. {
  417. sysset_HDMI_HPD_1K_OnOff(HDMI_PORT_A, TRUE);
  418. }
  419. else if( DrvHDMIPortSelectBitsGet()==0x1)
  420. {
  421. sysset_HDMI_HPD_1K_OnOff(HDMI_PORT_B, TRUE);
  422. }
  423. else if( DrvHDMIPortSelectBitsGet()==0x2)
  424. {
  425. sysset_HDMI_HPD_1K_OnOff(HDMI_PORT_C, TRUE);
  426. }
  427. }
  428. #endif
  429. }
  430. }
  431. }
  432. /* Notice hdmi status */
  433. hdmi_repot_hpd_status();
  434. }
  435. void hdmi_hpd_update(void)
  436. {
  437. #ifdef HDMI_DDC5V_WORKAROUND
  438. hpd_debounce(NULL);
  439. #else
  440. /* Use 100 ms debounce to handle un-stable hpd interrupts */
  441. debounce_notice(&hpd_db, NULL, 100);
  442. #endif
  443. }
  444. HDMI_PORT_T hdmi_get_cur_port(void)
  445. {
  446. hdmidbg("%s %d\n", __FUNCTION__, cur_port);
  447. return cur_port;
  448. }
  449. void hdmi_hpd_init(void)
  450. {
  451. INT32 i;
  452. init_timer(&term_timer);
  453. #ifndef HDMI_DDC5V_WORKAROUND
  454. debounce_init(&hpd_db, hpd_debounce);
  455. #endif
  456. hdmi_status = 0x0;
  457. hpd_status = 0x0;
  458. switch_hpd_status = 0x0;
  459. hpd_mask_hw = 0;
  460. hpd_mask_sw = 0;
  461. for (i = 0; i < 4; i++)
  462. {
  463. if (hdmi_get_channel_at_hw_port(i) != HDMI_SRC_NULL)
  464. {
  465. hpd_mask_hw |= (1 << i);
  466. }
  467. if (hdmi_get_channel_at_switch_port(i) != HDMI_SRC_NULL)
  468. {
  469. hpd_mask_sw |= (1 << i);
  470. }
  471. }
  472. //reset hpd value when hdmi connecter with-out signal
  473. if((HDMI_RegisterRead(CEC_ddc5v_analog_0) == 0) && (HDMI_RegisterRead(CEC_R_hpd_val_0) == 1)) {HDMI_RegisterWrite(CEC_R_hpd_val_0, 0);hdmidbg("set CEC_R_hpd_val_0 0");}
  474. if((HDMI_RegisterRead(CEC_ddc5v_analog_1) == 0) && (HDMI_RegisterRead(CEC_R_hpd_val_1) == 1)) {HDMI_RegisterWrite(CEC_R_hpd_val_1, 0);hdmidbg("set CEC_R_hpd_val_1 0");}
  475. if((HDMI_RegisterRead(CEC_ddc5v_analog_2) == 0) && (HDMI_RegisterRead(CEC_R_hpd_val_2) == 1)) {HDMI_RegisterWrite(CEC_R_hpd_val_2, 0);hdmidbg("set CEC_R_hpd_val_2 0");}
  476. }
  477. void hdmi_hpd_handler(HDMI_SRC_T src)
  478. {
  479. cur_src = src;
  480. cur_port = hdmi_hw_port(src);
  481. cur_sw_port = hdmi_sw_port(src);
  482. if (IsHDMISelected())
  483. {
  484. /* Enter hdmi source */
  485. /* Patch: Toggle hpd low for 500 ms */
  486. if (IsHWPortSelected() && (hpd_status & (1 << cur_port)))
  487. {
  488. bToggle = true;
  489. hdmi_hpd_update();
  490. }
  491. }
  492. else
  493. {
  494. /* Leave hdmi source */
  495. bToggle = false;
  496. }
  497. }