📄 dsp3_config.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("\n\n --->set audio buffer address a:%x b:%x c:%x\n",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:%x\n",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:%x\n",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 : %x\n", 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 : %x\n", 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -