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

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. #if defined(CE2746)||defined(NEWCE2746)
  271. #define Chip_addr 0x6a     
  272. #define Register_addr 0x00  
  273. void init_ce2746()  
  274. {
  275. #ifdef NEWCE2746
  276. int I2c_data1=0x40,I2c_data2=0x00;
  277. #else
  278. int I2c_data1=0x01,I2c_data2=0x80;
  279. #endif
  280. WriteI2c(Chip_addr,Register_addr,I2c_data1,1);
  281. delay_1ms(10);
  282. WriteI2c(Chip_addr,Register_addr+1,I2c_data2,1);
  283. }
  284. #endif
  285. #if defined(CE2766)
  286. #define Chip_addr 0x6a     
  287. #define Register_addr 0x00  
  288. void init_ce2766()  
  289. {
  290. // int I2c_data1=0x80,I2c_data2=0x00;
  291. int I2c_data1=0x20,I2c_data2=0x00;
  292. WriteI2c(Chip_addr,Register_addr,I2c_data1,1);
  293. delay_1ms(10);
  294. WriteI2c(Chip_addr,Register_addr+1,I2c_data2,1);
  295. }
  296. #endif
  297. #if defined(CE2766_I2S)
  298. void init_ce2766()  
  299. {
  300.    WriteI2c(0x6a,0x00,0x80,1);
  301.    WriteI2c(0x6a,0x01,0x80,1);
  302.    WriteI2c(0x6a,0x02,0x80,1);
  303.    WriteI2c(0x6a,0x03,0x80,1);
  304.    WriteI2c(0x6a,0x04,0x80,1);
  305.    WriteI2c(0x6a,0x05,0x80,1);
  306.    WriteI2c(0x6a,0x06,0x80,1);
  307.    WriteI2c(0x6a,0x07,0x80,1);
  308. }
  309. #endif
  310. //=====================================================
  311. //* function decalare
  312. //=====================================================
  313. void InitVar(void)
  314. {
  315.     //init pe engine
  316.     pe_run = 0;
  317. //    dVts_iso9600_addr = 0;//terry,2003/8/6 04:01PM
  318. #ifdef TP6317_PANNEL   //yaowh add  04-10-25
  319.     TP6317_Power = 0 ;
  320. #endif
  321.     PE_ClearNav();
  322.     mpeg_audio=0;
  323.     dspWatchDog=DSP_WD_INIT;
  324.     
  325. #ifdef BAD_DISC_AUTO_STOP //terry,2003/8/31 12:00AM                   
  326.     bad_disc_auto_stop=0;
  327. #endif 
  328.     //init navigation
  329.     cd_subtype = CDROM_UNSUPPORT;
  330.     bDiscType=CDUNKNOWN;
  331.     still_timer=0;
  332.     //#ifdef SUPPORT_MIX_MP3_CDDA   //linrc change "SUPPORT_MIX_MP3_CDDA" to "SUPPORT_MIX_DATA_CDDA_DISC"
  333.     #ifdef SUPPORT_MIX_DATA_CDDA_DISC //because we not only support this type mix mode disc 2004-12-15 15:53
  334.     mp3_cd_end_trk = 0;
  335.     #endif
  336.     play_dir = 0;
  337.     Mp3ReadFinish=0;//mp3 ........
  338.     logo_play_mp3_flag=1;
  339.     fore_disp_time=-1;
  340.     jpg_slide_time = JPEG_SLIDE_TIME;//jpeg .......... wanghaoying 2003-8-26 20:21
  341.     
  342. #ifdef NO_BLACK_for_PIC_CD    
  343.     pic_cd_first_play = 0;
  344. #endif    
  345.     bPbcOff=0; //vcd ..........
  346.     cd_trk_now=0;
  347.     cd_trk_hi=0xff;
  348.     cd_trk_lo_now=0;
  349.     cd_trk_lo=0;
  350.     dVMG_LSN = 0; //dvd.......
  351.     HL_exist=0;
  352.     read_sector=0;
  353.     dvd_error=0;
  354.     min_astn_id=0;//terry,2003/12/15 02:33PM
  355.     dvd_karaoke_mode = 0; //terry,2004/2/16 11:11AM
  356.     #ifdef DVD_AUDIO
  357.     dAMG_LSN = 0;
  358.     #endif
  359.     #ifdef TUNR_OFF_PARENTAL_LVL
  360.     bTurnOffParentalLVL=0; //terry,2002/9/20 11:40PM
  361.     #endif
  362.     #ifdef JUST_SHOW_CD_TYPE    //Maoyong 2004.02.26
  363.     track_play_diff_time = 0;
  364.     #endif
  365.     
  366. #ifdef DVD_SEQ_PLAY
  367. #ifdef AUTO_PLAY
  368.     extern BYTE auto_play_on();
  369.     if (auto_play_on())
  370.         dvd_menu_play = 0;
  371.     else
  372.         dvd_menu_play = 1;
  373. #else
  374.     dvd_menu_play = 0;
  375. #endif
  376. #endif
  377.     // 2004/07/16 yltseng
  378.     wb_tag_init();          
  379.     
  380.     //init UI
  381.     init_ir_num();
  382.     goto_active=0;
  383.     mp3_user_select=0;
  384.     pFsJpeg->iso9660_file_cnt = 0;
  385.     disp_trk_now = 0;
  386.     Mp3_kbitrate=0;
  387.     bIntro=0;
  388.     //keep_cmd_code=0;
  389.     keep_cmd_code=IR_CODE_MAX_NUM;//2004-3-30 19:14
  390.     disc_st_time=0;
  391.     #if defined(IR_PLAY_RESUME) && defined(POWER_RESUME)  //yw 021003
  392.     power_resumeflag = 0;
  393.     #endif
  394.     
  395.     #ifdef SUPPORT_REP_READ    //Maoyong 2004.06.03
  396.     InitRead();
  397.     #endif
  398.     
  399.     #ifdef  SUPPORT_BOOK
  400.     init_book();
  401.     #endif
  402.     
  403.     goto_time = 0;//4-4-13 16:22
  404.     
  405.     pe_timesearch_clear();//nono 5-4-4 22:00 clear time search flag.
  406.     
  407. //#ifdef OP_UI//zhaoyanhua 2004-5-24 17:35
  408. //    prog_cnt = 0;
  409. //#endif
  410.     //nono move from ap_mian(): SYSTEM_READ_TITTLE.2004-2-27 12:00
  411.     coding_mode_now=AUDIF_CODING_MODE_NONE;//wangfeng 2003-12-19 17:44
  412. #ifdef USE_PIN31_CONTROL_POWER_LED      //gerry,2004-3-9 19:42
  413.     gbm_gpio_led_flag=0;
  414. #endif//USE_PIN31_CONTROL_POWER_LED
  415.     nOldFst = 0;          //Maoyong 2004.05.25 move from labif.c
  416. #ifdef SUPPORT_WMA        //Maoyong 2004.05.31 for WMA     
  417.     asf_resume_pck = 0;
  418. #endif
  419. #if defined(SUPPORT_WMA) || defined(SUPPORT_MP4)
  420.     nGotoPck = 0;
  421. #endif
  422.     //FS SWD
  423.     #ifdef SUPPORT_PLAY_SWD
  424.         START_POLLING_SWD = 0;
  425.     #endif
  426.     //OSD 16bit direct color
  427.     #ifdef SUPPORT_PS2
  428.         OSD_buffer_16bit = 0;
  429.     #endif
  430.     
  431.     //initiate PS2 mouse 
  432.     #ifdef SUPPORT_PS2
  433.         START_POLLING_PS2 = 0;  //hold polling
  434.         mouse_pos_x = 180;
  435.         mouse_pos_y = 120;
  436.         mouse_btn_status = 0x0;
  437.         PS2_INIT_DONE = 0x0;
  438.     #endif
  439. //==============================================
  440. //for QSI source switch     //added by JS   //20040726
  441. #if defined(QSI_PORTABLE_DVD) && defined(SUPPORT_CARD_STORAGE)
  442.     #ifdef SUPPORT_QSI_SOURCE_SWITCH
  443.         source_type_now = source_disc;
  444.         source_type_old = source_disc;
  445.     #endif
  446. #endif  
  447. //==============================================
  448. }
  449. extern  char    _stextf[];
  450. extern  char    _text_drv[], _text_drv_dvd[], _text_drv_ap[], _text_drv_iop[], _text_other[], _text_drv_cdrom[];
  451. extern  char    _text_drv_srvdp[], _text_drv_ap2[], _text_drv_free[];
  452. #include "kernel.h"
  453. #define CUSTM_LOGO 0
  454. #define SETUP_LOGO 1
  455. UINT8 logo_type=CUSTM_LOGO;
  456. extern const unsigned char Setup_Logo[];
  457. //
  458. //  show logo
  459. //
  460. //  Terry,2003/9/13 12:20AM
  461. //  integration mpeg logo/new style setup logo function
  462. void    ShowTitle()
  463. {
  464.     BYTE *p;
  465.     UINT32  unOffset;
  466. #ifdef NEW_STYLE_SETUP    //terry,2004/2/17 11:09AM
  467.     UINT8 setup;
  468. #endif  
  469.     #ifdef MONE_LOGO
  470.     printf("logo inn");
  471.     #endif
  472.     
  473. #ifdef LINUX_USER_LOGO  //MIKEY 2004.07.01
  474.         if(f_check_user_logo==0) {
  475.             printf("INFO: f_check_user_logo USER_LOGO_ROM_ADDR=[%x]n", USER_LOGO_ROM_ADDR);
  476.             f_check_user_logo=1;
  477.             p = (BYTE *) USER_LOGO_ROM_ADDR;
  478.             memset((BYTE *) USER_LOGO_RAM_ADDR, 0, USER_LOGO_RAM_SIZE);
  479.             if(*(p+0x80)=='T' && *(p+0x81)=='M') {
  480.                 //printf("INFO: cp USER_LOGO_RAM_ADDR=[%x] USER_LOGO_RAM_SIZE=[%x]n", USER_LOGO_ROM_ADDR, USER_LOGO_RAM_SIZE);
  481.                 memcpyS((BYTE *) USER_LOGO_RAM_ADDR, (BYTE *) USER_LOGO_ROM_ADDR, USER_LOGO_RAM_SIZE);
  482.                 //printf("INFO: cp USER_LOGO_RAM_ADDR=[%x] USER_LOGO_RAM_SIZE=[%x] OK!!n", USER_LOGO_ROM_ADDR, USER_LOGO_RAM_SIZE);
  483.                 f_check_user_logo=2;
  484.             }
  485.         }
  486. #endif
  487.     LoadModual(MODUAL_MPEG);
  488.     show_logo=1;
  489.     Abort();
  490.     unOffset = ((UINT32 *)_stextf)[MODUAL_ROM3];
  491.     
  492.     #ifdef NEW_STYLE_SETUP
  493.     #ifdef SDRAM_16Mb_Mode//zhaoyanhua add 2003-8-7 10:12
  494.     if((prog_state == 4 )||(prog_state == 5))
  495.     #else
  496.     if((setup_state == 1 )||(setup_state == 3))
  497.     #endif//SDRAM_16Mb_Mode
  498.        setup =1;
  499.     else
  500.        setup =0;
  501. #endif//NEW_STYLE_SETUP
  502.     
  503.     set_vpp_disp_size(0,0);
  504. #ifdef NEW_STYLE_SETUP
  505.     if(setup)
  506.     {
  507.         set_video_aspect();
  508.             p = Setup_Logo;
  509.         logo_type = SETUP_LOGO;
  510.             printf("==============>display setup logon");  
  511.     }
  512.     else 
  513. #endif
  514. #ifdef USER_MPEG_LOGO
  515.     // alan, 2003/9/24 11:33AM
  516.     if(Is_User_Mpeg_Logo()) p=(UINT8 *)(ROM_BASE_UNCACHED+768*1024); //Flash offset addr 0x90000(for 080)
  517.     else 
  518. #endif
  519.     {
  520. #ifdef LINUX_USER_LOGO  //MIKEY 2004.07.01
  521.         p = (BYTE *) USER_LOGO_RAM_ADDR;
  522.         if(*(p+0x80)=='T' && *(p+0x81)=='M')
  523.             f_check_user_logo=3;
  524.         else
  525. #endif
  526.         p = DVDTitle; 
  527.        printf("Manufacture Logon");
  528.     
  529.     #ifdef DOUBLE_LOGO
  530.        if(OsdIsEnglish())  p=DVDTitle1;
  531.     #endif
  532. #ifdef CD_PLAYER    //liweihua 2003-9-3
  533.        if((cd_type_loaded==CDDA)&&(play_state!=VCD_STATE_OPEN))
  534.           p=CDPlayerTitle;
  535. #endif
  536.     } 
  537.     PlayRomSlide(p);
  538. #ifdef LOGO_STARTUP_VPP_NOW
  539.     startup_vpp_now();//nono 4-6-10 0:25 for ZOOMING IN,show logo startup_vpp_now.
  540. #endif//LOGO_STARTUP_VPP_NOW
  541.     MediaMainLoop();
  542.     PlayRomSlide(p);
  543.     MediaMainLoop();
  544. #ifdef NEW_STYLE_SETUP  // alan, 2003/8/13 11:44PM
  545.     if(setup)
  546.     {//terry,0813
  547.             if(getVPP_TVsystem()) set_vpp_disp_size(720,540);
  548.             else set_vpp_disp_size(0,0);
  549.     }
  550. #endif
  551.     #ifdef NEW_STYLE_SETUP
  552.     if(logo_type == CUSTM_LOGO)
  553.     #endif
  554.     tv_setup_misc(0);
  555.         
  556.     reset_sup();
  557.     Sync();
  558.     show_logo=0;
  559.     set_video_default_offset();
  560.     startup_vpp();
  561.     
  562.     #ifdef NEW_STYLE_SETUP
  563.     if(setup==0)
  564.         logo_type = CUSTM_LOGO;
  565.     #endif//#ifdef NEW_STYLE_SETUP    
  566.     
  567.     #ifdef MONE_LOGO
  568.     printf("logo outn");
  569.     #endif
  570. }
  571. #ifdef LOGO_PLAY_MP3
  572.  
  573. void Show_Logo_Play_MP3()
  574. {
  575.     extern const unsigned char LOGO_MP3[];  
  576.     int a;  
  577.     /*Play Background MP3*/
  578.    
  579.     #define PlayLen 3 
  580.  
  581.     //b=sizeof(LOGO_MP3);
  582.     //printf("MP3 size=%dn",b); 
  583.      
  584.     for(a=0;a<PlayLen;a++) 
  585.     {    
  586.      stream_ptr = (BYTE*)(LOGO_MP3 + playindex*PlayLen*1024+a*1024); 
  587.      //print_block(stream_ptr,1024);
  588.      dma_iptr  = 0;
  589.      dma_ilen  = 1024;   
  590.      logo_play_mp3_flag=0;
  591.      do_mp3();     
  592.      logo_play_mp3_flag=1;
  593.     }   
  594.     
  595.     playindex++;    
  596.     if(playindex==MaxPlayLen/PlayLen) playindex=0;
  597. }
  598. #endif
  599. /****************************************************/
  600. /* initial subroutine                               */
  601. /****************************************************/
  602. void volume_init(void)
  603. {
  604.     #if !defined(Ti3001_OSD_UI_1)
  605.         #ifdef VOLUME_RECODE
  606.         {
  607.             //audio_volume  = VOL_VALUE;   //set to maximum volume
  608.             int read_volume=0;
  609.             int i=0; 
  610.         #ifdef CNTR_5SPK_VOLUME
  611.         for (i=0; i<7; i++) {
  612.         #endif 
  613.             read_volume=ReadFromI2c(0xa0,ADDR_I2C_VOLUME+i,(BYTE *)&audio_volume,sizeof(audio_volume));
  614.             if(read_volume!=1)
  615.             {
  616.             //#if 1//def    ROTARY_VOL_HUAJIA1251
  617.                     #ifdef CNTR_5SPK_VOLUME// defined(HIMAGE1251) || defined(HIMAGE1250_03_185W)//wangfeng 2003-10-31 21:11
  618.                     #ifdef SW_VOL_63
  619.                     if(i==6){
  620.                         audio_volume  = SUB_DEFAULT;
  621.                     
  622.                     }
  623.                     else
  624.                     #endif
  625.                 audio_volume  = DEFAULT_VOL;
  626.                 #else
  627.                 audio_volume  = DEFAULT_VOL;
  628.                     #endif
  629.             //#else
  630.             //    audio_volume  = VOL_VALUE;
  631.             //#endif
  632.             }
  633.             audio_volume = (audio_volume<=DEFAULT_VOL)?audio_volume:DEFAULT_VOL;
  634.         #ifdef CNTR_5SPK_VOLUME
  635.  
  636.                 volume_5SPK[i]      = audio_volume;//VOL_VALUE; //set to maximum volume
  637.                 if(i==0)//wangfeng 2003-11-03 15:33
  638.                 idVolume_5SPK[i]    = Volume_Font_ID;
  639.                 else
  640.                 idVolume_5SPK[i]    = VOL_FL_ID+i-1;
  641.             } //for
  642.             audio_volume  = volume_5SPK[0] ;
  643.             volume_Switch = 0;     //set to main volume
  644.         #endif
  645.         }
  646.         #else //VOLUME_RECODE
  647.             #if 1//def  ROTARY_VOL_HUAJIA1251
  648.             audio_volume  = DEFAULT_VOL;//VOL_VALUE;   //set to maximum volume
  649.             #else
  650.             audio_volume  = VOL_VALUE;
  651.         #endif
  652.         #endif //VOLUME_RECODE
  653.     #else
  654.         //ti_set_volume(SET_TOTAL_VOLUME,TI_VOL_VALUE);
  655.         ti_set_volume(SET_ALL_VALUE);//2002 0918
  656.     #endif
  657.     #if 0 //def TAS3001_AMP  // jason mark 2-10-5 16:29
  658.         //  tas3001_vol   = TI_VOL_VALUE;//2002 0918
  659.         iBalance=10;
  660.         ti_set_volume(SET_TOTAL_VOLUME,TI_VOL_VALUE);//2002 0918
  661.     #endif
  662.     #ifdef TAS5026_AMP
  663.     tas5026_vol   = TI_VOL_VALUE;
  664.     iBalance=10;
  665.     #endif
  666. }
  667. /* The main initial function  */
  668. static inline void VCD_init()
  669. {
  670.     psd_state = PSD_PLAY_TRACK;          //for cdda vcd1.0 &1.1
  671.     psd_st.psd_list_id = 0xffff;
  672.     playmode_sel(CLEAR_ALL);
  673. }
  674. /*
  675. ** FUNCTION
  676. ** ReadCDTitle
  677. **
  678. ** DESCRIPTION
  679. ** reading DISC information.
  680. */
  681. int ReadCDTitle(void)
  682. {
  683.     extern  UINT8   DiscType;
  684.     int Res;
  685.     //
  686.     // reset hardware
  687.     //
  688.     cd_type_loaded=CDUNKNOWN;
  689.     if (CDOpened())
  690.         return -1;
  691.     if(system_state==SYSTEM_POWER)
  692.         return -3;
  693.     //
  694.     // setup interrupt-mask
  695.     //
  696.     SetIntrMask(INTR_MASK_READTOC);
  697.     //
  698.     // READTOC
  699.     //
  700.     pbcoff();
  701.     play_state = VCD_STATE_READTOC;
  702.     #ifdef DVD_SERVO
  703.     Res=read_toc();
  704.     #endif
  705.     disc_init();
  706.     if (!is_user_opened())
  707.     {
  708.         //if (cd_type_loaded != CDDVD)
  709.         if ( (cd_type_loaded != CDDVD) || ( (cd_type_loaded==CDDVD) && (dVMG_LSN==0) ) ) //add more DVD-video checking, Jeff 20031124
  710.         {
  711.             get_disc_info();
  712.             //CSSEnable = 0;
  713.             //
  714.             // software reset and initial variable
  715.             //
  716.             VCD_init();
  717.             #ifndef DVD_SERVO
  718.             Res=read_toc();
  719.             #endif
  720.             #ifdef DVD_SERVO
  721.             if( (Res>=0)||(DiscType == CDDVD) )
  722.             #else
  723.             if(Res>=0)
  724.             #endif
  725.             {
  726.                 Res=check_cdtype();
  727. #ifdef SYSMAIN2_DBG
  728.                 if (cd_type_loaded != CDDVD) {
  729.                     printf("check_cdtype:after disc_init, DVD xxx, dVMG_LSN=%xn", dVMG_LSN);
  730.                 } else {
  731.                     printf("check_cdtype:after disc_init, DVD ooo, dVMG_LSN=%xn", dVMG_LSN);
  732.                 }
  733.                 printf("check_cdtype:Res=%d, cd_type_loaded=%xn", Res, cd_type_loaded);
  734. #endif//SYSMAIN2_DBG
  735.                 disc_time=M2I(gettrkmsf_leadout()); //terry 891004
  736.                 if(cd_type_loaded!=CDDVD)//terry,2003/8/7 03:57PM
  737.                 save_cmp_disc_info(disc_time);
  738.             }
  739.         }else
  740.         {
  741.             Res=0;
  742.         }
  743.     }
  744.     if (is_user_opened())
  745.         Res =  -1;
  746. #ifdef SUPPORT_CD_TEXT
  747.     else
  748.         read_cd_text();
  749. #endif
  750. #ifdef DIP_CFG_ENABLE
  751.    SetDeInterlace(dip_sel);
  752. #else
  753.    dip_enable = 0;
  754. #endif
  755.     if( (cd_type_loaded==CDVCD10)&&( (cd_trk_hi<1)||(cd_trk_hi>100) ) )
  756.     {//terrry,2003/12/30 11:00AM
  757.         printf("toc errn");
  758.         cd_trk_hi = 1;
  759.         cd_type_loaded=CDROM;
  760.     }
  761.     return Res;
  762. }
  763. //detect tray function subroutin
  764. UINT8 is_user_opened(void)
  765. {
  766.     //printf("no_disk_cnt:%x s:%x p:%xn",no_disk_cnt,system_state,play_state);
  767.     if( (no_disk_cnt==DETECT_TIMES)||(system_state==SYSTEM_POWER) )
  768.         return TRUE;
  769.     else
  770.     {
  771.         return FALSE;
  772.     }
  773. }
  774. UINT8 is_test_unit(void)//2001/10/23
  775. {
  776.     //if(no_disk_cnt!=DETECT_TIMES&&no_disk_cnt!=0)    
  777.     //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.            
  778.     //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.            
  779.     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. 
  780.         return TRUE;
  781.     else
  782.         return FALSE;
  783. }
  784. void close_tray_init(void)
  785. {
  786.     #ifdef WHEN_READTOC_AUTO_EXIT_SETUPPAGE
  787.         if((full_scrn&SETUP) || (full_scrn&CUSTM))
  788.         {
  789.             ExitSetupPage(1);   //dingzhy for tonic auto close setup menu 2004-2-5 2:40
  790.         }
  791.     #endif
  792.     OSD1000ISP_STATUS(OSDISP_READ, OSDIR_GLOBAL);
  793.     PrintOsdMsg(STR_OS_READ,REGION1,0,0);
  794.     sys_cmd=(CMD_FUNC|CMD_FUNC_CLOSE);
  795.     CDSetStop();
  796.     play_state=VCD_STATE_CLOSE;
  797.     no_disk_cnt=DETECT_TIMES;
  798. #if defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)//liweihua add 20031223
  799.     if(!(card_plug_state&USER_DO_PLUG_OUT)){
  800.         printf("ENTER COLSE TRAY INIT!n");
  801.         card_plug_state |= USER_DO_PLUG_IN;
  802.     }
  803. #endif
  804. }
  805. //BYTE gbCloseTrayFail = 0;//terry 2003-7-31 0:55
  806. #if DISC_SYSTEM==DISC_SYSTEM_ATAPI
  807. void test_atapi_drv_rdy(void)
  808. {
  809.     int test_ready_ret;
  810.     UINT8 door;
  811.     test_ready_ret=atapi_p_test_unit_ready();//start up loader
  812.     delay_srv_10ms(15); //
  813.     door = atapi_p_mechanism_status();
  814.     if( door==ATAPI_DOOR_CLOSE )
  815.     {//tray close
  816.         #ifdef SYSMAIN2_DBG
  817.         printf("cnt: %xn",no_disk_cnt);
  818.         #endif
  819.         if(no_disk_cnt==0)
  820.         {
  821.             close_tray_init();
  822.         }else if(no_disk_cnt==1)
  823.         {
  824.             #ifdef HOBO_DVD //Jefftest 20020930
  825.             if (test_ready_ret != 2)
  826.                 play_state=VCD_STATE_CLOSE;
  827.             else
  828.             #endif
  829.                 play_state=VCD_STATE_IDLE;
  830.             system_state=SYSTEM_NODISC;
  831.             
  832.             #ifdef FILE_MODE_WRITE//added by wangwei,2005-1-9 16:13
  833.             detect_CD = 0;
  834.             #endif//FILE_MODE_WRITE
  835.             
  836.        
  837.         }else
  838.         {//test
  839.             no_disk_cnt--;
  840.             if(test_ready_ret==0)//unit is ready or not
  841.             {
  842.                 // set feature
  843.                 #ifdef SYSMAIN2_DBG
  844.                 printf("system read titlen");
  845.                 #endif
  846.                 #ifdef TONIC_DVD
  847.                 if((full_scrn&SETUP) || (full_scrn&CUSTM))
  848.                 {
  849.                 ExitSetupPage(1);   //dingzhy for tonic auto close setup menu 2004-2-5 2:40
  850.                 }
  851.                 #endif
  852.                 OSD1000ISP_STATUS(OSDISP_READ, OSDIR_GLOBAL);
  853.                 PrintOsdMsg(STR_OS_READ,REGION1,0,0);
  854.                 
  855.                 drv_do_set_features();
  856.                 
  857.                 if(!is_user_opened())
  858.                 {
  859.                     #ifdef FILE_MODE_WRITE//added by wangwei,2005-1-9 16:21
  860.                     printf("detect_CD = %xn",detect_CD);
  861.                     detect_CD = 1;
  862.                     #endif//FILE_MODE_WRITE
  863.                     
  864.                     system_state=SYSTEM_READ_TITLE;
  865.                     no_disk_cnt=0;
  866.                     
  867.                     extern UINT8 old_cd_type;   //2004/10/01 yltseng, set this value in order to let hostx_servo_buf_init() really reconfig/clear data
  868.                     old_cd_type=0xff;
  869.                 }
  870.             }
  871.             //else if((test_ready_ret==ATAPI_NO_MEDIA)&&(no_disk_cnt>1)&&!CDOpened())//NO disc
  872.             else if(((test_ready_ret==ATAPI_NO_MEDIA)||(test_ready_ret==ATAPI_MEDIA_UPSIDE_DOWN)||(test_ready_ret==ATAPI_UNKNOWN_MEDIA)
  873. ||(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. 
  874.             {
  875.                 if(no_disk_cnt>NO_DISC_TIMES)
  876.                 {
  877.                     no_disk_cnt-=NO_DISC_TIMES;
  878.                 }else {
  879.                     no_disk_cnt=1;
  880.                 }
  881.             }
  882.          }
  883.     }else if( door==ATAPI_DOOR_CLOSE_ERR )//terry 2003-7-31 0:55
  884.     {
  885. //         printf("~~~~~~~~~~~open~~~~~~~~~~:%xn",door);
  886. //         gbCloseTrayFail=0;//terry 2003-7-31 0:55
  887.          ircmd_trayout();
  888.     }else
  889.     {
  890.         
  891.         no_disk_cnt=0;
  892.         #ifdef NO_DVD_SERVO //ycwen 2004/08/10 
  893.             system_state=SYSTEM_NODISC;            
  894.         #else
  895.         
  896.         #ifdef FILE_MODE_WRITE//added by wangwei,2005-1-9 16:21
  897.         printf("detect_CD = %xn",detect_CD);
  898.         detect_CD = 1;
  899.         #endif//FILE_MODE_WRITE
  900.             
  901.             no_disk_cnt=0;
  902.         #endif
  903.     } //if(atapi_p_mechanism_status()==2)
  904. }
  905. #elif   DISC_SYSTEM==DISC_SYSTEM_AVB
  906. void test_avb_drv_rdy(void)
  907. {
  908.     int test_ready_ret;
  909.     if(is_tray_close())
  910.     {//tray close
  911. #ifdef SYSMAIN2_DBG
  912.         printf("cnt: %xn",no_disk_cnt);
  913. #endif
  914.         test_ready_ret=is_ready2play();
  915.         if(no_disk_cnt==0)
  916.         {//read disc
  917.                 close_tray_init();
  918.         }else if(no_disk_cnt==1)
  919.         {//
  920.                 play_state=VCD_STATE_IDLE;
  921.                 system_state=SYSTEM_NODISC;
  922.         }else
  923.         {//test
  924.                 no_disk_cnt--;
  925.                 if(test_ready_ret)//unit is ready or not
  926.                 {
  927.                         no_disk_cnt=0;
  928.                         // set feature
  929.                         #ifdef SYSMAIN2_DBG
  930.                         printf("system read titlen");
  931.                         #endif
  932.                         OSD1000ISP_STATUS(OSDISP_READ, OSDIR_GLOBAL);
  933.                         PrintOsdMsg(STR_OS_READ,REGION1,0,0);
  934.                         system_state=SYSTEM_READ_TITLE;
  935.                 }
  936.                 else if( is_no_disc()&&(no_disk_cnt>1)&&!CDOpened() )//NO disc
  937.                 {
  938.                     if(no_disk_cnt>NO_DISC_TIMES)
  939.                         no_disk_cnt-=NO_DISC_TIMES;
  940.                     else
  941.                         no_disk_cnt=1;
  942.                 }
  943.          }
  944.     }else
  945.         no_disk_cnt=0;
  946. }
  947. #endif
  948. //terry,2003/8/14 12:22AM
  949. void power_on_gpio_demute(int demute)
  950. {
  951.     if( power_on_mute&&((system_state==SYSTEM_NODISC)||(demute)) )
  952.     {//terry,2003/8/14 12:10AM
  953.       if(system_state==SYSTEM_NODISC) AUDIF_Init_CDDA();//2004AUDDRV init_cdda();//terry,for bbk
  954.         
  955.       power_on_mute=0;
  956.         
  957.       #ifdef POWER_ON_MUTE_MIC   //axel 2004/2/26 04:10pm mute mic during initialization
  958.       AUDIF_Set_MICVol(mic_volume);//2004AUDDRV AudioSetMICVol(mic_volume);
  959.       #endif
  960.         
  961.       GPIO_DEMUTE();
  962.      setup_SetSPDIFConfig();//2003-8-15 20:56 for avoid SPDIF noise when power on.
  963.     }
  964. }
  965. /*
  966. CheckRecordKey
  967. CheckDiscParentLvl
  968. Maoyong 2004.03.05 move to IR_VFDrsm_util.h
  969.  */
  970. //
  971. // interface setup
  972. //
  973. #if defined(SPHE8202_CARD_STORAGE)
  974. //#define  SPHE8202_216PIN  //wthsin,    2004/2/23 10:49am  
  975. //#define  SPHE8202_256PIN  //wthsin,    2004/2/23 10:49am  
  976. extern void Card_gpio_init();
  977. void setup_8202_card_storage_interface()
  978. {
  979.    #if defined(CARD_SETUP_TYPE_1)||defined(CARD_SETUP_TYPE_2) 
  980.     regs0->sft_cfg7 = regs0->sft_cfg7 | 0x2;    // Set FM 256-PIN package
  981.     regs0->fm_gpio_mode = 8;                    // Set FM GPIO TABLE to ALL IN ONE case
  982.     regs0->fm_gpio_len  = 12                    // Set FMGPIO_B[41:0] turn on
  983.                         |  (0xf << 4);          // Set FMGPIO_B[41:0] enable   
  984.    #elif defined(CARD_SETUP_TYPE_3) ||defined(CARD_SETUP_TYPE_5) 
  985.     regs0->sft_cfg7 = regs0->sft_cfg7 & (~0x2);    // Set FM 256-PIN package
  986.         #ifdef HDMI_SMC_CLE//for HDDVD Non CF config.chenzhao on 2004-12-1 21:27  
  987.         regs0->fm_gpio_len  = 10                    
  988.                             |  (0xf << 4);          // Set FMGPIO_B[26:0] enable  
  989.         #else
  990.     regs0->fm_gpio_len  = 11                    // Set FMGPIO_B[26:0] turn on
  991.                         |  (0xf << 4);          // Set FMGPIO_B[26:0] enable  
  992.         #endif//HDMI_SMC_CLE
  993.    #elif defined(CARD_SETUP_TYPE_4) 
  994.     regs0->sft_cfg7 = regs0->sft_cfg7 & (~0x2);    // Set FM 256-PIN package
  995.     regs0->fm_gpio_len  = 3                    // Set FMGPIO_B[5:0] turn on
  996.                         |  (0x1 << 4);          // Set FMGPIO_B[5:0] enable    
  997.     //regs0->gpio_mode_B=0;                                       
  998.    #endif                                          
  999.     Card_gpio_init();    //wthsin,  2004/3/24 04:55pm
  1000. }
  1001. #endif
  1002. #if defined(SUPPORT_CARD_STORAGE)
  1003. void setup_card_storage_interface()
  1004. {
  1005.     if(regs0->stamp==1)               //Version-B ,wthsin 10/18
  1006.         regs0->pcmcia_iorw_wait = 0x2222;   // Must be 0x2222 in 8200B, setup and hold time for both ior, iow is 0xf,
  1007.      else
  1008.         regs0->pcmcia_iorw_wait = 0xffff;  
  1009.     regs0->wait_cyc1_0 = regs0->wait_cyc1_0 | 0x3f00; // maximum cs timing for R_CS2_B
  1010.     regs0->wait_cyc3_2 = regs0->wait_cyc3_2 | 0x003f; // maximum cs timing for R_CS3_B
  1011. }
  1012. #endif
  1013. #if defined(SUPPORT_USB)&&defined(HOST_SL811HS) //wthsin, 2004/1/12 01:36pm
  1014. void setup_usbhost_sl811hs_interface()
  1015.     regs0->oe_wait_cyc1_0=regs0->oe_wait_cyc1_0|0x3200;
  1016.     regs0->we_wait_cyc1_0=regs0->we_wait_cyc1_0|0x3200;
  1017.     regs0->wait_cyc1_0 = regs0->wait_cyc1_0 | 0x1f00; // maximum cs timing for R_CS2_B
  1018.     regs0->rom1_base = 0x100;       // rom2 n*64k-base ,pcmcia
  1019.     regs0->rom2_base = 0x160;       // rom2 n*64k-base ,pcmcia
  1020.     regs0->rom3_base = 0x200;       // rom3 n*64k-base ,pcmcia
  1021.     regs0->rom_config = 0x7000;   // pcmcia,rom2,3
  1022. }
  1023. #endif
  1024. //
  1025. // setup supporting for extra interfaces
  1026. //
  1027. void
  1028. init_extra_interface() //terry,2004/2/18 10:12AM
  1029. {
  1030.     #if defined(SPHE8202_CARD_STORAGE)
  1031.         setup_8202_card_storage_interface();
  1032.     #elif defined(SUPPORT_CARD_STORAGE)
  1033.         setup_card_storage_interface();
  1034.     #elif  defined(SUPPORT_USB)&&defined(HOST_SL811HS) //wthsin, 2004/1/12 01:36pm
  1035.         setup_usbhost_sl811hs_interface();
  1036.     #endif 
  1037. }
  1038. void dvd_startup(void)//20040316
  1039. {
  1040. #ifdef PULIANG_EJECT_MODE    //yaowh add for puliang 04-12-17
  1041.     BYTE    I2c_Data;
  1042.     BYTE    I2C_Clear=0;
  1043. #endif
  1044.     
  1045.     disc_time = 0xefff;//terry 891004
  1046.     #ifdef TOP_DOOR_LOADER
  1047.         #ifdef SUNPLUS_8202P_DEMOBOARD
  1048.         regs0->sft_cfg4 &= ~((0x03)<<2);    //Enable GPIO2,3 For COVER & TFT SW
  1049.         #endif
  1050.         bDoorStatus = GPIO_GET_DOOR_STATUS();
  1051.         if (bDoorStatus==DOOR_OPEN) {
  1052.             OSD1000ISP_STATUS(OSDISP_OC_OPEN, OSDIR_OPEN);
  1053.             PrintOsdMsg(STR_OS_OPEN,REGION1,0,0);
  1054.             //SERVO_LDOff();//maybe use it.
  1055.             //SERVO_STSledHome();//maybe use it.
  1056.             ircmd_trayout();
  1057.             play_state=VCD_STATE_OPEN;
  1058.         } else {
  1059.             ircmd_trayin();
  1060.             play_state=VCD_STATE_CLOSE;
  1061.         }
  1062.     #else
  1063.         #ifdef PULIANG_EJECT_MODE  //yaowh add 04-12-17
  1064.         ReadFromI2c(0xa0,0xfc,&I2c_Data,1);
  1065.         if((I2c_Data==0x80))
  1066.         {
  1067.             call_ir_func(IRC_EJECT);   
  1068.             WriteToI2c(0xa0,0xfc,&I2C_Clear,1);   
  1069.         }else
  1070.         #endif
  1071.         {
  1072.         #if !(defined(SPHE1000)||defined(PMP_UI))
  1073.         PrintOsdMsg(STR_OS_READ,REGION1,0,0);
  1074.         #endif
  1075.         play_state=VCD_STATE_CLOSE;
  1076.         }
  1077.     #endif //#ifdef TOP_DOOR_LOADER
  1078.     #ifdef  REPEAT_RESET_IOP //zhaoyanhua add 2004-2-13 13:59  //fengjl edit 2004-02-27 15:49
  1079.     //only for DSS 555(VFD Driver: NEC 16312)
  1080.     //This vfd is very strange! When power switch between on and off 
  1081.     //more than 20 times, it will not show VFD informaiton again!
  1082.     //we found it that the data which IOP send to 16312 is abnormal,
  1083.     //so reset IOP here. 
  1084.     reset_iop();
  1085.     reset_ir();
  1086.     reset_vfd();
  1087.     #endif //ifdef REPEAT_RESET_IOP
  1088.     #if defined(CE2746)||defined(NEWCE2746) //yaowh modify 2005-4-5 11:46
  1089.     init_ce2746(); 
  1090.     #endif
  1091. #if defined(CE2766)||defined(CE2766_I2S) //han
  1092. init_ce2766();
  1093. #endif
  1094.     //
  1095.     // CONTROL FLOW
  1096.     //
  1097.     AVD_ResetMediaStatus();
  1098.     ClearCommand();
  1099.     no_disk_cnt=DETECT_TIMES;
  1100.     #ifdef DVB1000_NON_OS
  1101.     system_state=SYSTEM_TS;
  1102.     ControlDvbDvdMic(); //Maoyong 2005-1-18 16:33 turn off MIC when DVB state
  1103.     #else
  1104.     system_state=SYSTEM_OPEN;
  1105.     #endif
  1106.     //play_state=VCD_STATE_CLOSE;
  1107.     sys_cmd=CMD_FUNC|CMD_FUNC_CLOSE;
  1108. //    init_audio_dsp_coding_mode();
  1109.     power_on=2;
  1110. }
  1111. /*
  1112. ** FUNCTION
  1113. ** main()
  1114. **
  1115. ** DESCRIPTION
  1116. ** main function...  what else?
  1117. */
  1118. #ifdef SUPPORT_RECEIVER
  1119. #include "sysmain_receiver.c"  //huziqin 2004-3-12
  1120. #endif
  1121. #ifdef SUPPORT_POWER_OFF_CLOCK_FUNC  //xyy 2004-10-11 17:18
  1122. #include "clock_func.c"
  1123. #endif
  1124. #ifdef DVB_SETUP
  1125.  UINT8 eBuffer[128];
  1126. void SP_SetVolume(UINT8 volume);
  1127. #endif   
  1128. #ifdef QSI_SHOW_ERR_RATE
  1129. #include "sysmain2_QSI.c"
  1130. #endif
  1131. #ifdef  AUTO_ADJUST_TV_TYPE  //lijd 2004-9-15 13:27
  1132. extern BYTE  Adjust_TV_type ;
  1133. #endif
  1134. #ifdef SUPPORT_MIDI           //xlluo 2004-12-28
  1135. #include "fsmidi.h"
  1136. #ifdef SUPPORT_MIDI_MENU_SEL
  1137. #include "fsmidiui.h"
  1138. #endif
  1139. #endif
  1140. #ifdef QSI_SUPPORT_SLOT_TEST
  1141. extern  BYTE SERVO_GetRunInState(void);
  1142. BYTE is_do_slot_test(void)
  1143. {
  1144.     if(SERVO_GetRunInState()==PRODUCTION_RUNIN_ST_IS_SLOT_TEST)
  1145.     {
  1146.         return(1);
  1147.     }
  1148.     return(0);
  1149. }
  1150. #else
  1151. #define is_do_slot_test()   0
  1152. #endif
  1153. void ap_main(void)  // benson update 2004/3/1 04:25