hdmi_processing.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083
  1. #include "drv_types.h"
  2. #include <linux/module.h>
  3. #include "hdmi_dbg.h"
  4. #include "hdmi_cfg.h"
  5. #include "hdmi_hw.h"
  6. #include "hdmi_notice.h"
  7. #include "hdmi_processing.h"
  8. #include "hdmi_video.h"
  9. #include "hdmi_hpd.h"
  10. #include "cec.h"
  11. #include "drv_hdmi_internal.h"
  12. #ifdef CONFIG_SUPPORT_MONITOR_POWERSAVE
  13. #include "drv_kmf_interface.h"
  14. #include "tv_base.h"
  15. #endif
  16. #include "hdmi.h"
  17. #include "sysreg.h"
  18. #include "hdmi_time.h"
  19. #include "../../module_include/drv_gpio.h"
  20. #include "../vip/6710/reg_vip_def.h"
  21. #include "../vip/6710/drv_reg_access.h"
  22. #ifdef CONFIG_HDMI_SUPPORT_MHL
  23. #include "cbus_drv.h"
  24. #include "cbus_mid.h"
  25. #endif
  26. static UINT32 local_signal_status;
  27. static BOOL bHdmiMode = false;
  28. static VIP_InterfaceKIC stKic;
  29. static INT32 active_run = 0;
  30. static struct timer_list active_timer;
  31. static struct timer_list nosignal_timer;
  32. static struct timer_list turn_off_sw_5V_timer;
  33. static struct timer_list signal_monitor_timer;
  34. static struct work_struct wq_active;
  35. static struct work_struct wq_nosignal;
  36. static struct work_struct wq_avi_change;
  37. static struct work_struct wq_turn_off_sw_5V;
  38. extern GPIOPin_t geGpio5V_Pin;
  39. extern UINT8 gbSupportMaxHz;
  40. extern BOOL OpenScreen_Flag;
  41. extern BOOL MHL_CABLE_IN;
  42. #ifdef CONFIG_SUPPORT_MONITOR_POWERSAVE
  43. extern UINT8 WEAKUP_EVENT;
  44. #endif
  45. static void WQ_ACTIVE(void *dummy);
  46. static UINT8 WQ_NOSIGNAL_CNT=0;
  47. static UINT8 VBUS_TOGGLE_CNT=0;
  48. static void WQ_NOSIGNAL(void *dummy);
  49. static void WQ_AVI_CHANGE(void *dummy);
  50. static void NOSIGNAL_TIMER(void *dummy);
  51. static void nosignal_timer_schedule(UINT32 delay_ms);
  52. static void nosignal_timer_remove(void);
  53. static void ACTIVE_TIMER(void* dummy);
  54. extern void HDMI_Toggle_HPD(void);
  55. #ifdef CONFIG_SUPPORT_MONITOR_POWERSAVE
  56. extern BOOL vip_SourceSelect(input_type_t inputType);
  57. #endif
  58. BOOL DRV_HDMI_IsHDMIMode(void)
  59. {
  60. return bHdmiMode;
  61. }
  62. void hdmi_flag_set(SIGNAL_T s)
  63. {
  64. local_signal_status |= (1 << s);
  65. }
  66. void hdmi_flag_clear(SIGNAL_T s)
  67. {
  68. local_signal_status = local_signal_status & (~(1 << s));
  69. }
  70. BOOL hdmi_flag_check(SIGNAL_T s)
  71. {
  72. return (local_signal_status & (1 << s)) == 0?FALSE:TRUE;
  73. }
  74. void hdmi_flag_reset(void)
  75. {
  76. local_signal_status = 0;
  77. }
  78. //==========================================
  79. // Work Queue Function
  80. //==========================================
  81. static void WQ_ACTIVE(void *dummy)
  82. {
  83. UINT8 bSignalStatus;
  84. WQ_NOSIGNAL_CNT =0;
  85. VBUS_TOGGLE_CNT=0;
  86. HDMI_RegisterWrite(HDMIRX_R_VIDEO_MUTE, 0);
  87. bSignalStatus = HDMI_GetInputInformation(&stKic);
  88. signal_monitor_timer_schedule(50);
  89. switch (bSignalStatus)
  90. {
  91. default:
  92. case 0: /* Not Support */
  93. HDMI_NoticeHandler(HDMINOTICE_NOTSUPPORT, "WQ_ACTIVE");
  94. break;
  95. case 1: /* Support */
  96. #ifdef SUPPORT_XVYCC
  97. if(HDMI_RegisterRead(HDMIRX_R_GBD_exist) == 1) //if Gamut Boundary Description exist, handle xvycc
  98. {
  99. hdmi_handler_xvycc();
  100. }
  101. #endif
  102. HDMI_NoticeHandler(HDMINOTICE_HAVESIGNAL, "WQ_ACTIVE");
  103. #ifdef CONFIG_SUPPORT_MONITOR_POWERSAVE
  104. if(WEAKUP_EVENT&INPUT_TYPE_HDMI)
  105. {
  106. drv_gated_clk_ctrl(GATED_ICLK_VIP, 0);
  107. *((volatile u8*)(0xbe00010c )) = 0x5;
  108. clear_bit(26, (volatile void __iomem *) 0xbe0001ac); // [26]R_LVDSPLL_PWDN
  109. clear_bit(15, (volatile void __iomem *) 0xbe00000c); // [15]R_AUDIO_RST
  110. vip_init_forwakeup();
  111. vip_SourceSelect(INPUT_TYPE_HDMI);
  112. }
  113. #endif
  114. VIP_SendInformation(&stKic);
  115. HDMI_RegisterWrite(HDMIRX_R_force_blk_screen, 0);
  116. /* Indicate flow control that hdmi/dvi mode */
  117. if (HDMI_RegisterRead(HDMIRX_R_HDMI_en) == 1)
  118. {
  119. HDMI_NoticeAudioMode(HDMI_MODE);
  120. bHdmiMode = true;
  121. }
  122. else
  123. {
  124. HDMI_NoticeAudioMode(DVI_MODE);
  125. bHdmiMode = false;
  126. }
  127. #ifdef HDMI_DDC5V_WORKAROUND
  128. if(!((MHL_CABLE_IN == TRUE)&&( DrvHDMIPortSelectBitsGet() == CONFIG_HDMI_MHL_PORT)))
  129. {
  130. #ifdef CONFIG_HDMI_GPIO_DETECT
  131. if(
  132. #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_A
  133. (hdmi_get_cur_port() != HDMI_PORT_A) &&
  134. #endif
  135. #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_B
  136. (hdmi_get_cur_port() != HDMI_PORT_B) &&
  137. #endif
  138. #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_C
  139. (hdmi_get_cur_port() != HDMI_PORT_C) &&
  140. #endif
  141. (TRUE))
  142. #endif
  143. HDMI_TurnOff_SW_5V_schedule(2000, hdmi_get_cur_port()); //restart HW DDC 5V detection after signal is stable
  144. }
  145. #endif
  146. OpenScreen_Flag = TRUE;
  147. break;
  148. case 2: /* No Signal */
  149. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "WQ_ACTIVE");
  150. break;
  151. }
  152. }
  153. extern BOOL MHL_CABLE_IN;
  154. static void WQ_NOSIGNAL(void *dummy)
  155. {
  156. BOOL bNotSupport;
  157. UINT32 pixel_clk_freq,uiHactive;
  158. pixel_clk_freq = get_pixel_clock();
  159. uiHactive = HDMI_RegisterRead(HDMIRX_de_h_width_lock) / (HDMI_RegisterRead(HDMIRX_R_AVI_PR) + 1);
  160. if((pixel_clk_freq >= 165000000) && (uiHactive < 2560))
  161. {
  162. bNotSupport = TRUE; // Not Support
  163. }
  164. #ifdef CONFIG_HDMI_SUPPORT_MHL
  165. #ifdef CONFIG_HDMI_MHL_PORT
  166. if((HDMI_RegisterRead(HDMIRX_IN_RANGE)==0)&&(DrvHDMIPortSelectBitsGet()==CONFIG_HDMI_MHL_PORT))
  167. {
  168. if(( MHL_ADOPTER_ID_Check()== FALSE)&&(VBUS_TOGGLE_CNT==0)&&(GPIOGetValueByPinFunc(GPIO_PIN_MHL_CD_SENSE_DETECT)==1))
  169. {
  170. #if 0
  171. printk("MHL TOGGLE Vbus1!!!!!! \n");
  172. sysset_VbusEnable(0);
  173. HDMI_DelayMs(100);
  174. sysset_VbusEnable(1);
  175. VBUS_TOGGLE_CNT ++;
  176. #endif
  177. }
  178. }
  179. #endif
  180. #endif
  181. #if 1
  182. if(HDMI_RegisterRead(HDMIRX_PHYPLLLOCK))
  183. {
  184. hdmidbg("p timeout = %d, rd_cnt = %d WQ_NOSIGNAL_CNT = %d\n",sysget_DDC_non_idle_timeout(hdmi_get_cur_port()),sysget_DDC_rd_block_cnt(hdmi_get_cur_port()), WQ_NOSIGNAL_CNT);
  185. if(WQ_NOSIGNAL_CNT<2)
  186. {
  187. printk("HDMIRX_PHYPLLLOCK!!!!!! \n");
  188. //HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 0);
  189. //HDMI_DelayMs(2);
  190. /* Power On PHY */
  191. //HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 1);
  192. HDMI_RegisterWrite(HDMIRX_R_DDC5V_reset, 1);
  193. HDMI_RegisterWrite(HDMIRX_R_rst_n, 0);
  194. HDMI_DelayMs(2);
  195. HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 0);
  196. HDMI_SetPLL_ByFreq();
  197. HDMI_DelayMs(2);
  198. HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 1);
  199. HDMI_DelayMs(2);
  200. HDMI_RegisterWrite(HDMIRX_R_rst_n, 1);
  201. HDMI_RegisterWrite(HDMIRX_R_DDC5V_reset, 0);
  202. #ifdef CONFIG_HDMI_MHL_PORT
  203. if((MHL_CABLE_IN == TRUE)&&(DrvHDMIPortSelectBitsGet()==CONFIG_HDMI_MHL_PORT))
  204. {
  205. if(CbusMidGetWhiteListToResetCubs())
  206. {
  207. printk("MHL reset cbus!!!!!! \n");
  208. //reset cbus
  209. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_cbus_reset, 1);
  210. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_debounce_reset, 1);
  211. HDMI_DelayMs(150);
  212. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_debounce_reset, 0);
  213. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_cbus_reset, 0);
  214. }
  215. else
  216. {
  217. printk("ignore MHL reset cbus!!!!!! \n");
  218. }
  219. }
  220. #endif
  221. hdmi_signal_lock_check_start();
  222. WQ_NOSIGNAL_CNT++;
  223. }
  224. else if(WQ_NOSIGNAL_CNT<4)
  225. {
  226. printk("HDMIRX_PHYPLLLOCK!!!!!! \n");
  227. printk("Reset PLL!!!!!! \n");
  228. //Reset PLL
  229. HDMI_Reset_HDMI_PLL();
  230. //HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 0);
  231. //HDMI_DelayMs(2);
  232. /* Power On PHY */
  233. //HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 1);
  234. HDMI_RegisterWrite(HDMIRX_R_DDC5V_reset, 1);
  235. HDMI_RegisterWrite(HDMIRX_R_rst_n, 0);
  236. HDMI_DelayMs(2);
  237. HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 0);
  238. HDMI_DelayMs(2);
  239. HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 1);
  240. HDMI_DelayMs(2);
  241. HDMI_RegisterWrite(HDMIRX_R_rst_n, 1);
  242. HDMI_RegisterWrite(HDMIRX_R_DDC5V_reset, 0);
  243. #ifdef CONFIG_HDMI_MHL_PORT
  244. if((MHL_CABLE_IN == TRUE)&&(DrvHDMIPortSelectBitsGet()==CONFIG_HDMI_MHL_PORT))
  245. {
  246. if(CbusMidGetWhiteListToResetCubs())
  247. {
  248. printk("MHL reset cbus!!!!!! \n");
  249. //reset cbus
  250. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_cbus_reset, 1);
  251. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_debounce_reset, 1);
  252. HDMI_DelayMs(150);
  253. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_debounce_reset, 0);
  254. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_cbus_reset, 0);
  255. }
  256. else
  257. {
  258. printk("ignore MHL reset cbus!!!!!! \n");
  259. }
  260. }
  261. #endif
  262. hdmi_signal_lock_check_start();
  263. WQ_NOSIGNAL_CNT++;
  264. }
  265. /*
  266. else if(WQ_NOSIGNAL_CNT<5)
  267. {
  268. HDMI_Toggle_HPD();
  269. WQ_NOSIGNAL_CNT++;
  270. }
  271. */
  272. else
  273. {
  274. /* mantis 27479, chroma 2402 unsupport timing issue*/
  275. #ifdef HDMI_DDC5V_WORKAROUND
  276. #ifdef CONFIG_HDMI_GPIO_DETECT
  277. if(
  278. #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_A
  279. (hdmi_get_cur_port() != HDMI_PORT_A) &&
  280. #endif
  281. #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_B
  282. (hdmi_get_cur_port() != HDMI_PORT_B) &&
  283. #endif
  284. #ifdef CONFIG_HDMI_GPIO_DETECT_PORT_C
  285. (hdmi_get_cur_port() != HDMI_PORT_C) &&
  286. #endif
  287. (TRUE))
  288. #endif
  289. HDMI_TurnOff_SW_5V_schedule(0, hdmi_get_cur_port()); //restart HW DDC 5V detection after signal is stable
  290. #endif
  291. WQ_NOSIGNAL_CNT =0;
  292. //HDMI_NoticeHandler(HDMINOTICE_NOTSUPPORT, "NOSIGNAL_TIMER");
  293. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "NOSIGNAL_TIMER");
  294. HDMI_Toggle_HPD();
  295. }
  296. }
  297. #ifdef CONFIG_HDMI_SUPPORT_MHL
  298. #ifdef CONFIG_HDMI_MHL_PORT
  299. else if((CbusMidGetDevCapReadyBit()==FALSE)&&(MHL_CABLE_IN == TRUE)&&(DrvHDMIPortSelectBitsGet()==CONFIG_HDMI_MHL_PORT))
  300. {
  301. if(WQ_NOSIGNAL_CNT<26)
  302. {
  303. if((WQ_NOSIGNAL_CNT==5)||(WQ_NOSIGNAL_CNT==10)||(WQ_NOSIGNAL_CNT==15)||(WQ_NOSIGNAL_CNT==20)||(WQ_NOSIGNAL_CNT==25))
  304. {
  305. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "NOSIGNAL_TIMER");
  306. if(CbusMidGetWhiteListToResetCubs())
  307. {
  308. printk("MHL reset cbus!!!!!! \n");
  309. //reset cbus
  310. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_cbus_reset, 1);
  311. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_debounce_reset, 1);
  312. HDMI_DelayMs(150);
  313. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_debounce_reset, 0);
  314. HDMI_RegisterWrite(HDMIRX_CBUS_cfg_cbus_reset, 0);
  315. }
  316. else
  317. {
  318. printk("ignore MHL reset cbus!!!!!! \n");
  319. }
  320. }
  321. #if 0
  322. if(( MHL_ADOPTER_ID_Check()== FALSE)&&((WQ_NOSIGNAL_CNT==10)||(WQ_NOSIGNAL_CNT==20))&&(GPIOGetValueByPinFunc(GPIO_PIN_MHL_CD_SENSE_DETECT)==1))
  323. {
  324. printk("MHL TOGGLE Vbus2!!!!!! \n");
  325. sysset_VbusEnable(0);
  326. HDMI_DelayMs(100);
  327. sysset_VbusEnable(1);
  328. VBUS_TOGGLE_CNT ++;
  329. }
  330. #endif
  331. hdmi_signal_check_start();
  332. WQ_NOSIGNAL_CNT++;
  333. }
  334. else
  335. {
  336. WQ_NOSIGNAL_CNT =0;
  337. VBUS_TOGGLE_CNT =0;
  338. #if 0
  339. if((HDMI_RegisterRead(HDMIRX_IN_RANGE)==0)&&(DrvHDMIPortSelectBitsGet()==CONFIG_HDMI_MHL_PORT))
  340. {
  341. if(( MHL_ADOPTER_ID_Check()== FALSE)&&(VBUS_TOGGLE_CNT==0)&&(GPIOGetValueByPinFunc(GPIO_PIN_MHL_CD_SENSE_DETECT)==1))
  342. {
  343. printk("MHL TOGGLE Vbus3!!!!!! \n");
  344. sysset_VbusEnable(0);
  345. HDMI_DelayMs(100);
  346. sysset_VbusEnable(1);
  347. }
  348. }
  349. #endif
  350. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "NOSIGNAL_TIMER");
  351. }
  352. }
  353. #endif
  354. #endif
  355. else
  356. #endif
  357. {
  358. if(HDMI_RegisterRead(HDMIRX_IN_RANGE))
  359. {
  360. hdmidbg("i timeout = %d, rd_cnt = %d WQ_NOSIGNAL_CNT = %d\n",sysget_DDC_non_idle_timeout(hdmi_get_cur_port()),sysget_DDC_rd_block_cnt(hdmi_get_cur_port()), WQ_NOSIGNAL_CNT);
  361. if(WQ_NOSIGNAL_CNT<3)
  362. {
  363. HDMI_RegisterWrite(HDMIRX_PDACJ_CK, 0);//For No siglal issue
  364. HDMI_DelayMs(2);
  365. HDMI_RegisterWrite(HDMIRX_PDACJ_CK, 1);
  366. hdmi_signal_lock_check_start();
  367. WQ_NOSIGNAL_CNT++;
  368. }
  369. else
  370. {
  371. WQ_NOSIGNAL_CNT =0;
  372. VBUS_TOGGLE_CNT =0;
  373. //HDMI_NoticeHandler(HDMINOTICE_NOTSUPPORT, "NOSIGNAL_TIMER");
  374. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "NOSIGNAL_TIMER");
  375. }
  376. }
  377. else
  378. {
  379. #ifdef CONFIG_HDMI_DELAY_START_5V_DETECTION
  380. if(CEC_Get_SW5V(hdmi_get_cur_port()) == DRV_5V_LEVEL_HIGH)
  381. {
  382. if(NormalScreen == HDMI_GetNoticedScreenMode())
  383. {
  384. //power off
  385. hdmidbg("1 timeout = %d, rd_cnt = %d WQ_NOSIGNAL_CNT = %d\n",sysget_DDC_non_idle_timeout(hdmi_get_cur_port()),sysget_DDC_rd_block_cnt(hdmi_get_cur_port()), WQ_NOSIGNAL_CNT);
  386. if(1)//if(sysget_DDC_non_idle_timeout(hdmi_get_cur_port()) == 0)
  387. {
  388. if((WQ_NOSIGNAL_CNT<2))
  389. {
  390. WQ_NOSIGNAL_CNT++;
  391. hdmi_signal_lock_check_start();
  392. }
  393. else
  394. {
  395. //power off
  396. WQ_NOSIGNAL_CNT =0;
  397. VBUS_TOGGLE_CNT =0;
  398. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "NOSIGNAL_TIMER_D5V01");
  399. }
  400. }
  401. else
  402. {
  403. WQ_NOSIGNAL_CNT =0;
  404. VBUS_TOGGLE_CNT =0;
  405. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "NOSIGNAL_TIMER_D5V03");
  406. }
  407. }
  408. else
  409. {
  410. //gtx 730 750 power on,
  411. //dvd play plug-in cable in standby mode(5v is exsit not read edid)
  412. hdmidbg("2 timeout = %d, rd_cnt = %d WQ_NOSIGNAL_CNT = %d\n",sysget_DDC_non_idle_timeout(hdmi_get_cur_port()),sysget_DDC_rd_block_cnt(hdmi_get_cur_port()), WQ_NOSIGNAL_CNT);
  413. if((WQ_NOSIGNAL_CNT<2))
  414. {
  415. WQ_NOSIGNAL_CNT++;
  416. hdmi_signal_lock_check_start();
  417. }
  418. else
  419. {
  420. WQ_NOSIGNAL_CNT =0;
  421. VBUS_TOGGLE_CNT =0;
  422. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "NOSIGNAL_TIMER_D5V02");
  423. }
  424. }
  425. }
  426. else
  427. #endif
  428. {
  429. hdmidbg("3 timeout = %d, rd_cnt = %d\n",sysget_DDC_non_idle_timeout(hdmi_get_cur_port()),sysget_DDC_rd_block_cnt(hdmi_get_cur_port()));
  430. if((MHL_CABLE_IN == TRUE)&&(DrvHDMIPortSelectBitsGet()==CONFIG_HDMI_MHL_PORT))
  431. {
  432. #if 0
  433. if((WQ_NOSIGNAL_CNT<5))
  434. {
  435. WQ_NOSIGNAL_CNT++;
  436. hdmi_signal_lock_check_start();
  437. }
  438. else
  439. {
  440. WQ_NOSIGNAL_CNT =0;
  441. VBUS_TOGGLE_CNT =0;
  442. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "NOSIGNAL_TIMER");
  443. }
  444. #else
  445. WQ_NOSIGNAL_CNT =0;
  446. VBUS_TOGGLE_CNT =0;
  447. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "NOSIGNAL_TIMER");
  448. #endif
  449. }
  450. else
  451. {
  452. if((WQ_NOSIGNAL_CNT<HDMI_NOSIGNAL_CNT_WITH_5V))
  453. {
  454. WQ_NOSIGNAL_CNT++;
  455. hdmi_signal_lock_check_start();
  456. }
  457. else
  458. {
  459. WQ_NOSIGNAL_CNT =0;
  460. VBUS_TOGGLE_CNT =0;
  461. if (hdmi_get_hpd_at_cur_src() && bNotSupport)
  462. {
  463. //HDMI_NoticeHandler(HDMINOTICE_NOTSUPPORT, "NOSIGNAL_TIMER");
  464. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "NOSIGNAL_TIMER");
  465. }
  466. else
  467. {
  468. HDMI_NoticeHandler(HDMINOTICE_NOSIGNAL, "NOSIGNAL_TIMER");
  469. }
  470. HDMI_Toggle_HPD();
  471. }
  472. }
  473. }
  474. }
  475. }
  476. }
  477. static void WQ_AVI_CHANGE(void *dummy)
  478. {
  479. if(HDMI_IsAviChanged(&stKic) == true)
  480. {
  481. HDMI_RegisterWrite(HDMIRX_R_force_blk_screen, 1);
  482. VIP_MuteScreen();
  483. VIP_SendInformation(&stKic);
  484. /* Indicate flow control that hdmi/dvi mode */
  485. if(HDMI_RegisterRead(HDMIRX_R_HDMI_en) == 1)
  486. {
  487. HDMI_NoticeAudioMode(HDMI_MODE);
  488. bHdmiMode = true;
  489. }
  490. else
  491. {
  492. HDMI_NoticeAudioMode(DVI_MODE);
  493. bHdmiMode = false;
  494. }
  495. HDMI_RegisterWrite(HDMIRX_R_force_blk_screen, 0);
  496. }
  497. }
  498. static void WQ_TURN_OFF_SW5V(UINT32 data)
  499. {
  500. if(((HDMI_PORT_T)data != DRV_Get_GPIO5V_ARCPort())||(geGpio5V_Pin== GPIO_NOT_USE)) //do not turn off SW 5V at ARC GPIO 5V port,workaround for SONY BDP-S360
  501. {
  502. sysset_HDMI_SW5V((HDMI_PORT_T)data, FALSE);
  503. }
  504. }
  505. //==========================================
  506. // Timer
  507. //==========================================
  508. /* no signal */
  509. static void NOSIGNAL_TIMER(void *dummy)
  510. {
  511. if (hdmi_flag_check(HAS_ACTIVE_DATA) == FALSE)
  512. {
  513. schedule_work(&wq_nosignal);
  514. }
  515. }
  516. static void nosignal_timer_schedule(UINT32 delay_ms)
  517. {
  518. hdmidbg("%s: check signal after %d ms\n", __FUNCTION__, delay_ms);
  519. del_timer(&nosignal_timer);
  520. nosignal_timer.expires = jiffies + ((HZ / 1000) * delay_ms) + HZ / 1000;
  521. nosignal_timer.data = (UINT32)NULL;
  522. nosignal_timer.function = (void (*)(ULONG))NOSIGNAL_TIMER;
  523. add_timer(&nosignal_timer);
  524. }
  525. static void nosignal_timer_remove(void)
  526. {
  527. del_timer(&nosignal_timer);
  528. //#ifdef CONFIG_HDMI_DELAY_START_5V_DETECTION
  529. WQ_NOSIGNAL_CNT=0;
  530. VBUS_TOGGLE_CNT=0;
  531. //#endif
  532. }
  533. void hdmi_signal_check_start(void)
  534. {
  535. UINT32 delay_ms;
  536. UINT8 fInRange = HDMI_RegisterRead(HDMIRX_IN_RANGE);
  537. if(fInRange==0)
  538. {
  539. if(hdmi_get_cur_port() == HDMI_PORT_C)
  540. {
  541. delay_ms = 1500;
  542. }
  543. else
  544. {
  545. delay_ms = HDMI_INFORM_NOSIGNAL_DELAY_NO_5V;
  546. }
  547. }
  548. else
  549. {
  550. /* Wait for Long Time if 5V is high, otherwise wait for Short Time */
  551. #ifdef HDMI_DDC5V_WORKAROUND
  552. #ifdef CONFIG_HDMI_SUPPORT_MHL
  553. #ifdef CONFIG_HDMI_MHL_PORT
  554. if((MHL_CABLE_IN == TRUE)&&(DrvHDMIPortSelectBitsGet()==CONFIG_HDMI_MHL_PORT))
  555. {
  556. delay_ms = HDMI_INFORM_NOSIGNAL_DELAY_NO_5V;
  557. }
  558. else
  559. {
  560. delay_ms = (CEC_Get_SW5V(hdmi_get_cur_port()) == DRV_5V_LEVEL_HIGH) ? HDMI_INFORM_NOSIGNAL_DELAY_WITH_5V : HDMI_INFORM_NOSIGNAL_DELAY_NO_5V;
  561. }
  562. #endif
  563. #else
  564. delay_ms = (CEC_Get_SW5V(hdmi_get_cur_port()) == DRV_5V_LEVEL_HIGH) ? HDMI_INFORM_NOSIGNAL_DELAY_WITH_5V : HDMI_INFORM_NOSIGNAL_DELAY_NO_5V;
  565. #endif
  566. #else
  567. #ifdef CONFIG_HDMI_SUPPORT_MHL
  568. #ifdef CONFIG_HDMI_MHL_PORT
  569. if((MHL_CABLE_IN == TRUE)&&(DrvHDMIPortSelectBitsGet()==CONFIG_HDMI_MHL_PORT))
  570. {
  571. delay_ms = HDMI_INFORM_NOSIGNAL_DELAY_NO_5V;
  572. }
  573. else
  574. {
  575. delay_ms = hdmi_get_hpd_at_cur_src() ? HDMI_INFORM_NOSIGNAL_DELAY_WITH_5V : HDMI_INFORM_NOSIGNAL_DELAY_NO_5V;
  576. }
  577. #endif
  578. #else
  579. delay_ms = hdmi_get_hpd_at_cur_src() ? HDMI_INFORM_NOSIGNAL_DELAY_WITH_5V : HDMI_INFORM_NOSIGNAL_DELAY_NO_5V;
  580. #endif
  581. #endif
  582. }
  583. hdmidbg("%s: check signal after %d ms\n", __FUNCTION__, delay_ms);
  584. nosignal_timer_schedule(delay_ms);
  585. }
  586. void hdmi_signal_lock_check_start(void)
  587. {
  588. nosignal_timer_schedule(1000);
  589. }
  590. void hdmi_signal_check_stop(void)
  591. {
  592. hdmidbg("%s: removed\n", __FUNCTION__);
  593. nosignal_timer_remove();
  594. }
  595. /* active */
  596. #ifdef CONFIG_QSD
  597. #define ACTIVE_DEBOUNCE_DELAY (1) //unit:10ms
  598. #else
  599. //#define ACTIVE_DEBOUNCE_DELAY (20) //unit:10ms
  600. #define ACTIVE_DEBOUNCE_DELAY (25) //unit:10ms
  601. #endif
  602. //#define ACTIVE_DEBOUNCE_TIMES (10)
  603. #define ACTIVE_DEBOUNCE_TIMES (1)
  604. #define MAX_HDCP_WAIT_TIMES (10)
  605. #define MAX_AVI_INFO_WAIT_TIMES (7)
  606. UINT32 MAX_BCH_ERROR_CNT = 0x20;
  607. #define ACTIVE_SIGNAL_MONITOR_DELAY (1) //unit:10ms
  608. static void ACTIVE_TIMER(void* dummy)
  609. {
  610. BOOL bWait = false;
  611. #ifdef CONFIG_QSD //for module test, reduce debounce time
  612. if(HDMI_GetInputInformation(&stKic) == 1)
  613. {
  614. if((stKic.bDviEnable == 0) && (stKic.uiHactive > 600) && (stKic.uiVactive > 200) &&(stKic.uiVfreq > 20))
  615. {
  616. hdmidbg("%s: Status verified after %d run\n", __FUNCTION__, active_run);
  617. hdmidbg("\t%s Mode\n", HDMI_RegisterRead(HDMIRX_R_HDMI_en) ? "HDMI" : "DVI");
  618. hdmidbg("\t%s AVI InfoFrame\n", hdmi_flag_check(HAS_AVIINFO_PKT) ? "Have" : "No");
  619. hdmidbg("\t%s HDCP HandShake\n", hdmi_flag_check(HAS_HDCP) ? "Have" : "No");
  620. /* Remove nosignal timer */
  621. hdmi_signal_check_stop();
  622. /* Set flag */
  623. hdmi_flag_set(HAS_ACTIVE_DATA);
  624. schedule_work(&wq_active);
  625. signal_monitor_timer_schedule(ACTIVE_SIGNAL_MONITOR_DELAY);
  626. /* Enable audio sample coming isrs */
  627. HDMI_Interrupt_Enable(INTR_audio_sample_coming | INTR_HBR_audio_sample_coming);
  628. return;
  629. }
  630. }
  631. hdmidbg("%s MT_code active round:%d\n", __FUNCTION__, active_run);
  632. active_run++;
  633. active_timer_schedule(ACTIVE_DEBOUNCE_DELAY);
  634. return;
  635. #endif
  636. if (active_run == 0)
  637. {
  638. //HDMI_NoticeHandler(HDMINOTICE_PROCESSING_IN, "ACTIVE_TIMER");
  639. }
  640. hdmidbg("%s[%d] bch_cnt:0x%x\n", __FUNCTION__, active_run, HDMI_RegisterRead(HDMIRX_R_bch_ep_cnt));
  641. if(HDMI_RegisterRead(HDMIRX_R_bch_ep_cnt)>MAX_BCH_ERROR_CNT)
  642. {
  643. HDMI_RegisterWrite(HDMIRX_Clr_bch_epcnt, 1);
  644. if (active_run >= 3)
  645. {
  646. printk("[H] BCH error, Reset HDMI and toggle HPD!!! \n");
  647. //Reset PLL
  648. //HDMI_RegisterWrite(HDMIRX_CTL_R_MORECTRLI_15_0_, 0x0020);
  649. //HDMI_DelayMs(2);
  650. //HDMI_RegisterWrite(HDMIRX_CTL_R_MORECTRLI_15_0_, 0x0028);
  651. HDMI_RegisterWrite(HDMIRX_R_DDC5V_reset, 1);
  652. HDMI_RegisterWrite(HDMIRX_R_rst_n, 0);
  653. HDMI_DelayMs(2);
  654. HDMI_RegisterWrite(HDMIRX_R_rst_n, 1);
  655. HDMI_RegisterWrite(HDMIRX_R_DDC5V_reset, 0);
  656. /* Check signal status */
  657. //hdmi_signal_check_start();
  658. HDMI_Toggle_HPD();
  659. active_run = 0;
  660. return;
  661. }
  662. }
  663. #ifdef USE_HW_ADAPTIVE_EQ
  664. #ifdef CONFIG_HDMI_SUPPORT_MHL
  665. if((MHL_CABLE_IN != TRUE)||( DrvHDMIPortSelectBitsGet() != CONFIG_HDMI_MHL_PORT))
  666. #endif
  667. {
  668. if (active_run == 0)
  669. {
  670. printk("(HDMIRX_unstable_align_cnt) Clear \n");
  671. HDMI_RegisterWrite(HDMIRX_unstable_align_cnt, 1);//Write 1 clear
  672. }
  673. #if 0
  674. if(HDMI_RegisterRead(HDMIRX_unstable_align_cnt)>0x20)
  675. {
  676. printk("(HDMIRX_unstable_align_cnt)=%d\n",HDMI_RegisterRead(HDMIRX_unstable_align_cnt));
  677. printk("(HDMIRX_unstable_align_cnt)>0x0 Reset PLL!!!!!! \n");
  678. //Reset PLL
  679. HDMI_Reset_HDMI_PLL();
  680. HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 0);
  681. HDMI_DelayMs(2);
  682. /* Power On PHY */
  683. HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 1);
  684. HDMI_RegisterWrite(HDMIRX_R_DDC5V_reset, 1);
  685. HDMI_RegisterWrite(HDMIRX_R_rst_n, 0);
  686. HDMI_DelayMs(2);
  687. HDMI_RegisterWrite(HDMIRX_R_rst_n, 1);
  688. HDMI_RegisterWrite(HDMIRX_R_DDC5V_reset, 0);
  689. /* Check signal status */
  690. //hdmi_signal_check_start();
  691. active_run = 0;
  692. return;
  693. }
  694. #else
  695. printk("(HDMIRX_unstable_align_cnt)=%d\n",HDMI_RegisterRead(HDMIRX_unstable_align_cnt));
  696. #endif
  697. }
  698. #endif
  699. if (HDMI_RegisterRead(HDMIRX_R_HDMI_en) &&
  700. hdmi_flag_check(HAS_HDCP) == false &&
  701. hdmi_flag_check(HAS_AVIINFO_PKT) == false &&
  702. active_run < MAX_HDCP_WAIT_TIMES)
  703. {
  704. bWait = true;
  705. }
  706. if (HDMI_RegisterRead(HDMIRX_R_HDMI_en) &&
  707. hdmi_flag_check(HAS_AVIINFO_PKT) == false &&
  708. active_run < MAX_AVI_INFO_WAIT_TIMES)
  709. {
  710. bWait = true;
  711. }
  712. #ifdef CONFIG_HDMI_SUPPORT_MHL
  713. if((MHL_CABLE_IN == TRUE)&&( DrvHDMIPortSelectBitsGet() == CONFIG_HDMI_MHL_PORT))
  714. {
  715. if(hdmi_flag_check(HAS_AVIINFO_PKT) == false && hdmi_get_cur_port() == CONFIG_HDMI_MHL_PORT)
  716. bWait = true;
  717. if (hdmi_flag_check(HAS_HDCP_REQUEST_EARLY_THEN_PLL_LOCK) == true && hdmi_flag_check(HAS_HDCP) == false &&
  718. active_run < MAX_HDCP_WAIT_TIMES)
  719. {
  720. bWait = true;
  721. }
  722. if (hdmi_flag_check(HAS_HDCP) == false &&
  723. active_run < MAX_HDCP_WAIT_TIMES)
  724. {
  725. bWait = true;
  726. }
  727. }
  728. #endif
  729. if ((hdmi_flag_check(HAS_AVIINFO_PKT) == true) &&
  730. (0x00 == (HDMI_RegisterRead(HDMIRX_0134_DW_0134))) &&
  731. (active_run < MAX_AVI_INFO_WAIT_TIMES))
  732. {
  733. bWait = true;
  734. }
  735. if (active_run < ACTIVE_DEBOUNCE_TIMES)
  736. {
  737. bWait = true;
  738. }
  739. if (bWait)
  740. {
  741. active_run++;
  742. active_timer_schedule(ACTIVE_DEBOUNCE_DELAY);
  743. return;
  744. }
  745. //HDMI_RegisterWrite(HDMIRX_R_BYTE_ALIGN_CNT2, 4);
  746. hdmidbg("%s: Status verified after %d run\n", __FUNCTION__, active_run);
  747. hdmidbg("\t%s Mode\n", HDMI_RegisterRead(HDMIRX_R_HDMI_en) ? "HDMI" : "DVI");
  748. hdmidbg("\t%s AVI InfoFrame\n", hdmi_flag_check(HAS_AVIINFO_PKT) ? "Have" : "No");
  749. hdmidbg("\t%s HDCP HandShake\n", hdmi_flag_check(HAS_HDCP) ? "Have" : "No");
  750. /* Remove nosignal timer */
  751. hdmi_signal_check_stop();
  752. /* Set flag */
  753. hdmi_flag_set(HAS_ACTIVE_DATA);
  754. if(false == Hdmi_Check_H_V_Ready())
  755. {
  756. hdmidbg("Top field active lines and H active width are not ready!!\n");
  757. }
  758. schedule_work(&wq_active);
  759. // signal_monitor_timer_schedule(ACTIVE_SIGNAL_MONITOR_DELAY);
  760. /* Enable audio sample coming isrs */
  761. HDMI_Interrupt_Enable(INTR_audio_sample_coming | INTR_HBR_audio_sample_coming);
  762. }
  763. void active_timer_schedule(UINT32 ten_ms)
  764. {
  765. hdmidbg("Active Run #%d, wait for %d ms\n", active_run, ten_ms * 10);
  766. del_timer(&active_timer);
  767. active_timer.expires = jiffies + ((HZ / 100) * ten_ms) + HZ / 100;
  768. active_timer.data = (UINT32)NULL;
  769. active_timer.function = (void (*)(ULONG))ACTIVE_TIMER;
  770. add_timer(&active_timer);
  771. }
  772. void active_timer_remove(void)
  773. {
  774. del_timer(&active_timer);
  775. active_run = 0;
  776. }
  777. static void SIGNAL_MONITOR_TIMER(void* dummy)
  778. {
  779. VIP_InterfaceKIC CurKic;
  780. bool fResolution_change = false;
  781. UINT32 Vactive_o, Vactive_e;
  782. UINT32 BCH_ERR_CNT_THRE;
  783. UINT8 Vfreq_Tolerance;
  784. /* Horizontal */
  785. CurKic.uiHactive = HDMI_RegisterRead(HDMIRX_de_h_width_lock) / (HDMI_RegisterRead(HDMIRX_R_AVI_PR) + 1);
  786. if (active_run <= ACTIVE_DEBOUNCE_TIMES*2)
  787. {
  788. active_run++;
  789. }
  790. else
  791. {
  792. if(CurKic.uiHactive >= 2560)
  793. {
  794. BCH_ERR_CNT_THRE = 0x4000;
  795. }
  796. else
  797. {
  798. BCH_ERR_CNT_THRE = 0x1000;
  799. }
  800. if(HDMI_RegisterRead(HDMIRX_R_bch_ep_cnt)>BCH_ERR_CNT_THRE)
  801. {
  802. printk("%s bch_cnt:0x%x\n", __FUNCTION__,HDMI_RegisterRead(HDMIRX_R_bch_ep_cnt));
  803. HDMI_Toggle_HPD();
  804. return;
  805. }
  806. }
  807. /* Interlace */
  808. CurKic.bInterlace = HDMI_RegisterRead(HDMIRX_R_Interlace);
  809. /* Vertical */
  810. Vactive_o = HDMI_RegisterRead(HDMIRX_top_de_v_width_lock);
  811. Vactive_e = HDMI_RegisterRead(HDMIRX_btn_de_v_width_lock);
  812. /* Vfreq */
  813. CurKic.uiVfreq = (6000 / (VIP_RegisterRead(VIP_sta_hdmi_frmcnt)+1));
  814. if(((INT32)(HDMI_RegisterRead(HDMIRX_R_TOP_VDEE) - HDMI_RegisterRead(HDMIRX_R_TOP_VDES))) < 0)
  815. {
  816. Vactive_o = Vactive_o + 1;
  817. }
  818. if(((INT32)(HDMI_RegisterRead(HDMIRX_R_BTM_VDEE) - HDMI_RegisterRead(HDMIRX_R_BTM_VDES))) < 0)
  819. {
  820. Vactive_e = Vactive_e + 1;
  821. }
  822. if (Vactive_o != 0)
  823. {
  824. CurKic.uiVactive = Vactive_o;
  825. CurKic.uiVtotal = HDMI_RegisterRead(HDMIRX_R_TOP_VT);
  826. CurKic.uiVstart = HDMI_RegisterRead(HDMIRX_R_TOP_VDES);
  827. }
  828. else
  829. {
  830. CurKic.uiVactive = Vactive_e;
  831. CurKic.uiVtotal = HDMI_RegisterRead(HDMIRX_R_BTM_VT);
  832. CurKic.uiVstart = HDMI_RegisterRead(HDMIRX_R_BTM_VDES);
  833. }
  834. if(CurKic.bInterlace == 1)
  835. {
  836. if(Vactive_o == (Vactive_e + 1))
  837. CurKic.uiVactive = Vactive_e;
  838. else
  839. CurKic.uiVactive = Vactive_o;
  840. }
  841. CurKic.uiVend = CurKic.uiVstart + CurKic.uiVactive ;
  842. /* Horizontal */
  843. //CurKic.uiHactive = HDMI_RegisterRead(HDMIRX_de_h_width_lock) / (HDMI_RegisterRead(HDMIRX_R_AVI_PR) + 1);
  844. /* Patch: hactive should be a even number in DVI mode */
  845. if (HDMI_RegisterRead(HDMIRX_R_HDMI_en) == 0)
  846. {
  847. CurKic.uiHactive &= 0xfffffffe;
  848. }
  849. CurKic.uiHtotal = HDMI_RegisterRead(HDMIRX_R_HT) + 1;
  850. CurKic.uiHstart = HDMI_RegisterRead(HDMIRX_R_HDES) + 1;
  851. CurKic.uiHend = CurKic.uiHstart + CurKic.uiHactive;
  852. #ifdef CONFIG_SUPPORT_4K_2K_30
  853. if (CurKic.uiHactive == 3840)
  854. {
  855. //hdmidbg("......4K x 2K.....\n");
  856. CurKic.uiHactive = (CurKic.uiHactive)/2;
  857. CurKic.uiHtotal = (CurKic.uiHtotal)/2;
  858. CurKic.uiHstart = (CurKic.uiHstart)/2 ;
  859. CurKic.uiHend = (CurKic.uiHend)/2;
  860. }
  861. if (CurKic.uiHactive >= 2560)
  862. {
  863. CurKic.uiHactive = (CurKic.uiHactive)/2;
  864. CurKic.uiHtotal = (CurKic.uiHtotal)/2;
  865. CurKic.uiHstart = (CurKic.uiHstart)/2 ;
  866. CurKic.uiHend = (CurKic.uiHend)/2;
  867. }
  868. #endif
  869. if(abs(stKic.uiVfreq* HDMI_VFREQ_TOLERANCE_PERMILE / 100) < 1)
  870. {
  871. Vfreq_Tolerance = 1;
  872. }
  873. else
  874. {
  875. Vfreq_Tolerance = abs(stKic.uiVfreq* HDMI_VFREQ_TOLERANCE_PERMILE / 100);
  876. }
  877. if(abs(CurKic.uiHactive - stKic.uiHactive ) > abs(stKic.uiHactive * HDMI_HVAILD_TOLERANCE_PERMILE / 1000))
  878. {
  879. printk("#UNSTBL_H:HVld=%d(%d)\n", CurKic.uiHactive, stKic.uiHactive);
  880. fResolution_change = true;
  881. }
  882. else if (abs(CurKic.uiVactive - stKic.uiVactive ) > abs(stKic.uiVactive * HDMI_VVAILD_TOLERANCE_PERMILE / 1000))
  883. {
  884. printk("#UNSTBL_H:VVld=%d(%d)\n", CurKic.uiVactive, stKic.uiVactive);
  885. fResolution_change = true;
  886. }
  887. else if (abs(CurKic.uiHtotal - stKic.uiHtotal ) > abs(stKic.uiHtotal * HDMI_HTOTAL_TOLERANCE_PERMILE / 1000))
  888. {
  889. printk("#UNSTBL:HTotal=%d\n", CurKic.uiHtotal);
  890. fResolution_change = true;
  891. }
  892. else if (abs(CurKic.uiVtotal - stKic.uiVtotal) > abs(stKic.uiVtotal* HDMI_VTOTAL_TOLERANCE_PERMILE / 1000))
  893. {
  894. printk("#UNSTBL:VTotal=%d\n", CurKic.uiVtotal);
  895. fResolution_change = true;
  896. }
  897. else if (abs (CurKic.uiVfreq - stKic.uiVfreq) > Vfreq_Tolerance)
  898. {
  899. printk("#UNSTBL:Vfreq=%d\n", CurKic.uiVfreq);
  900. fResolution_change = true;
  901. }
  902. if(fResolution_change == true)
  903. {
  904. printk("Mode Change!!!!!! \n");
  905. VIP_MuteScreenDirectly(); // VIP_MuteScreen_ISR(); might be pending until the next V sync ISR
  906. HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 0);
  907. HDMI_DelayMs(2);
  908. /* Power On PHY */
  909. HDMI_RegisterWrite(HDMIRX_PHY_DIV_RESETJ, 1);
  910. HDMI_RegisterWrite(HDMIRX_R_DDC5V_reset, 1);
  911. HDMI_RegisterWrite(HDMIRX_R_rst_n, 0);
  912. HDMI_DelayMs(2);
  913. HDMI_RegisterWrite(HDMIRX_R_rst_n, 1);
  914. HDMI_RegisterWrite(HDMIRX_R_DDC5V_reset, 0);
  915. }
  916. else
  917. {
  918. signal_monitor_timer_schedule(ACTIVE_SIGNAL_MONITOR_DELAY);
  919. }
  920. HDMI_RegisterWrite(HDMIRX_Clr_bch_epcnt, 1);
  921. }
  922. UINT8 Hdmi_Check_H_V_Ready(void)
  923. {
  924. UINT8 i,Status;
  925. Status = false;
  926. for(i=0;i<40;i++)
  927. {
  928. if((0 == HDMI_RegisterRead(HDMIRX_top_de_v_ready)) ||
  929. (0 == HDMI_RegisterRead(HDMIRX_de_h_ready)) ||
  930. (0 == HDMI_RegisterRead(HDMIRX_R_TOP_VDEE_ready)))
  931. {
  932. HDMI_DelayMs(25);
  933. }
  934. else
  935. {
  936. Status = TRUE;
  937. break;
  938. }
  939. }
  940. return Status;
  941. }
  942. void signal_monitor_timer_schedule(UINT32 ten_ms)
  943. {
  944. //hdmidbg("bch_check, wait for %d ms\n",ten_ms * 10);
  945. del_timer(&signal_monitor_timer);
  946. //signal_monitor_timer.expires = jiffies + ((HZ / 100) * ten_ms) + HZ / 100;
  947. signal_monitor_timer.expires = jiffies + ((HZ / 100) * ten_ms);
  948. signal_monitor_timer.data = (UINT32)NULL;
  949. signal_monitor_timer.function = (void (*)(ULONG))SIGNAL_MONITOR_TIMER;
  950. add_timer(&signal_monitor_timer);
  951. }
  952. void signal_monitor_timer_remove(void)
  953. {
  954. del_timer(&signal_monitor_timer);
  955. }
  956. /* avi */
  957. void avi_change_schedule(void)
  958. {
  959. schedule_work(&wq_avi_change);
  960. }
  961. /* turn off software 5V */
  962. void HDMI_TurnOff_SW_5V_schedule(UINT32 delay_ms, HDMI_PORT_T ePort)
  963. {
  964. hdmidbg("%s: Turn off Software 5V after %d ms\n", __FUNCTION__, delay_ms);
  965. del_timer(&turn_off_sw_5V_timer);
  966. turn_off_sw_5V_timer.expires = jiffies + ((HZ / 1000) * delay_ms) + HZ / 1000;
  967. turn_off_sw_5V_timer.data = (UINT32)ePort;
  968. turn_off_sw_5V_timer.function = (void (*)(ULONG))WQ_TURN_OFF_SW5V;
  969. add_timer(&turn_off_sw_5V_timer);
  970. }
  971. void HDMI_TurnOff_SW_5V_schedule_cancel(HDMI_PORT_T ePort)
  972. {
  973. //hdmidbg("%s: Turn off Software 5V cancel\n", __FUNCTION__);
  974. del_timer(&turn_off_sw_5V_timer);
  975. }
  976. //==========================================
  977. // Initial
  978. //==========================================
  979. void hdmi_processing_init(void)
  980. {
  981. init_timer(&nosignal_timer);
  982. init_timer(&active_timer);
  983. init_timer(&signal_monitor_timer);
  984. init_timer(&turn_off_sw_5V_timer);
  985. INIT_WORK(&wq_active, (work_func_t) WQ_ACTIVE);
  986. INIT_WORK(&wq_nosignal, (work_func_t) WQ_NOSIGNAL);
  987. INIT_WORK(&wq_avi_change, (work_func_t) WQ_AVI_CHANGE);
  988. INIT_WORK(&wq_turn_off_sw_5V, (work_func_t) WQ_TURN_OFF_SW5V);
  989. }