dsp3_config.c
资源名称:8202s.rar [点击查看]
上传用户:poi891205
上传日期:2013-07-15
资源大小:9745k
文件大小:25k
源码类别:
DVD
开发平台:
C/C++
- /**************************************************************************
- * *
- * Copyright (c) 2002 by Sunplus Technology Co., Ltd. *
- * *
- * This software is copyrighted by and is the property of Sunplus *
- * Technology Co., Ltd. All rights are reserved by Sunplus Technology *
- * Co., Ltd. This software may only be used in accordance with the *
- * corresponding license agreement. Any unauthorized use, duplication, *
- * distribution, or disclosure of this software is expressly forbidden. *
- * *
- * This Copyright notice MUST not be removed or modified without prior *
- * written consent of Sunplus Technology Co., Ltd. *
- * *
- * Sunplus Technology Co., Ltd. reserves the right to modify this *
- * software without notice. *
- * *
- * Sunplus Technology Co., Ltd. *
- * 19, Innovation First Road, Science-Based Industrial Park, *
- * Hsin-Chu, Taiwan, R.O.C. *
- **************************************************************************/
- /*WMA/HDCD:
- * "This product is protected by certain intellectual property rights of
- * Microsoft and cannot be used or further
- * distributed without a license from Microsoft.
- */
- //
- // FILE
- // dsp3_config.c
- //
- //
- // Terry,2004/2/17 04:59PM
- // a.add in write24 function b.add LmRm/DTS 9624 config.
- //
- #include "user_init.h"//nono 2003-10-21 21:04
- #include "config.h"
- #include "regmap.h"
- #include "global.h"
- #include "memmap.h"
- #include "lbc.h"
- #include "NESinit.h"
- #include "gpio.h"
- extern UINT8 power_on_mute;//terry 20030805
- extern UINT32 setupGetSetting(BYTE x);
- extern int setup_IsSet2SPDIF_Bitstream();
- extern void setup_SetFreqMaskConfig(void);
- extern int is_dts_force_spdif_bitstream(void);
- extern int check_chipinfo(int n);
- #include "dsp3rom.h" //Jeff 20010807
- #include "dsp3_if.h"
- #include "auddrv.h" //2004AUDDRV oliver 20041004 for using audio driver purpose
- //#include "audif.h"
- #ifdef MP3_JPEG_COWORK
- #include "fsNav.h"
- #endif
- //
- // DEBUG
- //
- #ifndef DVDRELEASE
- //#define DSP3_DBG 1
- #endif
- #define dsp3_puts(s) ((void)0)
- #define dsp3_printf(s...) ((void)0)
- #ifdef DSP3_DBG
- #include "sio.h"
- #include "emuio.h"
- #undef dsp3_puts
- #undef dsp3_printf
- #define dsp3_puts puts_nw
- #define dsp3_printf printf_w
- //#define MONE_DSP3_LOAD
- //#define MONE_DSP3_ERROR
- //#define DBG_DSP_CMD
- #endif
- #if defined(SPHE1000) && !defined(DVB1000_NON_OS)
- #define MONE_LINUX_TRAP
- #endif
- #ifdef MONE_LINUX_TRAP
- extern BYTE mone_trap;
- #define LOAD_LINUX_TRAP() {if (mone_trap) load_linux_trap();}
- #else
- #define LOAD_LINUX_TRAP()
- #endif
- //
- // DSP buffers
- //
- #define get_dsp3_im_ptr() get_dsp_im_ptr(0,0)
- #define get_dsp3_pm_ptr() get_dsp_pcm_ptr(0,0)
- #define get_dsp3_dm_ptr() get_dsp_aud_ptr(0,0)
- #define AUDIO_BITSTREAM_START 0 // in 24-b word
- //ycwen 2005/1/21 :
- //When mp3_jpeg_cowork, we allocate 48k bytes PM for mp3
- //But must adjust back to 9k bytes when WMA or AC3 decoder is using
- #ifdef MP3_JPEG_COWORK
- #define MP3_AUDIO_BITSTREAM_LEN 16*1024 // in 24-b word
- #define NON_DTS_AUDIO_BITSTREAM_LEN 3*1024 // in 24-b word
- #else
- //Use the common dsp code file "dsp3rom.d16.mp3".
- #define NON_DTS_AUDIO_BITSTREAM_LEN 3*1024 // in 24-b word
- #endif
- #ifdef SDRAM_16Mb_Mode//nono 3-12-2 14:09
- #define DTS_AUDIO_BITSTREAM_LEN 3*1024 // in 24-b word
- #else//SDRAM_16Mb_Mode
- #define DTS_AUDIO_BITSTREAM_LEN 4*1024 // in 24-b word
- #endif//SDRAM_16Mb_Mode
- #define LPCM_AUDIO_BITSTREAM_LEN (5*1024) //terry,2004/3/26 11:14AM
- #define AUDIO_BITSTREAM_LEN NON_DTS_AUDIO_BITSTREAM_LEN
- UINT16 dsp24ya, audya, pcmya;
- UINT8 force_set_cd_md;
- /**************************************************************************
- * Function Name: set_aud_buf
- * Purposes:
- * Set audio buffer address
- * Descriptions:
- * Set start buffer address of IM,PM and DM for DSP
- * Arguments:
- * a in : IM start address
- * b in : PM start address
- * c in : DM start address
- * Returns:
- *
- * See also:
- *
- **************************************************************************/
- void
- set_aud_buf(unsigned a, unsigned b, unsigned c)
- {
- printf("nn --->set audio buffer address a:%x b:%x c:%xn",a,b,c);
- regs0->dsp24ya = dsp24ya = a;
- regs0->audya = audya = b;
- regs0->pcmya = pcmya = c;
- bpcm_ya_ptr = (BYTE *)(SDRAM_BASE_UNCACHED+MEM_PCMYA*1024);//terry,2004/1/14 02:23PM
- }
- /**************************************************************************
- * Function Name: write_24
- * Purposes:
- * write data to DSP PM
- * Descriptions:
- *
- * Arguments:
- * q in/out : Start address for writing data
- * offset in : Offset for writing data
- * x in : Data for writing
- * Returns:
- * Address after writing data
- * See also:
- *
- **************************************************************************/
- //
- // FUNCTION
- // write_24()
- //
- #if 0
- BYTE *write_24(BYTE *q, int offset, UINT32 x)
- {
- #ifdef DBG_DSP_CMD
- printf("q:%x offset:%x x:%xn",q,offset,x);
- #endif
- q += offset*3;
- q[0] = (x>>16) & 0x00ff; // MSB first
- q[1] = (x>> 8) & 0x00ff; //
- q[2] = (x>> 0) & 0x00ff; // LSB last
- return q;
- }
- #else
- void write24(int offset, UINT32 x)
- {
- #ifdef DBG_DSP_CMD
- printf("offset:%x x:%xn",offset,x);
- #endif
- BYTE *q = (BYTE*)get_dsp3_pm_ptr();
- //q = get_dsp3_pm_ptr();
- q += offset*3;
- q[0] = (x>>16) & 0x00ff; // MSB first
- q[1] = (x>> 8) & 0x00ff; //
- q[2] = (x>> 0) & 0x00ff; // LSB last
- }
- #endif
- /**************************************************************************
- * Function Name: set_dsp3_pcm_value
- * Purposes:
- * Write data to DSP PCM buffer
- * Descriptions:
- *
- * Arguments:
- * off in : Offset for writing data
- * value in : Data for writing
- * Returns:
- *
- * See also:
- *
- **************************************************************************/
- //
- // void set_dsp3_pcm_value(unsigned x_off, unsigned value)
- //
- void set_dsp3_pcm_value(unsigned x_off, unsigned value)
- {
- #ifdef MESSAGE_QUEUE
- DSP_AudioIOControl(WRITE2PCM ,x_off,value);
- #else
- BYTE *pcm_ptr=get_dsp_pcm_ptr(x_off*3, 0);
- // dsp3_printf(" set PCM @ %x %x : %xn", x_off, pcm_ptr, value);
- *(pcm_ptr) = (value>>16) & 0xff;
- *(pcm_ptr+1) = (value>>8) & 0xff;
- *(pcm_ptr+2) = (value>>0) & 0xff;
- #endif
- }
- /**************************************************************************
- * Function Name: get_dsp3_pcm_value
- * Purposes:
- * Read data from DSP PCM buffer
- * Descriptions:
- *
- * Arguments:
- * off in : Offset for reading data
- * Returns:
- * Data read
- * See also:
- *
- **************************************************************************/
- #if defined( SUPPORT_REP_READ)||defined (SUPPORT_TESTSPK)
- UINT32 get_dsp3_pcm_value(unsigned x_off)
- {
- UINT32 value;
- BYTE *pcm_ptr=get_dsp_pcm_ptr(x_off*3, 0);
- value = (*pcm_ptr << 16) | (*(pcm_ptr+1) << 8) | *(pcm_ptr+2);
- dsp3_printf(" get PCM @ %x %x : %xn", x_off, pcm_ptr, value);
- return value;
- }
- #endif //#ifdef SUPPORT_REP_READ
- /**************************************************************************
- * Function Name: dsp3_get_rest_buf_size
- * Purposes:
- * Get rest space of audio buffer
- * Descriptions:
- * Distance between Dump pointer and Barrier pointer in bytes.
- * Arguments:
- *
- * Returns:
- * Rest buffer size in bytes.
- * See also:
- *
- **************************************************************************/
- inline int dsp3_get_rest_buf_size()
- {
- int barN = (int)AudioGetBarrier()*3;
- int apb = (int)AudioGetBytePtr();
- int free;
- free = barN - apb;
- if (free <= 0)
- free += abv_size;
- return free;
- }
- /**************************************************************************
- * Function Name: set_aud_buf_size
- * Purposes:
- * Set audio bitstream size
- * Descriptions:
- * Set buffer size to AUDIO_BITSTREAM_LEN*3, *3 because the unit in DSP is WORD (3 bytes)
- * Arguments:
- *
- * Returns:
- *
- * See also:
- *
- **************************************************************************/
- void set_aud_buf_size(void)
- {
- //terry,2002/7/2 05:32PM
- extern UINT32 coding_mode_now;
- //extern BYTE isSPDIFBitstream;
- //BYTE *q;
- //if( (coding_mode_now==AUDIF_CODING_MODE_DTS)&&(isSPDIFBitstream==0) )
- if(coding_mode_now==AUDIF_CODING_MODE_DTS)//terry,2004/3/26 11:13AM
- abv_size = DTS_AUDIO_BITSTREAM_LEN*3;
- #ifdef LPCM_EXTEND_BUF
- else if(coding_mode_now==AUDIF_CODING_MODE_LPCM)
- abv_size = LPCM_AUDIO_BITSTREAM_LEN*3;
- #endif
- #ifdef MP3_JPEG_COWORK
- else if(coding_mode_now==AUDIF_CODING_MODE_MP3) //ycwen 2005/1/21 allocate 48K bytes for mp3 when mp3_jpeg_cowork
- abv_size = MP3_AUDIO_BITSTREAM_LEN*3;
- #endif
- else
- abv_size = AUDIO_BITSTREAM_LEN*3;
- if(coding_mode_now!=AUDIF_CODING_MODE_JPG)
- {
- //q = get_dsp3_pm_ptr();
- write24(1,abv_size/3);
- }
- }
- /**************************************************************************
- * Function Name: reset_audio_buf
- * Purposes:
- * Reset audio buffer size, and set Dump/Barrier pointer to 0
- * Descriptions:
- *
- * Arguments:
- *
- * Returns:
- *
- * See also:
- *
- **************************************************************************/
- //
- // FUNCTION
- // reset_audio_buf
- //
- void
- reset_audio_buf(void)
- {
- #ifdef MP3_JPEG_COWORK//screen the operation when in JPEG side
- if(pFsJpeg->gifsFuncBtn!=FS_FUNC_JPEG)//mark the action of reseting buffer
- #endif
- {
- abv_start = get_dsp3_dm_ptr() + AUDIO_BITSTREAM_START*3;
- set_aud_buf_size();
- AudioSetBytePtr(0);
- AudioSetDumpPointer(0);
- }
- }
- /**************************************************************************
- * Function Name: setup_eq_display
- * Purposes:
- * Turn on or turn off EQ display
- * Descriptions:
- *
- * Arguments:
- * val in : 0 - off, 1 - on
- * Returns:
- *
- * See also:
- *
- **************************************************************************/
- void setup_eq_display(UINT8 val)
- {//terry,2003/9/26 04:42PM
- bEqDisplay = val;
- //wanghaoying add 2003-12-11 9:56
- //Problem: when change sound page or close sound menu, the effect shut off.
- #if 1//!defined(YUXING_SOUND)&&!defined(REMB_3DSOUND)//yanlb add REMB_3DSOUND 2004-07-11 16:00
- AUDIF_Set_EQType(bEqDisplay);//2004AUDDRV AudioSetEQType(bEqDisplay);
- #endif
- }
- /**************************************************************************
- * Function Name: dsp3_config
- * Purposes:
- * Set dsp3 memory space, memory based arguments. (through DM)
- * Descriptions:
- *
- * Arguments:
- *
- * Returns:
- *
- * See also:
- * Documents such as DSPProtocol.doc in /doc
- **************************************************************************/
- //
- // FUNCTION
- // dsp3_config
- //
- // DESCRIPTION
- // setup dsp3 memory space, memory based arguments.
- //
- extern const short DTSrom[];
- #ifdef CHANGE_DSP_SPDIF_OFF//nono 2003-10-21 21:06
- extern BYTE audioNotContinuous;
- #endif
- void dsp3_config(void)
- {
- int i, v;
- //BYTE *q;
- // reset all DSP24 mailbox ports
- //for (i=0;i<16;i++) regs0->dsp24_port[i] = 0; //Jeff 20011029
- // reset risc32 audio buffer pointers
- reset_audio_buf();
- #if !defined(NO_DTS_OUTPUT)||defined(FORCE_NO_DTS_OUTPUT)//nono 4-5-5 13:50
- DTSSetRomLocation((UINT32)DTSrom);
- #endif
- //q = get_dsp3_pm_ptr();
- // clear configs
- for (i=0;i<64;i++) write24(i,0);
- // write configs
- write24(0,AUDIO_BITSTREAM_START);
- write24(1,abv_size/3);
- //write24(2,0);
- // write configs
- write24(3, setupGetSetting(3) ); //Time of Mic auto on after sound detect on
- write24(4, setupGetSetting(4) ); //Time of Mic auto off after sound detect off
- write24(5, setupGetSetting(5) ); //Mic sound detect gain threshold
- write24(6, setupGetSetting(6) ); //Mic switch
- write24(7, setupGetSetting(7) ); //Aduio gain
- write24(8, setupGetSetting(8) ); //MIC gain
- write24(9, setupGetSetting(9) ); //Key shift
- write24(10,setupGetSetting(10)); //Echo delay
- write24(11,setupGetSetting(11)); //Echo gain
- write24(12,setupGetSetting(12)); //3D surround
- write24(13,setupGetSetting(13)); //subwoof
- // 14
- v = setupGetSetting(14);
- #ifdef CHANGE_DSP_SPDIF_OFF
- if( (power_on_mute==0)&&(audioNotContinuous==0) ) {//2003-8-15 20:56 for avoid SPDIF noise when power on.
- #else//#ifdef CHANGE_DSP_SPDIF_OFF
- if(power_on_mute==0) {//2003-8-15 20:56 for avoid SPDIF noise when power on.
- #endif//#ifdef CHANGE_DSP_SPDIF_OFF
- #if !defined(DTS_CD_OUT_RAW_A)&&!defined(NO_DTS_OUTPUT)//NONO 20040117
- if ( (cd_type_loaded==CDDA) && (setup_IsSet2SPDIF_Bitstream()) )
- {
- if (force_set_cd_md==0)
- v = 2;
- else
- v = 1;
- }
- #endif
- if (v==1 && is_dts_force_spdif_bitstream()) v=2;
- write24(14,v); //PCM mode
- }
- write24(15,setupGetSetting(15)); //EQ
- write24(16,setupGetSetting(16)); //SPDIF
- //Jeff 20020521
- write24(17,DACFORMAT); //audio DAC format
- write24(18,DAC_INVERT); //dac polarity
- //DAC output mapping
- write24(19,DACOUTLm);
- write24(20,DACOUTRm);
- write24(21,DACOUT0L);
- write24(22,DACOUT0R);
- write24(23,DACOUT1L);
- write24(24,DACOUT1R);
- write24(25,DACOUT2L);
- write24(26,DACOUT2R);
- // Bass Management
- // 0: Out 1, No Bass Management for 5 full-range spks and subwoofer output
- // 1: Out 2, Configuration 1 for 5 satellites spks
- // 2: Out 3, Simplified Bass Management for multi-channel source products
- // with fixed to L/R
- #ifdef AC3_BASS_MANAGEMENT
- write24(27,setupGetSetting(27)); //Bass Management
- #else
- //write24(27,0);
- #endif
- #if 1//def SPDIF_PLUS_ANALOG
- write24(28,1);
- #else
- //write24(28,0);
- #endif
- if (cd_type_loaded==CDDA) { //Jeff update 20031223
- #ifdef DTS_CD_OUT_RAW_A
- if ( (force_set_cd_md==0) && (cd_subtype==CD_DTS))
- #else
- if ( (force_set_cd_md==0) &&
- ( (setup_IsSet2SPDIF_Bitstream()) || (cd_subtype==CD_DTS) )
- )
- #endif
- {
- UINT32 dtscdbstmidx=0;
- if (smp_rate_now==FS_44K)
- dtscdbstmidx=1;
- else if (smp_rate_now==FS_48K)
- dtscdbstmidx=2;
- else if (smp_rate_now==FS_32K)
- dtscdbstmidx=3;
- write24(29,dtscdbstmidx);
- } //else {
- //write24(29,0);
- //}
- } //else {
- //write24(29,0);
- //}
- /*
- #ifdef USE_FREQ_MASK
- setup_SetFreqMaskConfig();//terry,2003/12/15 11:07AM
- #else
- AUDIF_Set_FrqMsk(FREQ_MASK_DEFAULT);//2004AUDDRV audif_set_frequency_mask(FREQ_MASK_DEFAULT);
- #endif
- */
- //20041222 JSLin // always goest to setup_SetFreqMaskConfig()
- setup_SetFreqMaskConfig();
- //write24(31,0);
- //set_dsp3_pcm_value(32, frequency_multiple);
- write24(32,frequency_multiple);
- write24(33,setupGetSetting(33));
- #ifdef SUPPORT_PROLOGIC_II
- write24(35,setupGetSetting(35));
- #endif
- // ADC config ( default: 0)
- // 0: Select Line_in L/R capability,but only mix right channel
- // 1: Select Mic_Amp capability (only left channel capability)
- // 2: Select Line_in L/R capability,mix left channel
- // 3: Select Line_in L/R capability, Stereo ADC mic function
- //write24(36,0);
- write24(36,ADC_CONFIG_MODE);//nono 20030730
- //CD pcm content under DTSCD and HDCD (default: 0)
- // bit0: 1: If DTSCD is not allowable for customer,do not mute PCM output.
- // 0: mute
- // bit1: 1: Force CD type to do HDCD filter.
- // 0: CD PCM output do not any modify.
- // bit2: 1: HDCD function disable.
- // 0: HDCD function enable.
- //write24(37,0);
- #if defined(PLAY_HDCD_AS_CD)
- write24(37,4); //heqiang add for Ngailik, output with CD format when HDCD is loaded 4-2-23 17:38
- #endif
- //RISC set ADC gain for custumer request (default:2)
- // DSP will range it between 1~5
- #ifdef ENHANCE_MIC_VOL_4 //axel add to enhancing MIC VOL 2003/11/26 11:46am
- write24(38,4);
- #else
- write24(38,2);
- #endif
- write24(39, setupGetSetting(39) ); //Left channel gain , Jeff 20030901
- write24(40, setupGetSetting(40) ); //Right channel gain
- write24(41, setupGetSetting(41) ); //Left surround channel gain
- write24(42, setupGetSetting(42) ); //Right surround channel gain
- write24(43, setupGetSetting(43) ); //Center channel gain
- write24(44, setupGetSetting(44) ); //MIC-2 gain
- write24(46, setupGetSetting(46) ); //Sub-woofer channel gain, Jeff 20031028
- //write24(47, setupGetSetting(46) ); //DTS/DVD-Audio Enable
- #ifdef DTS_94_24_CFG
- write24(48, DTS_94_24_CFG ); //DTS 96/24 function (0: disable, 1:enable, default 0)
- #endif
- #ifdef LmRm_CFG
- write24(49, LmRm_CFG ); //Lm/Rm channel mapping to the same with L/R (0: disable, 1:enable, default 0)
- #endif
- #ifdef SPHE8202//terry,2004/4/9 10:39AM
- write24(50,SPHE8202);
- #endif
- #ifdef SPHE1000 //MIKEY 2004.07.15 for SPDIF
- write24(50,1);
- #endif
- #ifdef SUPPORT_RECEIVER
- write24(52,1); /*for tuner ADC gain,range 1--5*/
- #endif
- #ifdef SUPPORT_TESTSPK // benson 2004/7/2 04:37