/******************************************************************************/ /* DNA PROPRIETARY INFORMATION */ /* (C) Copyright 1997,1998 by DNA Enterprises, Inc. */ /* All rights reserved */ /******************************************************************************/ /* CODEC.H - CS4231A Audio Codec driver routines */ /* */ /* This module is the device library for the CS4231A Audio Codec on the */ /* EVM board. */ /* */ /* MACRO FUNCTIONS: */ /* */ /* FUNCTIONS: */ /* codec_init() - Perform required initialization and default configuration*/ /* codec_set_base() - Sets base address based upon memory map and endianess*/ /* codec_reset() - Reset the CS4231A by asserting and deasserting PWDN */ /* codec_id() - Returns codec ID, codec version and chip ID */ /* codec_timer() - Use codec timer in polled or interrupt driven fashion */ /* codec_adc_control() - Control input A/D converters */ /* codec_line_in_control() - Control Line inputs */ /* codec_aux_control() - Control auxillary inputs */ /* codec_dac_control() - Control D/A converter output */ /* codec_audio_data_format() - assign audio data format for capture & playb*/ /* codec_calibrate() - perform selected calibration */ /* codec_playback_enable() - enable playback mode */ /* codec_playback_disable() - disable playback mode. */ /* codec_capture_enable() - enable capture mode */ /* codec_capture_disable() - disable capture mode */ /* codec_interrupt_enable() - enable codec to generate interrupts */ /* codec_interrupt_disable() - disable codec from generating interrupts */ /* codec_loopback_enable() - mix ADC data with DAC data */ /* codec_loopback_disable() - disable loopback mode */ /* codec_serial_port_enable() - enable SDOUT and SDIN */ /* codec_serial_port_disable() - disable SDOUT and SDIN */ /* codec_change_sample_rate() - change capture and playback sample rates */ /* */ /******************************************************************************/ #ifndef _CODEC_H_ #define _CODEC_H_ #define CODEC_MAP0_BASE_ADDR 0x01320000 #define CODEC_MAP1_BASE_ADDR 0x01720000 /* selection options */ #define CAPTURE 1 #define PLAYBACK 2 #define BOTH 3 /* left right selection */ #define LEFT 1 #define RIGHT 2 /* channel selection */ #define CHAN1 1 #define CHAN2 2 /* min max gain values */ #define MIN_ADC_INPUT_GAIN 0.0 #define MAX_ADC_INPUT_GAIN 22.5 #define ADC_INPUT_GAIN_STEP 1.5 #define MIN_AUX_LINE_GAIN -34.5 #define MAX_AUX_LINE_GAIN 12.0 #define AUX_LINE_GAIN_STEP 1.5 #define AUX_LINE_GAIN_OFFSET 12.0 #define MIN_DAC_LBACK_ATTEN 0.0 #define MAX_DAC_LBACK_ATTEN 94.5 #define DAC_LBACK_ATTEN_STEP 1.5 #define MIN_MONO_MIX_ATTEN 0.0 #define MAX_MONO_MIX_ATTEN 45.0 #define MONO_MIX_ATTEN_STEP 3.0 #define MAX_CAL_IN_MS 34 /* register field values */ /* input sources for left/right ADC channel */ #define LINE_SEL 0 /* Line Select */ #define AUX1_SEL 1 /* Auxillary 1 */ #define MIC_SEL 2 /* Microphone */ #define LINE_OUT_LBACK_SEL 3 /* Line Output Loopback */ /* C_L and FMT fields FMT1 FMT0 C_L */ #define LINEAR_8BIT_UNSIGNED 0 /* 0 0 0 */ #define ULAW_8BIT_COMPANDED 1 /* 0 0 1 */ #define LINEAR_16BIT_SIGNED_LE 2 /* 0 1 0 */ #define ALAW_8BIT_COMPANDED 3 /* 0 1 1 */ #define RSVD_FORMAT 4 /* 1 0 0 */ #define ADPCM_4BIT_IMA 5 /* 1 0 1 */ #define LINEAR_16BIT_SIGNED_BE 6 /* 1 1 0 */ /* CAL modes */ #define NO_CAL 0 /* NO Calibration(0,40 for 1st)*/ #define CONVERTER_CAL 1 /* Converter calibration (136) */ #define DAC_CAL 2 /* DAC calibration (40) */ #define FULL_CAL 3 /* Full Calibration (168) */ /* serial formats */ #define SERIAL_64BIT_ENHANCED 0 #define SERIAL_64BIT 1 #define SERIAL_32BIT 2 /*----------------------------------------------------------------------------*/ /* GLOBAL VARIABLES */ /*----------------------------------------------------------------------------*/ extern int codecBaseAddr; /*----------------------------------------------------------------------------*/ /* PUBLIC FUNCTION PROTOTYPES */ /*----------------------------------------------------------------------------*/ /******************************************************************************/ /* codec_evm_init() - Perform required initialization and default config */ /******************************************************************************/ int codec_evm_init(void); /******************************************************************************/ /* codec_set_base() - set CODEC register addresses */ /* This function sets the addresses of the codec memory mapped registers */ /* based upon the memory map and endian mode. Static globals codecBase, */ /* regIndex, regStatus, regData and regIoData are updated. */ /******************************************************************************/ void codec_set_base( int mapMode, /* IN: mapMode (0 or 1) */ int littleEndian /* IN: T/F */ ); /******************************************************************************/ /* codec_reset() - Reset chip to Power On Reset Configuration */ /* */ /* This function resets the CS4231A codec by asserting then de-asserting */ /* the PWDN pin. All registers are configured to their POR values. */ /******************************************************************************/ void codec_reset(void); /******************************************************************************/ /* codec_id() - Returns codec ID, codec version and chip ID */ /******************************************************************************/ int codec_id(int *pVersion,int *pChipId); /******************************************************************************/ /* codec_timer() - Use codec timer in polled or interrupt driven fashion */ /* */ /* This function will operate the timer on the CS4231A codec in either a */ /* polled (blocking) or interrupt driven (non-blocking) fashion. If fp is */ /* a NULL pointer, this routine will block until the timer expires. If fp */ /* is not a NULL pointer, this routine will configure the codec and EVM to */ /* generate an interrupt and hook fp to the NMI. NOTE: the ISR is */ /* responsible for clearing and disabling subsequent codec interrupts when */ /* desired. */ /******************************************************************************/ int codec_timer( /* RET: OK or ERROR */ int usec, /* IN: number of usec for timer */ void (*fp)(void) /* IN: pointer to ISR or NULL for polling*/ ); /******************************************************************************/ /* codec_adc_control() - Control input A/D converters */ /* This function is used to control the left and right A/D converters in */ /* the CS4231A. */ /******************************************************************************/ int codec_adc_control( int leftRightSel, /* IN: LEFT or RIGHT */ float adcGain, /* IN: ADC gain (0-22.5 in 1.5 inc) */ int micGain, /* IN: TRUE or FALSE (fixed 20dB) */ int sourceSel); /* IN: (L/R)LINE,(L/R)AUX1,(L/R)MIC */ /* (L/R)LINE_OUT_LBACK_SEL */ /******************************************************************************/ /* codec_line_in_control() - Control Line inputs */ /* This function is used to control the left and right line inputs */ /******************************************************************************/ int codec_line_in_control( int leftRightSel, float mixGain, int mute ); /******************************************************************************/ /* codec_aux_control() - Control Auxillary inputs */ /* This function is used to control the (2) pairs of auxillary inputs on the*/ /* CS4231A. */ /******************************************************************************/ int codec_aux_control( int leftRightSel, /* IN: LEFT or RIGHT */ int channelSel, /* IN: CHAN1 or CHAN2 */ float mixGain, /* IN: aux mixer;-34.5 to 12 dB */ int mute /* IN: TRUE or FALSE */ ); /*****************************************************************************/ /* codec_dac_control - control D/A converter output */ /*****************************************************************************/ int codec_dac_control( int leftRightSel, /* IN: LEFT or RIGHT */ float dacAtten, /* IN: 0 to 94.5 in 1.5 dB steps */ int mute /* IN: TRUE or FALSE */ ); /******************************************************************************/ /* codec_audio_data_format() - assign audio data format for capture & playback*/ /******************************************************************************/ int codec_audio_data_format(unsigned char format, /* IN: selected audio fmt */ int stereo, /* IN: T/F */ int selection); /* IN: CAPTURE, PLAYBACK */ /* or BOTH */ /******************************************************************************/ /* codec_calibrate() - perform selected calibration */ /******************************************************************************/ int codec_calibrate(int calVal); /******************************************************************************/ /* codec_playback_enable() - enable playback mode. */ /******************************************************************************/ void codec_playback_enable(void); /******************************************************************************/ /* codec_playback_disable() - disable playback mode. */ /******************************************************************************/ void codec_playback_disable(void); /******************************************************************************/ /* codec_capture_enable() - enable capture mode */ /******************************************************************************/ void codec_capture_enable(void); /*****************************************************************************/ /* codec_capture_disable() - disable capture mode */ /*****************************************************************************/ void codec_capture_disable(void); /******************************************************************************/ /* codec_interrupt_enable() - enable codec to generate interrupts */ /******************************************************************************/ void codec_interrupt_enable(void); /******************************************************************************/ /* codec_interrupt_disable() - disable codec from generating interrupts */ /******************************************************************************/ void codec_interrupt_disable(void); /******************************************************************************/ /* codec_loopback_enable - mix ADC data with DAC data */ /******************************************************************************/ int codec_loopback_enable(float loopbackAtten); /******************************************************************************/ /* codec_loopback_disable - disable loopback mode */ /******************************************************************************/ void codec_loopback_disable(void); /******************************************************************************/ /* codec_serial_port_enable() - enable SDOUT and SDIN */ /******************************************************************************/ int codec_serial_port_enable(int serialFormat); /*****************************************************************************/ /* codec_serial_port_disable() - disable SDOUT and SDIN */ /*****************************************************************************/ int codec_serial_port_disable(void); /******************************************************************************/ /* codec_change_sample_rate() - change capture and playback sample rates */ /* */ /* This function changes the capture and playback sample rates to the */ /* closest value found in the freqTable[]. Actual Fs returned. */ /* */ /******************************************************************************/ int codec_change_sample_rate( /* RET:actual sample rate in Hz */ int sampleRate, /* IN: requested sample rate in Hz */ int returnFromMce /* IN: T/F; clear MCE? */ ); #endif