sysmain2.c
上传用户:poi891205
上传日期:2013-07-15
资源大小:9745k
文件大小:81k
源码类别:

DVD

开发平台:

C/C++

  1. /*
  2. ** FILE
  3. ** sysmain2.c
  4. **
  5. ** DESCRIPTION
  6. ** Main entry of DVD system firmware
  7. **
  8. ** Maintain by terry , 2003.03.07
  9. **
  10. */
  11. #include "sysmain2_h.h"
  12. #include "gpio.h"
  13. #include "user_init.h"
  14. #include "kinf.h"
  15. #include "sinf.h"
  16. #include "user_if.h"
  17. #include "timer.h"
  18. #ifdef POWER_ON_MUTE_MIC   //axel 2004/2/26 04:10pm mute mic during initialization
  19. #include "dsp3_if.h"
  20. #endif
  21. #ifdef TP6317_PANNEL   //yaowh add 04-10-25
  22.    extern BYTE TP6317_Power ;   //flag
  23. #endif
  24. #ifdef SPHE1000
  25. #ifdef  DVB1000_NON_OS
  26. #include "TunerDrv.h"   //maoyong 2004-9-27 16:58
  27. #include "sp_dtv.h"
  28. #endif //DVB1000_NON_OS
  29. //#define TEST_DVD
  30. #define LINUX_USER_LOGO     //MIKEY 2004.07.01
  31. #endif //SPHE1000
  32. #ifdef LINUX_USER_LOGO  //MIKEY 2004.07.01
  33. UINT8 f_check_user_logo=0;
  34. UINT8 *user_logo_rom_addr=(UINT8 *)0x88080000;
  35. UINT8 *user_logo_ram_addr=(UINT8 *)0x804e0000;
  36. int user_logo_ram_size=(128*1024);
  37. #define USER_LOGO_ROM_ADDR  (user_logo_rom_addr)
  38. #define USER_LOGO_RAM_ADDR  (user_logo_ram_addr)
  39. #define USER_LOGO_RAM_SIZE  (user_logo_ram_size)
  40. #endif
  41. #if 1//def TEST_SERVO//nono 2004-3-30 19:13
  42. #include "ircode.h"
  43. #endif
  44. #include "srv_test.c"
  45. extern UINT8 volume_value;
  46. #ifdef SUPPORT_RECEIVER     //benson  2004/03/01
  47. #include "dsp3_if.h"
  48. #endif
  49. #ifdef SUPPORT_APOGEE_AMP
  50. #include "ddx8000.h"
  51. #endif
  52. #include "auddrv.h" //2004AUDDRV oliver 20041004 for using audio driver purpose
  53. #ifdef SUPPORT_SPDIF_IN
  54. #include "audif.h"
  55. #endif
  56. #ifdef SUPPORT_WMA          
  57. #include "asf_if.h"
  58. #endif
  59. //jslin //for QSI PIPO  //20040901
  60. #ifdef QSI_SHOW_ERR_RATE
  61. #include "uart.h"
  62. #endif
  63. #ifdef DVB1000_OSD_MENU     //Maoyong 2004-10-12 11:28
  64. #include "dvbmenu.h"
  65. #endif
  66. //=========================
  67. #if defined(SUPPORT_WMA) || defined(SUPPORT_MP4)
  68. extern UINT32 nGotoPck;
  69. #endif
  70. //Maoyong 2004.03.05, move some resume relative declare/def to "rsm_util.h"
  71. #ifdef  CHECK_RECORD_DISK_PARENT_LVL    //Maoyong 2004.03.04
  72. extern BYTE CheckDiscParentLvl(void); 
  73. #endif
  74. extern BYTE CheckLoadRsmInfo(void); 
  75. extern void RecordRsmPlay(void);
  76. #if defined(AUDIO_2CH_5_1CH)&&defined(SUPPORT_PROLOGIC_II)//axel modified 2004/3/16 10:53am zhaoyanhua add 2003-12-17 9:47
  77. extern int setup_IsSpkDownmixOff(void);//setup_tab.c
  78. extern void AudioSet2chOutput(void);//setup_tab.c
  79. #endif
  80. #ifdef  DYNAMIC_SPECTRUM //zhaoyanhua add 03-11-6 15:26
  81. extern void Show3dspectrum(void); 
  82. #endif
  83. #ifdef USER_MPEG_LOGO
  84. extern UINT8 Is_User_Mpeg_Logo();
  85. #endif
  86. #ifdef CORTROL_VCD_ONF
  87. extern int setup_IsVCD_OFF();
  88. #endif
  89. #if defined(SUPPORT_CARD_STORAGE)||defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)
  90. extern BYTE IsCardMediaExist(void);
  91. extern void SwitchMedia(BYTE direction);
  92. #endif
  93. #ifdef  SUPPORT_REP_READ
  94. #include "read.h"
  95. #endif
  96. #ifdef PROVIEW_GPIO_KEY
  97. void set_proview_gpio_key(void);
  98. #endif
  99. void system_check_media_switch(void);
  100. void system_check_source_switch(void);// for QSI disccard switch   //added by JS   //20040727
  101. #ifdef PMP_DVD //wthsin, 2004/11/9 07:19
  102.  UINT8 PMP_ENABLE=0;
  103.  extern void pc_usb_access_mode();
  104. #endif //#ifdef PMP_DVD 
  105. #ifdef SUPPORT_Auo_2inch_Digital_panel
  106. extern void init_auo_digital_panel(void);
  107. #endif
  108. #ifdef SUPPORT_Auo_UPS053_Digital_panel
  109. extern void init_auo_ups053_digital_panel(void);                                
  110. #endif
  111. #ifdef FILE_MODE_WRITE//added by wangwei,2005-1-9 21:40
  112. extern unsigned int detect_CD;
  113. #endif
  114. #if defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)  //modefied by wangwei,2004-11-19 17:31(for storage no files screen refresh problem)
  115. extern UINT8 MediaIsEmpty;
  116. //#define MEDIA_EMPTY 1         //dingzhy moved to gb_def.h
  117. //#define MEDIA_NOT_EMPTY 0
  118. #endif
  119. //=====================================================
  120. //* debug option
  121. //=====================================================
  122. #ifndef DVDRELEASE
  123. //#define SYSMAIN2_DBG        1
  124. //#define MONE_LOGO
  125. #endif
  126. #undef FORCE_SKIP_VCD_MOSAIC//nono 4-6-9 0:35
  127. #ifndef SYSMAIN2_DBG
  128. #undef printf
  129. #undef print_block
  130. #define printf(f, a...) do {} while (0)
  131. #define print_block(x,y) do {} while (0)
  132. #endif
  133. //=====================================================
  134. //* var. and extern function decalare
  135. //=====================================================
  136. #include "sysmain2.h"
  137. extern UINT8 Subp_stream_Chg(UINT8,int);
  138. extern UINT16 Audio_stream_Chg_SVCD(UINT8);
  139. //2004AUDDRV extern void init_mp3(void);
  140. extern void do_mp3(void);
  141. extern int AUDIF_Set_Play();//2004AUDDRV AudioSetPlay();  //huziqin 2004-2-26
  142. extern int AUDIF_Set_Stop();//2004AUDDRV AudioSetStop();  //change type to int
  143. extern void RsmInfo2Flash(int);
  144. extern void LoadRsmInfo(void);
  145. extern void LoadModual(UINT16);
  146. extern void RS42Init();
  147. extern void RS2420Init();
  148. extern void DisplayScreenSaver();
  149. #ifdef DVD_SERVO
  150. extern UINT8 cServoWrongDataPass;
  151. #endif
  152. void SetDeInterlace(BYTE nVal);
  153. extern void setup_SetSPDIFConfig();//nono 3-8-18 15:45
  154. #ifdef CD_PLAYER    //liweihua 2003-9-3    
  155. extern void show_cdplayer(void);
  156. #endif
  157. #if defined(CF_CARD_WRITE) || defined(SPHE8202_FAT_Write_Function)//|| defined(WRITE_USB)
  158. extern BYTE read_card_sign,flag_cf2cd,flag_cd2cf;          //xulf
  159. #endif
  160. #ifdef VIRTUAL_KEYBOARD//liweihua 2003-9-18
  161. extern BYTE KeyID;
  162. void hl_keyboard_button(BYTE SelectID);
  163. void osd_draw_virtual_keyboard(int xStart, int yStart,BYTE r);
  164. #endif
  165. #ifdef LOGO_PLAY_MP3
  166.  int playindex;
  167. #endif 
  168. BYTE logo_play_mp3_flag;
  169. extern UINT8 power_on_mute;//terry 20030805
  170. extern void set_video_default_offset(void);//wanghaoying 2003-8-12 20:21
  171. extern void save_cmp_disc_info(UINT32 info1);//wanghaoying 2003-8-12 20:22
  172. #ifdef SUPPORT_HDD_ACCESS
  173.     UINT8 f_force_browser=0;
  174.     UINT8 f_browser_mode=0;
  175. #endif
  176. #ifdef USE_PIN31_CONTROL_POWER_LED      //gerry,2004-3-9 19:41
  177. int gbm_gpio_led_flag;
  178. #endif//USE_PIN31_CONTROL_POWER_LED
  179. void show_osd_disc_type(void)
  180. {//terry,2003/12/29 08:25PM
  181.     #if defined(JUST_SHOW_CD_TYPE)||defined(NOSHOW_CDROM_WHEN_DISP)||defined(BEAUTIFUL_STYLE)       //Not show CD Icon for NINTAUS Maoyong 2004.02.12
  182.     #if defined(NOSHOW_CDROM_WHEN_DISP)||defined(BEAUTIFUL_STYLE)//nono 2004-6-15 0:02    //dingzhy for beautiful
  183.     if(cd_type_loaded == CDROM)
  184.     #else
  185.     if(cd_type_loaded == CDDA)
  186.     #endif
  187.     {
  188.         osd_tog_region(REGION1, OSD_OFF);       
  189.         return;
  190.     }
  191.     #endif
  192.     
  193.     #ifdef GBM_DVD
  194.     PrintOsdMsg(osd_cd_id[cd_type_loaded],REGION1,2,0);
  195.     #elif defined(DVD_AUDIO)    // alan, 2003/8/15 04:23PM, to distinguish DVD-VIDEO or DVD-AUDIO
  196. #ifdef SHOW_DVD_ROM//NONO 4-2-10 19:08  
  197.     if( (is_svo_dvd())&&(cd_type_loaded==CDROM) ) 
  198.         {
  199.             OSD1000ISP_STATUS(OSDISP_TYPE_DVDROM, OSDIR_CDTYPE);
  200.             psprintf(RegionValStr[REGION1], "DVDROM");
  201.             PrintOsdMsg(STR_OS_SPACE,REGION1, 1, 1);
  202.         }
  203.     else 
  204. #endif//SHOW_DVD_ROM
  205.     
  206.     if (cd_type_loaded==CDDVD)  
  207.     {
  208.         if (dAMG_LSN==0)
  209.             psprintf(RegionValStr[REGION1], "DVD-VIDEO");     
  210.         else
  211.             psprintf(RegionValStr[REGION1], "DVD-AUDIO");
  212.         OSD1000ISP_STATUS(OSDISP_TYPE_DVD, OSDIR_CDTYPE);
  213.         PrintOsdMsg(STR_OS_SPACE,REGION1, 1, 1);
  214.     } else {
  215. #ifdef DVD_SERVO
  216.         if ((cd_type_loaded == CDVCD10) && (is_svo_dvd()))
  217. #else
  218.         if (cd_type_loaded == CDVCD10)
  219. #endif
  220. {
  221.             OSD1000ISP_STATUS(OSDISP_TYPE_DVD, OSDIR_CDTYPE);
  222.             PrintOsdMsg(osd_cd_id[CDDVD],REGION1,1,0);
  223. }
  224.         else
  225.         {
  226.             OSD1000ISP_STATUS(cd_type_loaded, OSDIR_CDTYPE);
  227.             PrintOsdMsg(osd_cd_id[cd_type_loaded],REGION1,1,0);        
  228.         }
  229.     }
  230.     #elif defined (FENGKAI_DVD)
  231.     ///////clead 2003-8-27 17:31
  232.     printf("**--- cd_type_loaded:%d  bDiscType:%d ---**n",cd_type_loaded,bDiscType);
  233.     
  234.     if((cd_type_loaded==CDSVCD)&&(bDiscType == CD_CVD))
  235.     {
  236.         OSD1000ISP_STATUS(OSDISP_TYPE_CVD, OSDIR_CDTYPE);
  237.         psprintf(RegionValStr[REGION1], "CVD");
  238.         PrintOsdMsg(STR_OS_SPACE,REGION1, 1, 1);
  239.     }else 
  240.     {
  241.         OSD1000ISP_STATUS(cd_type_loaded, OSDIR_CDTYPE);
  242.         PrintOsdMsg(osd_cd_id[cd_type_loaded],REGION1,1,0);
  243.     }
  244.     #elif defined(SKYWORTH_DVD)
  245.         if(cd_type_loaded!=CDROM)
  246.         {
  247.             OSD1000ISP_STATUS(cd_type_loaded, OSDIR_CDTYPE);
  248.             PrintOsdMsg(osd_cd_id[cd_type_loaded],REGION1,1,0);
  249.         }
  250.         else
  251.         PrintOsdMsg(STR_OS_SPACE,REGION1,1,0);
  252.     #else//#ifdef GBM_DVD
  253.     #ifdef DVD_SERVO
  254.         if ((cd_type_loaded == CDVCD10) && (is_svo_dvd()))
  255.     #else
  256.         if (cd_type_loaded == CDVCD10)
  257.     #endif
  258.         {
  259.             OSD1000ISP_STATUS(OSDISP_TYPE_DVD, OSDIR_CDTYPE);
  260.             PrintOsdMsg(osd_cd_id[CDDVD],REGION1,1,0);
  261.         }
  262.         else
  263.         {
  264.             OSD1000ISP_STATUS(cd_type_loaded, OSDIR_CDTYPE);
  265.             PrintOsdMsg(osd_cd_id[cd_type_loaded],REGION1,1,0);        
  266.         }
  267.     #endif//#ifdef GBM_DVD
  268. }
  269. //*******init ce2746 dac ******** wangap 2004/4/21
  270. #ifdef CE2746
  271. #define Chip_addr 0x6a     
  272. #define Register_addr 0x00  
  273. void init_ce2746()  
  274. {
  275.    int I2c_data1=0x01,I2c_data2=0x80;
  276.    WriteI2c(Chip_addr,Register_addr,I2c_data1,1);
  277.    delay_1ms(10);
  278.    WriteI2c(Chip_addr,Register_addr+1,I2c_data2,1);
  279. }
  280. #endif
  281. //=====================================================
  282. //* function decalare
  283. //=====================================================
  284. void InitVar(void)
  285. {
  286.     //init pe engine
  287.     pe_run = 0;
  288. //    dVts_iso9600_addr = 0;//terry,2003/8/6 04:01PM
  289. #ifdef TP6317_PANNEL   //yaowh add  04-10-25
  290.     TP6317_Power = 0 ;
  291. #endif
  292.     PE_ClearNav();
  293.     mpeg_audio=0;
  294.     dspWatchDog=DSP_WD_INIT;
  295.     
  296. #ifdef BAD_DISC_AUTO_STOP //terry,2003/8/31 12:00AM                   
  297.     bad_disc_auto_stop=0;
  298. #endif 
  299.     //init navigation
  300.     cd_subtype = CDROM_UNSUPPORT;
  301.     bDiscType=CDUNKNOWN;
  302.     still_timer=0;
  303.     //#ifdef SUPPORT_MIX_MP3_CDDA   //linrc change "SUPPORT_MIX_MP3_CDDA" to "SUPPORT_MIX_DATA_CDDA_DISC"
  304.     #ifdef SUPPORT_MIX_DATA_CDDA_DISC //because we not only support this type mix mode disc 2004-12-15 15:53
  305.     mp3_cd_end_trk = 0;
  306.     #endif
  307.     play_dir = 0;
  308.     Mp3ReadFinish=0;//mp3 ........
  309.     logo_play_mp3_flag=1;
  310.     fore_disp_time=-1;
  311.     jpg_slide_time = JPEG_SLIDE_TIME;//jpeg .......... wanghaoying 2003-8-26 20:21
  312.     
  313. #ifdef NO_BLACK_for_PIC_CD    
  314.     pic_cd_first_play = 0;
  315. #endif    
  316.     bPbcOff=0; //vcd ..........
  317.     cd_trk_now=0;
  318.     cd_trk_hi=0xff;
  319.     cd_trk_lo_now=0;
  320.     cd_trk_lo=0;
  321.     dVMG_LSN = 0; //dvd.......
  322.     HL_exist=0;
  323.     read_sector=0;
  324.     dvd_error=0;
  325.     min_astn_id=0;//terry,2003/12/15 02:33PM
  326.     dvd_karaoke_mode = 0; //terry,2004/2/16 11:11AM
  327.     #ifdef DVD_AUDIO
  328.     dAMG_LSN = 0;
  329.     #endif
  330.     #ifdef TUNR_OFF_PARENTAL_LVL
  331.     bTurnOffParentalLVL=0; //terry,2002/9/20 11:40PM
  332.     #endif
  333.     #ifdef JUST_SHOW_CD_TYPE    //Maoyong 2004.02.26
  334.     track_play_diff_time = 0;
  335.     #endif
  336.     
  337. #ifdef DVD_SEQ_PLAY
  338. #ifdef AUTO_PLAY
  339.     extern BYTE auto_play_on();
  340.     if (auto_play_on())
  341.         dvd_menu_play = 0;
  342.     else
  343.         dvd_menu_play = 1;
  344. #else
  345.     dvd_menu_play = 0;
  346. #endif
  347. #endif
  348.     // 2004/07/16 yltseng
  349.     wb_tag_init();          
  350.     
  351.     //init UI
  352.     init_ir_num();
  353.     goto_active=0;
  354.     mp3_user_select=0;
  355.     pFsJpeg->iso9660_file_cnt = 0;
  356.     disp_trk_now = 0;
  357.     Mp3_kbitrate=0;
  358.     bIntro=0;
  359.     //keep_cmd_code=0;
  360.     keep_cmd_code=IR_CODE_MAX_NUM;//2004-3-30 19:14
  361.     disc_st_time=0;
  362.     #if defined(IR_PLAY_RESUME) && defined(POWER_RESUME)  //yw 021003
  363.     power_resumeflag = 0;
  364.     #endif
  365.     
  366.     #ifdef SUPPORT_REP_READ    //Maoyong 2004.06.03
  367.     InitRead();
  368.     #endif
  369.     
  370.     #ifdef  SUPPORT_BOOK
  371.     init_book();
  372.     #endif
  373.     
  374.     goto_time = 0;//4-4-13 16:22
  375.         
  376. //#ifdef OP_UI//zhaoyanhua 2004-5-24 17:35
  377. //    prog_cnt = 0;
  378. //#endif
  379.     //nono move from ap_mian(): SYSTEM_READ_TITTLE.2004-2-27 12:00
  380.     coding_mode_now=AUDIF_CODING_MODE_NONE;//wangfeng 2003-12-19 17:44
  381. #ifdef USE_PIN31_CONTROL_POWER_LED      //gerry,2004-3-9 19:42
  382.     gbm_gpio_led_flag=0;
  383. #endif//USE_PIN31_CONTROL_POWER_LED
  384.     nOldFst = 0;          //Maoyong 2004.05.25 move from labif.c
  385. #ifdef SUPPORT_WMA        //Maoyong 2004.05.31 for WMA     
  386.     asf_resume_pck = 0;
  387. #endif
  388. #if defined(SUPPORT_WMA) || defined(SUPPORT_MP4)
  389.     nGotoPck = 0;
  390. #endif
  391.     //FS SWD
  392.     #ifdef SUPPORT_PLAY_SWD
  393.         START_POLLING_SWD = 0;
  394.     #endif
  395.     //OSD 16bit direct color
  396.     #ifdef SUPPORT_PS2
  397.         OSD_buffer_16bit = 0;
  398.     #endif
  399.     
  400.     //initiate PS2 mouse 
  401.     #ifdef SUPPORT_PS2
  402.         START_POLLING_PS2 = 0;  //hold polling
  403.         mouse_pos_x = 180;
  404.         mouse_pos_y = 120;
  405.         mouse_btn_status = 0x0;
  406.         PS2_INIT_DONE = 0x0;
  407.     #endif
  408. //==============================================
  409. //for QSI source switch     //added by JS   //20040726
  410. #if defined(QSI_PORTABLE_DVD) && defined(SUPPORT_CARD_STORAGE)
  411.     #ifdef SUPPORT_QSI_SOURCE_SWITCH
  412.         source_type_now = source_disc;
  413.         source_type_old = source_disc;
  414.     #endif
  415. #endif  
  416. //==============================================
  417. }
  418. extern  char    _stextf[];
  419. extern  char    _text_drv[], _text_drv_dvd[], _text_drv_ap[], _text_drv_iop[], _text_other[], _text_drv_cdrom[];
  420. extern  char    _text_drv_srvdp[], _text_drv_ap2[], _text_drv_free[];
  421. #include "kernel.h"
  422. #define CUSTM_LOGO 0
  423. #define SETUP_LOGO 1
  424. UINT8 logo_type=CUSTM_LOGO;
  425. extern const unsigned char Setup_Logo[];
  426. //
  427. //  show logo
  428. //
  429. //  Terry,2003/9/13 12:20AM
  430. //  integration mpeg logo/new style setup logo function
  431. void    ShowTitle()
  432. {
  433.     BYTE *p;
  434.     UINT32  unOffset;
  435. #ifdef NEW_STYLE_SETUP    //terry,2004/2/17 11:09AM
  436.     UINT8 setup;
  437. #endif  
  438.     #ifdef MONE_LOGO
  439.     printf("logo inn");
  440.     #endif
  441.     
  442. #ifdef LINUX_USER_LOGO  //MIKEY 2004.07.01
  443.         if(f_check_user_logo==0) {
  444.             printf("INFO: f_check_user_logo USER_LOGO_ROM_ADDR=[%x]n", USER_LOGO_ROM_ADDR);
  445.             f_check_user_logo=1;
  446.             p = (BYTE *) USER_LOGO_ROM_ADDR;
  447.             memset((BYTE *) USER_LOGO_RAM_ADDR, 0, USER_LOGO_RAM_SIZE);
  448.             if(*(p+0x80)=='T' && *(p+0x81)=='M') {
  449.                 //printf("INFO: cp USER_LOGO_RAM_ADDR=[%x] USER_LOGO_RAM_SIZE=[%x]n", USER_LOGO_ROM_ADDR, USER_LOGO_RAM_SIZE);
  450.                 memcpyS((BYTE *) USER_LOGO_RAM_ADDR, (BYTE *) USER_LOGO_ROM_ADDR, USER_LOGO_RAM_SIZE);
  451.                 //printf("INFO: cp USER_LOGO_RAM_ADDR=[%x] USER_LOGO_RAM_SIZE=[%x] OK!!n", USER_LOGO_ROM_ADDR, USER_LOGO_RAM_SIZE);
  452.                 f_check_user_logo=2;
  453.             }
  454.         }
  455. #endif
  456.     LoadModual(MODUAL_MPEG);
  457.     show_logo=1;
  458.     Abort();
  459.     unOffset = ((UINT32 *)_stextf)[MODUAL_ROM3];
  460.     
  461.     #ifdef NEW_STYLE_SETUP
  462.     #ifdef SDRAM_16Mb_Mode//zhaoyanhua add 2003-8-7 10:12
  463.     if((prog_state == 4 )||(prog_state == 5))
  464.     #else
  465.     if((setup_state == 1 )||(setup_state == 3))
  466.     #endif//SDRAM_16Mb_Mode
  467.        setup =1;
  468.     else
  469.        setup =0;
  470. #endif//NEW_STYLE_SETUP
  471.     
  472.     set_vpp_disp_size(0,0);
  473. #ifdef NEW_STYLE_SETUP
  474.     if(setup)
  475.     {
  476.         set_video_aspect();
  477.             p = Setup_Logo;
  478.         logo_type = SETUP_LOGO;
  479.             printf("==============>display setup logon");  
  480.     }
  481.     else 
  482. #endif
  483. #ifdef USER_MPEG_LOGO
  484.     // alan, 2003/9/24 11:33AM
  485.     if(Is_User_Mpeg_Logo()) p=(UINT8 *)(ROM_BASE_UNCACHED+768*1024); //Flash offset addr 0x90000(for 080)
  486.     else 
  487. #endif
  488.     {
  489. #ifdef LINUX_USER_LOGO  //MIKEY 2004.07.01
  490.         p = (BYTE *) USER_LOGO_RAM_ADDR;
  491.         if(*(p+0x80)=='T' && *(p+0x81)=='M')
  492.             f_check_user_logo=3;
  493.         else
  494. #endif
  495.         p = DVDTitle; 
  496.        printf("Manufacture Logon");
  497.     
  498.     #ifdef DOUBLE_LOGO
  499.        if(OsdIsEnglish())  p=DVDTitle1;
  500.     #endif
  501. #ifdef CD_PLAYER    //liweihua 2003-9-3
  502.        if((cd_type_loaded==CDDA)&&(play_state!=VCD_STATE_OPEN))
  503.           p=CDPlayerTitle;
  504. #endif
  505.     } 
  506.     PlayRomSlide(p);
  507. #ifdef LOGO_STARTUP_VPP_NOW
  508.     startup_vpp_now();//nono 4-6-10 0:25 for ZOOMING IN,show logo startup_vpp_now.
  509. #endif//LOGO_STARTUP_VPP_NOW
  510.     MediaMainLoop();
  511.     PlayRomSlide(p);
  512.     MediaMainLoop();
  513. #ifdef NEW_STYLE_SETUP  // alan, 2003/8/13 11:44PM
  514.     if(setup)
  515.     {//terry,0813
  516.             if(getVPP_TVsystem()) set_vpp_disp_size(720,540);
  517.             else set_vpp_disp_size(0,0);
  518.     }
  519. #endif
  520.     #ifdef NEW_STYLE_SETUP
  521.     if(logo_type == CUSTM_LOGO)
  522.     #endif
  523.     tv_setup_misc(0);
  524.         
  525.     reset_sup();
  526.     Sync();
  527.     show_logo=0;
  528.     set_video_default_offset();
  529.     startup_vpp();
  530.     
  531.     #ifdef NEW_STYLE_SETUP
  532.     if(setup==0)
  533.         logo_type = CUSTM_LOGO;
  534.     #endif//#ifdef NEW_STYLE_SETUP    
  535.     
  536.     #ifdef MONE_LOGO
  537.     printf("logo outn");
  538.     #endif
  539. }
  540. #ifdef LOGO_PLAY_MP3
  541.  
  542. void Show_Logo_Play_MP3()
  543. {
  544.     extern const unsigned char LOGO_MP3[];  
  545.     int a;  
  546.     /*Play Background MP3*/
  547.    
  548.     #define PlayLen 3 
  549.  
  550.     //b=sizeof(LOGO_MP3);
  551.     //printf("MP3 size=%dn",b); 
  552.      
  553.     for(a=0;a<PlayLen;a++) 
  554.     {    
  555.      stream_ptr = (BYTE*)(LOGO_MP3 + playindex*PlayLen*1024+a*1024); 
  556.      //print_block(stream_ptr,1024);
  557.      dma_iptr  = 0;
  558.      dma_ilen  = 1024;   
  559.      logo_play_mp3_flag=0;
  560.      do_mp3();     
  561.      logo_play_mp3_flag=1;
  562.     }   
  563.     
  564.     playindex++;    
  565.     if(playindex==MaxPlayLen/PlayLen) playindex=0;
  566. }
  567. #endif
  568. /****************************************************/
  569. /* initial subroutine                               */
  570. /****************************************************/
  571. void volume_init(void)
  572. {
  573.     #if !defined(Ti3001_OSD_UI_1)
  574.         #ifdef VOLUME_RECODE
  575.         {
  576.             //audio_volume  = VOL_VALUE;   //set to maximum volume
  577.             int read_volume=0;
  578.             int i=0; 
  579.         #ifdef CNTR_5SPK_VOLUME
  580.         for (i=0; i<7; i++) {
  581.         #endif 
  582.             read_volume=ReadFromI2c(0xa0,ADDR_I2C_VOLUME+i,(BYTE *)&audio_volume,sizeof(audio_volume));
  583.             if(read_volume!=1)
  584.             {
  585.             //#if 1//def    ROTARY_VOL_HUAJIA1251
  586.                     #ifdef CNTR_5SPK_VOLUME// defined(HIMAGE1251) || defined(HIMAGE1250_03_185W)//wangfeng 2003-10-31 21:11
  587.                     #ifdef SW_VOL_63
  588.                     if(i==6){
  589.                         audio_volume  = SUB_DEFAULT;
  590.                     
  591.                     }
  592.                     else
  593.                     #endif
  594.                 audio_volume  = DEFAULT_VOL;
  595.                 #else
  596.                 audio_volume  = DEFAULT_VOL;
  597.                     #endif
  598.             //#else
  599.             //    audio_volume  = VOL_VALUE;
  600.             //#endif
  601.             }
  602.             audio_volume = (audio_volume<=DEFAULT_VOL)?audio_volume:DEFAULT_VOL;
  603.         #ifdef CNTR_5SPK_VOLUME
  604.  
  605.                 volume_5SPK[i]      = audio_volume;//VOL_VALUE; //set to maximum volume
  606.                 if(i==0)//wangfeng 2003-11-03 15:33
  607.                 idVolume_5SPK[i]    = Volume_Font_ID;
  608.                 else
  609.                 idVolume_5SPK[i]    = VOL_FL_ID+i-1;
  610.             } //for
  611.             audio_volume  = volume_5SPK[0] ;
  612.             volume_Switch = 0;     //set to main volume
  613.         #endif
  614.         }
  615.         #else //VOLUME_RECODE
  616.             #if 1//def  ROTARY_VOL_HUAJIA1251
  617.             audio_volume  = DEFAULT_VOL;//VOL_VALUE;   //set to maximum volume
  618.             #else
  619.             audio_volume  = VOL_VALUE;
  620.         #endif
  621.         #endif //VOLUME_RECODE
  622.     #else
  623.         //ti_set_volume(SET_TOTAL_VOLUME,TI_VOL_VALUE);
  624.         ti_set_volume(SET_ALL_VALUE);//2002 0918
  625.     #endif
  626.     #if 0 //def TAS3001_AMP  // jason mark 2-10-5 16:29
  627.         //  tas3001_vol   = TI_VOL_VALUE;//2002 0918
  628.         iBalance=10;
  629.         ti_set_volume(SET_TOTAL_VOLUME,TI_VOL_VALUE);//2002 0918
  630.     #endif
  631.     #ifdef TAS5026_AMP
  632.     tas5026_vol   = TI_VOL_VALUE;
  633.     iBalance=10;
  634.     #endif
  635. }
  636. /* The main initial function  */
  637. static inline void VCD_init()
  638. {
  639.     psd_state = PSD_PLAY_TRACK;          //for cdda vcd1.0 &1.1
  640.     psd_st.psd_list_id = 0xffff;
  641.     playmode_sel(CLEAR_ALL);
  642. }
  643. /*
  644. ** FUNCTION
  645. ** ReadCDTitle
  646. **
  647. ** DESCRIPTION
  648. ** reading DISC information.
  649. */
  650. int ReadCDTitle(void)
  651. {
  652.     extern  UINT8   DiscType;
  653.     int Res;
  654.     //
  655.     // reset hardware
  656.     //
  657.     cd_type_loaded=CDUNKNOWN;
  658.     if (CDOpened())
  659.         return -1;
  660.     if(system_state==SYSTEM_POWER)
  661.         return -3;
  662.     //
  663.     // setup interrupt-mask
  664.     //
  665.     SetIntrMask(INTR_MASK_READTOC);
  666.     //
  667.     // READTOC
  668.     //
  669.     pbcoff();
  670.     play_state = VCD_STATE_READTOC;
  671.     #ifdef DVD_SERVO
  672.     Res=read_toc();
  673.     #endif
  674.     disc_init();
  675.     if (!is_user_opened())
  676.     {
  677.         //if (cd_type_loaded != CDDVD)
  678.         if ( (cd_type_loaded != CDDVD) || ( (cd_type_loaded==CDDVD) && (dVMG_LSN==0) ) ) //add more DVD-video checking, Jeff 20031124
  679.         {
  680.             get_disc_info();
  681.             //CSSEnable = 0;
  682.             //
  683.             // software reset and initial variable
  684.             //
  685.             VCD_init();
  686.             #ifndef DVD_SERVO
  687.             Res=read_toc();
  688.             #endif
  689.             #ifdef DVD_SERVO
  690.             if( (Res>=0)||(DiscType == CDDVD) )
  691.             #else
  692.             if(Res>=0)
  693.             #endif
  694.             {
  695.                 Res=check_cdtype();
  696. #ifdef SYSMAIN2_DBG
  697.                 if (cd_type_loaded != CDDVD) {
  698.                     printf("check_cdtype:after disc_init, DVD xxx, dVMG_LSN=%xn", dVMG_LSN);
  699.                 } else {
  700.                     printf("check_cdtype:after disc_init, DVD ooo, dVMG_LSN=%xn", dVMG_LSN);
  701.                 }
  702.                 printf("check_cdtype:Res=%d, cd_type_loaded=%xn", Res, cd_type_loaded);
  703. #endif//SYSMAIN2_DBG
  704.                 disc_time=M2I(gettrkmsf_leadout()); //terry 891004
  705.                 if(cd_type_loaded!=CDDVD)//terry,2003/8/7 03:57PM
  706.                 save_cmp_disc_info(disc_time);
  707.             }
  708.         }else
  709.         {
  710.             Res=0;
  711.         }
  712.     }
  713.     if (is_user_opened())
  714.         Res =  -1;
  715. #ifdef SUPPORT_CD_TEXT
  716.     else
  717.         read_cd_text();
  718. #endif
  719. #ifdef DIP_CFG_ENABLE
  720.    SetDeInterlace(dip_sel);
  721. #else
  722.    dip_enable = 0;
  723. #endif
  724.     if( (cd_type_loaded==CDVCD10)&&( (cd_trk_hi<1)||(cd_trk_hi>100) ) )
  725.     {//terrry,2003/12/30 11:00AM
  726.         printf("toc errn");
  727.         cd_trk_hi = 1;
  728.         cd_type_loaded=CDROM;
  729.     }
  730.     return Res;
  731. }
  732. //detect tray function subroutin
  733. UINT8 is_user_opened(void)
  734. {
  735.     //printf("no_disk_cnt:%x s:%x p:%xn",no_disk_cnt,system_state,play_state);
  736.     if( (no_disk_cnt==DETECT_TIMES)||(system_state==SYSTEM_POWER) )
  737.         return TRUE;
  738.     else
  739.     {
  740.         return FALSE;
  741.     }
  742. }
  743. UINT8 is_test_unit(void)//2001/10/23
  744. {
  745.     //if(no_disk_cnt!=DETECT_TIMES&&no_disk_cnt!=0)    
  746.     //if((no_disk_cnt!=DETECT_TIMES&&no_disk_cnt!=0 )||(atapi_p_mechanism_status()==2))      //he qiang,4-2-11 1:07,avoid displaying "CLOSE" when should show "LOAD" on VFD when a poor disc is put in.            
  747.     //if((no_disk_cnt!=DETECT_TIMES&&no_disk_cnt!=0 )||(atapi_p_mechanism_status()==2)||(atapi_p_mechanism_status()==1))      //he qiang,4-2-11 10:23,avoid displaying "CLOSE" when should show "LOAD" on VFD when a poor disc is put in.            
  748.     if((no_disk_cnt!=DETECT_TIMES&&no_disk_cnt!=0 )||(atapi_p_mechanism_status()==ATAPI_DOOR_CLOSE)||(atapi_p_mechanism_status()==ATAPI_ERROR))      //he qiang,4-2-11 10:25,avoid displaying "CLOSE" when should show "LOAD" on VFD when a poor disc is put in. 
  749.         return TRUE;
  750.     else
  751.         return FALSE;
  752. }
  753. void close_tray_init(void)
  754. {
  755.     #ifdef WHEN_READTOC_AUTO_EXIT_SETUPPAGE
  756.         if((full_scrn&SETUP) || (full_scrn&CUSTM))
  757.         {
  758.             ExitSetupPage(1);   //dingzhy for tonic auto close setup menu 2004-2-5 2:40
  759.         }
  760.     #endif
  761.     OSD1000ISP_STATUS(OSDISP_READ, OSDIR_GLOBAL);
  762.     PrintOsdMsg(STR_OS_READ,REGION1,0,0);
  763.     sys_cmd=(CMD_FUNC|CMD_FUNC_CLOSE);
  764.     CDSetStop();
  765.     play_state=VCD_STATE_CLOSE;
  766.     no_disk_cnt=DETECT_TIMES;
  767. #if defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)//liweihua add 20031223
  768.     if(!(card_plug_state&USER_DO_PLUG_OUT)){
  769.         printf("ENTER COLSE TRAY INIT!n");
  770.         card_plug_state |= USER_DO_PLUG_IN;
  771.     }
  772. #endif
  773. }
  774. //BYTE gbCloseTrayFail = 0;//terry 2003-7-31 0:55
  775. #if DISC_SYSTEM==DISC_SYSTEM_ATAPI
  776. void test_atapi_drv_rdy(void)
  777. {
  778.     int test_ready_ret;
  779.     UINT8 door;
  780.     test_ready_ret=atapi_p_test_unit_ready();//start up loader
  781.     delay_srv_10ms(15); //
  782.     door = atapi_p_mechanism_status();
  783.     if( door==ATAPI_DOOR_CLOSE )
  784.     {//tray close
  785.         #ifdef SYSMAIN2_DBG
  786.         printf("cnt: %xn",no_disk_cnt);
  787.         #endif
  788.         if(no_disk_cnt==0)
  789.         {
  790.             close_tray_init();
  791.         }else if(no_disk_cnt==1)
  792.         {
  793.             #ifdef HOBO_DVD //Jefftest 20020930
  794.             if (test_ready_ret != 2)
  795.                 play_state=VCD_STATE_CLOSE;
  796.             else
  797.             #endif
  798.                 play_state=VCD_STATE_IDLE;
  799.             system_state=SYSTEM_NODISC;
  800.             
  801.             #ifdef FILE_MODE_WRITE//added by wangwei,2005-1-9 16:13
  802.             detect_CD = 0;
  803.             #endif//FILE_MODE_WRITE
  804.             
  805.        
  806.         }else
  807.         {//test
  808.             no_disk_cnt--;
  809.             if(test_ready_ret==0)//unit is ready or not
  810.             {
  811.                 // set feature
  812.                 #ifdef SYSMAIN2_DBG
  813.                 printf("system read titlen");
  814.                 #endif
  815.                 #ifdef TONIC_DVD
  816.                 if((full_scrn&SETUP) || (full_scrn&CUSTM))
  817.                 {
  818.                 ExitSetupPage(1);   //dingzhy for tonic auto close setup menu 2004-2-5 2:40
  819.                 }
  820.                 #endif
  821.                 OSD1000ISP_STATUS(OSDISP_READ, OSDIR_GLOBAL);
  822.                 PrintOsdMsg(STR_OS_READ,REGION1,0,0);
  823.                 
  824.                 drv_do_set_features();
  825.                 
  826.                 if(!is_user_opened())
  827.                 {
  828.                     #ifdef FILE_MODE_WRITE//added by wangwei,2005-1-9 16:21
  829.                     printf("detect_CD = %xn",detect_CD);
  830.                     detect_CD = 1;
  831.                     #endif//FILE_MODE_WRITE
  832.                     
  833.                     system_state=SYSTEM_READ_TITLE;
  834.                     no_disk_cnt=0;
  835.                     
  836.                     extern UINT8 old_cd_type;   //2004/10/01 yltseng, set this value in order to let hostx_servo_buf_init() really reconfig/clear data
  837.                     old_cd_type=0xff;
  838.                 }
  839.             }
  840.             //else if((test_ready_ret==ATAPI_NO_MEDIA)&&(no_disk_cnt>1)&&!CDOpened())//NO disc
  841.             else if(((test_ready_ret==ATAPI_NO_MEDIA)||(test_ready_ret==ATAPI_MEDIA_UPSIDE_DOWN)||(test_ready_ret==ATAPI_UNKNOWN_MEDIA)
  842. ||(test_ready_ret==ATAPI_ILLEGAL_MODE))&&(no_disk_cnt>1)&&!CDOpened())//zhongshan modified 05/01/17 if media err ,will not show "play" for a long time. 
  843.             {
  844.                 if(no_disk_cnt>NO_DISC_TIMES)
  845.                 {
  846.                     no_disk_cnt-=NO_DISC_TIMES;
  847.                 }else {
  848.                     no_disk_cnt=1;
  849.                 }
  850.             }
  851.          }
  852.     }else if( door==ATAPI_DOOR_CLOSE_ERR )//terry 2003-7-31 0:55
  853.     {
  854. //         printf("~~~~~~~~~~~open~~~~~~~~~~:%xn",door);
  855. //         gbCloseTrayFail=0;//terry 2003-7-31 0:55
  856.          ircmd_trayout();
  857.     }else
  858.     {
  859.         
  860.         no_disk_cnt=0;
  861.         #ifdef NO_DVD_SERVO //ycwen 2004/08/10 
  862.             system_state=SYSTEM_NODISC;            
  863.         #else
  864.         
  865.         #ifdef FILE_MODE_WRITE//added by wangwei,2005-1-9 16:21
  866.         printf("detect_CD = %xn",detect_CD);
  867.         detect_CD = 1;
  868.         #endif//FILE_MODE_WRITE
  869.             
  870.             no_disk_cnt=0;
  871.         #endif
  872.     } //if(atapi_p_mechanism_status()==2)
  873. }
  874. #elif   DISC_SYSTEM==DISC_SYSTEM_AVB
  875. void test_avb_drv_rdy(void)
  876. {
  877.     int test_ready_ret;
  878.     if(is_tray_close())
  879.     {//tray close
  880. #ifdef SYSMAIN2_DBG
  881.         printf("cnt: %xn",no_disk_cnt);
  882. #endif
  883.         test_ready_ret=is_ready2play();
  884.         if(no_disk_cnt==0)
  885.         {//read disc
  886.                 close_tray_init();
  887.         }else if(no_disk_cnt==1)
  888.         {//
  889.                 play_state=VCD_STATE_IDLE;
  890.                 system_state=SYSTEM_NODISC;
  891.         }else
  892.         {//test
  893.                 no_disk_cnt--;
  894.                 if(test_ready_ret)//unit is ready or not
  895.                 {
  896.                         no_disk_cnt=0;
  897.                         // set feature
  898.                         #ifdef SYSMAIN2_DBG
  899.                         printf("system read titlen");
  900.                         #endif
  901.                         OSD1000ISP_STATUS(OSDISP_READ, OSDIR_GLOBAL);
  902.                         PrintOsdMsg(STR_OS_READ,REGION1,0,0);
  903.                         system_state=SYSTEM_READ_TITLE;
  904.                 }
  905.                 else if( is_no_disc()&&(no_disk_cnt>1)&&!CDOpened() )//NO disc
  906.                 {
  907.                     if(no_disk_cnt>NO_DISC_TIMES)
  908.                         no_disk_cnt-=NO_DISC_TIMES;
  909.                     else
  910.                         no_disk_cnt=1;
  911.                 }
  912.          }
  913.     }else
  914.         no_disk_cnt=0;
  915. }
  916. #endif
  917. //terry,2003/8/14 12:22AM
  918. void power_on_gpio_demute(int demute)
  919. {
  920.     if( power_on_mute&&((system_state==SYSTEM_NODISC)||(demute)) )
  921.     {//terry,2003/8/14 12:10AM
  922.       if(system_state==SYSTEM_NODISC) AUDIF_Init_CDDA();//2004AUDDRV init_cdda();//terry,for bbk
  923.         
  924.       power_on_mute=0;
  925.         
  926.       #ifdef POWER_ON_MUTE_MIC   //axel 2004/2/26 04:10pm mute mic during initialization
  927.       AUDIF_Set_MICVol(mic_volume);//2004AUDDRV AudioSetMICVol(mic_volume);
  928.       #endif
  929.         
  930.       GPIO_DEMUTE();
  931.      setup_SetSPDIFConfig();//2003-8-15 20:56 for avoid SPDIF noise when power on.
  932.     }
  933. }
  934. /*
  935. CheckRecordKey
  936. CheckDiscParentLvl
  937. Maoyong 2004.03.05 move to IR_VFDrsm_util.h
  938.  */
  939. //
  940. // interface setup
  941. //
  942. #if defined(SPHE8202_CARD_STORAGE)
  943. //#define  SPHE8202_216PIN  //wthsin,    2004/2/23 10:49am  
  944. //#define  SPHE8202_256PIN  //wthsin,    2004/2/23 10:49am  
  945. extern void Card_gpio_init();
  946. void setup_8202_card_storage_interface()
  947. {
  948.    #if defined(CARD_SETUP_TYPE_1)||defined(CARD_SETUP_TYPE_2) 
  949.     regs0->sft_cfg7 = regs0->sft_cfg7 | 0x2;    // Set FM 256-PIN package
  950.     regs0->fm_gpio_mode = 8;                    // Set FM GPIO TABLE to ALL IN ONE case
  951.     regs0->fm_gpio_len  = 12                    // Set FMGPIO_B[41:0] turn on
  952.                         |  (0xf << 4);          // Set FMGPIO_B[41:0] enable   
  953.    #elif defined(CARD_SETUP_TYPE_3) ||defined(CARD_SETUP_TYPE_5) 
  954.     regs0->sft_cfg7 = regs0->sft_cfg7 & (~0x2);    // Set FM 256-PIN package
  955.         #ifdef HDMI_SMC_CLE//for HDDVD Non CF config.chenzhao on 2004-12-1 21:27  
  956.         regs0->fm_gpio_len  = 10                    
  957.                             |  (0xf << 4);          // Set FMGPIO_B[26:0] enable  
  958.         #else
  959.     regs0->fm_gpio_len  = 11                    // Set FMGPIO_B[26:0] turn on
  960.                         |  (0xf << 4);          // Set FMGPIO_B[26:0] enable  
  961.         #endif//HDMI_SMC_CLE
  962.    #elif defined(CARD_SETUP_TYPE_4) 
  963.     regs0->sft_cfg7 = regs0->sft_cfg7 & (~0x2);    // Set FM 256-PIN package
  964.     regs0->fm_gpio_len  = 3                    // Set FMGPIO_B[5:0] turn on
  965.                         |  (0x1 << 4);          // Set FMGPIO_B[5:0] enable    
  966.     //regs0->gpio_mode_B=0;                                       
  967.    #endif                                          
  968.     Card_gpio_init();    //wthsin,  2004/3/24 04:55pm
  969. }
  970. #endif
  971. #if defined(SUPPORT_CARD_STORAGE)
  972. void setup_card_storage_interface()
  973. {
  974.     if(regs0->stamp==1)               //Version-B ,wthsin 10/18
  975.         regs0->pcmcia_iorw_wait = 0x2222;   // Must be 0x2222 in 8200B, setup and hold time for both ior, iow is 0xf,
  976.      else
  977.         regs0->pcmcia_iorw_wait = 0xffff;  
  978.     regs0->wait_cyc1_0 = regs0->wait_cyc1_0 | 0x3f00; // maximum cs timing for R_CS2_B
  979.     regs0->wait_cyc3_2 = regs0->wait_cyc3_2 | 0x003f; // maximum cs timing for R_CS3_B
  980. }
  981. #endif
  982. #if defined(SUPPORT_USB)&&defined(HOST_SL811HS) //wthsin, 2004/1/12 01:36pm
  983. void setup_usbhost_sl811hs_interface()
  984.     regs0->oe_wait_cyc1_0=regs0->oe_wait_cyc1_0|0x3200;
  985.     regs0->we_wait_cyc1_0=regs0->we_wait_cyc1_0|0x3200;
  986.     regs0->wait_cyc1_0 = regs0->wait_cyc1_0 | 0x1f00; // maximum cs timing for R_CS2_B
  987.     regs0->rom1_base = 0x100;       // rom2 n*64k-base ,pcmcia
  988.     regs0->rom2_base = 0x160;       // rom2 n*64k-base ,pcmcia
  989.     regs0->rom3_base = 0x200;       // rom3 n*64k-base ,pcmcia
  990.     regs0->rom_config = 0x7000;   // pcmcia,rom2,3
  991. }
  992. #endif
  993. //
  994. // setup supporting for extra interfaces
  995. //
  996. void
  997. init_extra_interface() //terry,2004/2/18 10:12AM
  998. {
  999.     #if defined(SPHE8202_CARD_STORAGE)
  1000.         setup_8202_card_storage_interface();
  1001.     #elif defined(SUPPORT_CARD_STORAGE)
  1002.         setup_card_storage_interface();
  1003.     #elif  defined(SUPPORT_USB)&&defined(HOST_SL811HS) //wthsin, 2004/1/12 01:36pm
  1004.         setup_usbhost_sl811hs_interface();
  1005.     #endif 
  1006. }
  1007. void dvd_startup(void)//20040316
  1008. {
  1009. #ifdef PULIANG_EJECT_MODE    //yaowh add for puliang 04-12-17
  1010.     BYTE    I2c_Data;
  1011.     BYTE    I2C_Clear=0;
  1012. #endif
  1013.     
  1014.     disc_time = 0xefff;//terry 891004
  1015.     #ifdef TOP_DOOR_LOADER
  1016.         #ifdef SUNPLUS_8202P_DEMOBOARD
  1017.         regs0->sft_cfg4 &= ~((0x03)<<2);    //Enable GPIO2,3 For COVER & TFT SW
  1018.         #endif
  1019.         bDoorStatus = GPIO_GET_DOOR_STATUS();
  1020.         if (bDoorStatus==DOOR_OPEN) {
  1021.             OSD1000ISP_STATUS(OSDISP_OC_OPEN, OSDIR_OPEN);
  1022.             PrintOsdMsg(STR_OS_OPEN,REGION1,0,0);
  1023.             //SERVO_LDOff();//maybe use it.
  1024.             //SERVO_STSledHome();//maybe use it.
  1025.             ircmd_trayout();
  1026.             play_state=VCD_STATE_OPEN;
  1027.         } else {
  1028.             ircmd_trayin();
  1029.             play_state=VCD_STATE_CLOSE;
  1030.         }
  1031.     #else
  1032.         #ifdef PULIANG_EJECT_MODE  //yaowh add 04-12-17
  1033.         ReadFromI2c(0xa0,0xfc,&I2c_Data,1);
  1034.         if((I2c_Data==0x80))
  1035.         {
  1036.             call_ir_func(IRC_EJECT);   
  1037.             WriteToI2c(0xa0,0xfc,&I2C_Clear,1);   
  1038.         }else
  1039.         #endif
  1040.         {
  1041.         #if !(defined(SPHE1000)||defined(PMP_UI))
  1042.         PrintOsdMsg(STR_OS_READ,REGION1,0,0);
  1043.         #endif
  1044.         play_state=VCD_STATE_CLOSE;
  1045.         }
  1046.     #endif //#ifdef TOP_DOOR_LOADER
  1047.     #ifdef  REPEAT_RESET_IOP //zhaoyanhua add 2004-2-13 13:59  //fengjl edit 2004-02-27 15:49
  1048.     //only for DSS 555(VFD Driver: NEC 16312)
  1049.     //This vfd is very strange! When power switch between on and off 
  1050.     //more than 20 times, it will not show VFD informaiton again!
  1051.     //we found it that the data which IOP send to 16312 is abnormal,
  1052.     //so reset IOP here. 
  1053.     reset_iop();
  1054.     reset_ir();
  1055.     reset_vfd();
  1056.     #endif //ifdef REPEAT_RESET_IOP
  1057.     #ifdef CE2746
  1058.     init_ce2746(); 
  1059.     #endif
  1060.     //
  1061.     // CONTROL FLOW
  1062.     //
  1063.     AVD_ResetMediaStatus();
  1064.     ClearCommand();
  1065.     no_disk_cnt=DETECT_TIMES;
  1066.     #ifdef DVB1000_NON_OS
  1067.     system_state=SYSTEM_TS;
  1068.     ControlDvbDvdMic(); //Maoyong 2005-1-18 16:33 turn off MIC when DVB state
  1069.     #else
  1070.     system_state=SYSTEM_OPEN;
  1071.     #endif
  1072.     //play_state=VCD_STATE_CLOSE;
  1073.     sys_cmd=CMD_FUNC|CMD_FUNC_CLOSE;
  1074. //    init_audio_dsp_coding_mode();
  1075.     power_on=2;
  1076. }
  1077. /*
  1078. ** FUNCTION
  1079. ** main()
  1080. **
  1081. ** DESCRIPTION
  1082. ** main function...  what else?
  1083. */
  1084. #ifdef SUPPORT_RECEIVER
  1085. #include "sysmain_receiver.c"  //huziqin 2004-3-12
  1086. #endif
  1087. #ifdef SUPPORT_POWER_OFF_CLOCK_FUNC  //xyy 2004-10-11 17:18
  1088. #include "clock_func.c"
  1089. #endif
  1090. #ifdef DVB_SETUP
  1091.  UINT8 eBuffer[128];
  1092. void SP_SetVolume(UINT8 volume);
  1093. #endif   
  1094. #ifdef QSI_SHOW_ERR_RATE
  1095. #include "sysmain2_QSI.c"
  1096. #endif
  1097. #ifdef  AUTO_ADJUST_TV_TYPE  //lijd 2004-9-15 13:27
  1098. extern BYTE  Adjust_TV_type ;
  1099. #endif
  1100. #ifdef SUPPORT_MIDI           //xlluo 2004-12-28
  1101. #include "fsmidi.h"
  1102. #ifdef SUPPORT_MIDI_MENU_SEL
  1103. #include "fsmidiui.h"
  1104. #endif
  1105. #endif
  1106. #ifdef QSI_SUPPORT_SLOT_TEST
  1107. extern  BYTE SERVO_GetRunInState(void);
  1108. BYTE is_do_slot_test(void)
  1109. {
  1110.     if(SERVO_GetRunInState()==PRODUCTION_RUNIN_ST_IS_SLOT_TEST)
  1111.     {
  1112.         return(1);
  1113.     }
  1114.     return(0);
  1115. }
  1116. #else
  1117. #define is_do_slot_test()   0
  1118. #endif
  1119. void ap_main(void)  // benson update 2004/3/1 04:25