sysmain2.c
上传用户:caisangzi8
上传日期:2013-10-25
资源大小:15756k
文件大小:82k
- /*
- ** FILE
- ** sysmain2.c
- **
- ** DESCRIPTION
- ** Main entry of DVD system firmware
- **
- ** Maintain by terry , 2003.03.07
- **
- */
- #include "sysmain2_h.h"
- #include "gpio.h"
- #include "user_init.h"
- #include "kinf.h"
- #include "sinf.h"
- #include "user_if.h"
- #include "timer.h"
- #ifdef POWER_ON_MUTE_MIC //axel 2004/2/26 04:10pm mute mic during initialization
- #include "dsp3_if.h"
- #endif
- #ifdef TP6317_PANNEL //yaowh add 04-10-25
- extern BYTE TP6317_Power ; //flag
- #endif
- #ifdef SPHE1000
- #ifdef DVB1000_NON_OS
- #include "TunerDrv.h" //maoyong 2004-9-27 16:58
- #include "sp_dtv.h"
- #endif //DVB1000_NON_OS
- //#define TEST_DVD
- #define LINUX_USER_LOGO //MIKEY 2004.07.01
- #endif //SPHE1000
- #ifdef LINUX_USER_LOGO //MIKEY 2004.07.01
- UINT8 f_check_user_logo=0;
- UINT8 *user_logo_rom_addr=(UINT8 *)0x88080000;
- UINT8 *user_logo_ram_addr=(UINT8 *)0x804e0000;
- int user_logo_ram_size=(128*1024);
- #define USER_LOGO_ROM_ADDR (user_logo_rom_addr)
- #define USER_LOGO_RAM_ADDR (user_logo_ram_addr)
- #define USER_LOGO_RAM_SIZE (user_logo_ram_size)
- #endif
- #if 1//def TEST_SERVO//nono 2004-3-30 19:13
- #include "ircode.h"
- #endif
- #include "srv_test.c"
- extern UINT8 volume_value;
- #ifdef SUPPORT_RECEIVER //benson 2004/03/01
- #include "dsp3_if.h"
- #endif
- #ifdef SUPPORT_APOGEE_AMP
- #include "ddx8000.h"
- #endif
- #include "auddrv.h" //2004AUDDRV oliver 20041004 for using audio driver purpose
- #ifdef SUPPORT_SPDIF_IN
- #include "audif.h"
- #endif
- #ifdef SUPPORT_WMA
- #include "asf_if.h"
- #endif
- //jslin //for QSI PIPO //20040901
- #ifdef QSI_SHOW_ERR_RATE
- #include "uart.h"
- #endif
- #ifdef DVB1000_OSD_MENU //Maoyong 2004-10-12 11:28
- #include "dvbmenu.h"
- #endif
- //=========================
- #if defined(SUPPORT_WMA) || defined(SUPPORT_MP4)
- extern UINT32 nGotoPck;
- #endif
- //Maoyong 2004.03.05, move some resume relative declare/def to "rsm_util.h"
- #ifdef CHECK_RECORD_DISK_PARENT_LVL //Maoyong 2004.03.04
- extern BYTE CheckDiscParentLvl(void);
- #endif
- extern BYTE CheckLoadRsmInfo(void);
- extern void RecordRsmPlay(void);
- #if defined(AUDIO_2CH_5_1CH)&&defined(SUPPORT_PROLOGIC_II)//axel modified 2004/3/16 10:53am zhaoyanhua add 2003-12-17 9:47
- extern int setup_IsSpkDownmixOff(void);//setup_tab.c
- extern void AudioSet2chOutput(void);//setup_tab.c
- #endif
- #ifdef DYNAMIC_SPECTRUM //zhaoyanhua add 03-11-6 15:26
- extern void Show3dspectrum(void);
- #endif
- #ifdef USER_MPEG_LOGO
- extern UINT8 Is_User_Mpeg_Logo();
- #endif
- #ifdef CORTROL_VCD_ONF
- extern int setup_IsVCD_OFF();
- #endif
- #if defined(SUPPORT_CARD_STORAGE)||defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)
- extern BYTE IsCardMediaExist(void);
- extern void SwitchMedia(BYTE direction);
- #endif
- #ifdef SUPPORT_REP_READ
- #include "read.h"
- #endif
- #ifdef PROVIEW_GPIO_KEY
- void set_proview_gpio_key(void);
- #endif
- void system_check_media_switch(void);
- void system_check_source_switch(void);// for QSI disccard switch //added by JS //20040727
- #ifdef PMP_DVD //wthsin, 2004/11/9 07:19
- UINT8 PMP_ENABLE=0;
- extern void pc_usb_access_mode();
- #endif //#ifdef PMP_DVD
- #ifdef SUPPORT_Auo_2inch_Digital_panel
- extern void init_auo_digital_panel(void);
- #endif
- #ifdef SUPPORT_Auo_UPS053_Digital_panel
- extern void init_auo_ups053_digital_panel(void);
- #endif
- #ifdef FILE_MODE_WRITE//added by wangwei,2005-1-9 21:40
- extern unsigned int detect_CD;
- #endif
- #if defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE) //modefied by wangwei,2004-11-19 17:31(for storage no files screen refresh problem)
- extern UINT8 MediaIsEmpty;
- //#define MEDIA_EMPTY 1 //dingzhy moved to gb_def.h
- //#define MEDIA_NOT_EMPTY 0
- #endif
- //=====================================================
- //* debug option
- //=====================================================
- #ifndef DVDRELEASE
- //#define SYSMAIN2_DBG 1
- //#define MONE_LOGO
- #endif
- #undef FORCE_SKIP_VCD_MOSAIC//nono 4-6-9 0:35
- #ifndef SYSMAIN2_DBG
- #undef printf
- #undef print_block
- #define printf(f, a...) do {} while (0)
- #define print_block(x,y) do {} while (0)
- #endif
- //=====================================================
- //* var. and extern function decalare
- //=====================================================
- #include "sysmain2.h"
- extern UINT8 Subp_stream_Chg(UINT8,int);
- extern UINT16 Audio_stream_Chg_SVCD(UINT8);
- //2004AUDDRV extern void init_mp3(void);
- extern void do_mp3(void);
- extern int AUDIF_Set_Play();//2004AUDDRV AudioSetPlay(); //huziqin 2004-2-26
- extern int AUDIF_Set_Stop();//2004AUDDRV AudioSetStop(); //change type to int
- extern void RsmInfo2Flash(int);
- extern void LoadRsmInfo(void);
- extern void LoadModual(UINT16);
- extern void RS42Init();
- extern void RS2420Init();
- extern void DisplayScreenSaver();
- #ifdef DVD_SERVO
- extern UINT8 cServoWrongDataPass;
- #endif
- void SetDeInterlace(BYTE nVal);
- extern void setup_SetSPDIFConfig();//nono 3-8-18 15:45
- #ifdef CD_PLAYER //liweihua 2003-9-3
- extern void show_cdplayer(void);
- #endif
- #if defined(CF_CARD_WRITE) || defined(SPHE8202_FAT_Write_Function)//|| defined(WRITE_USB)
- extern BYTE read_card_sign,flag_cf2cd,flag_cd2cf; //xulf
- #endif
- #ifdef VIRTUAL_KEYBOARD//liweihua 2003-9-18
- extern BYTE KeyID;
- void hl_keyboard_button(BYTE SelectID);
- void osd_draw_virtual_keyboard(int xStart, int yStart,BYTE r);
- #endif
- #ifdef LOGO_PLAY_MP3
- int playindex;
- #endif
- BYTE logo_play_mp3_flag;
- extern UINT8 power_on_mute;//terry 20030805
- extern void set_video_default_offset(void);//wanghaoying 2003-8-12 20:21
- extern void save_cmp_disc_info(UINT32 info1);//wanghaoying 2003-8-12 20:22
- #ifdef SUPPORT_HDD_ACCESS
- UINT8 f_force_browser=0;
- UINT8 f_browser_mode=0;
- #endif
- #ifdef USE_PIN31_CONTROL_POWER_LED //gerry,2004-3-9 19:41
- int gbm_gpio_led_flag;
- #endif//USE_PIN31_CONTROL_POWER_LED
- void show_osd_disc_type(void)
- {//terry,2003/12/29 08:25PM
- #if defined(JUST_SHOW_CD_TYPE)||defined(NOSHOW_CDROM_WHEN_DISP)||defined(BEAUTIFUL_STYLE) //Not show CD Icon for NINTAUS Maoyong 2004.02.12
- #if defined(NOSHOW_CDROM_WHEN_DISP)||defined(BEAUTIFUL_STYLE)//nono 2004-6-15 0:02 //dingzhy for beautiful
- if(cd_type_loaded == CDROM)
- #else
- if(cd_type_loaded == CDDA)
- #endif
- {
- osd_tog_region(REGION1, OSD_OFF);
- return;
- }
- #endif
-
- #ifdef GBM_DVD
- PrintOsdMsg(osd_cd_id[cd_type_loaded],REGION1,2,0);
- #elif defined(DVD_AUDIO) // alan, 2003/8/15 04:23PM, to distinguish DVD-VIDEO or DVD-AUDIO
- #ifdef SHOW_DVD_ROM//NONO 4-2-10 19:08
- if( (is_svo_dvd())&&(cd_type_loaded==CDROM) )
- {
- OSD1000ISP_STATUS(OSDISP_TYPE_DVDROM, OSDIR_CDTYPE);
- psprintf(RegionValStr[REGION1], "DVDROM");
- PrintOsdMsg(STR_OS_SPACE,REGION1, 1, 1);
- }
- else
- #endif//SHOW_DVD_ROM
-
- if (cd_type_loaded==CDDVD)
- {
- if (dAMG_LSN==0)
- psprintf(RegionValStr[REGION1], "DVD-VIDEO");
- else
- psprintf(RegionValStr[REGION1], "DVD-AUDIO");
- OSD1000ISP_STATUS(OSDISP_TYPE_DVD, OSDIR_CDTYPE);
- PrintOsdMsg(STR_OS_SPACE,REGION1, 1, 1);
- } else {
- #ifdef DVD_SERVO
- if ((cd_type_loaded == CDVCD10) && (is_svo_dvd()))
- #else
- if (cd_type_loaded == CDVCD10)
- #endif
- {
- OSD1000ISP_STATUS(OSDISP_TYPE_DVD, OSDIR_CDTYPE);
- PrintOsdMsg(osd_cd_id[CDDVD],REGION1,1,0);
- }
- else
- {
- OSD1000ISP_STATUS(cd_type_loaded, OSDIR_CDTYPE);
- PrintOsdMsg(osd_cd_id[cd_type_loaded],REGION1,1,0);
- }
- }
- #elif defined (FENGKAI_DVD)
- ///////clead 2003-8-27 17:31
- printf("**--- cd_type_loaded:%d bDiscType:%d ---**n",cd_type_loaded,bDiscType);
-
- if((cd_type_loaded==CDSVCD)&&(bDiscType == CD_CVD))
- {
- OSD1000ISP_STATUS(OSDISP_TYPE_CVD, OSDIR_CDTYPE);
- psprintf(RegionValStr[REGION1], "CVD");
- PrintOsdMsg(STR_OS_SPACE,REGION1, 1, 1);
- }else
- {
- OSD1000ISP_STATUS(cd_type_loaded, OSDIR_CDTYPE);
- PrintOsdMsg(osd_cd_id[cd_type_loaded],REGION1,1,0);
- }
- #elif defined(SKYWORTH_DVD)
- if(cd_type_loaded!=CDROM)
- {
- OSD1000ISP_STATUS(cd_type_loaded, OSDIR_CDTYPE);
- PrintOsdMsg(osd_cd_id[cd_type_loaded],REGION1,1,0);
- }
- else
- PrintOsdMsg(STR_OS_SPACE,REGION1,1,0);
- #else//#ifdef GBM_DVD
- #ifdef DVD_SERVO
- if ((cd_type_loaded == CDVCD10) && (is_svo_dvd()))
- #else
- if (cd_type_loaded == CDVCD10)
- #endif
- {
- OSD1000ISP_STATUS(OSDISP_TYPE_DVD, OSDIR_CDTYPE);
- PrintOsdMsg(osd_cd_id[CDDVD],REGION1,1,0);
- }
- else
- {
- OSD1000ISP_STATUS(cd_type_loaded, OSDIR_CDTYPE);
- PrintOsdMsg(osd_cd_id[cd_type_loaded],REGION1,1,0);
- }
- #endif//#ifdef GBM_DVD
- }
- //*******init ce2746 dac ******** wangap 2004/4/21
- #if defined(CE2746)||defined(NEWCE2746)
- #define Chip_addr 0x6a
- #define Register_addr 0x00
- void init_ce2746()
- {
- #ifdef NEWCE2746
- int I2c_data1=0x40,I2c_data2=0x00;
- #else
- int I2c_data1=0x01,I2c_data2=0x80;
- #endif
- WriteI2c(Chip_addr,Register_addr,I2c_data1,1);
- delay_1ms(10);
- WriteI2c(Chip_addr,Register_addr+1,I2c_data2,1);
- }
- #endif
- #if defined(CE2766)
- #define Chip_addr 0x6a
- #define Register_addr 0x00
- void init_ce2766()
- {
- // int I2c_data1=0x80,I2c_data2=0x00;
- int I2c_data1=0x20,I2c_data2=0x00;
-
- WriteI2c(Chip_addr,Register_addr,I2c_data1,1);
- delay_1ms(10);
- WriteI2c(Chip_addr,Register_addr+1,I2c_data2,1);
- }
- #endif
- #if defined(CE2766_I2S)
- void init_ce2766()
- {
- WriteI2c(0x6a,0x00,0x80,1);
- WriteI2c(0x6a,0x01,0x80,1);
- WriteI2c(0x6a,0x02,0x80,1);
- WriteI2c(0x6a,0x03,0x80,1);
- WriteI2c(0x6a,0x04,0x80,1);
- WriteI2c(0x6a,0x05,0x80,1);
- WriteI2c(0x6a,0x06,0x80,1);
- WriteI2c(0x6a,0x07,0x80,1);
- }
- #endif
- //=====================================================
- //* function decalare
- //=====================================================
- void InitVar(void)
- {
- //init pe engine
- pe_run = 0;
- // dVts_iso9600_addr = 0;//terry,2003/8/6 04:01PM
- #ifdef TP6317_PANNEL //yaowh add 04-10-25
- TP6317_Power = 0 ;
- #endif
- PE_ClearNav();
- mpeg_audio=0;
- dspWatchDog=DSP_WD_INIT;
-
- #ifdef BAD_DISC_AUTO_STOP //terry,2003/8/31 12:00AM
- bad_disc_auto_stop=0;
- #endif
- //init navigation
- cd_subtype = CDROM_UNSUPPORT;
- bDiscType=CDUNKNOWN;
- still_timer=0;
- //#ifdef SUPPORT_MIX_MP3_CDDA //linrc change "SUPPORT_MIX_MP3_CDDA" to "SUPPORT_MIX_DATA_CDDA_DISC"
- #ifdef SUPPORT_MIX_DATA_CDDA_DISC //because we not only support this type mix mode disc 2004-12-15 15:53
- mp3_cd_end_trk = 0;
- #endif
- play_dir = 0;
- Mp3ReadFinish=0;//mp3 ........
- logo_play_mp3_flag=1;
- fore_disp_time=-1;
- jpg_slide_time = JPEG_SLIDE_TIME;//jpeg .......... wanghaoying 2003-8-26 20:21
-
- #ifdef NO_BLACK_for_PIC_CD
- pic_cd_first_play = 0;
- #endif
- bPbcOff=0; //vcd ..........
- cd_trk_now=0;
- cd_trk_hi=0xff;
- cd_trk_lo_now=0;
- cd_trk_lo=0;
- dVMG_LSN = 0; //dvd.......
- HL_exist=0;
- read_sector=0;
- dvd_error=0;
- min_astn_id=0;//terry,2003/12/15 02:33PM
- dvd_karaoke_mode = 0; //terry,2004/2/16 11:11AM
- #ifdef DVD_AUDIO
- dAMG_LSN = 0;
- #endif
- #ifdef TUNR_OFF_PARENTAL_LVL
- bTurnOffParentalLVL=0; //terry,2002/9/20 11:40PM
- #endif
- #ifdef JUST_SHOW_CD_TYPE //Maoyong 2004.02.26
- track_play_diff_time = 0;
- #endif
-
- #ifdef DVD_SEQ_PLAY
- #ifdef AUTO_PLAY
- extern BYTE auto_play_on();
- if (auto_play_on())
- dvd_menu_play = 0;
- else
- dvd_menu_play = 1;
- #else
- dvd_menu_play = 0;
- #endif
- #endif
- // 2004/07/16 yltseng
- wb_tag_init();
-
- //init UI
- init_ir_num();
- goto_active=0;
- mp3_user_select=0;
- pFsJpeg->iso9660_file_cnt = 0;
- disp_trk_now = 0;
- Mp3_kbitrate=0;
- bIntro=0;
- //keep_cmd_code=0;
- keep_cmd_code=IR_CODE_MAX_NUM;//2004-3-30 19:14
- disc_st_time=0;
- #if defined(IR_PLAY_RESUME) && defined(POWER_RESUME) //yw 021003
- power_resumeflag = 0;
- #endif
-
- #ifdef SUPPORT_REP_READ //Maoyong 2004.06.03
- InitRead();
- #endif
-
- #ifdef SUPPORT_BOOK
- init_book();
- #endif
-
- goto_time = 0;//4-4-13 16:22
-
- pe_timesearch_clear();//nono 5-4-4 22:00 clear time search flag.
-
- //#ifdef OP_UI//zhaoyanhua 2004-5-24 17:35
- // prog_cnt = 0;
- //#endif
- //nono move from ap_mian(): SYSTEM_READ_TITTLE.2004-2-27 12:00
- coding_mode_now=AUDIF_CODING_MODE_NONE;//wangfeng 2003-12-19 17:44
- #ifdef USE_PIN31_CONTROL_POWER_LED //gerry,2004-3-9 19:42
- gbm_gpio_led_flag=0;
- #endif//USE_PIN31_CONTROL_POWER_LED
- nOldFst = 0; //Maoyong 2004.05.25 move from labif.c
- #ifdef SUPPORT_WMA //Maoyong 2004.05.31 for WMA
- asf_resume_pck = 0;
- #endif
- #if defined(SUPPORT_WMA) || defined(SUPPORT_MP4)
- nGotoPck = 0;
- #endif
- //FS SWD
- #ifdef SUPPORT_PLAY_SWD
- START_POLLING_SWD = 0;
- #endif
- //OSD 16bit direct color
- #ifdef SUPPORT_PS2
- OSD_buffer_16bit = 0;
- #endif
-
- //initiate PS2 mouse
- #ifdef SUPPORT_PS2
- START_POLLING_PS2 = 0; //hold polling
- mouse_pos_x = 180;
- mouse_pos_y = 120;
- mouse_btn_status = 0x0;
- PS2_INIT_DONE = 0x0;
- #endif
- //==============================================
- //for QSI source switch //added by JS //20040726
- #if defined(QSI_PORTABLE_DVD) && defined(SUPPORT_CARD_STORAGE)
- #ifdef SUPPORT_QSI_SOURCE_SWITCH
- source_type_now = source_disc;
- source_type_old = source_disc;
- #endif
- #endif
- //==============================================
- }
- extern char _stextf[];
- extern char _text_drv[], _text_drv_dvd[], _text_drv_ap[], _text_drv_iop[], _text_other[], _text_drv_cdrom[];
- extern char _text_drv_srvdp[], _text_drv_ap2[], _text_drv_free[];
- #include "kernel.h"
- #define CUSTM_LOGO 0
- #define SETUP_LOGO 1
- UINT8 logo_type=CUSTM_LOGO;
- extern const unsigned char Setup_Logo[];
- //
- // show logo
- //
- // Terry,2003/9/13 12:20AM
- // integration mpeg logo/new style setup logo function
- void ShowTitle()
- {
- BYTE *p;
- UINT32 unOffset;
- #ifdef NEW_STYLE_SETUP //terry,2004/2/17 11:09AM
- UINT8 setup;
- #endif
- #ifdef MONE_LOGO
- printf("logo inn");
- #endif
-
- #ifdef LINUX_USER_LOGO //MIKEY 2004.07.01
- if(f_check_user_logo==0) {
- printf("INFO: f_check_user_logo USER_LOGO_ROM_ADDR=[%x]n", USER_LOGO_ROM_ADDR);
- f_check_user_logo=1;
- p = (BYTE *) USER_LOGO_ROM_ADDR;
- memset((BYTE *) USER_LOGO_RAM_ADDR, 0, USER_LOGO_RAM_SIZE);
- if(*(p+0x80)=='T' && *(p+0x81)=='M') {
- //printf("INFO: cp USER_LOGO_RAM_ADDR=[%x] USER_LOGO_RAM_SIZE=[%x]n", USER_LOGO_ROM_ADDR, USER_LOGO_RAM_SIZE);
- memcpyS((BYTE *) USER_LOGO_RAM_ADDR, (BYTE *) USER_LOGO_ROM_ADDR, USER_LOGO_RAM_SIZE);
- //printf("INFO: cp USER_LOGO_RAM_ADDR=[%x] USER_LOGO_RAM_SIZE=[%x] OK!!n", USER_LOGO_ROM_ADDR, USER_LOGO_RAM_SIZE);
- f_check_user_logo=2;
- }
- }
- #endif
- LoadModual(MODUAL_MPEG);
- show_logo=1;
- Abort();
- unOffset = ((UINT32 *)_stextf)[MODUAL_ROM3];
-
- #ifdef NEW_STYLE_SETUP
- #ifdef SDRAM_16Mb_Mode//zhaoyanhua add 2003-8-7 10:12
- if((prog_state == 4 )||(prog_state == 5))
- #else
- if((setup_state == 1 )||(setup_state == 3))
- #endif//SDRAM_16Mb_Mode
- setup =1;
- else
- setup =0;
- #endif//NEW_STYLE_SETUP
-
- set_vpp_disp_size(0,0);
- #ifdef NEW_STYLE_SETUP
- if(setup)
- {
- set_video_aspect();
- p = Setup_Logo;
- logo_type = SETUP_LOGO;
- printf("==============>display setup logon");
- }
- else
- #endif
- #ifdef USER_MPEG_LOGO
- // alan, 2003/9/24 11:33AM
- if(Is_User_Mpeg_Logo()) p=(UINT8 *)(ROM_BASE_UNCACHED+768*1024); //Flash offset addr 0x90000(for 080)
- else
- #endif
- {
- #ifdef LINUX_USER_LOGO //MIKEY 2004.07.01
- p = (BYTE *) USER_LOGO_RAM_ADDR;
- if(*(p+0x80)=='T' && *(p+0x81)=='M')
- f_check_user_logo=3;
- else
- #endif
- p = DVDTitle;
- printf("Manufacture Logon");
-
- #ifdef DOUBLE_LOGO
- if(OsdIsEnglish()) p=DVDTitle1;
- #endif
- #ifdef CD_PLAYER //liweihua 2003-9-3
- if((cd_type_loaded==CDDA)&&(play_state!=VCD_STATE_OPEN))
- p=CDPlayerTitle;
- #endif
- }
- PlayRomSlide(p);
- #ifdef LOGO_STARTUP_VPP_NOW
- startup_vpp_now();//nono 4-6-10 0:25 for ZOOMING IN,show logo startup_vpp_now.
- #endif//LOGO_STARTUP_VPP_NOW
- MediaMainLoop();
- PlayRomSlide(p);
- MediaMainLoop();
- #ifdef NEW_STYLE_SETUP // alan, 2003/8/13 11:44PM
- if(setup)
- {//terry,0813
- if(getVPP_TVsystem()) set_vpp_disp_size(720,540);
- else set_vpp_disp_size(0,0);
- }
- #endif
- #ifdef NEW_STYLE_SETUP
- if(logo_type == CUSTM_LOGO)
- #endif
- tv_setup_misc(0);
-
- reset_sup();
- Sync();
- show_logo=0;
- set_video_default_offset();
- startup_vpp();
-
- #ifdef NEW_STYLE_SETUP
- if(setup==0)
- logo_type = CUSTM_LOGO;
- #endif//#ifdef NEW_STYLE_SETUP
-
- #ifdef MONE_LOGO
- printf("logo outn");
- #endif
- }
- #ifdef LOGO_PLAY_MP3
-
- void Show_Logo_Play_MP3()
- {
- extern const unsigned char LOGO_MP3[];
- int a;
- /*Play Background MP3*/
-
- #define PlayLen 3
-
- //b=sizeof(LOGO_MP3);
- //printf("MP3 size=%dn",b);
-
- for(a=0;a<PlayLen;a++)
- {
- stream_ptr = (BYTE*)(LOGO_MP3 + playindex*PlayLen*1024+a*1024);
- //print_block(stream_ptr,1024);
- dma_iptr = 0;
- dma_ilen = 1024;
- logo_play_mp3_flag=0;
- do_mp3();
- logo_play_mp3_flag=1;
- }
-
- playindex++;
- if(playindex==MaxPlayLen/PlayLen) playindex=0;
- }
- #endif
- /****************************************************/
- /* initial subroutine */
- /****************************************************/
- void volume_init(void)
- {
- #if !defined(Ti3001_OSD_UI_1)
- #ifdef VOLUME_RECODE
- {
- //audio_volume = VOL_VALUE; //set to maximum volume
- int read_volume=0;
- int i=0;
- #ifdef CNTR_5SPK_VOLUME
- for (i=0; i<7; i++) {
- #endif
- read_volume=ReadFromI2c(0xa0,ADDR_I2C_VOLUME+i,(BYTE *)&audio_volume,sizeof(audio_volume));
- if(read_volume!=1)
- {
- //#if 1//def ROTARY_VOL_HUAJIA1251
- #ifdef CNTR_5SPK_VOLUME// defined(HIMAGE1251) || defined(HIMAGE1250_03_185W)//wangfeng 2003-10-31 21:11
- #ifdef SW_VOL_63
- if(i==6){
- audio_volume = SUB_DEFAULT;
-
- }
- else
- #endif
- audio_volume = DEFAULT_VOL;
- #else
- audio_volume = DEFAULT_VOL;
- #endif
- //#else
- // audio_volume = VOL_VALUE;
- //#endif
- }
- audio_volume = (audio_volume<=DEFAULT_VOL)?audio_volume:DEFAULT_VOL;
- #ifdef CNTR_5SPK_VOLUME
-
- volume_5SPK[i] = audio_volume;//VOL_VALUE; //set to maximum volume
- if(i==0)//wangfeng 2003-11-03 15:33
- idVolume_5SPK[i] = Volume_Font_ID;
- else
- idVolume_5SPK[i] = VOL_FL_ID+i-1;
- } //for
- audio_volume = volume_5SPK[0] ;
- volume_Switch = 0; //set to main volume
- #endif
- }
- #else //VOLUME_RECODE
- #if 1//def ROTARY_VOL_HUAJIA1251
- audio_volume = DEFAULT_VOL;//VOL_VALUE; //set to maximum volume
- #else
- audio_volume = VOL_VALUE;
- #endif
- #endif //VOLUME_RECODE
- #else
- //ti_set_volume(SET_TOTAL_VOLUME,TI_VOL_VALUE);
- ti_set_volume(SET_ALL_VALUE);//2002 0918
- #endif
- #if 0 //def TAS3001_AMP // jason mark 2-10-5 16:29
- // tas3001_vol = TI_VOL_VALUE;//2002 0918
- iBalance=10;
- ti_set_volume(SET_TOTAL_VOLUME,TI_VOL_VALUE);//2002 0918
- #endif
- #ifdef TAS5026_AMP
- tas5026_vol = TI_VOL_VALUE;
- iBalance=10;
- #endif
- }
- /* The main initial function */
- static inline void VCD_init()
- {
- psd_state = PSD_PLAY_TRACK; //for cdda vcd1.0 &1.1
- psd_st.psd_list_id = 0xffff;
- playmode_sel(CLEAR_ALL);
- }
- /*
- ** FUNCTION
- ** ReadCDTitle
- **
- ** DESCRIPTION
- ** reading DISC information.
- */
- int ReadCDTitle(void)
- {
- extern UINT8 DiscType;
- int Res;
- //
- // reset hardware
- //
- cd_type_loaded=CDUNKNOWN;
- if (CDOpened())
- return -1;
- if(system_state==SYSTEM_POWER)
- return -3;
- //
- // setup interrupt-mask
- //
- SetIntrMask(INTR_MASK_READTOC);
- //
- // READTOC
- //
- pbcoff();
- play_state = VCD_STATE_READTOC;
- #ifdef DVD_SERVO
- Res=read_toc();
- #endif
- disc_init();
- if (!is_user_opened())
- {
- //if (cd_type_loaded != CDDVD)
- if ( (cd_type_loaded != CDDVD) || ( (cd_type_loaded==CDDVD) && (dVMG_LSN==0) ) ) //add more DVD-video checking, Jeff 20031124
- {
- get_disc_info();
- //CSSEnable = 0;
- //
- // software reset and initial variable
- //
- VCD_init();
- #ifndef DVD_SERVO
- Res=read_toc();
- #endif
- #ifdef DVD_SERVO
- if( (Res>=0)||(DiscType == CDDVD) )
- #else
- if(Res>=0)
- #endif
- {
- Res=check_cdtype();
- #ifdef SYSMAIN2_DBG
- if (cd_type_loaded != CDDVD) {
- printf("check_cdtype:after disc_init, DVD xxx, dVMG_LSN=%xn", dVMG_LSN);
- } else {
- printf("check_cdtype:after disc_init, DVD ooo, dVMG_LSN=%xn", dVMG_LSN);
- }
- printf("check_cdtype:Res=%d, cd_type_loaded=%xn", Res, cd_type_loaded);
- #endif//SYSMAIN2_DBG
- disc_time=M2I(gettrkmsf_leadout()); //terry 891004
- if(cd_type_loaded!=CDDVD)//terry,2003/8/7 03:57PM
- save_cmp_disc_info(disc_time);
- }
- }else
- {
- Res=0;
- }
- }
- if (is_user_opened())
- Res = -1;
- #ifdef SUPPORT_CD_TEXT
- else
- read_cd_text();
- #endif
- #ifdef DIP_CFG_ENABLE
- SetDeInterlace(dip_sel);
- #else
- dip_enable = 0;
- #endif
- if( (cd_type_loaded==CDVCD10)&&( (cd_trk_hi<1)||(cd_trk_hi>100) ) )
- {//terrry,2003/12/30 11:00AM
- printf("toc errn");
- cd_trk_hi = 1;
- cd_type_loaded=CDROM;
- }
- return Res;
- }
- //detect tray function subroutin
- UINT8 is_user_opened(void)
- {
- //printf("no_disk_cnt:%x s:%x p:%xn",no_disk_cnt,system_state,play_state);
- if( (no_disk_cnt==DETECT_TIMES)||(system_state==SYSTEM_POWER) )
- return TRUE;
- else
- {
- return FALSE;
- }
- }
- UINT8 is_test_unit(void)//2001/10/23
- {
- //if(no_disk_cnt!=DETECT_TIMES&&no_disk_cnt!=0)
- //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.
- //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.
- 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.
- return TRUE;
- else
- return FALSE;
- }
- void close_tray_init(void)
- {
- #ifdef WHEN_READTOC_AUTO_EXIT_SETUPPAGE
- if((full_scrn&SETUP) || (full_scrn&CUSTM))
- {
- ExitSetupPage(1); //dingzhy for tonic auto close setup menu 2004-2-5 2:40
- }
- #endif
- OSD1000ISP_STATUS(OSDISP_READ, OSDIR_GLOBAL);
- PrintOsdMsg(STR_OS_READ,REGION1,0,0);
- sys_cmd=(CMD_FUNC|CMD_FUNC_CLOSE);
- CDSetStop();
- play_state=VCD_STATE_CLOSE;
- no_disk_cnt=DETECT_TIMES;
- #if defined(SUPPORT_USB)||defined(SPHE8202_CARD_STORAGE)//liweihua add 20031223
- if(!(card_plug_state&USER_DO_PLUG_OUT)){
- printf("ENTER COLSE TRAY INIT!n");
- card_plug_state |= USER_DO_PLUG_IN;
- }
- #endif
- }
- //BYTE gbCloseTrayFail = 0;//terry 2003-7-31 0:55
- #if DISC_SYSTEM==DISC_SYSTEM_ATAPI
- void test_atapi_drv_rdy(void)
- {
- int test_ready_ret;
- UINT8 door;
- test_ready_ret=atapi_p_test_unit_ready();//start up loader
- delay_srv_10ms(15); //
- door = atapi_p_mechanism_status();
- if( door==ATAPI_DOOR_CLOSE )
- {//tray close
- #ifdef SYSMAIN2_DBG
- printf("cnt: %xn",no_disk_cnt);
- #endif
- if(no_disk_cnt==0)
- {
- close_tray_init();
- }else if(no_disk_cnt==1)
- {
- #ifdef HOBO_DVD //Jefftest 20020930
- if (test_ready_ret != 2)
- play_state=VCD_STATE_CLOSE;
- else
- #endif
- play_state=VCD_STATE_IDLE;
- system_state=SYSTEM_NODISC;
-
- #ifdef FILE_MODE_WRITE//added by wangwei,2005-1-9 16:13
- detect_CD = 0;
- #endif//FILE_MODE_WRITE
-
-
- }else
- {//test
- no_disk_cnt--;
- if(test_ready_ret==0)//unit is ready or not
- {
- // set feature
- #ifdef SYSMAIN2_DBG
- printf("system read titlen");
- #endif
- #ifdef TONIC_DVD
- if((full_scrn&SETUP) || (full_scrn&CUSTM))
- {
- ExitSetupPage(1); //dingzhy for tonic auto close setup menu 2004-2-5 2:40
- }
- #endif
- OSD1000ISP_STATUS(OSDISP_READ, OSDIR_GLOBAL);
- PrintOsdMsg(STR_OS_READ,REGION1,0,0);
-
- drv_do_set_features();
-
- if(!is_user_opened())
- {
- #ifdef FILE_MODE_WRITE//added by wangwei,2005-1-9 16:21
- printf("detect_CD = %xn",detect_CD);
- detect_CD = 1;
- #endif//FILE_MODE_WRITE
-
- system_state=SYSTEM_READ_TITLE;
- no_disk_cnt=0;
-
- extern UINT8 old_cd_type; //2004/10/01 yltseng, set this value in order to let hostx_servo_buf_init() really reconfig/clear data
- old_cd_type=0xff;
- }
- }
- //else if((test_ready_ret==ATAPI_NO_MEDIA)&&(no_disk_cnt>1)&&!CDOpened())//NO disc
- else if(((test_ready_ret==ATAPI_NO_MEDIA)||(test_ready_ret==ATAPI_MEDIA_UPSIDE_DOWN)||(test_ready_ret==ATAPI_UNKNOWN_MEDIA)
- ||(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.
- {
- if(no_disk_cnt>NO_DISC_TIMES)
- {
- no_disk_cnt-=NO_DISC_TIMES;
- }else {
- no_disk_cnt=1;
- }
- }
- }
- }else if( door==ATAPI_DOOR_CLOSE_ERR )//terry 2003-7-31 0:55
- {
- // printf("~~~~~~~~~~~open~~~~~~~~~~:%xn",door);
- // gbCloseTrayFail=0;//terry 2003-7-31 0:55
- ircmd_trayout();
- }else
- {
-
- no_disk_cnt=0;
- #ifdef NO_DVD_SERVO //ycwen 2004/08/10
- system_state=SYSTEM_NODISC;
- #else
-
- #ifdef FILE_MODE_WRITE//added by wangwei,2005-1-9 16:21
- printf("detect_CD = %xn",detect_CD);
- detect_CD = 1;
- #endif//FILE_MODE_WRITE
-
- no_disk_cnt=0;
- #endif
- } //if(atapi_p_mechanism_status()==2)
- }
- #elif DISC_SYSTEM==DISC_SYSTEM_AVB
- void test_avb_drv_rdy(void)
- {
- int test_ready_ret;
- if(is_tray_close())
- {//tray close
- #ifdef SYSMAIN2_DBG
- printf("cnt: %xn",no_disk_cnt);
- #endif
- test_ready_ret=is_ready2play();
- if(no_disk_cnt==0)
- {//read disc
- close_tray_init();
- }else if(no_disk_cnt==1)
- {//
- play_state=VCD_STATE_IDLE;
- system_state=SYSTEM_NODISC;
- }else
- {//test
- no_disk_cnt--;
- if(test_ready_ret)//unit is ready or not
- {
- no_disk_cnt=0;
- // set feature
- #ifdef SYSMAIN2_DBG
- printf("system read titlen");
- #endif
- OSD1000ISP_STATUS(OSDISP_READ, OSDIR_GLOBAL);
- PrintOsdMsg(STR_OS_READ,REGION1,0,0);
- system_state=SYSTEM_READ_TITLE;
- }
- else if( is_no_disc()&&(no_disk_cnt>1)&&!CDOpened() )//NO disc
- {
- if(no_disk_cnt>NO_DISC_TIMES)
- no_disk_cnt-=NO_DISC_TIMES;
- else
- no_disk_cnt=1;
- }
- }
- }else
- no_disk_cnt=0;
- }
- #endif
- //terry,2003/8/14 12:22AM
- void power_on_gpio_demute(int demute)
- {
- if( power_on_mute&&((system_state==SYSTEM_NODISC)||(demute)) )
- {//terry,2003/8/14 12:10AM
- if(system_state==SYSTEM_NODISC) AUDIF_Init_CDDA();//2004AUDDRV init_cdda();//terry,for bbk
-
- power_on_mute=0;
-
- #ifdef POWER_ON_MUTE_MIC //axel 2004/2/26 04:10pm mute mic during initialization
- AUDIF_Set_MICVol(mic_volume);//2004AUDDRV AudioSetMICVol(mic_volume);
- #endif
-
- GPIO_DEMUTE();
- setup_SetSPDIFConfig();//2003-8-15 20:56 for avoid SPDIF noise when power on.
- }
- }
- /*
- CheckRecordKey
- CheckDiscParentLvl
- Maoyong 2004.03.05 move to IR_VFDrsm_util.h
- */
- //
- // interface setup
- //
- #if defined(SPHE8202_CARD_STORAGE)
- //#define SPHE8202_216PIN //wthsin, 2004/2/23 10:49am
- //#define SPHE8202_256PIN //wthsin, 2004/2/23 10:49am
- extern void Card_gpio_init();
- void setup_8202_card_storage_interface()
- {
- #if defined(CARD_SETUP_TYPE_1)||defined(CARD_SETUP_TYPE_2)
- regs0->sft_cfg7 = regs0->sft_cfg7 | 0x2; // Set FM 256-PIN package
- regs0->fm_gpio_mode = 8; // Set FM GPIO TABLE to ALL IN ONE case
- regs0->fm_gpio_len = 12 // Set FMGPIO_B[41:0] turn on
- | (0xf << 4); // Set FMGPIO_B[41:0] enable
- #elif defined(CARD_SETUP_TYPE_3) ||defined(CARD_SETUP_TYPE_5)
- regs0->sft_cfg7 = regs0->sft_cfg7 & (~0x2); // Set FM 256-PIN package
- #ifdef HDMI_SMC_CLE//for HDDVD Non CF config.chenzhao on 2004-12-1 21:27
- regs0->fm_gpio_len = 10
- | (0xf << 4); // Set FMGPIO_B[26:0] enable
- #else
- regs0->fm_gpio_len = 11 // Set FMGPIO_B[26:0] turn on
- | (0xf << 4); // Set FMGPIO_B[26:0] enable
- #endif//HDMI_SMC_CLE
- #elif defined(CARD_SETUP_TYPE_4)
- regs0->sft_cfg7 = regs0->sft_cfg7 & (~0x2); // Set FM 256-PIN package
- regs0->fm_gpio_len = 3 // Set FMGPIO_B[5:0] turn on
- | (0x1 << 4); // Set FMGPIO_B[5:0] enable
- //regs0->gpio_mode_B=0;
- #endif
- Card_gpio_init(); //wthsin, 2004/3/24 04:55pm
- }
- #endif
- #if defined(SUPPORT_CARD_STORAGE)
- void setup_card_storage_interface()
- {
- if(regs0->stamp==1) //Version-B ,wthsin 10/18
- regs0->pcmcia_iorw_wait = 0x2222; // Must be 0x2222 in 8200B, setup and hold time for both ior, iow is 0xf,
- else
- regs0->pcmcia_iorw_wait = 0xffff;
- regs0->wait_cyc1_0 = regs0->wait_cyc1_0 | 0x3f00; // maximum cs timing for R_CS2_B
- regs0->wait_cyc3_2 = regs0->wait_cyc3_2 | 0x003f; // maximum cs timing for R_CS3_B
- }
- #endif
- #if defined(SUPPORT_USB)&&defined(HOST_SL811HS) //wthsin, 2004/1/12 01:36pm
- void setup_usbhost_sl811hs_interface()
- {
- regs0->oe_wait_cyc1_0=regs0->oe_wait_cyc1_0|0x3200;
- regs0->we_wait_cyc1_0=regs0->we_wait_cyc1_0|0x3200;
- regs0->wait_cyc1_0 = regs0->wait_cyc1_0 | 0x1f00; // maximum cs timing for R_CS2_B
- regs0->rom1_base = 0x100; // rom2 n*64k-base ,pcmcia
- regs0->rom2_base = 0x160; // rom2 n*64k-base ,pcmcia
- regs0->rom3_base = 0x200; // rom3 n*64k-base ,pcmcia
- regs0->rom_config = 0x7000; // pcmcia,rom2,3
- }
- #endif
- //
- // setup supporting for extra interfaces
- //
- void
- init_extra_interface() //terry,2004/2/18 10:12AM
- {
- #if defined(SPHE8202_CARD_STORAGE)
- setup_8202_card_storage_interface();
- #elif defined(SUPPORT_CARD_STORAGE)
- setup_card_storage_interface();
- #elif defined(SUPPORT_USB)&&defined(HOST_SL811HS) //wthsin, 2004/1/12 01:36pm
- setup_usbhost_sl811hs_interface();
- #endif
- }
- void dvd_startup(void)//20040316
- {
- #ifdef PULIANG_EJECT_MODE //yaowh add for puliang 04-12-17
- BYTE I2c_Data;
- BYTE I2C_Clear=0;
- #endif
-
- disc_time = 0xefff;//terry 891004
- #ifdef TOP_DOOR_LOADER
- #ifdef SUNPLUS_8202P_DEMOBOARD
- regs0->sft_cfg4 &= ~((0x03)<<2); //Enable GPIO2,3 For COVER & TFT SW
- #endif
- bDoorStatus = GPIO_GET_DOOR_STATUS();
- if (bDoorStatus==DOOR_OPEN) {
- OSD1000ISP_STATUS(OSDISP_OC_OPEN, OSDIR_OPEN);
- PrintOsdMsg(STR_OS_OPEN,REGION1,0,0);
- //SERVO_LDOff();//maybe use it.
- //SERVO_STSledHome();//maybe use it.
- ircmd_trayout();
- play_state=VCD_STATE_OPEN;
- } else {
- ircmd_trayin();
- play_state=VCD_STATE_CLOSE;
- }
- #else
- #ifdef PULIANG_EJECT_MODE //yaowh add 04-12-17
- ReadFromI2c(0xa0,0xfc,&I2c_Data,1);
- if((I2c_Data==0x80))
- {
- call_ir_func(IRC_EJECT);
- WriteToI2c(0xa0,0xfc,&I2C_Clear,1);
- }else
- #endif
- {
- #if !(defined(SPHE1000)||defined(PMP_UI))
- PrintOsdMsg(STR_OS_READ,REGION1,0,0);
- #endif
- play_state=VCD_STATE_CLOSE;
- }
- #endif //#ifdef TOP_DOOR_LOADER
- #ifdef REPEAT_RESET_IOP //zhaoyanhua add 2004-2-13 13:59 //fengjl edit 2004-02-27 15:49
- //only for DSS 555(VFD Driver: NEC 16312)
- //This vfd is very strange! When power switch between on and off
- //more than 20 times, it will not show VFD informaiton again!
- //we found it that the data which IOP send to 16312 is abnormal,
- //so reset IOP here.
- reset_iop();
- reset_ir();
- reset_vfd();
- #endif //ifdef REPEAT_RESET_IOP
- #if defined(CE2746)||defined(NEWCE2746) //yaowh modify 2005-4-5 11:46
- init_ce2746();
- #endif
- #if defined(CE2766)||defined(CE2766_I2S) //han
- init_ce2766();
- #endif
- //
- // CONTROL FLOW
- //
- AVD_ResetMediaStatus();
- ClearCommand();
- no_disk_cnt=DETECT_TIMES;
- #ifdef DVB1000_NON_OS
- system_state=SYSTEM_TS;
- ControlDvbDvdMic(); //Maoyong 2005-1-18 16:33 turn off MIC when DVB state
- #else
- system_state=SYSTEM_OPEN;
- #endif
- //play_state=VCD_STATE_CLOSE;
- sys_cmd=CMD_FUNC|CMD_FUNC_CLOSE;
- // init_audio_dsp_coding_mode();
- power_on=2;
- }
- /*
- ** FUNCTION
- ** main()
- **
- ** DESCRIPTION
- ** main function... what else?
- */
- #ifdef SUPPORT_RECEIVER
- #include "sysmain_receiver.c" //huziqin 2004-3-12
- #endif
- #ifdef SUPPORT_POWER_OFF_CLOCK_FUNC //xyy 2004-10-11 17:18
- #include "clock_func.c"
- #endif
- #ifdef DVB_SETUP
- UINT8 eBuffer[128];
- void SP_SetVolume(UINT8 volume);
- #endif
- #ifdef QSI_SHOW_ERR_RATE
- #include "sysmain2_QSI.c"
- #endif
- #ifdef AUTO_ADJUST_TV_TYPE //lijd 2004-9-15 13:27
- extern BYTE Adjust_TV_type ;
- #endif
- #ifdef SUPPORT_MIDI //xlluo 2004-12-28
- #include "fsmidi.h"
- #ifdef SUPPORT_MIDI_MENU_SEL
- #include "fsmidiui.h"
- #endif
- #endif
- #ifdef QSI_SUPPORT_SLOT_TEST
- extern BYTE SERVO_GetRunInState(void);
- BYTE is_do_slot_test(void)
- {
- if(SERVO_GetRunInState()==PRODUCTION_RUNIN_ST_IS_SLOT_TEST)
- {
- return(1);
- }
- return(0);
- }
- #else
- #define is_do_slot_test() 0
- #endif
- void ap_main(void) // benson update 2004/3/1 04:25