📄 dsp3_if.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. *
**************************************************************************/
/*
* Terry,2004/2/17 11:08AM
* a.modify warning message
*/
//#define USE_MIC_ECHO_PARAM
#include "config.h"
#include "regmap.h"
#include "global.h"
#include "macro.h"
#include "func.h"
#include "util.h"
#include "stdlib.h" //huo 2000.12.14
#include "cdfunc.h"
#include "cfont.h"
#include "sio.h"
#include "vfdfunc.h"
#include "ringbuf.h"
#include "ircmd.h"
#include "ircode.h"
#include "cd.h"
#include "auctrl.h"
#include "user_init.h" //terry,2001/1/9 03:29PM
#include "avd.h"
#include "dvdpe.h"
#include "fs96602.h"
#include "osd.h"
#include "framebuf.h"
#include "cderr.h"
#include "vpp.h"
#include "user_if.h"
#include "dsp3_if.h"
#include "atapi_if.h"
#include "dma.h" //Jeff 20010919
#include "auddrv.h" //2004AUDDRV oliver 20041004 for using audio driver purpose
//#include "audif.h"
#include "setup.h"
#include "fsGUI.h"
#include "tvif.h"
#include "drv.h"
//#include "auddac.h"
#include "iop.h"//2-7-9 9:40
#include "UartTxd.h"
#ifdef TUNER_T988
#include "radio_t988.h" //jinping 2-6-20 14:04
#elif defined(TUNER_MV114)
#include "radio_mv114.h" //jinping 2002-7-1 20:30
#endif
#if defined(PT2322)||defined(PT2320)
#include "audctrl.h"
#endif
#if defined(TAS3001_AMP) //use TI 3001 amplifier jason ych add 2-8-9 10:10
#include "ti3001.h"
#endif
#if defined(TAS5026_AMP) //use TI 3001 amplifier jason ych add 2-8-9 10:10
#include "ti5026.h"
#endif
#ifdef SUPPORT_CDG //Jeff 20020824
#include "cdg.h"
#endif
#ifdef MP3_JPEG_COWORK
#include "fsNav.h"
#endif
#ifndef DVDRELEASE
//#define DSPADUIODBG
#endif
#ifndef DSPADUIODBG
#undef printf
#undef print_block
#define printf(f, a...) do {} while (0)
#define print_block(x,y) do {} while (0)
#endif
extern int check_chipinfo(int n);
/**************************************************************************
* Function Name: is_dts_force_spdif_bitstream
* Purposes:
* Should DTS SPDIF out set to raw data?
* Descriptions:
* Under some situation, SPDIF should output DTS raw bitstream only
* Arguments:
*
* Returns:
* 1 : DTS SPDIF output shuld set to raw data
* 0 : DTS SPDIF output with no restriction
* See also:
*
**************************************************************************/
int is_dts_force_spdif_bitstream()
{
if ((cd_type_loaded==CDDA && cd_subtype==CD_DTS) || (coding_mode_now&AUDIF_CODING_MODE_DTS) )
{
#if defined(NO_DTS_OUTPUT) || defined(FORCE_NO_DTS_OUTPUT)
return 1;
#endif
if (!check_chipinfo(2)) return 1;
}
return 0;
}
extern BYTE wait_dsp_port0_5(int port0,int port5,int val,UINT32 risc_waiting_dsp_tm);
UINT16 oldDSPbarrier=0;
extern BYTE bOutVol; //2004AUDDRV:declaration move to dspkernel.c
//BYTE de_mute;
INT8 audio_key;
INT8 echo_level=4; //range:0~8, 0:off
INT8 echo_decay=4; //range:0~8, 0:off
extern INT8 mic_volume; //2004AUDDRV:declaration move to auddrv.h
#ifndef AC3_BASS_MANAGEMENT
extern BYTE cspk_volume;
extern BYTE fspk_volume;
extern BYTE sspk_volume;
extern int downmix_off;
#endif
#if 0 //2004AUDDRV : move to auddrv.c
#ifdef USE_MIC_ECHO_PARAM
// decay : 0 ~ 127
// delay : 0 ~ 12000
#ifdef ECHO_SPECIAL_PARA
UINT16 echo_para[9][2]={
{0,0},
{76,2976}, // decay : 76/128= 0.6 , delay: 2976/44100=67ms
{79,3648},
{81,4320},
{84,4992},
{87,5664},
{89,6336},
{92,7008},
{94,7680},
};
#elif defined(SUPPORT_MIDI) //Jeff 20040303
UINT16 echo_para[9][2]={
{0,0},
{7,12000},
{15,13000},
{23,12000},
{31,12000},
{39,12000},
{47,12000},
{55,12000},
{63,12000},
};
#else//ECHO_SPECIAL_PARA
UINT16 echo_para[9][2]={
{0,0},
{7,10000},
{15,10000},
{23,10000},
{31,10000},
{39,10000},
{47,10000},
{55,10000},
{63,10000},
};
#endif//ECHO_SPECIAL_PARA
#endif
#endif //2004AUDDRV
//terry,2004/2/11 01:22PM
#ifdef VOL_80
const BYTE VolTab[17+65] = {
#ifdef HIMAGE1251 //fengjl TEST 2004-03-02 14:57
0x00, //0
0x01, 0x02, 0x03, 0x03, 0x04, //01--05
0x06, 0x07, 0x08, 0x08, 0x09, //06--10
0x0b, 0x0c, 0x0d, 0x0d, 0x0e, //11--15
0x10, 0x11, 0x12, 0x12, 0x13, //16--20
0x15, 0x16, 0x17, 0x17, 0x18, //21--25
0x1a, 0x1b, 0x1c, 0x1c, 0x1d, //26--30
0x20, 0x21, 0x22, 0x22, 0x23, //31--25
0x25, 0x26, 0x27, 0x27, 0x28, //35--40
0x2a, 0x2b, 0x2c, 0x2c, 0x2a, //41--45
0x31, 0x33, 0x35, 0x35, 0x36, //46--50
0x39, 0x3a, 0x3b, 0x3b, 0x3c, //51--55
0x3e, 0x3f, 0x40, 0x41, 0x43, //56--60
0x46, 0x48, 0x4a, 0x4b, 0x4c, //61--65
0x4f, 0x50, 0x51, 0x52, 0x54, //66--70
0x58, 0x5a, 0x5d, 0x60, 0x65, //71--75
0x6c, 0x70, 0x74, 0x76, 0x7a, //76--80
0x7f, //81
#else
0x00, //0
0x01, 0x02, 0x03, 0x04, 0x05, //01--05
0x06, 0x07, 0x08, 0x09, 0x0a, //06--10
0x0b, 0x0c, 0x0d, 0x0e, 0x0f, //11--15
0x10, 0x11, 0x12, 0x13, 0x14, //16--20
0x15, 0x16, 0x17, 0x18, 0x19, //21--25
0x1a, 0x1b, 0x1c, 0x1d, 0x1f, //26--30
0x20, 0x21, 0x22, 0x23, 0x24, //31--25
0x25, 0x26, 0x27, 0x28, 0x29, //35--40
0x2a, 0x2b, 0x2c, 0x2d, 0x30, //41--45
0x31, 0x33, 0x35, 0x36, 0x37, //46--50
0x39, 0x3a, 0x3b, 0x3c, 0x3d, //51--55
0x3e, 0x3f, 0x40, 0x42, 0x44, //56--60
0x46, 0x48, 0x4a, 0x4c, 0x4d, //61--65
0x4f, 0x50, 0x51, 0x53, 0x55, //66--70
0x58, 0x5a, 0x5d, 0x62, 0x67, //71--75
0x6c, 0x70, 0x74, 0x78, 0x7f, //76--80
0x7f, //81
#endif
};
#elif defined(VOL_20) //fengjl add 2004-03-08 21:33
const BYTE VolTab[22] = {
0x00, //0
0x01, //1
0x02, //2
0x03, //3
0x04, //4
0x05, //5
0x07, //6
0x0a, //7
0x0d, //8
0x11, //9
0x15, //10
0x19, //11
0x1d, //12
0x22, //13
0x28, //14
0x2f, //15
0x3f, //16
0x4f, //17
0x5f, //18
0x6f, //19
0x7f, //20
0x7f, //21
};
#else
const BYTE VolTab[17] = {
0x00, //0
0x02, //1
0x03, //2
0x04, //3
0x05, //4
0x07, //5
0x09, //6
0x0c, //7
0x11, //8
0x16, //9
0x1e, //10
0x28, //11
0x36, //12
0x47, //13
0x5f, //14
0x7f, //15
0x7f, //16
};
#endif //VOL_80
#ifdef GBM_DVD
const BYTE MICVolTab[9] = {
0x00, //0
0x0f, //1
0x16, //2
0x20, //3
0x36, //4
0x47, //5
0x55,//0x57, //6
0x60,//0x64, //7
0x64,//0x7f, //8
};
#else//GBM_DVD
const BYTE MICVolTab[9] = {
0x00, //0
0x0f, //1
0x16, //2
0x20, //3
0x36, //4
0x47, //5
0x57, //6
0x64, //7
0x7f, //8
};
#endif//GBM_DVD
/**************************************************************************
* Function Name: dsp_watchdog
* Purposes:
* DSP watch dog mechanism
* Descriptions:
* We use DSP watch dog to monitor DSP.
* If DSP behavier abnormally, watch dog will reset DSP.
* Arguments:
*
* Returns:
*
* See also:
*
**************************************************************************/
inline void dsp_watchdog(void)
{
//DSP watchdog
if(dspWatchDog!=DSP_WD_INIT)
{
extern const UINT32 ir_invalid_state[];
int reset_cnt=0;
if(ir_invalid_state[IRC_RESET_DSP]&(0x01<<play_state))
reset_cnt=1;
if(audio_only&&(adv_search_time||video_slow))
reset_cnt=0;
if( (oldDSPbarrier!=AudioGetBarrier())||reset_cnt||(pe_run==0) )//terry 2003-8-6 18:02
{
oldDSPbarrier = AudioGetBarrier();
dspWatchDog = 0;
}
else
{
dspWatchDog++;
if (dspWatchDog > DSPWATCHDOG)
{
dspWatchDog = 0;
AUDIF_Reset_DSP();//2004AUDDRV DSPReset();//reset DSP
printf("reset DSP\n");
}
}
} //DSP watchdog
}
/**************************************************************************
* Function Name: AudioSetEchoPara
* Purposes:
* Set Echo Parameter
* Descriptions:
* Set Echo parameter through AuioIOControl
* Arguments:
* x in : Echo Parameter
* Returns:
* 1 : success
* 0 : fail
* -1 : not support
* See also:
*
**************************************************************************/
#if 0 //2004AUDDRV : move to auddrv.c
#ifdef USE_MIC_ECHO_PARAM
int AudioSetEchoPara(UINT16 x)
{
int res;
res = AudioSetEcho(echo_para[x][0],echo_para[x][1] );
return res;
}
#endif
/**************************************************************************
* Function Name: AudioSetVolume
* Purposes:
* Set Audio Volume
* Descriptions:
* Set Audio Volume through AuioIOControl
* Arguments:
* x in : Audio Volume
* Returns:
* 1 : success
* 0 : fail
* -1 : not support
* See also:
*
**************************************************************************/
//freyman 2002-7-26 21:40
//2002-7-27 11:53
#ifdef SUPPORT_AMP
int AudioSetVolume(UINT16 x)
{
int res;
res = AudioIOControl(VOLUME, x, 0);
return res;
}
#endif
#ifdef NO_AUD_MIC_OFF
int AudioSetVolume(UINT16 x)
{
int res=AudioIOControl(VOLUME, x, 0);
//printf("<x:%x>\n",x);
if(x)
x=mic_volume;
AudioSetMICVol(x);
return res;
}
#endif
#ifdef NO_AUD_ECHO_OFF
int AudioSetVolume(UINT16 x)
{
int res=AudioIOControl(VOLUME, x, 0);
//printf("<x:%x>\n",x);
if(x)
x=echo_level;
AudioSetEcho(x, x);
return res;
}
#endif
#endif //2004AUDDRV
/**************************************************************************
* Function Name: dsp_AD_cmd
* Purposes:
* Set command to A/D gain channel 1 and channel 2
* Descriptions:
*
* Arguments:
* cmd in : 1200 for A/D gain channel 1, 1700 for A/D gain channel 2
* cType : parameter to A/D
* Returns:
*
* See also:
*
**************************************************************************/
void dsp_AD_cmd(UINT16 cmd,UINT16 cType)
{
if(cType!=0)//2002-5-29 for fuss mic
regs0->dsp24_port[1] = 0xffff;
regs0->dsp24_port[0] = cmd | (MICVolTab[cType]);
#ifdef DSPADUIODBG
printf("AD:0x%x ", (VolTab[cType*2]));
#endif
}
/**************************************************************************
* Function Name: dsp3_if_set_vol
* Purposes:
* Set Audio Volume directly (didn't through AudioIOControl)
* Descriptions:
*
* Arguments:
* cType in : Index for VolTab[ ]
* Returns:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -