sysmain_receiver.c
上传用户:caisangzi8
上传日期:2013-10-25
资源大小:15756k
文件大小:12k
- #if defined (SUPPORT_APOGEE_AMP)||defined(SUPPORT_TUNER_MV114)||defined(SUPPORT_TUNER_ALPS)||defined(SUPPORT_RECEIVER)
- #ifdef SUPPORT_COAXIAL_IN //xyy 2004-4-29 for XQ
- BYTE bCoaxialIn;
- #endif
- /*
- huziqin 2004-2-26
- call by tuner application and power amp's
- */
- UINT16 check_sum(BYTE *data,BYTE len)
- {
- UINT16 sum = 0;
- //printf("len %dn",len);
- while(len>0)
- {
- sum += *data;
- len --;
- data ++;
- };
- //printf("sum %xn",sum);
- return sum;
- }
- /*======================================================
- switch audio and video by gpio
- video: lower 4 bits
- 0--DVD
- 1--Video 1 in
- 2--Video 2 in
- Audio: upper 4 bits
- 0--MIC
- 1--AUDIO 1 in
- 2--AUDIO 2 in
- 3--TUNER in
- =======================================================*/
- //extern void set_downmix_off();//UINT8 setup_sel[MAX_SETUP_PAGE + MAX_CUSTM_SETUP_PAGE][MAX_PAGE_ITEM];
- /*
- When use av input function, the sft_cfg(part of GPIO setting) setting is done in this function.
- */
- void set_av_in_sft_cfg(void)//xyy 2004-3-23
- {
- #if defined(SUNPLUS_RECEIVER_DVD)
- regs0->sft_cfg6 &= ~(0x1 << 5);
- #elif defined(XINGQIU_DVD_RECEIVER)
- //
- #endif
- }
- void av_in_switch(BYTE mode)
- {
- printf("av_in_switchn");
- #if 0
- set_av_in_sft_cfg();//xyy 2004-3-23
- GPIO_M_SET(AUIN_SL0, 1); //xulf modified at 2004-2-20
- GPIO_M_SET(AUIN_SL1, 1);
- GPIO_M_SET(VIDEO_SL0, 1);
- GPIO_M_SET(VIDEO_SL1, 1);
- GPIO_E_SET(AUIN_SL0, 1);
- GPIO_E_SET(AUIN_SL1, 1);
- GPIO_E_SET(VIDEO_SL0, 1);
- GPIO_E_SET(VIDEO_SL1, 1);
- //AudioSetEcho(0,0);
- //echo_level = 0;
- //setup_SetEcho();
- //AudioSetMIC(1, 0); //Set MIC always on, 1:always on, (the second parameter:unsed now)
- //AudioSetMIC(1,1);
- //AudioSetMICVol(8);
- //AudioSetMICVol_2(8);
- //downmix off
- //set_downmix_off();
- //AudioSetOutputMode(6, 0); //Set Output mode(4:AC3 5.1 channel)
- //run_save_sel_cmd(3, 0);
- //Audio ======================================
- if((mode>>4) == 0)
- {
- printf("mic inputn");
- GPIO_O_SET(AUIN_SL1, 0);
- GPIO_O_SET(AUIN_SL0, 0);
- }
- if((mode>>4) == 1)
- {
- printf("audio 1 inputn");
- GPIO_O_SET(AUIN_SL1, 0);
- GPIO_O_SET(AUIN_SL0, 1);
- }
- if((mode>>4) == 2)
- {
- printf("audio 2 inputn");
- GPIO_O_SET(AUIN_SL1, 1);
- GPIO_O_SET(AUIN_SL0, 0);
- }
- if((mode>>4) == 3)
- {
- printf("tuner inputn");
- GPIO_O_SET(AUIN_SL1, 1);
- GPIO_O_SET(AUIN_SL0, 1);
- }
- //Video ======================================
- if((mode&0x0f) == 0)
- {
- printf("out_0n");
- GPIO_O_SET(VIDEO_SL1, 0);
- GPIO_O_SET(VIDEO_SL0, 0);
- }
- if((mode&0x0f) == 1)
- {
- printf("out_1n");
- GPIO_O_SET(VIDEO_SL1, 1);
- GPIO_O_SET(VIDEO_SL0, 0);
- }
- if((mode&0x0f) == 2)
- {
- printf("out_2n");
- GPIO_O_SET(VIDEO_SL1, 0);
- GPIO_O_SET(VIDEO_SL0, 1);
- }
- #endif
- }
- #ifdef DOLBY_AMP_VOLUME_CTRL
- extern void init_subvol();
- #endif
- void receiver_startup()
- {
- next_rcvr_mode =RECEIVER_MODE_DVD; // this is changeable
-
- // Simon 12-4-2003
- // Calculate support bits
- rcvr_support_bits = 0;
- #ifdef SUPPORT_DVD_PLAYER
- rcvr_support_bits += (1 << RECEIVER_MODE_DVD);
- #endif
- #ifdef SUPPORT_AV_IN
- rcvr_support_bits += (1 << RECEIVER_MODE_AV1);
- #endif
- #ifdef SUPPORT_SECOND_AV_IN
- rcvr_support_bits += (1 << RECEIVER_MODE_AV2);
- #endif
- #ifdef SUPPORT_SPDIF_IN
- rcvr_support_bits += (1 << RECEIVER_MODE_SPDIF);
- #endif
- #ifdef SUPPORT_COAXIAL_IN //xyy 2004-4-29 for XQ
- rcvr_support_bits += (1 << RECEIVER_MODE_COAXIAL);
- #endif
- #ifdef SUPPORT_TUNER_MV114
- rcvr_support_bits += (1 << RECEIVER_MODE_TUNER);
- #endif
- #ifdef SUPPORT_DUMMY_MODE
- rcvr_support_bits += (1 << RECEIVER_MODE_DUMMY);
- #endif
-
- if (next_rcvr_mode == RECEIVER_MODE_DVD)
- {
- // original code moved to dvd_startup()
- // The code is right before ap_main()
- dvd_startup();
- switch_modes_now = 0;
- servo_inited = 1;
- av_in_switch(0);
- //psprintf(RegionValStr[REGION2], "DVD");
- //PrintOsdMsg(STR_OS_SPACE, REGION2, 0, 1);
- }
- else // Start in a non-DVD mode
- {
- // In the future, we will enter this first,
- // as soon as I figure out how to manage the states and loader
- // correctly.
- // 12-16-2003 Update: DVD works w/o starting in DVD
- #if DISC_SYSTEM==DISC_SYSTEM_ATAPI
- servo_inited = 1;
- #endif
- switch_modes_now = 1;
- system_state = SYSTEM_MODE_CHANGE;
- }
- #ifdef DOLBY_AMP_VOLUME_CTRL
- init_subvol();
- #endif
- }
- void show_noise_channel(ch)
- {
- switch(ch)
- {
- case 0:
- psprintf(RegionValStr[REGION2], "TEST FL");
- break;
- case 1:
- psprintf(RegionValStr[REGION2], "TEST CE");
- break;
- case 2:
- psprintf(RegionValStr[REGION2], "TEST FR");
- break;
- case 3:
- psprintf(RegionValStr[REGION2], "TEST SR");
- break;
- case 4:
- psprintf(RegionValStr[REGION2], "TEST SL");
- break;
- default:
- break;
-
- }
-
- PrintOsdMsg(STR_OS_SPACE, REGION2, 0, 1);
- }
- void do_noise_sequencer(void)
- {
- BYTE ch = 0;
- AUDIF_Reset_DSP();//2004AUDDRV DSPReset();
- //init_audio_dsp_coding_mode();
- AUDIF_Init_DSPCodingMode();
- AUDIF_Set_SampleRate(FS_44K);//2004AUDDRV audif_set_sample_rate(FS_44K);
- AUDIF_Set_CodingMode(AUDIF_CODING_MODE_NOISE);//2004AUDDRV audif_set_coding_mode(AUDIF_CODING_MODE_NOISE);
- GPIO_DEMUTE();
- watchdog_onoff(0);
- system_state = SYSTEM_DOING_NOISE;
- while (system_state == SYSTEM_DOING_NOISE)
- {
- ch = get_dsp3_pcm_value(22);
- show_noise_channel(ch);
-
- polling();
- }
-
- }
- #ifdef TP6311_DRIVER_VFD
- extern UINT16 vfd_set_av1(UINT16 index);
- extern UINT16 vfd_set_av2(UINT16 index);
- extern UINT16 vfd_set_spdifin(UINT16 index);
- #endif
- extern void stop_loader(void);
- #include "hc4094.c"
- #include "hc165.c"
- #include "rom_bus_io.h"
- #define STOP_SERVO_IN_OTHER_MODE //huziqin 2004-4-27
- #ifdef STOP_SERVO_IN_OTHER_MODE
- void wait_servo_stop(void)
- {
- //drv_init();
- delay_srv_10ms(100);
- //system_stop();
- stop_loader();
- delay_srv_10ms(5);
- }
- #endif
- void receiver_check_system_state()
- {
- int init_cnt=0;
- switch(system_state)
- {
- case SYSTEM_MODE_CHANGE:
- switch_modes_now = 0;
- ClearOsdMsg(0);
- current_rcvr_mode = next_rcvr_mode;
- #ifdef SUPPORT_COAXIAL_IN //xyy 2004-4-29 for XQ
- if(current_rcvr_mode == RECEIVER_MODE_SPDIF)
- {
- bCoaxialIn = 0;
- GPIO_O_SET(OPT_COAX_SEL,0);
- }
- else if(current_rcvr_mode == RECEIVER_MODE_COAXIAL)
- {
- bCoaxialIn = 1;
- GPIO_O_SET(OPT_COAX_SEL,1);
- }
- #endif
-
-
- switch (current_rcvr_mode)
- {
- case RECEIVER_MODE_DVD:
- #ifdef HC4094
- hc4094_set_io(HC4094_DVD_MODE); // wzj 2004-7-13
- #endif
- #ifdef ROM_BUS_EXTENT_IO
- audio_sel_gnd();
- #endif //ROM_BUS_EXTENT_IO
- if (!servo_inited)
- {
- drv_init();
- servo_inited = 1;
- }
- else
- {
- close_tray(0);
- }
- dvd_startup();
-
- break;
- case RECEIVER_MODE_AV1:
- AUDIF_Reset_DSP();//2004AUDDRV DSPReset();
- //init_audio_dsp_coding_mode();
- AUDIF_Init_DSPCodingMode();
- AUDIF_Set_SampleRate(FS_44K);//2004AUDDRV audif_set_sample_rate(FS_44K);
- AUDIF_Set_CodingMode(AUDIF_CODING_MODE_TUNER);//2004AUDDRV audif_set_coding_mode(AUDIF_CODING_MODE_TUNER);
- #ifdef HC4094
- hc4094_set_io(HC4094_AV1_MODE);
- #endif
- #ifdef ROM_BUS_EXTENT_IO
- audio_sel_aux();
- #endif //ROM_BUS_EXTENT_IO
- //av_in_switch(0x11);
- GPIO_DEMUTE();
- AUDIF_Set_Echo(0,0);//2004AUDDRV AudioSetEcho(0,0); //huziqin 2004-2-26
- #ifdef TP6311_DRIVER_VFD
- vfd_set_av1(0);
- #endif
- #ifdef STOP_SERVO_IN_OTHER_MODE
-
- wait_servo_stop();
- psprintf(RegionValStr[REGION2], "AV1");
- PrintOsdMsg(STR_OS_SPACE, REGION2, 0, 1);
- #endif
-
- system_state = SYSTEM_DOING_AV1;
- while (system_state == SYSTEM_DOING_AV1)
- {
- polling();
- }
- break;
- case RECEIVER_MODE_AV2:
- do_noise_sequencer();
-
- break;
- #ifdef SUPPORT_SPDIF_IN
- case RECEIVER_MODE_SPDIF:
- #ifdef SUPPORT_COAXIAL_IN //xyy 2004-4-29 for XQ
- case RECEIVER_MODE_COAXIAL:
- #endif
-
-
- #ifdef SUPPORT_COAXIAL_IN //xyy 2004-4-29 for XQ
- vfd_set_spdifin(bCoaxialIn);
- #else
- //vfd_set_spdifin(0);
- #endif
- GPIO_DEMUTE();
- //av_in_switch(0x02);
-
- AUDIF_Reset_DSP();//2004AUDDRV DSPReset();
- //init_audio_dsp_coding_mode();
- AUDIF_Init_DSPCodingMode();
- AUDIF_Set_SampleRate(FS_44K);//2004AUDDRV audif_set_sample_rate(FS_44K);
- AUDIF_Set_CodingMode(AUDIF_CODING_MODE_SPDIFINCD);//2004AUDDRV audif_set_coding_mode(AUDIF_CODING_MODE_SPDIFINCD);
-
-
- spdif_in_init();
- #ifdef TP6311_DRIVER_VFD
- vfd_set_spdifin(0);
- #endif
- system_state = SYSTEM_DOING_SPDIF;
- while (system_state == SYSTEM_DOING_SPDIF)
- {
- delay_1ms(1);
- polling();
- if(!(full_scrn & SOUND))
- spdif_in_init();
- }
-
- break;
- #endif // SUPPORT_SPDIF_IN
- case RECEIVER_MODE_TUNER:
- #ifdef HC4094
- hc4094_set_io(HC4094_TUNER_MODE);
- #endif
- GPIO_DEMUTE();
- #ifdef SUPPORT_TUNER_MV114 //xyy 2003-10-10 13:30
- ShowTitle();
- AUDIF_Reset_DSP();//2004AUDDRV DSPReset();
- //init_audio_dsp_coding_mode();
- AUDIF_Init_DSPCodingMode();
- AUDIF_Set_SampleRate(FS_44K);//2004AUDDRV audif_set_sample_rate(FS_44K);
- AUDIF_Set_CodingMode(AUDIF_CODING_MODE_TUNER);//2004AUDDRV audif_set_coding_mode(AUDIF_CODING_MODE_TUNER);
- system_state = SYSTEM_DOING_TUNER;
-
- watchdog_onoff(0); //close watchdog for tuner auto search no reset hongfeng 2005-01-21
- tuner_main();
- #endif
- #ifdef ROM_BUS_EXTENT_IO
- tuner_power_set(0);
- #endif //ROM_BUS_EXTENT_IO
- break;
- }
- break;
- // Simon: 1-7-2004
- // This state occurs when we use eject
- // To switch back to DVD mode
- case SYSTEM_EJECT_CHANGE:
- next_rcvr_mode = RECEIVER_MODE_DVD;
- current_rcvr_mode = next_rcvr_mode;
- switch_modes_now = 0;
- ircmd_trayout();
- system_state = SYSTEM_OPEN;
- psprintf(RegionValStr[REGION2], "DVD");
- PrintOsdMsg(STR_OS_SPACE, REGION2, 0, 1);
- break;
- }
- }
- #endif