dspkernel.c
上传用户:caisangzi8
上传日期:2013-10-25
资源大小:15756k
文件大小:22k
- #include "config.h"
- #include "regmap.h"
- #include "global.h"
- #include "macro.h"
- #include "dsp3_def.h"
- #include "iop.h"
- #include "audkernel.h"
- // use extern temporary...
- // These 2 tables should be define here, but not doing so is for compiling issue.
- #ifdef VOL_80
- extern BYTE VolTab[17+65];
- #elif defined(VOL_20)
- extern BYTE VolTab[22];
- #else
- extern BYTE VolTab[17];
- #endif
- BYTE bOutVol=0xff;
- extern BYTE MICVolTab[9];
- extern UINT8 power_on_mute;
- extern int check_chipinfo(int n);
- extern BYTE wait_dsp_port0_5(int port0,int port5,int val,UINT32 risc_waiting_dsp_tm);
- extern int WriteToI2c(int,int,BYTE *,int); // using I2C function in iop.c
- /***********************************************************************
- * Code Session
- ***********************************************************************/
- void DSP_ADCmd(UINT16 cmd,UINT16 cType)
- {
- //2002-5-29 for fuss mic
- if(cType!=0) regs0->dsp24_port[1] = 0xffff;
- regs0->dsp24_port[0] = cmd | (MICVolTab[cType]);
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : MIC:0x%x AD:0x%x ", MICVolTab[cType], (VolTab[cType*2]));
- #endif
- }
- // Function Description : Do DSP Audio-IO-Control
- // Parameters :
- // #define VOL0_IS_NO_VOICE
- // mute: cType=0 , port1=0
- // vol0: cType=0 , port1=1
- // BBK vol0: cType=0 , port1=1
- void DSP_Set_Vol(UINT8 cType)
- {
- printf("cType:%dn",cType);
-
- if (user_mute)
- regs0->dsp24_port[1] = 0;
- #if defined(NO_DTS_OUTPUT)&&!defined(DIVIDE_AC3_DTS_SPDIF_OUTPUTS)&&!defined(EASTECH_NEW_SETUP_MENU)
- else if(setup_DTSCD_IsSet2SPDIF_PCMAndOff()==1) {
- regs0->dsp24_port[1] = 0;
- cType=0;
- }
- #endif
- else if(((audio_only==1)&&((adv_search_time<4)&&(adv_search_time>(-4))))||(cType==0)) {
- if((cd_subtype==CD_DTS)&&(adv_search_time))
- regs0->dsp24_port[1]= 0;
- else {
- #ifdef MP3_CD_FF1_BF1_MUTE//YX822BC//nono 20020822
- //mix YUXING822BC when forward||backwardX2,pressing SELECT,demute will be run.
- if(adv_search_time)
- regs0->dsp24_port[1] = 0;
- else
- #endif
- #ifdef VOL0_IS_NO_VOICE
- regs0->dsp24_port[1]=0;
- #else
- regs0->dsp24_port[1]=1;
- #endif
- } //else
- } //else if(((audio_onlu
-
- //Jeff 20020530
- if(cType!=0)
- regs0->dsp24_port[1] = 0xffff;
-
- if(bOutVol != VolTab[cType]) {
- regs0->dsp24_port[0] = 0x1100 | (VolTab[cType]);
- bOutVol = VolTab[cType];
- #ifdef Ti3001_OSD_UI_1
- amp_setup[ADDR_M_VOL]=audio_volume;
- save_amplifier_setup(ADDR_M_VOL+ADDR_I2C_START,&audio_volume);
- #endif
- #ifdef VOLUME_RECODE
- {
- int volume;
- #ifdef CNTR_5SPK_VOLUME
- volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME, (BYTE *)&volume_5SPK[0],1);
- #else
- volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME, (BYTE *)&audio_volume, 1);
- #endif
- }
- #endif
- } else if (bOutVol==0) {
- //there are two types of volume-0: 1.sound-0(0x1100-0x0001), 2.mute(0x1100-0x0000)
- //bOutVol only record 0x1100(not include 0x0001 or 0x0000), so we force to send it
- regs0->dsp24_port[0] = 0x1100;
- }
-
- #ifdef AUDKRNL_DBG
- printf("Source VOLUME,VolTab[cType]:%d cType:%d bOutVol:%d",VolTab[cType],cType,bOutVol);
- printf("regs0->dsp24_port[1]=%xn", regs0->dsp24_port[1]);
- #endif
- }
- // Function Description : Do DSP Audio-IO-Control
- // Parameters :
- // wCode : Command code
- // cType : sub-command or parameter
- // wParam: optional parameter
- //
- #ifdef SUPPORT_SOUND_EFFECT
- int DSP_AudioIOControl(UINT16 wCode, UINT32 cType, UINT32 wParam)
- #else
- int DSP_AudioIOControl(UINT16 wCode, BYTE cType, UINT16 wParam)
- #endif
- {
- int iRes = 0;
- #ifdef NO_AUDIO_DSP
- return 1;
- #endif
-
- //these DSP code doesn't support generic audio command
- if (coding_mode_now&(AUDIF_CODING_MODE_NES) ) {
- return 1;
- }
- #ifdef SUPPORT_MIDI_MENU_SEL // Jeff 20031104
- if (coding_mode_now&AUDIF_CODING_MODE_MIDI) {
- extern BYTE midiState; //dtb in 20040109
- if(midiState != 2) //MIDI_STATE_PAYLOAD
- return 1;
- }
- #endif
-
- regs0->dsp24_port[1] = wParam;
-
- switch (wCode) {
- case FLOW:
- regs0->dsp24_port[0] = 0x0200 | cType;
-
- switch (cType) {
- case AUDIOPLAY:
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set AUDIOPLAY ");
- #endif
- break;
- case AUDIOCONTINUE:
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set AUDIOCONTINUE ");
- #endif
- break;
- case AUDIOSTOP:
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set AUDIOSTOP ");
- #endif
- break;
- case AUDIOPAUSE:
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set AUDIOPAUSE ");
- #endif
- break;
- case AUDIOFLUSH:
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set AUDIOFLUSH ");
- #endif
- break;
- case AUDIOFF2X:
- case AUDIOFF4X:
- case AUDIOFF5X:
- case AUDIOFF8X:
- case AUDIOFF10X:
- case AUDIOFF20X:
- case AUDIOFF16X:
- case AUDIOFF30X:
- case AUDIOFF32X:
- case AUDIOFF60X:
- //to check DSP mode
- if (regs0->dsp24_port[5]!=0) {
- regs0->dsp24_port[0] = 0x0200 | cType;
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set AUDIO FF-%d x ", cType);
- #endif
- }
- break;
-
- case AUDIOFF2PLAY:
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set AUDIOFF2PLAY ");
- #endif
- break;
-
- default:
- iRes = -1;
- break;
- } //end of switch (cType)
-
- break;
- case OUTMODE:
- regs0->dsp24_port[0] = 0x0300 | cType;
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set OUTMODE:%d %x", cType, regs0->dsp24_port[1]);
- #endif
- break;
- case VOLUME:
- DSP_Set_Vol(cType);//dsp3_if_set_vol(cType);//terry,2004/2/11 05:40PM
- break;
- case KEY:
- regs0->dsp24_port[0] = 0x0500 | cType;
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set KEY:%d ", cType);
- #endif
- break;
- case ECHO:
- regs0->dsp24_port[0] = 0x0600 | cType;
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set ECHO:%d ", cType);
- #endif
- break;
- case SURROUND:
- regs0->dsp24_port[0] = 0x0700 | cType;
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set SURROUND:%d ", cType);
- #endif
- break;
- case SUBWOOF:
- regs0->dsp24_port[0] = 0x0800 | cType;
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set SUBWOOF:%d ", cType);
- #endif
- break;
- #ifdef TEST_BASS_MANAGEMENT
- #ifdef TEST_BASS_COMMAND
- case BASSMANAGEMENT:
- regs0->dsp24_port[0] = 0x2000 | cType;
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set BASS_MANAGEMENT:%xn", wParam);
- #endif
- break;
- #endif
- #endif
- case SPDIF:
- if (is_dts_force_spdif_bitstream() && cType==1)
- cType=2;
- regs0->dsp24_port[0] = 0x0900 | cType;
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set SPDIF:%d ", cType);
- #endif
- break;
- case EQ:
- regs0->dsp24_port[0] = 0x0a00 | cType;
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set EQ:%d ", cType);
- #endif
- break;
- case MIC:
- regs0->dsp24_port[0] = 0x0d00 | cType;
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set MIC:%d ", cType);
- #endif
- break;
- case AD: // oliver : set AD Gain (MIC) Control, channel 1
- DSP_ADCmd(0x1200,cType);//dsp_AD_cmd(0x1200,cType);
- break;
- case AD_2: // oliver : AD Gain, channel 2 //wangfeng 2003-09-12 17:11
- DSP_ADCmd(0x1700,cType);//dsp_AD_cmd(0x1700,cType);
- break;
- case SPKDELAY:
- regs0->dsp24_port[0] = 0x0c00 | cType;
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set SPKDELAY(%d):%d msn", cType, wParam);
- #endif
- break;
- case FSPKGAIN:
- regs0->dsp24_port[0] = 0x1300 | (VolTab[cType*2]);//nono 2003-9-3 11:54 add"*2"
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set FSPKGAIN:%dn", cType);
- #endif
- break;
- #if !defined(CNTR_5SPK_VOLUME)
- case CSPKGAIN:
- #ifdef YUXING_DVD
- //wangap add it when CSPKGAIN is 0/1 the volumn is wrong 2003/12/23
- if((cType+2)==257)
- regs0->dsp24_port[0] = 0x1500 | 0x02;
- else if((cType+2)==256)
- regs0->dsp24_port[0] = 0x1500 | 0x00;
- else
- regs0->dsp24_port[0] = 0x1500 | (VolTab[(cType+2)*2]);
- #else
- regs0->dsp24_port[0] = 0x1500 | (VolTab[cType*2]);
- #endif
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set CSPKGAIN:%dn", cType);
- #endif
- break;
- #endif
- case SSPKGAIN:
- regs0->dsp24_port[0] = 0x1400 | (VolTab[cType*2]);//nono 2003-9-3 11:54 add"*2"
-
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set SSPKGAIN:%dn", cType);
- #endif
- break;
- #ifdef CNTR_5SPK_VOLUME
- case FLSPKGAIN:
- regs0->dsp24_port[0] = 0x1A00 | (VolTab[cType]);
- #ifdef VOLUME_RECODE
- {
- int volume;
- printf("DSPKRNL : set audio_vol=%dn",audio_volume);
- volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+1, (BYTE *)&volume_5SPK[1], 1);
- }
- #endif
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set FLSPKGAIN:%dn", cType);
- #endif
- break;
- case FRSPKGAIN:
- regs0->dsp24_port[0] = 0x1B00 | (VolTab[cType]);
- #ifdef VOLUME_RECODE
- {
- int volume;
- printf("DSPKRNL : set audio_vol=%dn",audio_volume);
- volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+2, (BYTE *)&volume_5SPK[2], 1);
- }
- #endif
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set FRSPKGAIN:%dn", cType);
- #endif
- break;
- case SLSPKGAIN:
- regs0->dsp24_port[0] = 0x1C00 | (VolTab[cType]);
- #ifdef VOLUME_RECODE
- {
- int volume;
- printf("DSPKRNL : set audio_vol=%dn",audio_volume);
- volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+3, (BYTE *)&volume_5SPK[3], 1);
- }
- #endif
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set SLSPKGAIN:%dn", cType);
- #endif
- break;
- case SRSPKGAIN:
- regs0->dsp24_port[0] = 0x1D00 | (VolTab[cType]);
- #ifdef VOLUME_RECODE
- {
- int volume;
- printf("DSPKRNL : set audio_vol=%dn",audio_volume);
- volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+4, (BYTE *)&volume_5SPK[4], 1);
- }
- #endif
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set SRSPKGAIN:%dn", cType);
- #endif
- break;
- case CSPKGAIN:
- regs0->dsp24_port[0] = 0x1500 | (VolTab[cType]);
- #ifdef VOLUME_RECODE
- {
- int volume;
- printf("DSPKRNL : set audio_vol=%dn",audio_volume);
- volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+5, (BYTE *)&volume_5SPK[5], 1);
- }
- #endif
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set CSPKGAIN:%dn", cType);
- #endif
- break;
- case SWSPKGAIN: //Jeff 20031028
- regs0->dsp24_port[0] = 0x1E00 | (VolTab[cType]);
- #ifdef VOLUME_RECODE
- {
- int volume;
- printf("DSPKRNL : set audio_vol=%dn",audio_volume);
- volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+6, (BYTE *)&volume_5SPK[6], 1);
- }
- #endif
- #ifdef AUDKRNL_DBG
- printf("DSPKRNL : set SWSPKGAIN:%dn", cType);
- #endif
- break;
- #endif //#ifdef CNTR_5SPK_VOLUME
- #ifdef SUPPORT_PROLOGIC_II // alan, 2003/7/11 03:28