app_dac.h 3.5 KB
#ifndef _APP_DAC_H_
#define _APP_DAC_H_


//#include "app_dec.h"
#include "fifo.h"


#define DOLBY_AC3_OUT_SAMPLE_PER_CH    256


#define MAX_DAC_BUFS    2


#define MP3_DEC_FRAME_SIZE      1152
#define MP3_ENC_FRAME_SAMPLE    1152


#if 0//def DOLBY_AC3_DEC

#ifdef DD_AC3_DEC_16BIT_OUT
//#define AUDIO_OUT_BUF_SIZE    (256*1*2/2) //1 data's lines, 1*2 channels
//#define AUDIO_OUT_BUF_SIZE    (256*3*2/2) //3 data's lines, 3*2 channels
#define AUDIO_OUT_BUF_SIZE    (DOLBY_AC3_OUT_SAMPLE_PER_CH*3*2/2) //3 data's lines, 3*2 channels
#else
//#define AUDIO_OUT_BUF_SIZE    (256*1*2*1) //1 data's lines, 1*2 channels
//#define AUDIO_OUT_BUF_SIZE    (256*3*2*3) //3 data's lines, 3*2 channels
#define AUDIO_OUT_BUF_SIZE    (DOLBY_AC3_OUT_SAMPLE_PER_CH*3*2) //3 data's lines, 3*2 channels
#endif

#else

#ifdef MP3_ENCODE_ENABLE
#ifdef AUDIO_OUT_BUF_IS_HALF_OF_MP3_ENC_FRAME_SAMPLE
#define AUDIO_OUT_BUF_SIZE    (MP3_DEC_FRAME_SIZE*1)
#else
#define AUDIO_OUT_BUF_SIZE    (MP3_DEC_FRAME_SIZE*2)
#endif
#else
//#define AUDIO_OUT_BUF_SIZE    (640*2) //for calling
#define AUDIO_OUT_BUF_SIZE    (1152)
#endif //MP3_ENCODE_ENABLE

#endif //DOLBY_AC3_DEC


#define MIN_DAC_DMA_Phase_2_SIZE       192  //byte
#define MIN_DAC_DMA_RESERVED_SIZE      1024 //byte

#if 1
#define SPDIF_FRAME_SIZE               (192*4) //a block has 192 audio samples ((8/2) * 192 bytes)
#else
#define SPDIF_FRAME_SIZE               (480*2)//(192*4*2) //a block has 192 audio samples ((8/2) * 192 bytes)
#endif

#define PCM_BLOCK                      (192*2)


#define EX_AUDIO_STREAM_THRESHOLD      (SPDIF_FRAME_SIZE*4)   //4 spdif frames

#ifdef USB_HOST_AUDIO_ENABLE
//#define MIC_FIFO_BUF_SIZE   (1024*2)
#define MIC_FIFO_BUF_SIZE   (1024*4)

extern U8 micFifo_buf[MIC_FIFO_BUF_SIZE];
#endif


typedef struct {

	//U32 awOutSampleStore[2][640*2];
	//U32 awOutSampleStore[2][AUDIO_OUT_BUF_SIZE/2];
	U32 awOutSampleStore[2][AUDIO_OUT_BUF_SIZE];

} AWOUTSTORE;

extern AWOUTSTORE awOutStore;

typedef struct{
	U16 awSize;
	U8 awIndex;
} AWOUT_CONTRLS;

extern AWOUT_CONTRLS awOut_contrls;

typedef struct{
	//U32 awInSampleStore1[2][SPDIF_FRAME_SIZE / 4];//for audio in
#if 0//def MIC_REVERB
	U32 awInSampleStore1[2][1024 / 4];//for hfp in
#else
	//U32 awInSampleStore1[2][240*6*8 / 4];//for hfp in
	//U32 awInSampleStore1[2][1152*10/4];
	U32 awInSampleStore1[2][480*4/4];
	//U32 awInSampleStore1[2][1152*2 / 4];
	//U32 awInSampleStore1[2][1152*1 / 4];
#endif

#if 0//def OPTEK_DSP_MX1
	U32 awInSampleStore2[2][1024 / 4];//for mic in
#endif	

} AWINSTORE;


extern AWINSTORE awInStore;
#define ADC_IN_FIFO_SIZE	(sizeof(awInStore.awInSampleStore1))

extern U8 pcmRcvIndex;
extern BOOL uiDacMute;
extern BOOL uiCdservoMute;
extern U8 audio_iso_mute;
extern U8 aux_mute_timer;
extern U8 audio_out_mode;


extern FIFO AdcInFifo;
extern U8 pcmRcvFlag;

extern U32 *pMicInSampleStore;
extern U32 MicInSampleStoreSize;

extern FIFO MicInFifo;
extern FIFO MicEchoFifo;

void app_dac_init (void);
void app_dac_open (void);
void app_dac_close (void);
void app_dac_fini (void);

void app_dac_outbuf_init(void);

void app_dac_cdservo_enable (void);
BOOL app_dac_get_cdservo_mute_state (void);

void app_dac_mute_enable (void);
void app_dac_mute_disable (void);

void app_adc_mute_enable (void);
void app_adc_mute_disable(void);

void app_adc_receive_disable (void);
void app_dac_receive_pcm_enable(U8 con);

void app_audio_iso_rcv_enable (void);
void app_audio_iso_rcv_disable (void);

void Spdif_rcv_disable(void);
void mix1_init(void);
void app_output_reset (void);

void mix1_init_reuse_audio_in_buf(void);

#endif //_APP_DAC_H_