polling.c
上传用户:caisangzi8
上传日期:2013-10-25
资源大小:15756k
文件大小:68k
源码类别:

DVD

开发平台:

C/C++

  1. /*
  2. ** FILE
  3. ** polling.c
  4. **
  5. ** DESCRIPTION
  6. ** polling hardware response.
  7. **
  8. **
  9. ** HISTORY     terry, maintain
  10. **             2003.03.07    reduce stack by inline function
  11. **
  12. **/
  13. #include "config.h"
  14. #include "global.h"
  15. #include "memmap.h"
  16. #include "memmap0.h"
  17. #include "avd.h"
  18. #include "util.h"
  19. #include "stc.h"
  20. #include "audio.h"
  21. #include "cd.h"
  22. #include "cddsp.h"
  23. #include "ringbuf.h"
  24. #include "sig.h"
  25. #include "user_init.h"
  26. #include "vfdfunc.h"
  27. #include "func.h"
  28. #include "cfont.h"
  29. #include "osd.h"
  30. #include "macro.h"
  31. #include "dsp3_if.h"
  32. #include "ircmd.h"
  33. #include "kernel.h"
  34. #include "fs96602.h"
  35. #include "fs.h"
  36. #include "nav.h"
  37. #include "polling.h"
  38. #include "fsnav.h"
  39. #include "kinf.h"
  40. #include "pinf.h"
  41. #include "gpio.h"
  42. #include "timer.h"
  43. #include "ircode.h"//terry 20030822
  44. #include "avi_if.h"
  45. #ifdef TTE_HOST_DVD
  46. #include "pca9564.c" //lijd for TTE PCA9564 2004-11-11 19:56
  47. #endif
  48. #ifdef UART_WITHOUT_DEBUG_MODE
  49. #include "io_uart0.h"
  50. #include "UartComm.h"
  51. #endif
  52. #ifdef UART_SWAP //axel swap uart0 and uar1 2004/10/29
  53. #include "io_uart1.h"
  54. #include "UartComm.h"
  55. #endif
  56. #ifdef QSI_PLATFORM //qsi: merge by johnson 20040712
  57. #include "drv.h"
  58. //sharon
  59. #endif
  60. #ifdef SUPPORT_MIDI
  61. #include "fsmidi.h"
  62.     #ifdef SUPPORT_MIDI_MENU_SEL  //by dtb in 20040225
  63. #include "fsMidiUI.h"
  64. #endif
  65. #endif
  66. #if defined(SUPPORT_TUNER_MV114) || defined(SUPPORT_TUNER_ALPS)
  67. #include "radio_mv114_kst.h"//xyy 2004-5-26
  68. #endif
  69. #ifdef SUPPORT_UART_UPGRADE
  70. #include "UartComm.h"
  71. #endif
  72. #ifdef SUPPORT_EXTERNAL_MIC
  73. #include "gpio.h"
  74. #endif
  75. #ifdef  SUPPORT_MP4_SUBTITLE
  76. #include "Subtitle.h"
  77. #endif
  78. #ifdef SUPPORT_REP_READ
  79. #include "read.h"
  80. #endif
  81. #ifdef PROVIEW_GPIO_KEY     //BRUCE ADD 2003/2/14 12:20PM
  82. #include ".\Customers\Conser\proviewkey.c"
  83. #endif
  84. #ifdef  SUPPORT_SPI
  85. #include "spi.h"
  86. #endif
  87. #ifdef SUPPORT_DISPLAY_MENU
  88. #include "setup_def.h"
  89. #endif
  90. #ifdef SUPPORT_CD_TEXT
  91. #include "CDTextUtil.h"
  92. #endif
  93. //for support SWD //jslin   //20041022
  94. #ifdef SUPPORT_PS2
  95. #include "polling_PS2.c"
  96. #endif
  97. #ifdef DVB1000_NON_OS //eric 2005-01-04 11:06
  98. #include "Sp_dtv.h"
  99. #endif
  100. #ifdef SUPPORT_PLAY_SWD
  101. extern void polling_SWD(void);
  102. #endif
  103. #ifdef HDMI
  104. //==========================kevin add for HDMI
  105. extern void HDCP_polling(void);
  106. //=============================================================
  107. #endif
  108. //=====================================================
  109. //* debug option
  110. //=====================================================
  111. #ifndef DVDRELEASE
  112. //#define POLLING_DBG     1
  113. #endif
  114. #ifdef  POLLING_DBG
  115. //#define MONE_TIMEOUT
  116. //#define MONE_TIMEOUT_SRC
  117. //#define MONE_DSP24
  118. #endif
  119. #ifndef POLLING_DBG
  120. #undef printf
  121. #undef print_block
  122. #define printf(f, a...) do {} while (0)
  123. #define print_block(x,y) do {} while (0)
  124. #endif
  125. #ifdef TTE_HOST_DVD  //lijd for TTE PCA9564 2004-11-11 19:56
  126. #define HDI_STATE_IDLE               0
  127. #define HDI_STATE_WAIT_CTL_RESERVED  1
  128. #define HDI_STATE_WAIT_CTL_CODE      2
  129. #define HDI_STATE_WAIT_SYS_RESERVED  3
  130. #define HDI_STATE_WAIT_SYS_CODE      4
  131. #define HDI_STATE_WAIT_INF_RESERVED  5
  132. #define HDI_STATE_WAIT_INF_CODE      6
  133. #define HDI_STATE_WAIT_SET_RESERVED  7
  134. #define HDI_STATE_WAIT_SET_CODE      8
  135. #endif
  136. //=====================================================
  137. //* extern function declare
  138. //=====================================================
  139. extern inline void  PollingI2CPageWrite();
  140. extern inline void Score_Polling(); // in score.c
  141. extern void ircmd_pre_paser(BYTE rx);
  142. extern inline void dvd_hl_force_action(void);
  143. extern void update_vfd_data(void);
  144. extern inline void polling_dvd_timer(void);
  145. extern inline void recover_hl_color(void);
  146. extern void DisplayEq(void);
  147. extern void DispPolling(BYTE bReset);
  148. extern void tv_format_machine(void);
  149. extern inline void dsp_watchdog(void);
  150. extern void reset_vfd_again(void);
  151. extern void polling_vfdsw(void);
  152. extern void polling_phone(void);            //////yangli 2004-10-12
  153. extern void AC3ShowReport();
  154. extern inline void polling_mp3(void);
  155. extern int ClockPolling(BYTE show);
  156. //extern void tuner_mute(int mute);
  157. extern void check_key_status(void);
  158. extern void check_key_status_ourmind();
  159. extern void check_ourmind_light_status();
  160. extern void check_keyboard_status();
  161. extern void check_keylight_status();
  162. #ifdef DVD_SERVO
  163. extern void ServoDecMainLoop(void);
  164. #endif
  165. extern void pollingUARTServo(void);
  166. extern void ircmd_play(void);
  167. extern inline void MPx_ChkSmpRate();
  168. extern UINT16 Is_JPEG_PLAY_STATE(void);
  169. extern void check_keyboard_status();
  170. #ifdef SUPPORT_CARD_STORAGE
  171. extern void polling_card_plug(void);
  172. #endif //SUPPORT_CARD_STORAGE
  173. #if defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)
  174. extern void polling_storage();  //wthsin,2004/4/12 02:16pm
  175. #endif 
  176. #ifdef PMP_DVD 
  177.  extern void PMP_PC_Usb_PlugInOut();
  178. #endif //#ifdef PMP_DVD 
  179. #if defined(PCM1742)&&defined(CHECK_DAC_ZERO_FLAG_TO_GPIO_MUTE)     //gerry,3-10-20 11:35
  180. extern void check_pcm1742_zero_flag();
  181. #endif
  182. #ifdef  SETUP_DONT_PAUSE
  183. extern void polling_10ms_save(void);
  184. #endif
  185. #ifdef POLLING_10MS_SAVE_RESUME //Maoyong, 2004.03.01 10:02
  186. extern void polling_10ms_save_rsm(void);
  187. #endif  
  188. #ifdef SHOW_STANDBY_TIMER//suqiaoli 2003-8-7 
  189. extern void polling_setup_standby_timer(void);
  190. #endif  
  191. #if defined(SUPPORT_FS_LONGNAME)
  192. extern void FS_ScrollDispFileName(void);
  193. #endif
  194. #ifdef SUPPORT_DSPMUTE
  195. extern UINT32 coding_mode_now;      // benson add 2004-08-20 for receiver 
  196. #endif 
  197. #ifdef SUPPORT_UPGRADE_WHEN_RUNNING
  198. extern void polling_upgrade_info();
  199. #endif
  200. //=====================================================
  201. //* external var. decalare
  202. //=====================================================
  203. extern BYTE gAC3onoff;
  204. extern BYTE audioNotContinuous;
  205. extern BYTE tuner_mute_flag;
  206. extern BYTE polling_clock;
  207. extern BYTE bJpgVFDPause;
  208. extern UINT8  safe_on;
  209. #if defined(SUPPORT_BASS_TREBLE)
  210. extern BYTE flag_BassAdjust; //xulf
  211. extern BYTE flag_TrebleAdjust; //xulf
  212. #endif
  213. //============================kevin add for HDMI==============
  214. #ifdef HDMI
  215. extern void ResetAuthentStates();
  216. extern void AuthenticationHandler();  //authenticate the RX include all processes
  217. extern void DSIntegratyLinkCheck();
  218. #endif
  219. //===================================================
  220. //=====================================================
  221. //* define
  222. //=====================================================
  223. #define GET_RTC_15_0()  (regs0->rtc_15_0)
  224. //=====================================================
  225. //* local var.
  226. //=====================================================
  227. #ifdef CHECKPHONE
  228. int phone_flag=0;   /////////////////yangli add it for 5.1ch phone,2004-10-10
  229. int phone_flag_k=0;
  230. #endif
  231. #ifdef AUTO_CLOSE_LOADER
  232. UINT16 auto_close_timer=0;
  233. #endif
  234. #ifdef RECORD_PER_SECOND
  235. int resume_time_ourmind=0;
  236. #endif
  237. UINT8   polling_avoid_reentry=0;
  238. UINT8   dsp_delay=0;
  239. #ifdef AVOID_READDISC_WHEN_STARTUP  //xyy add for Oritron
  240. UINT16 uStartCounter=0;
  241. UINT16 uCounterFlag=0;
  242. #endif
  243. #ifdef SUPPORT_EXTERNAL_MIC
  244. UINT16 auto_mute_extern_mic_timer=0;
  245. #endif
  246. #ifdef CD_PLAYER        //liweihua 2003-9-3
  247. extern void DisplaycdEq(void);
  248. #endif
  249. #ifdef DVB1000_NON_OS //eric add 2005-01-04 13:53 
  250. int progCount=0;
  251. stProgramInfo_t *progInfo; 
  252. int nTimeCounter = 0;
  253. #endif
  254. //=====================================================
  255. //* static inline function
  256. //=====================================================
  257. //#include "line21.c"
  258. #include "polling_fun.h"
  259. //=====================================================
  260. //* Option function
  261. //=====================================================
  262. //terry,2004/2/11 04:44PM
  263. //move asv function to asv.c
  264. #ifdef AUTO_CLOSE_LOADER
  265. static inline void auto_close_fun(void)
  266. {
  267.     if(auto_close_timer&0x8000)
  268.     {
  269.         auto_close_timer++;
  270.         //printf("auto_close_timer=%xn",auto_close_timer);
  271.         if(auto_close_timer>0x8040)
  272.         {
  273.             if(system_state == SYSTEM_OPEN)
  274.             {
  275.                 auto_close_timer=0;
  276.                 ircmd_play();
  277.             }
  278.             else
  279.             {
  280.                 auto_close_timer=0;
  281.             }
  282.         }
  283.    }
  284. }
  285. #else
  286. #define auto_close_fun();
  287. #endif
  288. #ifdef RECORD_PER_SECOND
  289. static inline void auto_record_per_s(void)
  290. {
  291.     if(play_state==VCD_STATE_NORMAL)
  292.     {
  293.         if(Is_MP3_STATE()||((cd_type_loaded!=CDROM)&&(!is_menu())))
  294.         {   if(resume_time_ourmind<6)
  295.             {
  296.                 resume_time_ourmind++;
  297.                 //printf("resume_time_ourmind=%dn",resume_time_ourmind);
  298.             }
  299.             if(resume_time_ourmind>=6)
  300.             {
  301.                 RsmInfo2Flash(0);
  302.                 resume_time_ourmind=0;
  303.                 //printf("resume_time_ourmind=%dn",resume_time_ourmind);
  304.             }
  305.         }
  306.     }
  307. }
  308. #else
  309. #define auto_record_per_s();
  310. #endif
  311. #ifdef STB_2_0
  312. static inline void ethernet_access(void)
  313. {
  314.     //for Ethernet Access test
  315.     if (iIntCnt != pr0Cnt)
  316.     {
  317.       printf("cnt=%dn",iIntCnt);
  318.       pr0Cnt=iIntCnt;
  319.     }
  320.     *pEth=0x01;
  321.     p=*pEth;
  322.     if (p!=0x01) printf("Eth Error!!n");
  323. }
  324. #else
  325. #define ethernet_access()       ((void)(0))
  326. #endif //STB_2_0
  327. static inline void dsp_dbg_fun(void)
  328. {
  329. #ifndef MONE_DSP24
  330. regs0->dsp24_port[6] = 0;
  331. #else//#ifndef MONE_DSP24
  332.     int dbg_msg;
  333.     if (regs0->dsp24_port[6])
  334.     {
  335.     #ifndef  MONE_DSP24_LONG  //ycwen 2004/12/15  Printf short message to prevent from disturbing audio debugging
  336.     printf("DSP: %04xn", regs0->dsp24_port[7]);
  337.     //ycwen 2004/12/15 Print video and audio buffer status if necessary
  338.     //printf("DSP3: %04x %x %xn", regs0->dsp24_port[7], get_vbv_free_exact(vbv_y), dsp3_get_rest_buf_size());
  339.     #else//#ifndef  MONE_DSP24_LONG  //ycwen 2004/12/15  Printf short message to prevent from disturbing audio debugging
  340.     dbg_msg=regs0->dsp24_port[7];//show DSP message
  341.     printf("DSP3:");
  342.     switch(dbg_msg)
  343.     {
  344.     case 0xC011:
  345.     printf(" %04x download dsp3rom.d16.ac3.2ch successfullyn",dbg_msg);
  346.     break;
  347.     case 0xC012:
  348.     printf(" %04x download dsp3rom.d16.ac3.5.1ch.16M successfullyn",dbg_msg);
  349.     break;
  350.     case 0xC031:
  351.     printf(" %04x download dsp3rom.d16.mp3.2ch successfullyn",dbg_msg);
  352.     break;
  353.     case 0xC032:
  354.     printf(" %04x download dsp3rom.d16.mp3.2ch.EQ.16M successfullyn",dbg_msg);
  355.     break;
  356.     case 0xC041:
  357.     printf(" %04x download dsp3rom.d16.lpcm.2ch successfullyn",dbg_msg);
  358.     break;
  359.     case 0xC042:
  360.     printf(" %04x download dsp3rom.d16.lpcm.2ch.EQ.16M successfullyn",dbg_msg);
  361.     break;
  362.     case 0xC061:
  363.     printf(" %04x download dsp3rom.d16.cd.2ch successfullyn",dbg_msg);
  364.     break;
  365.     case 0xC071:
  366.     printf(" %04x download dsp3rom.d16.wma.2ch successfullyn",dbg_msg);
  367.     break;
  368.     case 0xC091:
  369.     printf(" %04x download dsp3rom.d16.spdif.2ch successfullyn",dbg_msg);
  370.     break;
  371.     case 0xC0B1:
  372.     printf(" %04x download dsp3rom.d16.nes.2ch successfullyn",dbg_msg);
  373.     break;
  374.     case 0xD011:
  375.     printf(" %04x download dsp3rom.d16.ac3 successfullyn",dbg_msg);
  376.     break;
  377.     case 0xD012:
  378.     printf(" %04x download dsp3rom.d16.ac3.spi successfullyn",dbg_msg);
  379.     break;  
  380.     case 0xD013:
  381.     printf(" %04x download dsp3rom.d16.945.ac3 successfullyn",dbg_msg);
  382.     break;  
  383.     case 0xD021:
  384.     printf(" %04x download dsp3rom.d16.dts successfullyn",dbg_msg);
  385.     break;  
  386.     case 0xD022:
  387.     printf(" %04x download dsp3rom.d16.dts.spi successfullyn",dbg_msg);
  388.     break;  
  389.     case 0xD023:
  390.     printf(" %04x download dsp3rom.d16.dtscd successfullyn",dbg_msg);
  391.     break;  
  392.     case 0xD024:
  393.     printf(" %04x download dsp3rom.d16.945.dts successfullyn",dbg_msg);
  394.     break;  
  395.     case 0xD025:
  396.     printf(" %04x download dsp3rom.d16.108.dtscd successfullyn",dbg_msg);
  397.     break;
  398.     case 0xD026:
  399.     printf(" %04x download dsp3rom.d16.raw.dtscd successfullyn",dbg_msg);
  400.     break;
  401.     case 0xD031:
  402.     printf(" %04x download dsp3rom.d16.mp3 successfullyn",dbg_msg);
  403.     break;
  404.     case 0xD041:
  405.     printf(" %04x download dsp3rom.d16.lpcm successfullyn",dbg_msg);
  406.     break;
  407.     case 0xD042:
  408.     printf(" %04x download dsp3rom.d16.lpcm.fudo successfullyn",dbg_msg);
  409.     break;  
  410.     case 0xD051:
  411.     printf(" %04x download dsp3rom.d16.ppcm successfullyn",dbg_msg);
  412.     break;
  413.     case 0xD061:
  414.     printf(" %04x download dsp3rom.d16.cd successfullyn",dbg_msg);
  415.     break;
  416.     case 0xD062:
  417.     printf(" %04x download dsp3rom.d16.cd.spi successfullyn",dbg_msg);
  418.     break;
  419.     case 0xD071:
  420.     printf(" %04x download dsp3rom.d16.wma successfullyn",dbg_msg);
  421.     break;
  422.     case 0xD081:
  423.     printf(" %04x download dsp3rom.d16.midi successfullyn",dbg_msg);
  424.     break;
  425.     case 0xD091:
  426.     printf(" %04x download dsp3rom.d16.spdif successfullyn",dbg_msg);
  427.     break;
  428.     case 0xD0A1:
  429.     printf(" %04x download dsp3rom.d16.noise successfullyn",dbg_msg);
  430.     break;
  431.     case 0xD0B1:
  432.     printf(" %04x download dsp3rom.d16.nes successfullyn",dbg_msg);
  433.     break;
  434.     case 0xD0C1:
  435.     printf(" %04x download dsp3rom.d16.tuner successfullyn",dbg_msg);
  436.     break;
  437.     case 0xCDEF:
  438.     printf(" %04x DSP PCM output underflown",dbg_msg);
  439.     break;
  440.     case 0xDEAD:
  441.     printf(" %04x bitstream  errorn",dbg_msg);
  442.     break;
  443.     default:
  444.     printf(" %04xn",dbg_msg);
  445.     }//switch(dbg_msg)
  446. #endif //#ifndef  MONE_DSP24_LONG  //ycwen 2004/12/15  Printf short message to prevent from disturbing audio debugging
  447.         regs0->dsp24_port[6]=0;
  448.     }// if (regs0->dsp24_port[6])
  449. #endif // #ifndef MONE_DSP24
  450. }
  451. #ifdef TURN_OFF_POWER_RESUME
  452. //wangap add 2004/4/21
  453. void polling_resume(void)
  454. {
  455. RsmInfo2Flash(0);
  456. }    
  457. #endif
  458. //=====================================================
  459. //* function
  460. //=====================================================
  461. //
  462. // FUNCTION
  463. // polling_timeout()
  464. //
  465. // DESCRIPTION
  466. // check if timeout
  467. //
  468. void polling_timeout(void)
  469. {
  470.     if( ( timeout_playback )        // 2004/12/29 yltseng
  471. #ifndef SETUP_DONT_PAUSE
  472.         && ( full_scrn != SETUP )
  473. #endif
  474. #ifndef PROG_DONT_PAUSE
  475.         && ( full_scrn != PROGRAM )
  476. #endif
  477.     )
  478.     {
  479.         if (get_rtc() > timeout_playback)
  480.         {
  481.           //if (GetIntrMask()&INTR_TIMEOUT)
  482.           //    SetIntrFlag(GetIntrFlag()|INTR_TIMEOUT);
  483. #ifdef MONE_TIMEOUR_SRC
  484.           printf(__FUNCTION__" timeoutn");
  485. #endif
  486.           if(auto_pause)
  487.           {
  488.             timeout_playback=0;
  489.             ircmd_play();
  490.           }
  491.           else
  492.             AVD_SetMediaTimeout();
  493.         }
  494.     }
  495. }
  496. #ifdef SUPPORT_HEADPHONE  //xyy 2004-10-9
  497. #define TEST_HEADPHONE_SENSE      (regs0->gpio_in[HEADPHONE_SENSE/16]&(1<<(HEADPHONE_SENSE%16)))    //pin71
  498. extern void ddx_masterMute(BYTE mute);
  499. extern void ddx_enableEPAD(void);
  500. extern void ddx_disableEPAD(void);
  501. extern void write_reg_bit(int addr,BYTE bit,BYTE val);
  502. BYTE bHpPlug;  // 1: headphone plug in   0:headphone not plug in
  503. BYTE bCounter[2];
  504. void polling_headphone(void)
  505. {
  506. static BYTE bOldStas,bNewStas;
  507. if(TEST_HEADPHONE_SENSE)
  508. {
  509. bCounter[0]++;
  510. if(bCounter[0]<5 && !TEST_HEADPHONE_SENSE)
  511. bCounter[0] = 0;
  512. if(bCounter[0] == 5)
  513. {
  514. bHpPlug = 1;
  515. bCounter[0] = 0;
  516. }
  517. }
  518. else
  519. {
  520. bCounter[1]++;
  521. if(bCounter[1]<5 && TEST_HEADPHONE_SENSE)
  522. bCounter[1] = 0;
  523. if(bCounter[1] == 5)
  524. {
  525. bHpPlug = 0;
  526. bCounter[1] = 0;
  527. }
  528. }
  529. bNewStas = bHpPlug;
  530. if(bHpPlug && (bNewStas!=bOldStas))
  531. {
  532.     ddx_masterMute(1);
  533. ddx_disableEPAD();
  534. write_reg_bit(0x04,6,1);//set channel 7/8 to binary mode
  535. write_reg_bit(0x04,7,1);
  536. ddx_masterMute(0);
  537. }
  538. else if((!bHpPlug) && (bNewStas!=bOldStas))
  539. {
  540.     ddx_masterMute(1);
  541. write_reg_bit(0x04,6,0);//set channel 7/8 to ddx mode
  542. write_reg_bit(0x04,7,0);
  543. ddx_enableEPAD();
  544. ddx_masterMute(0);
  545. }
  546. bOldStas = bNewStas;
  547. }
  548. #endif
  549. void disp_fan_in(void)
  550. {
  551.     extern BYTE    osd0_state;           //OSD0 state
  552.     if (osd0_state>1)
  553.     {
  554.         #ifdef SUPPORT_FUNCTION_MENU
  555.         if ((full_scrn!=SETUP) && (full_scrn!=SETUP_PLUS))
  556.         #else
  557.         if (full_scrn!=SETUP)
  558.         #endif //end #ifdef SUPPORT_FUNCTION_MENU
  559.             DispPolling(2);
  560.     }
  561. }
  562. #ifdef QSI_PLATFORM//liulifeng add 2004-10-13////jhuang 2004/11/23
  563. enum  {
  564.     ERROR_CODE_N = 0x0,
  565.     ERROR_CODE_1,
  566.     ERROR_CODE_2,
  567.     ERROR_CODE_3,
  568.     ERROR_CODE_4
  569. };
  570. BYTE QSI_PIPO_error_code_station = ERROR_CODE_3;
  571. BYTE QSI_PIPO_error_code_time_flag=0;
  572. static inline void QSI_PIPO_error_code ( void )
  573. {
  574.     if ( QSI_PIPO_error_code_station != 0 )//error occur
  575.     {
  576.         if ( QSI_PIPO_error_code_time_flag < 21)
  577.         {
  578.             if ( ( (QSI_PIPO_error_code_time_flag / 3) %2 )
  579.                ||(  QSI_PIPO_error_code_time_flag  > ((QSI_PIPO_error_code_station - 1 )*6 + 3))
  580.                )
  581.                 GPIO_O_SET(GPIO_IS_FOR_SYSTEM_LED,0); // led Off
  582.             else
  583.                 GPIO_O_SET(GPIO_IS_FOR_SYSTEM_LED,1); // led On
  584.         }
  585.         else if ( QSI_PIPO_error_code_time_flag < 25 )
  586.         {
  587.             GPIO_O_SET(GPIO_IS_FOR_SYSTEM_LED,0); // led Off
  588.         }
  589.         else if ( QSI_PIPO_error_code_time_flag < 28 )
  590.         {
  591.             GPIO_O_SET(GPIO_IS_FOR_SYSTEM_LED,1); // led On
  592.         }
  593.         else if ( QSI_PIPO_error_code_time_flag < 50 )
  594.         {
  595.             GPIO_O_SET(GPIO_IS_FOR_SYSTEM_LED,0); // led Off
  596.         }
  597.         else
  598.             QSI_PIPO_error_code_time_flag = 0xff;
  599.         QSI_PIPO_error_code_time_flag++;
  600.     }
  601. }
  602. #endif//#ifdef QSI_PLATFORM
  603. //#define SUPPORT_DEBUG_FOR_TRAY_IN_AND_HOME_SWITCH   // 2004/12/17 yltseng
  604. static inline void DebugFuncForTrayInAndHomeSwitch()
  605. {
  606. #ifdef SUPPORT_DEBUG_FOR_TRAY_IN_AND_HOME_SWITCH
  607.     // First parameter is TryIn, Second is HomeSwitch
  608.     // TrayIn     : Defined in sys_servo.c TRAY_IS_IN_GPIO
  609.     // HomeSwitch : Fixed at GPIO 6
  610.     psprintf( RegionValStr[REGION1], "%d %d", GPIO_I_GET(5), GPIO_I_GET(6) );
  611.     PrintOsdMsg(STR_OS_SPACE, REGION1, 1, 1);
  612. #endif
  613. }
  614. //
  615. // FUNCTION
  616. // polling_100ms
  617. //
  618. extern BYTE keytimer; //chen edit 0512
  619. #ifdef   FUNC_AUTO_RETURN_VOL_STATE
  620. extern  BYTE func_key_set_flag;
  621. extern BYTE bFuncStep;
  622. #endif
  623. static inline void polling_100ms(void)
  624. {
  625. //--------- chen edit 0512--------- 
  626.   if(keytimer!=0)
  627.    {
  628.           keytimer--;
  629.    }
  630. #ifdef   FUNC_AUTO_RETURN_VOL_STATE
  631.  if(func_key_set_flag)
  632.   {
  633. if(timeout_osd[1]==0)
  634. {
  635.   func_key_set_flag=0;
  636.                              bFuncStep=0;
  637. }
  638.   }
  639.  
  640. #endif
  641.   //-------------------
  642.     DebugFuncForTrayInAndHomeSwitch();
  643.     
  644. #ifdef QSI_PLATFORM//liulifeng add 2004-10-13//jhuang 2004/11/23
  645.     QSI_PIPO_error_code ();
  646. #endif
  647. #ifdef PMP_MCU810
  648.   if((GetCurrentFileType() != CDROM_JPEG )&&(GetCurrentFileType() != CDROM_DAT )
  649.       &&(GetCurrentFileType() != CDROM_MPG) &&(GetCurrentFileType() != CDROM_MP4) 
  650.    ||(pFsJpeg->gifsState == FS_STATE_LIST||pFsJpeg->gifsState == FS_STATE_MP3))
  651.      Show_PMP_Bat();
  652. #endif
  653. #ifdef  SUPPORT_SPI
  654.     polling_spi();
  655.     spi_service();
  656. #endif
  657. #ifdef  SUPPORT_MP4_SUBTITLE
  658.     if (GetCurrentFileType() == CDROM_MP4) ///David add 2004-5-9,  no need to polling subtitle except MP4 disc. 
  659.     {
  660.         if( (full_scrn & SOUND) || (play_state == VCD_STATE_PAUSE) )  //David 2004-5-12
  661.             return;
  662.     if (IS_EXT_SUP_ACTIVATED())
  663.     {
  664.         extern ifunc polling_subtitle;
  665.         if( polling_subtitle )
  666.         {
  667.         #ifdef SPHE8202_FAT_Write_Function
  668.         if(!(full_scrn & PERIPHERAL))              //sunzhh add 2004-11-25
  669.         #endif
  670.         polling_subtitle();
  671.     }
  672.     }
  673.     }
  674. #endif
  675. #ifdef PDVD_USE_IO_SCAN_KEY //Jack modified 04/06/03
  676. //#ifdef GBM_PORTABLE_DVD
  677.   check_portable_key(); //rbhung for GBM Portable DVD
  678. #endif
  679. //freyman 2002-7-4 11:30
  680. #ifdef VFD_VOLUME_DISPLAY
  681. {
  682.     int diff;
  683.     //diff=timenow-rtc_100ms;
  684.     
  685.     polling_vfdtime(diff);
  686. }
  687. #endif
  688. #ifdef USE_GAMEPORT_TO_BUTTON//nono 20020824
  689.     check_key_status();
  690. #elif defined(OURMIND_VFDPORT_TO_BUTTON)//nono 20020824
  691.     check_key_status_ourmind();
  692.     check_ourmind_light_status();
  693. #elif defined(USE_VFDPORT_TO_BUTTON)
  694.     check_keyboard_status();
  695. #elif defined(USE_VFDPORT_TO_KEYLIGHT)
  696.     check_keylight_status();
  697. #endif
  698. #if defined(FAT_Write_UI)||defined(CF_CARD_WRITE)//||defined(WRITE_USB)//liweihua 2003-10-29
  699. extern void polling_input_name(void);
  700. extern BYTE input_flag;
  701. if((full_scrn & PERIPHERAL) && (input_flag == 1))
  702.     polling_input_name();
  703. #endif
  704. #ifdef AC3TEST
  705.   if (gAC3onoff==1) {
  706.     AC3ShowReport();
  707.   }
  708.   AC3CheckSampling();
  709. #endif
  710.     if ( (audioNotContinuous>0) && (play_state==VCD_STATE_NORMAL) ) { //count it when STATE_NORMAL, Jeff 20021202
  711.         audioNotContinuous--;
  712.         if (audioNotContinuous==0) {
  713.       if (!user_mute) {
  714.                 AUDIF_Demute();//2004AUDDRV AudioDemute();
  715. #ifdef CHANGE_DSP_SPDIF_OFF
  716.                 AUDIF_Set_SPDIF(setupGetSetting(14));//2004AUDDRV AudioSetSPDIF(setupGetSetting(14));
  717. #endif//#ifdef CHANGE_DSP_SPDIF_OFF
  718.       }
  719.     }
  720.   }
  721. #ifdef NF_100
  722.   if( (play_state!=VCD_STATE_PAUSE)&&(full_scrn!=SETUP) )
  723.   {
  724.     if( dvd_timer>0 )
  725.     {
  726.       //printf("polling_100ms  play_state = %dn",play_state);
  727.       polling_dvd_timer();
  728.     }
  729.   }
  730. #else
  731.     if( ( P_frame == 0 )            // 2004/12/29 yltseng
  732. #ifndef SETUP_DONT_PAUSE
  733.         && ( full_scrn != SETUP )
  734. #endif
  735. #ifndef PROG_DONT_PAUSE
  736.         && ( full_scrn != PROGRAM )
  737. #endif
  738.     )
  739.     {
  740.         if(!IsAVDPaused() && (dvd_timer>0) )
  741.           polling_dvd_timer();
  742.     }
  743. #endif
  744.   if (hl_timer>0)
  745.     recover_hl_color();
  746.   if (auto_pause)
  747.     polling_timeout();
  748.     
  749.     #ifdef SUPPORT_FUNCTION_MENU
  750.     if(setup_menu_plus_timer)
  751.       polling_setup_menu_plus();
  752.     #endif //end #ifdef SUPPORT_FUNCTION_MENU
  753.     
  754. #ifdef SUPPORT_REP_READ
  755.     if(IsReadMode())
  756.         PollingRecBufStatus();
  757. #endif
  758.     
  759. #ifdef FS_BMP_GUI//zhaoyanhua add 2004-6-29 15:58    
  760.     if(cd_type_loaded == CDROM) // Robert 021004
  761.     {
  762.         if ((GetCurrentFileType() == CDROM) || (GetCurrentFileType() == CD_DA) || (GetCurrentFileType() == CDROM_WMA) || (GetCurrentFileType() == CDROM_AAC))
  763.             polling_mp3();
  764.     }
  765. #endif//#ifdef FS_BMP_GUI   
  766.  
  767. #ifdef BRIGHTNESS_COLOR_KEY
  768.     polling_BCtimer();
  769. #endif
  770.    
  771. #ifdef SUPPORT_HEADPHONE  //xyy 2004-10-9 
  772. polling_headphone();
  773. #endif
  774. #ifdef ALONE_GPIO_KEY//Jack 20041008
  775.     polling_portable_akey();
  776. #endif
  777. #ifdef CONTINUOUS_NUM_KEY_SELECT
  778.   if(ir_num_timer)
  779.     polling_ir_num();  
  780. #endif 
  781. #ifdef DVB1000_NON_OS
  782. if(system_state == SYSTEM_TS)
  783. {
  784. CheckProgInterval();
  785. CheckDvbTunerStatus();
  786. }
  787. #endif
  788. }
  789. //
  790. //
  791. extern int gbm_gpio_led_flag;
  792. extern  BYTE   cd_type_loaded;
  793. #ifdef SunplusMoudleTest //axel 2004/4/2 11:55am while detected DVD, wait for 15 sec, tray out...
  794. UINT16 ModuleTicks=0;
  795. static inline void auto_modual_test(void)
  796. {
  797.     if(cd_type_loaded==CDDVD)
  798.     {
  799.         if(ModuleTicks>=45)
  800.          {
  801.             ModuleTicks=0;
  802.             ircmd_stop();
  803.             delay_srv_10ms(100);
  804.             //ircmd_power();
  805. /*          delay_srv_10ms(500);
  806.             ircmd_trayin();*/
  807.          }  
  808.         else
  809.          ModuleTicks++; 
  810.         
  811.     }   
  812. }
  813. #else
  814. #define auto_modual_test();
  815. #endif
  816. /*
  817. * polling_one_minute()  wangap add 2004/4/26 
  818. */
  819. static inline void polling_one_minute(void)
  820. {
  821.   #ifdef TURN_OFF_POWER_RESUME //wangap 2004/4/21  
  822.   if(play_state!=VCD_STATE_STOP)
  823.   polling_resume();
  824.   #endif  
  825. }
  826.                     
  827. #ifdef  AUTO_ADJUST_TV_TYPE
  828. BYTE  Adjust_TV_type =0;
  829. #endif                    
  830. #ifdef UART_WITHOUT_DEBUG_MODE //axelchen 2004/10/20 
  831.               
  832. void ReturnFromUart(void)
  833. {
  834.   int d;
  835.     if (!IsEPPRxEmpty())
  836.     {
  837.         d = EPP_GETC();
  838.         UART0_putc(d);
  839.     }   
  840. }
  841. #endif
  842. #ifdef SLEEP_CONTROL_COUNTER   //liumzh 2004-12-10 23:53
  843. UINT32 counter_sleep_control = 0;
  844. UINT32 sleep_time = 15;//seconds
  845. #endif
  846. #ifdef  STOP_15M_AUTO_POWEROFF
  847. extern UINT8 STOP_15M_STATE;
  848. unsigned short int second_counter=0;
  849. unsigned short int sleep_counter=0;
  850. unsigned char one_second_flag=1;
  851. int  timer_counter=0;
  852. unsigned char sleep_show_flags;
  853. #endif
  854. /*
  855. *   polling_500ms()
  856. */
  857. static inline void polling_500ms(void)
  858. {
  859. /*#ifdef DVB1000_NON_OS
  860. int iHasTDT=0;
  861. iHasTDT=PollingTDT(5);//eric add 2004-12-16 15:12 use Demux channel 5
  862. if((full_scrn == PROGRAMINFO)&&iHasTDT)
  863. {
  864. printf("full_scrn == PROGRAMINFO)&&PollingTDT(5)n");
  865.  DisplayProgramInfo(1);
  866. }
  867. #endif*/ //eric change  polling TDT to 1SEC 
  868. #ifdef PMP_KEYBOARD  //xyy 2005-1-10
  869.     extern polling_pmpkey(void);
  870.     polling_pmpkey();
  871. #endif
  872. #ifdef EASTECH_SETUPMENU
  873. extern BYTE check_show_pscan_wait_time_mode;
  874. extern void pscan_change_time_out(void);
  875. extern void refresh_pscan_wait_time(BYTE wait_time);
  876. static BYTE wait_time=CHANGE_TO_PSCAN_WAIT_TIME_TOTAL;
  877. if(check_show_pscan_wait_time_mode==1){
  878. wait_time--;
  879. if(wait_time==0){
  880. pscan_change_time_out();
  881. wait_time=0;
  882. check_show_pscan_wait_time_mode=0;
  883. }
  884. else{
  885. refresh_pscan_wait_time(wait_time);
  886. }
  887. }
  888. else wait_time=CHANGE_TO_PSCAN_WAIT_TIME_TOTAL;
  889. #endif
  890. #ifdef UART_WITHOUT_DEBUG_MODE //axelchen 2004/10/20 
  891. ReturnFromUart();
  892. #endif
  893. #ifdef SLEEP_CONTROL_COUNTER   //liumzh 2004-12-10 23:53
  894. if(counter_sleep_control >= sleep_time *100*60)
  895. {
  896. counter_sleep_control = 0;
  897. sleep_time = 0;
  898. ircmd_power();
  899. }
  900. #endif
  901. #ifdef  STOP_15M_AUTO_POWEROFF
  902. if(STOP_15M_STATE==1)
  903. {
  904. if((sleep_counter)/*&&(system_state== SYSTEM_STOP)*/)
  905. {
  906. sleep_show_flags--;
  907. if(!sleep_show_flags)
  908. ;//osd_sleep_disp(sleep_counter);
  909.          second_counter++;
  910.          if(second_counter>=60*2)
  911.          {  second_counter=0;          
  912.             
  913.                  sleep_counter--;
  914.                 if(sleep_counter==0)
  915.                  {
  916. if((system_state== SYSTEM_STOP)||(play_state==VCD_STATE_STOP))
  917. ircmd_power();  
  918.                  }
  919.          }
  920.  }
  921. }
  922. #endif
  923.     #ifdef SUPPORT_CD_TEXT             //lizhx  add 04/10/17
  924.     if (cd_type_loaded == CDDA)
  925.     {
  926.         if(!((full_scrn & PROGRAM)||(full_scrn & SETUP)||(full_scrn & SOUND)))
  927.             show_CDText_Title_Content(v11_trk_now);
  928.     }
  929.     #endif
  930. #ifdef  MIDI_SCORE_TEST //modify by xlluo for test
  931.     extern BYTE gb_showScore;
  932.     #endif
  933.     auto_modual_test();//terry,2004/4/2 04:49PM
  934.      #ifdef  AUTO_ADJUST_TV_TYPE
  935.     if((play_state==VCD_STATE_NORMAL) && (Adjust_TV_type==1))
  936.     {        
  937.         auto_adjust_tv_type();       
  938.     }
  939.     #endif
  940.     // mute mute
  941.     if (is_dts_force_spdif_bitstream()) {
  942.         regs0->aud_pcm_ramp_delta   = 0xff;
  943.         regs0->aud_pcm_ramp_cfg     = 1;
  944.     }
  945.     
  946.     #ifdef TEST_SERVO
  947.     srv_mode_test_polling();//terry,2003/9/10 12:57AM
  948.     #endif
  949. #ifdef  RECORD_KEY//zhaoyanhua add 03-11-5 13:02
  950.     if(same_disc_flag)
  951.         same_disc_flag++;
  952.     #endif
  953.     auto_close_fun();
  954.     auto_record_per_s();
  955. #ifdef SCRN_SAVER_WHEN_PAUSE
  956.     if (full_scrn & SETUP)//4-3-5 23:24
  957.         safe_srn_off();
  958.     else if(play_state == VCD_STATE_PAUSE)
  959.         #ifdef SUPPORT_MIDI    //ouyang add for don't show saver in midi2005-1-12 19:22
  960.         if(!gIsMidiSelMenu)  
  961.         #endif 
  962.         safe_srn_on();
  963. #endif
  964. #ifdef USE_PIN31_CONTROL_POWER_LED      //gerry,2004-3-9 19:42
  965.     if(gbm_gpio_led_flag<=4)
  966.     gbm_gpio_led_flag++;
  967.     else
  968.     {
  969.         GPIO_O_SET(4,1);
  970.     }
  971. #endif//USE_PIN31_CONTROL_POWER_LED
  972.     if (regs0->dsp24_port[4]==1)
  973.     { //to check whether MIC is on or off, Jeff 20020904
  974.         mic_on = 1;
  975.     } else {
  976.         mic_on = 0;
  977.     }
  978.   if ((full_scrn & SCORE)
  979. #ifdef  MIDI_SCORE_TEST //modify by xlluo 
  980.     ||(gb_showScore)
  981. #endif    
  982. #ifdef SUPPORT_SANJING_SCORE            //xlluo for sjspical score ui 04 -10 -15
  983.     ||(bIsSJScoreInvaild)
  984. #endif
  985.     )
  986.   { //Jeff 20020404
  987.     Score_Polling();
  988.   }
  989.   // check mp2/mp3 sample-rate (reported from audio decoder)
  990.   if(mpeg_audio) MPx_ChkSmpRate();
  991.   if(auto_download_audio_chn)
  992.   {
  993.        if(AUDIF_AutoDownload_Codec(auto_download_audio_chn-1))//2004AUDDRV audif_auto_download_codec(auto_download_audio_chn-1)
  994.        {//sucess
  995.            auto_download_audio_chn=0;
  996.        }
  997.   }
  998. #ifndef FS_BMP_GUI//zhaoyanhua 2004-6-29 15:58 
  999.   if(cd_type_loaded == CDROM) // Robert 021004
  1000.   {
  1001.       if ((GetCurrentFileType() == CDROM) || (GetCurrentFileType() == CD_DA) || (GetCurrentFileType() == CDROM_WMA) || (GetCurrentFileType() == CDROM_AAC))
  1002.           polling_mp3();
  1003.   }
  1004. #endif//#ifndef FS_BMP_GUI
  1005.   #ifdef REMAIN_TIME//nono 2-7-13 11:27
  1006. //  printf("polling:polling_clock=%dn",polling_clock);
  1007.   if(polling_clock<7)
  1008.   {
  1009.     if( (polling_clock==6)&&(t_disp) )
  1010.       t_disp+=10;
  1011.     polling_clock++;
  1012.    }
  1013.   #endif
  1014. #if defined(SUPPORT_TUNER_MV114) || defined(SUPPORT_TUNER_ALPS)  //xyy 2003-9-20 14:45
  1015.     if( system_state==SYSTEM_DOING_TUNER ) //huziqin 2004-2-26
  1016.      {
  1017.         if(tuner_mute_flag)
  1018.            tuner_mute_flag++;
  1019.         if(tuner_mute_flag>2)  // mute 500mS
  1020.           {
  1021.             tuner_mute_flag=0;
  1022.             if(!user_mute)
  1023.              tuner_mute(0);
  1024.            }
  1025.      }
  1026.  #endif
  1027. /*Here deleted by xyy 2004-8-5 */
  1028. #ifdef SUPPORT_FS_LONGNAME  //Maoyong 2004.06.24
  1029.     if( (play_state != VCD_STATE_PAUSE) && (play_state != VCD_STATE_STOP) 
  1030.         &&(pFsJpeg->gifsState == FS_STATE_LIST||pFsJpeg->gifsState == FS_STATE_MP3))                    
  1031.         FS_ScrollDispFileName();
  1032. #endif
  1033. //nono add "&&defined(USE_GPIO_MUTE)  "20040821
  1034. #if defined(SUPPORT_DSPMUTE)&&defined(USE_GPIO_MUTE)      //BENSON 2004/7/12 11:25