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

DVD

开发平台:

C/C++

  1. #include "config.h"
  2. #include "regmap.h"
  3. #include "global.h"
  4. #include "macro.h"
  5. #include "dsp3_def.h"
  6. #include "iop.h"
  7. #include "audkernel.h"
  8. // use extern temporary...
  9. // These 2 tables should be define here, but not doing so is for compiling issue.
  10. #ifdef  VOL_80  
  11. extern BYTE  VolTab[17+65];
  12. #elif defined(VOL_20)
  13. extern BYTE  VolTab[22];
  14. #else
  15. extern BYTE  VolTab[17];
  16. #endif
  17. BYTE bOutVol=0xff;
  18. extern BYTE  MICVolTab[9];
  19. extern UINT8 power_on_mute;
  20. extern int check_chipinfo(int n);
  21. extern BYTE wait_dsp_port0_5(int port0,int port5,int val,UINT32 risc_waiting_dsp_tm);
  22. extern int WriteToI2c(int,int,BYTE *,int); // using I2C function in iop.c
  23. /***********************************************************************
  24.  *  Code Session
  25.  ***********************************************************************/
  26. void DSP_ADCmd(UINT16 cmd,UINT16 cType)
  27. {
  28. //2002-5-29 for fuss mic
  29. if(cType!=0) regs0->dsp24_port[1] = 0xffff;
  30.     regs0->dsp24_port[0] = cmd | (MICVolTab[cType]);
  31.     #ifdef AUDKRNL_DBG 
  32.     printf("DSPKRNL : MIC:0x%x  AD:0x%x ", MICVolTab[cType], (VolTab[cType*2])); 
  33.     #endif
  34. }
  35. //  Function Description : Do DSP Audio-IO-Control
  36. //  Parameters :
  37. //    #define VOL0_IS_NO_VOICE
  38. //      mute: cType=0 , port1=0
  39. //      vol0: cType=0 , port1=1
  40. //      BBK vol0: cType=0 , port1=1
  41. void DSP_Set_Vol(UINT8 cType)
  42. {
  43.     printf("cType:%dn",cType);
  44.  
  45.     if (user_mute)  
  46.         regs0->dsp24_port[1] = 0;
  47.   #if defined(NO_DTS_OUTPUT)&&!defined(DIVIDE_AC3_DTS_SPDIF_OUTPUTS)&&!defined(EASTECH_NEW_SETUP_MENU)
  48.     else if(setup_DTSCD_IsSet2SPDIF_PCMAndOff()==1) {
  49.         regs0->dsp24_port[1] = 0;
  50.         cType=0;
  51.     } 
  52.   #endif
  53.     else if(((audio_only==1)&&((adv_search_time<4)&&(adv_search_time>(-4))))||(cType==0)) {
  54.         if((cd_subtype==CD_DTS)&&(adv_search_time))
  55.             regs0->dsp24_port[1]= 0;
  56.         else {
  57.           #ifdef  MP3_CD_FF1_BF1_MUTE//YX822BC//nono 20020822
  58.             //mix YUXING822BC when forward||backwardX2,pressing SELECT,demute will be run.
  59.             if(adv_search_time)
  60.                 regs0->dsp24_port[1] = 0;
  61.             else
  62.           #endif
  63.           #ifdef VOL0_IS_NO_VOICE
  64.             regs0->dsp24_port[1]=0;
  65.           #else
  66.             regs0->dsp24_port[1]=1;
  67.           #endif
  68.         } //else
  69.     } //else if(((audio_onlu
  70.             
  71.    //Jeff 20020530
  72.     if(cType!=0)
  73.         regs0->dsp24_port[1] = 0xffff;   
  74.     if(bOutVol != VolTab[cType]) {
  75.         regs0->dsp24_port[0] = 0x1100 | (VolTab[cType]);
  76.         bOutVol = VolTab[cType];
  77.       #ifdef Ti3001_OSD_UI_1
  78.         amp_setup[ADDR_M_VOL]=audio_volume;
  79.         save_amplifier_setup(ADDR_M_VOL+ADDR_I2C_START,&audio_volume);
  80.       #endif
  81.       #ifdef VOLUME_RECODE
  82.         {  
  83.         int volume;      
  84.         #ifdef CNTR_5SPK_VOLUME
  85.         volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME, (BYTE *)&volume_5SPK[0],1);
  86.         #else
  87.         volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME, (BYTE *)&audio_volume, 1);
  88.         #endif
  89.         }
  90.       #endif
  91.     } else if (bOutVol==0) {
  92.      //there are two types of volume-0: 1.sound-0(0x1100-0x0001), 2.mute(0x1100-0x0000)
  93.      //bOutVol only record 0x1100(not include 0x0001 or 0x0000), so we force to send it
  94.         regs0->dsp24_port[0] = 0x1100;
  95.     }
  96.    
  97.     #ifdef AUDKRNL_DBG 
  98.     printf("Source VOLUME,VolTab[cType]:%d cType:%d bOutVol:%d",VolTab[cType],cType,bOutVol);
  99.     printf("regs0->dsp24_port[1]=%xn", regs0->dsp24_port[1]);
  100.     #endif    
  101. }
  102. //  Function Description : Do DSP Audio-IO-Control
  103. //  Parameters :
  104. //    wCode : Command code
  105. //    cType : sub-command or parameter
  106. //    wParam: optional parameter
  107. //
  108. #ifdef SUPPORT_SOUND_EFFECT
  109. int DSP_AudioIOControl(UINT16 wCode, UINT32 cType, UINT32 wParam)
  110. #else
  111. int DSP_AudioIOControl(UINT16 wCode, BYTE cType, UINT16 wParam)
  112. #endif
  113. {
  114.     int iRes = 0;
  115. #ifdef NO_AUDIO_DSP
  116.     return 1;
  117. #endif    
  118.     
  119.     //these DSP code doesn't support generic audio command
  120.     if (coding_mode_now&(AUDIF_CODING_MODE_NES) ) {
  121.         return 1;
  122.     }
  123. #ifdef SUPPORT_MIDI_MENU_SEL // Jeff 20031104
  124.     if (coding_mode_now&AUDIF_CODING_MODE_MIDI) {
  125.         extern BYTE midiState;   //dtb in 20040109
  126.         if(midiState != 2) //MIDI_STATE_PAYLOAD
  127.             return 1;
  128.     }
  129. #endif
  130.     regs0->dsp24_port[1] = wParam;
  131.     switch (wCode) {
  132. case FLOW:
  133. regs0->dsp24_port[0] = 0x0200 | cType;
  134. switch (cType) {
  135. case AUDIOPLAY:
  136.             #ifdef AUDKRNL_DBG 
  137.             printf("DSPKRNL : set AUDIOPLAY "); 
  138.             #endif
  139. break;
  140. case AUDIOCONTINUE:
  141.             #ifdef AUDKRNL_DBG 
  142.             printf("DSPKRNL : set AUDIOCONTINUE "); 
  143.             #endif
  144. break;
  145. case AUDIOSTOP:
  146.             #ifdef AUDKRNL_DBG 
  147.             printf("DSPKRNL : set AUDIOSTOP "); 
  148.             #endif
  149. break;
  150. case AUDIOPAUSE:
  151.             #ifdef AUDKRNL_DBG 
  152.             printf("DSPKRNL : set AUDIOPAUSE "); 
  153.             #endif
  154. break;
  155. case AUDIOFLUSH:
  156.             #ifdef AUDKRNL_DBG 
  157.             printf("DSPKRNL : set AUDIOFLUSH "); 
  158.             #endif
  159. break;
  160. case AUDIOFF2X:
  161. case AUDIOFF4X:
  162. case AUDIOFF5X:
  163. case AUDIOFF8X:
  164. case AUDIOFF10X:
  165. case AUDIOFF20X:
  166. case AUDIOFF16X:
  167. case AUDIOFF30X:
  168. case AUDIOFF32X:
  169. case AUDIOFF60X:
  170. //to check DSP mode
  171. if (regs0->dsp24_port[5]!=0) {
  172. regs0->dsp24_port[0] = 0x0200 | cType;
  173.                 #ifdef AUDKRNL_DBG
  174. printf("DSPKRNL : set AUDIO FF-%d x ", cType);
  175.                 #endif
  176. }
  177. break;
  178. case AUDIOFF2PLAY:
  179.             #ifdef AUDKRNL_DBG 
  180.             printf("DSPKRNL : set AUDIOFF2PLAY "); 
  181.             #endif
  182. break;
  183. default:
  184. iRes = -1;
  185. break;
  186. } //end of switch (cType)
  187. break;
  188.         case OUTMODE:
  189.             regs0->dsp24_port[0] = 0x0300 | cType;
  190.             #ifdef AUDKRNL_DBG
  191.             printf("DSPKRNL : set OUTMODE:%d %x", cType, regs0->dsp24_port[1]);
  192.             #endif
  193.             break;
  194.         case VOLUME:            
  195.             DSP_Set_Vol(cType);//dsp3_if_set_vol(cType);//terry,2004/2/11 05:40PM
  196.         break;
  197.         case KEY:
  198.             regs0->dsp24_port[0] = 0x0500 | cType;
  199.             #ifdef AUDKRNL_DBG
  200.             printf("DSPKRNL : set KEY:%d ", cType);
  201.             #endif
  202.             break;
  203.         case ECHO:
  204.             regs0->dsp24_port[0] = 0x0600 | cType;
  205.             #ifdef AUDKRNL_DBG
  206.             printf("DSPKRNL : set ECHO:%d ", cType);
  207.             #endif
  208.             break;
  209.         case SURROUND:
  210.             regs0->dsp24_port[0] = 0x0700 | cType;
  211.             #ifdef AUDKRNL_DBG
  212.             printf("DSPKRNL : set SURROUND:%d ", cType);
  213.             #endif
  214.             break;
  215.         case SUBWOOF:
  216.             regs0->dsp24_port[0] = 0x0800 | cType;
  217.             #ifdef AUDKRNL_DBG
  218.             printf("DSPKRNL : set SUBWOOF:%d ", cType);
  219.             #endif
  220.             break;
  221.         #ifdef TEST_BASS_MANAGEMENT 
  222.             #ifdef TEST_BASS_COMMAND
  223.         case BASSMANAGEMENT:        
  224.             regs0->dsp24_port[0] = 0x2000 | cType;                   
  225.             #ifdef AUDKRNL_DBG
  226.             printf("DSPKRNL : set BASS_MANAGEMENT:%xn", wParam);
  227.             #endif
  228.              break;   
  229.             #endif
  230.         #endif    
  231.         case SPDIF:
  232.             if (is_dts_force_spdif_bitstream() && cType==1) 
  233.                 cType=2;
  234.             regs0->dsp24_port[0] = 0x0900 | cType;
  235.             #ifdef AUDKRNL_DBG
  236.             printf("DSPKRNL : set SPDIF:%d ", cType);
  237.             #endif
  238.             break;
  239.         case EQ:
  240.             regs0->dsp24_port[0] = 0x0a00 | cType;
  241.             #ifdef AUDKRNL_DBG
  242.             printf("DSPKRNL : set EQ:%d ", cType);
  243.             #endif
  244.             break;
  245.         case MIC:
  246.             regs0->dsp24_port[0] = 0x0d00 | cType;
  247.             #ifdef AUDKRNL_DBG
  248.             printf("DSPKRNL : set MIC:%d ", cType);
  249.             #endif
  250.             break;
  251.         case AD: // oliver : set AD Gain (MIC) Control, channel 1
  252.          DSP_ADCmd(0x1200,cType);//dsp_AD_cmd(0x1200,cType);
  253.             break;
  254.         case AD_2: // oliver : AD Gain, channel 2  //wangfeng 2003-09-12 17:11
  255.          DSP_ADCmd(0x1700,cType);//dsp_AD_cmd(0x1700,cType);
  256.             break;
  257.         case SPKDELAY:
  258.             regs0->dsp24_port[0] = 0x0c00 | cType;
  259.             #ifdef AUDKRNL_DBG
  260.             printf("DSPKRNL : set SPKDELAY(%d):%d msn", cType, wParam);
  261.             #endif
  262.             break;
  263.         case FSPKGAIN:
  264.             regs0->dsp24_port[0] = 0x1300 | (VolTab[cType*2]);//nono 2003-9-3 11:54 add"*2"
  265.             #ifdef AUDKRNL_DBG
  266.             printf("DSPKRNL : set FSPKGAIN:%dn", cType);
  267.             #endif
  268.             break;
  269.         #if !defined(CNTR_5SPK_VOLUME)
  270.         case CSPKGAIN:
  271.           #ifdef YUXING_DVD
  272.             //wangap add it when CSPKGAIN is 0/1 the volumn is wrong 2003/12/23
  273.             if((cType+2)==257)
  274.                 regs0->dsp24_port[0] = 0x1500 | 0x02;
  275.             else if((cType+2)==256)
  276.                 regs0->dsp24_port[0] = 0x1500 | 0x00;
  277.             else
  278.                 regs0->dsp24_port[0] = 0x1500 | (VolTab[(cType+2)*2]);
  279.           #else
  280.             regs0->dsp24_port[0] = 0x1500 | (VolTab[cType*2]);
  281.           #endif
  282.             #ifdef AUDKRNL_DBG
  283.             printf("DSPKRNL : set CSPKGAIN:%dn", cType);
  284.             #endif
  285.             break;
  286.         #endif
  287.         case SSPKGAIN:
  288.             regs0->dsp24_port[0] = 0x1400 | (VolTab[cType*2]);//nono 2003-9-3 11:54 add"*2"
  289.             #ifdef AUDKRNL_DBG
  290.             printf("DSPKRNL : set SSPKGAIN:%dn", cType);
  291.             #endif
  292.             break;
  293.         #ifdef CNTR_5SPK_VOLUME
  294.         case FLSPKGAIN:
  295.             regs0->dsp24_port[0] = 0x1A00 | (VolTab[cType]);
  296.   #ifdef VOLUME_RECODE
  297. {  
  298.     int volume;      
  299. printf("DSPKRNL : set audio_vol=%dn",audio_volume);
  300. volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+1, (BYTE *)&volume_5SPK[1], 1);
  301.             }
  302.       #endif
  303.      #ifdef AUDKRNL_DBG
  304.             printf("DSPKRNL : set FLSPKGAIN:%dn", cType);
  305.             #endif
  306.             break;
  307.         case FRSPKGAIN:
  308.             regs0->dsp24_port[0] = 0x1B00 | (VolTab[cType]);
  309.       #ifdef VOLUME_RECODE
  310. {  
  311.     int volume;      
  312. printf("DSPKRNL : set audio_vol=%dn",audio_volume);
  313.     volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+2, (BYTE *)&volume_5SPK[2], 1);
  314.             }
  315.       #endif
  316.             #ifdef AUDKRNL_DBG
  317.             printf("DSPKRNL : set FRSPKGAIN:%dn", cType);
  318.             #endif
  319.             break;
  320.         case SLSPKGAIN:
  321.             regs0->dsp24_port[0] = 0x1C00 | (VolTab[cType]);
  322.       #ifdef VOLUME_RECODE
  323. {  
  324.     int volume;      
  325. printf("DSPKRNL : set audio_vol=%dn",audio_volume);
  326.     volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+3, (BYTE *)&volume_5SPK[3], 1);
  327.             }
  328.       #endif
  329.             #ifdef AUDKRNL_DBG
  330.             printf("DSPKRNL : set SLSPKGAIN:%dn", cType);
  331.             #endif
  332.             break;
  333.         case SRSPKGAIN:
  334.             regs0->dsp24_port[0] = 0x1D00 | (VolTab[cType]);
  335.       #ifdef VOLUME_RECODE
  336. {  
  337.     int volume;      
  338. printf("DSPKRNL : set audio_vol=%dn",audio_volume);
  339.     volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+4, (BYTE *)&volume_5SPK[4], 1);
  340. }
  341.       #endif
  342.             #ifdef AUDKRNL_DBG
  343.             printf("DSPKRNL : set SRSPKGAIN:%dn", cType);
  344.             #endif
  345.             break;
  346.         case CSPKGAIN:
  347.             regs0->dsp24_port[0] = 0x1500 | (VolTab[cType]);
  348.       #ifdef VOLUME_RECODE
  349. {  
  350.     int volume;      
  351. printf("DSPKRNL : set audio_vol=%dn",audio_volume);
  352.     volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+5, (BYTE *)&volume_5SPK[5], 1);
  353. }
  354.       #endif
  355.             #ifdef AUDKRNL_DBG
  356.             printf("DSPKRNL : set CSPKGAIN:%dn", cType);
  357.             #endif
  358.             break;
  359.         case SWSPKGAIN: //Jeff 20031028
  360.             regs0->dsp24_port[0] = 0x1E00 | (VolTab[cType]);
  361.           #ifdef VOLUME_RECODE
  362.             {  
  363.                 int volume;      
  364.                 printf("DSPKRNL : set audio_vol=%dn",audio_volume);
  365.     volume=WriteToI2c(I2C_ID_MEMORY, ADDR_I2C_VOLUME+6, (BYTE *)&volume_5SPK[6], 1);
  366.             }
  367.           #endif
  368.             #ifdef AUDKRNL_DBG
  369.             printf("DSPKRNL : set SWSPKGAIN:%dn", cType);
  370.             #endif
  371.             break;
  372.         #endif //#ifdef CNTR_5SPK_VOLUME
  373.         #ifdef SUPPORT_PROLOGIC_II // alan, 2003/7/11 03:28