codec.h File Reference


Detailed Description

Codec module C header file.

REVISION

Definition in file codec.h.

#include "../feature.h"
#include "../PIPE/pipe.h"
#include "../GENERIC/generic.h"
#include "../SYSTEM/sys_cpld.h"
#include "aic23.h"

Include dependency graph for codec.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  st_PCM
 PCM_Globals structure definition. More...

Enumerations

enum  COP_MODE {
  COP_MUSIC = 0x0001, COP_TUNER = 0x0002, COP_FMXMIT = 0x0004, COP_ILINK = 0x0008, COP_MIC_RECORD = 0x0010, COP_LINE_RECORD = 0x0020,
  COP_FM_RECORD = 0x0040, COP_AUTOSCAN = 0x0080, COP_TUNER_MIC = 0x0100, COP_PCMHALTED = 0x0200, COP_POWERDOWN = 0x0000
}
 Codec operation mode definition. More...

Functions

void CODEC__spiWrite (unsigned short)
 Function writes commands to Codec chip.
void CODEC__defaultPcmGet (int *, int)
 Function serves as the default PCM data get handle.
void CODEC__defaultPcmPut (int *, int)
 Functions serves as the default PCM data put handle.
void CODEC_linkitPcmGet (int *, int)
 Function serves as the linkIt mode PCM data get handle.
void CODEC_linkitPcmPut (int *, int)
 Function serves as the linkIt mode PCM data put handle.
void CODEC_autoscanPcmGet (int *, int)
 Function serves as the autoscan PCM data get handle.
void CODEC_autoscanPcmPut (int *, int)
 Function serves as the autoscan PCM data put handle.
void CODEC_linePcmGet (int *, int)
 Function serves as the line-in record PCM data get handle.
void CODEC_linePcmPut (int *, int)
 Function serves as the line-in PCM data put handle.
void CODEC_micPcmGet (int *, int)
 Function serves as the mic record PCM data get handle.
void CODEC_tunerPcmPut (int *, int)
 Function serves as the FM radio PCM data put handle.
void CODEC_tunerPcmGet (int *, int)
 Function serves as the FM radio PCM data get handle.
void CODEC_playPcmPut (int *, int)
 Function serves as the normal playback PCM data put handle.
void CODEC_myfiPcmPut (int *, int)
 Function serves as the MyFi playback PCM data put handle.
void CODEC_config (COP_MODE)
 Function initializes the codec given the inputs.
void CODEC_data (void)
 Function serves as the data task handle to fetch data from codec ADC.
void CODEC_init (void)
 Function initializes Codec hardware interface.
void CODEC_hpVolume (int)
 Function controls headphone volume.
void CODEC_gain ()
 Function controls channel gain.
void CODEC_pcm (void)
 Function serves as the codec pcm task handle to output data to codec DAC.
void CODEC_power (COP_MODE)
 Function controls the power ON/OFF of the codec DAC and ADC.
void CODEC_setHandle (PFPCMGET, PFPCMPUT, PFPCMDEC, PFPCMENC)
 Function sets up the PCM get/put handle.
void CODEC_mute (void)
 Function mute the codec interface.
void CODEC_unmute (void)
 Function unmute the codec interface.
void CODEC_recordHdlReset (void)
 Function resets the encoder codec handle controls.


Enumeration Type Documentation

enum COP_MODE
 

Codec operation mode definition.

Enumeration values:
COP_MUSIC  Simple audio playback.
COP_TUNER  Simple FM tuner.
COP_FMXMIT  FM out while audio playback.
COP_ILINK  FM out for line in.
COP_MIC_RECORD  Record from microphone.
COP_LINE_RECORD  Record from line in.
COP_FM_RECORD  Record from FM radio.
COP_AUTOSCAN  Autoscan mode, similar to COP_TUNER.
COP_TUNER_MIC  tuner mode but with micrphone enabled...MFG test
COP_PCMHALTED  PCM halted.
COP_POWERDOWN  Shut down codec.

Definition at line 57 of file codec.h.

Referenced by AUDIO_start().

00058 {
00059     COP_MUSIC       = 0x0001,   
00060     COP_TUNER       = 0x0002,   
00061     COP_FMXMIT      = 0x0004,   
00062     COP_ILINK       = 0x0008,   
00063     COP_MIC_RECORD  = 0x0010,   
00064     COP_LINE_RECORD = 0x0020,   
00065     COP_FM_RECORD   = 0x0040,   
00066     COP_AUTOSCAN    = 0x0080,   
00067     COP_TUNER_MIC   = 0x0100,   
00068     COP_PCMHALTED   = 0x0200,   
00069     COP_POWERDOWN   = 0x0000    
00070 } COP_MODE;


Function Documentation

void CODEC__defaultPcmGet int *  pcmBuf,
int  len
 

Function serves as the default PCM data get handle.

Parameters:
pcmBuf PCM data buffer.
len Available PCM data length in words.

Definition at line 136 of file CODEC_pcm.c.

00137 {
00138 }

void CODEC__defaultPcmPut int *  pcmBuf,
int  len
 

Functions serves as the default PCM data put handle.

Parameters:
pcmBuf PCM data buffer.
len Pending PCM data length in words.

Definition at line 122 of file CODEC_pcm.c.

References GEN_zeroOut().

00123 {
00124     GEN_zeroOut((UINT16*)pcmBuf, len);
00125 }

Here is the call graph for this function:

void CODEC__spiWrite unsigned short  cmd  ) 
 

Function writes commands to Codec chip.

Parameters:
cmd command sent to Codec chip.

Definition at line 35 of file CODEC__spi.c.

References SYS_delayMicrosecond().

Referenced by CODEC_gain(), CODEC_hpVolume(), CODEC_init(), CODEC_mute(), and CODEC_power().

00036 {
00037     unsigned short i;
00038     unsigned short iTmp;
00039 
00040     SPI_lock(SYS_FOREVER);
00041         
00042     // clear the clock.  All data is latched in on the rising edge.
00043     iTmp = SPI_CLK;      
00044     
00045     // clear tuner data line to set to input.
00046     //iTmp = TUNER_DAT; 
00047     
00048     // clear the CODEC enable to enable.    
00049     iTmp = CODEC_EN;
00050     SYS_delayMicrosecond(1);
00051     for (i = 0; i < 16; i++)
00052     {
00053         iTmp = SPI_CLK;                 
00054         
00055         if (cmd & 0x8000) SPI_DATA = 0x0;
00056         else iTmp = SPI_DATA;
00057         
00058         SYS_delayMicrosecond(1);
00059         SPI_CLK = 0x0;
00060         SYS_delayMicrosecond(1);
00061         cmd = cmd<<1;
00062     }
00063     
00064     // disable the EEPROM;
00065     //  asm (" ssbx XF");       
00066         
00067     // clear SPI clock 
00068     iTmp = SPI_CLK;         
00069         
00070     // clear the DATA line, set to input.
00071     iTmp = SPI_DATA;
00072         
00073     // clear the DATA line on the tuner to set to input
00074     //iTmp = TUNER_DAT;     
00075         
00076     // set codec enable to disable
00077     CODEC_EN = 0x0; 
00078         
00079     // put tuner in read mode.
00080     //iTmp = TUNER_WR;
00081     
00082     SPI_unlock();
00083 }

Here is the call graph for this function:

void CODEC_autoscanPcmGet int *  pcmBuf,
int  len
 

Function serves as the autoscan PCM data get handle.

Parameters:
pcmBuf PCM data buffer.
len Available PCM data length in words.

Definition at line 87 of file CODEC_autoscanHdl.c.

00088 {
00089     leftChannel  = pcmBuf;
00090     rightChannel = pcmBuf + len/2;
00091 }

void CODEC_autoscanPcmPut int *  pcmBuf,
int  len
 

Function serves as the autoscan PCM data put handle.

Parameters:
pcmBuf PCM data buffer.
len Pending PCM data length in words.

Definition at line 48 of file CODEC_autoscanHdl.c.

References st_AUTOSCAN::pLeftInput, and st_AUTOSCAN::pRightInput.

00049 {
00050     unsigned int i;
00051     int *        pSrcLeft;
00052     int *        pSrcRight;
00053     int *        pDstLeft;
00054     int *        pDstRight;
00055     int          dataLen = len/2;
00056     
00057     pSrcLeft  = leftChannel;
00058     pSrcRight = rightChannel;
00059     pDstLeft  = pcmBuf;
00060     pDstRight = pcmBuf + dataLen;
00061     
00062     AutoscanGlobals.pLeftInput = pDstLeft;
00063     AutoscanGlobals.pRightInput = pDstRight;
00064 
00065     for (i = 0; i < dataLen; i++)
00066     {
00067         FIRDeemphasisLeftTaps[0] = *pSrcLeft++;
00068         FIRDeemphasisRightTaps[0] = *pSrcRight++;
00069     
00070         // apply demphasis filter
00071         *pDstLeft++  = TUNER_deemphasisFIR(&FIRDeemphasisLeft);
00072         *pDstRight++ = TUNER_deemphasisFIR(&FIRDeemphasisRight);
00073     }
00074     
00075     AUTOSCAN_genMetrics(&AutoscanGlobals);
00076 }

void CODEC_config COP_MODE  eMode  ) 
 

Function initializes the codec given the inputs.

This function will set up the corresponding DMA engines and initialize McBSP. DAC and ADC of the Codec will also be set to given state determined by eMode.

Parameters:
eMode New Codec operation mode.

Definition at line 56 of file CODEC_config.c.

References CODEC_power(), st_PCM::codecMode, st_PCM::flag, GEN_zeroOut(), st_PCM::getFunc, McBSP_init(), st_PCM::newGetFunc, st_PCM::newPutFunc, st_PCM::pipe, PIPE_reset(), PIPE_writeNext(), and st_PCM::putFunc.

Referenced by AUDIO_start().

00057 { 
00058     if(Pcm.codecMode != eMode)
00059     {
00060         /* Halt DMA3 and CODEC_McBSP */
00061         CODEC_haltPcm(); 
00062         Pcm.codecMode = eMode;
00063         Pcm.getFunc = Pcm.newGetFunc;
00064         Pcm.putFunc = Pcm.newPutFunc; 
00065         
00066         CODEC_power(eMode);
00067 
00068         if( (eMode != COP_MIC_RECORD) )
00069         {   
00070             /* Reset the pipe object, initialize to zero frames. */
00071             PIPE_reset(&Pcm.pipe);  
00072             GEN_zeroOut((UINT16 *)Pcm.pipe.WrFrame.Frame, PCM_PIPE_FRAMELEN);
00073             
00074             PIPE_writeNext(&Pcm.pipe);  
00075             GEN_zeroOut((UINT16 *)Pcm.pipe.WrFrame.Frame, PCM_PIPE_FRAMELEN);
00076             
00077             PIPE_writeNext(&Pcm.pipe);         
00078             Pcm.flag |= HAVE_NEXT_BLOCK;    
00079         }
00080 
00081         /* Initialize the pcm globals */                            
00082         Pcm.flag &= ~(UPPER_HALF_BUF|STARTED_NEXT_BLOCK);
00083         Pcm.flag |= IS_MUTED;
00084 
00085         /* DMA3/DMA4 has higher priority, Interrupt source selected. */
00086         DMPREC |= 0x1840; 
00087     
00088         /* Set the FREE bit so that transfers not stop with emulator */
00089         //DMPREC |= 0x8000; 
00090 
00091 
00092         /* Setup DMA3 to connect to McBSP transmitter to send out audio data. */  
00093         
00094         /* point to DMSRC3 register */
00095         DMSBAR = DMSRC3_SUBADDR;                
00096         
00097         /* DMSRC3 = Transmit buffer pong address */
00098         DMSBAI = (int)Pcm.pipe.RdFrame.Frame;   
00099         
00100         /* DMDST3 = CODEC_McBSP data transmit register */
00101         DMSBAI = MCBSP_DXR1_ADDR(CODEC_McBSP); 
00102     
00103         /* DMCTR3 = Transmit buffer size (2 words in sample--left/right) 
00104         ** 2 words per frame, 64 frames per block. 
00105         */
00106         DMSBAI = 1;                             
00107     
00108         /* Modification of CODEC_McBSP definition will cause changes here. */
00109         /* DMSFC3 = McBSP0 transmit sync event  frames = # of samples */
00110         DMSBAI = 0x2000+(PCM_CHANNEL_BUFLEN-1);
00111                                             
00112 
00113         /* DMMCR3 = Auto-init, 
00114         ** interrupt at block complete, 
00115         ** DMA interrupt enabled, 
00116         ** decrement mode (auto-init)
00117         */
00118         DMSBAI = 0xc541;                        
00119         
00120         DMSBAR = DMIDX0_SUBADDR;    
00121         
00122         
00123         /* DMIDX0 = step to next sample in frame */
00124         DMSBAN = PCM_CHANNEL_BUFLEN;            
00125         
00126         DMSBAR = DMFRI0_SUBADDR;
00127         
00128         /* DMFRI0 = step to next frame */
00129         DMSBAN = (unsigned short)(1 - PCM_CHANNEL_BUFLEN);      
00130         
00131         
00132         DMSBAR = DMGSA_SUBADDR;
00133         
00134         /* DMGSA = Transmit buffer pong address */
00135         DMSBAI = (int)Pcm.pipe.RdFrame.NextFrame;
00136     
00137 
00138         /* DMGDA = McBSP0 data transmit register */
00139         DMSBAI = MCBSP_DXR1_ADDR(CODEC_McBSP);  
00140     
00141         /* DMGCR = Transmit buffer size (2 words in sample--left/right) */
00142         DMSBAI = 1;                             
00143         
00144         
00145         /* DMGFR = McBSP0 transmit sync event frames = # of samples */
00146         DMSBAI = 0x2000+(PCM_CHANNEL_BUFLEN-1);
00147                         
00148         
00149         /* Setup DMA4 to connect to McBSP receiver to receive audio data. */   
00150         DMSBAR = DMSRC4_SUBADDR;
00151         
00152         /* DMA source:  CODEC_McBSP receiver address */
00153         DMSBAI = MCBSP_DRR1_ADDR(CODEC_McBSP); 
00154             
00155         /* DMA destination: BUF_input, which MUST be a circular buffer.*/
00156         DMSBAI = (int)BUF_output;           
00157     
00158         /* DMCTR4 = Transmit buffer size (2 words in sample--left/right) */ 
00159         DMSBAI = 4*PCM_CHANNEL_BUFLEN;          
00160 
00161 
00162         /* Modification of CODEC_McBSP definition will cause changes here. */
00163         /* DMSFC4 = McBSP0 receiver sync event */       
00164         DMSBAI = 0x1000;                        
00165     
00166         
00167         /* DMMCR4 = No Auto-init 
00168         **  DMA in ABU mode
00169         **  DMA interrupt occurs at half-buffer filled
00170         **  DMA index address autoincrement step: one word
00171         **  DMA in single word mode    
00172         **  DMA postincrement wiht index offset, similiar with DMA3.
00173         */
00174         DMSBAI = 0x7045;      
00175     
00176         
00177         /* clear the DMA3/4 interrupt here to prevent malfunction. */
00178         IFR |= 0x1800;  
00179 
00180         /* Unmute Codec & start DMA3/4. */ 
00181         CODEC_setActiveState(eMode);        
00182 
00183         /* Initialize CODEC_McBSP. */ 
00184         McBSP_init(CODEC_McBSP,                                     /* port number */
00185     
00186             /* Digital Loop back, just for testing. */
00187             //FIELD_VAL(DLB,     1,          1                  )|   /* spcr1 */
00188     
00189             FIELD_VAL(RINTM,     RINTM_SZ,  INTM_RDY           )|   /* spcr1 */
00190             FIELD_VAL(RJUST,     RJUST_SZ,   RXJUST_RJSE        )|   /* spcr1 */
00191             FIELD_VAL(CLKSTP,    CLKSTP_SZ,  0                  )|   /* spcr1 */
00192             FIELD_VAL(RRST,      1,          1                  ),   /* spcr1 - receiver is enabled */
00193     
00194             FIELD_VAL(FREE,      1,          1                  )|   /* spcr2 - free running mode is enabled */
00195             FIELD_VAL(SOFT,      1,          1                  )|   /* spcr2 - don't care. */
00196             FIELD_VAL(XINTM,     XINTM_SZ,   INTM_RDY           )|   /* spcr2 */
00197             FIELD_VAL(XRST,      1,          1                  )|   /* spcr2 - transmittor is enabled */
00198             FIELD_VAL(GRST,      1,          1                  )|   /* spcr2 */
00199             FIELD_VAL(FRST,      1,          0                  ),   /* spcr2 - Frame sync is provided by Codec */
00200     
00201             FIELD_VAL(RWDLEN1,   RWDLEN1_SZ, WORD_LENGTH_16     )|   /* rcr1 - 16 bits per word */
00202             FIELD_VAL(RFRLEN1,   RFRLEN1_SZ, 1                  ),   /* rcr1 - 2 words per frame */
00203     
00204             FIELD_VAL(RDATDLY,   RDATDLY_SZ, DATA_DELAY0        )|   /* rcr2 - N/A */
00205             FIELD_VAL(RFIG,      1,          FRAME_IGNORE       )|   /* rcr2 - N/A */
00206             FIELD_VAL(RCOMPAND,  RCOMPAND_SZ,NO_COMPAND_MSB_1ST )|   /* rcr2 - N/A */
00207             FIELD_VAL(RWDLEN2,   RWDLEN2_SZ, WORD_LENGTH_16     )|   /* rcr2 - N/A */
00208             FIELD_VAL(RFRLEN2,   RFRLEN2_SZ, 0                  )|   /* rcr2 - N/A */
00209             FIELD_VAL(RPHASE,    1,          SINGLE_PHASE       ),   /* rcr2 - N/A */
00210     
00211             FIELD_VAL(XWDLEN1,   XWDLEN1_SZ, WORD_LENGTH_16     )|   /* xcr1 - 16-bit words in the first phase */
00212             FIELD_VAL(XFRLEN1,   XFRLEN1_SZ, 1                  ),   /* xcr1 - 2 words in the first phase */
00213     
00214             FIELD_VAL(XDATDLY,   XDATDLY_SZ, DATA_DELAY0        )|   /* xcr2 - delay data clocks from frame sync. */
00215             FIELD_VAL(XFIG,      1,          FRAME_IGNORE       )|   /* xcr2 - ignore extraneous frame syncs */
00216             FIELD_VAL(XCOMPAND,  XCOMPAND_SZ,NO_COMPAND_MSB_1ST )|   /* xcr2 - MSB align data (no companding) */
00217             FIELD_VAL(XWDLEN2,   XWDLEN2_SZ, WORD_LENGTH_16     )|   /* xcr2 - N/A */
00218             FIELD_VAL(XFRLEN2,   XFRLEN2_SZ, 0                  )|   /* xcr2 - N/A */
00219             FIELD_VAL(XPHASE,    1,          SINGLE_PHASE       ),   /* xcr2 - single phase frame */
00220     
00221             0,                                                                          /* srgr1 - N/A */
00222             0,                                                                          /* srgr2 - N/A */
00223     
00224             FIELD_VAL(RMCM,      1,          0                  ),   /* mcr1 - all 128 RX channels are enabled */
00225             FIELD_VAL(XMCM,      XMCM_SZ,    0                  ),   /* mcr2 - all 128 TX channels are enabled */
00226             0,                                                       /* rcera - N/A */
00227             0,                                                       /* rcerb - N/A */
00228             0,                                                       /* xcera - N/A */
00229             0,                                                       /* xcerb - N/A */
00230     
00231             FIELD_VAL(CLKRP,     1,          CLKR_POL_FALLING   )|   /* pcr - N/A */
00232             FIELD_VAL(CLKXP,     1,          CLKX_POL_FALLING   )|   /* pcr - transmit data sampled on falling edge of CLKX */
00233             FIELD_VAL(FSRP,      1,          FSYNC_POL_HIGH     )|   /* pcr - N/A */
00234             FIELD_VAL(FSXP,      1,          FSYNC_POL_HIGH     )|   /* pcr - frame sync pulse (FSX) is active high */
00235             FIELD_VAL(CLKRM,     1,          CLK_MODE_EXT       )|   /* pcr - CLKR is an input pin */
00236             FIELD_VAL(CLKXM,     1,          CLK_MODE_EXT       )|   /* pcr - CLKX is an intput pin */
00237             FIELD_VAL(FSRM,      1,          FSYNC_MODE_EXT     )|   /* pcr - FSR is an input pin */
00238             FIELD_VAL(FSXM,      1,          FSYNC_MODE_EXT     )    /* pcr - FSX is an input */
00239     
00240         );
00241         
00242         // Wait till codec interface stablized before bringing up volume. We'll 
00243         // lose 50ms music here.
00244         //if( eMode & (COP_MUSIC|COP_TUNER|COP_ILINK|COP_LINE_RECORD|COP_FM_RECORD|COP_AUTOSCAN|COP_TUNER_MIC) )
00245         //{
00246         //    SYS_delayMicrosecond(50000);
00247         //    CODEC_hpVolume(sysParam.volume);
00248         //}
00249     }
00250     else 
00251     {
00252         SWI_disable();
00253         Pcm.getFunc = Pcm.newGetFunc;
00254         Pcm.putFunc = Pcm.newPutFunc;
00255         SWI_enable();
00256     }   
00257 } 

Here is the call graph for this function:

void CODEC_data void   ) 
 

Function serves as the data task handle to fetch data from codec ADC.

Also function checkes to feed data into pcm pipe.

Definition at line 40 of file CODEC_data.c.

References st_PCM::codecMode, COP_AUTOSCAN, COP_FM_RECORD, COP_FMXMIT, COP_ILINK, COP_LINE_RECORD, COP_MIC_RECORD, COP_MUSIC, COP_TUNER, st_PCM::flag, st_PCM::getFunc, st_PCM::pipe, PIPE_writeNext(), and st_PCM::putFunc.

00041 {
00042     PIPE_Obj *  pPipe = &Pcm.pipe;
00043     int *       pData;
00044 
00045     // Use input to sync.
00046     if ( PIPE_writeFrameNum(pPipe) )
00047     {
00048         // Check output first.
00049         #ifdef MIXER_SUPPORT 
00050         if( Pcm.codecMode & (COP_TUNER|COP_LINE_RECORD|COP_MIC_RECORD|COP_FM_RECORD|COP_AUTOSCAN|COP_ILINK|COP_MUSIC|COP_FMXMIT) )
00051         #else
00052         if( Pcm.codecMode & (COP_TUNER|COP_LINE_RECORD|COP_MIC_RECORD|COP_FM_RECORD|COP_AUTOSCAN|COP_ILINK) )
00053         #endif
00054         {       
00055             /* which part of the buffer is valid??? */
00056             if( Pcm.flag & UPPER_HALF_BUF )
00057             {                       
00058                 /* upper half. */
00059                 pData = &BUF_output[0];
00060             }
00061             else
00062             {
00063                 /* lower half. */
00064                 pData = &BUF_output[BUF_OUTPUTSIZE/2];
00065             }   
00066             _sortChannel(pData);
00067             Pcm.getFunc(ChannelBuf, BUF_OUTPUTSIZE/2);
00068         }   
00069                             
00070         if( Pcm.codecMode &(COP_MUSIC|COP_FMXMIT|COP_TUNER|COP_LINE_RECORD|COP_FM_RECORD|COP_AUTOSCAN|COP_ILINK) )
00071         {
00072             Pcm.putFunc(pPipe->WrFrame.Frame, pPipe->wFrameLen);
00073         }
00074         
00075         /* validate frame. */
00076         PIPE_writeNext(pPipe);                  
00077     }
00078 }

Here is the call graph for this function:

void CODEC_hpVolume int  volume  ) 
 

Function controls headphone volume.

Parameters:
volume New headphone volume.

Definition at line 267 of file CODEC_config.c.

References CODEC__spiWrite().

Referenced by CODEC_mute(), CODEC_unmute(), UI_CSF_volume(), and UI_PSF_radio().

00268 {
00269     /* Simultaneously update left/right channel???. */
00270     if(volume) volume += VOLUME_OFFSET;
00271     
00272     CODEC__spiWrite(AIC23REG_LHDPHONE | 0x100 | volume);
00273     //CODEC__spiWrite(AIC23REG_RHDPHONE | 0x100 | volume);  
00274 }

Here is the call graph for this function:

void CODEC_linePcmGet int *  pcmBuf,
int  len
 

Function serves as the line-in record PCM data get handle.

Parameters:
pcmBuf PCM data buffer.
len Available PCM data length in words.

Definition at line 99 of file CODEC_recordHdl.c.

References ENCODER_getInputBuf(), and ENCODER_putInputBuf().

Referenced by AUDIO_start().

00100 {
00101     int * pEncDstLeft;
00102     int * pEncDstRight;
00103     int   dataLen = len/2;
00104     
00105     leftChannel  = pcmBuf;
00106     rightChannel = pcmBuf + dataLen;
00107     
00108     if(FALSE == ENCODER_getInputBuf(&pEncDstLeft, &pEncDstRight))
00109     {
00110         // Encoder can not keep up, out of sync.
00111         asm(" nop");
00112     }
00113     else 
00114     {
00115         memcpy(pEncDstLeft, leftChannel, dataLen);
00116         memcpy(pEncDstRight, rightChannel, dataLen);
00117         ENCODER_putInputBuf();
00118     }
00119 }

Here is the call graph for this function:

void CODEC_linePcmPut int *  pcmBuf,
int  len
 

Function serves as the line-in PCM data put handle.

Parameters:
pcmBuf PCM data buffer.
len Pending PCM data length in words.

Definition at line 130 of file CODEC_recordHdl.c.

References st_AUDIOENERGY::pFrame.

Referenced by AUDIO_start().

00131 {
00132     unsigned int i;
00133     int          dataLen = len/2;
00134     int *        pTmp;
00135     int *        left;
00136     int *        right;
00137     
00138     pTmp  = pcmBuf + dataLen;
00139     left  = leftChannel;
00140     right = rightChannel;
00141     
00142     for (i = 0; i < dataLen; i++)
00143     {
00144         *pcmBuf++ = *left;
00145         *pTmp++   = *right;
00146             
00147         LeftInputEnergy.pFrame  = left++;
00148         RightInputEnergy.pFrame = right++;
00149         AUDIO_energy(&LeftInputEnergy);
00150         AUDIO_energy(&RightInputEnergy);
00151     }                       
00152 }

void CODEC_linkitPcmGet int *  pcmBuf,
int  len
 

Function serves as the linkIt mode PCM data get handle.

Parameters:
pcmBuf PCM data buffer.
len Available PCM data length in words.

Definition at line 367 of file CODEC_playHdl.c.

Referenced by AUDIO_start().

00368 {
00369     leftChannel  = pcmBuf;
00370     rightChannel = pcmBuf + len/2;
00371 }

void CODEC_linkitPcmPut int *  pcmBuf,
int  len
 

Function serves as the linkIt mode PCM data put handle.

Parameters:
pcmBuf PCM data buffer.
len Pending PCM data length in words.

Definition at line 305 of file CODEC_playHdl.c.

Referenced by AUDIO_start().

00306 {
00307     int i;
00308     
00309     /*if(SYS_HF_myfiTest())
00310     {
00311         st_AUDIO_OSCILLATOR LeftTestTone;
00312         st_AUDIO_OSCILLATOR RightTestTone;
00313         
00314         // set up oscillators for the test tones
00315         // 500 Hz, 95% full-scale sine wave (to prevent clipping due to
00316         // rounding)
00317         LeftTestTone.Coeff =
00318         RightTestTone.Coeff = 32753;
00319         LeftTestTone.Tap1 =
00320         RightTestTone.Tap1 = 887;
00321         LeftTestTone.Tap2 =
00322         RightTestTone.Tap2 = 0;
00323 
00324         LeftTestTone.pOutput = leftChannel;
00325         RightTestTone.pOutput = rightChannel;
00326         AUDIO_toneGen(&LeftTestTone);
00327         AUDIO_toneGen(&RightTestTone);
00328     }*/
00329         
00330     StereoMod.pSum = leftChannel;
00331     StereoMod.pDiff = rightChannel;
00332     StereoMod.OutputLeft = (int *)pcmBuf;
00333     StereoMod.OutputRight = (int *)pcmBuf + 64;
00334     
00335     //if(SYS_HF_myfiTest())
00336     {
00337         FIRPremphasisLeft.pOutput = leftChannel;
00338         FIRPremphasisRight.pOutput = rightChannel;
00339     }
00340     
00341     for (i = 0; i < PCM_CHANNEL_BUFLEN; i++)
00342     {
00343         //XMIT_Energy(&EnergyInputLeft);
00344         //XMIT_Energy(&EnergyInputRight);
00345 
00346         CarrierGen(&Carrier);
00347         
00348         //if(SYS_HF_myfiTest())
00349         {
00350             XMIT_preemphasisFIR(&FIRPremphasisLeft);
00351             XMIT_preemphasisFIR(&FIRPremphasisRight);
00352         }
00353             
00354         XMIT_Modulator(&StereoMod);
00355     }
00356 }

void CODEC_micPcmGet int *  pcmBuf,
int  len
 

Function serves as the mic record PCM data get handle.

Parameters:
pcmBuf PCM data buffer.
len Available PCM data length in words.

Definition at line 58 of file CODEC_recordHdl.c.

References ENCODER_getInputBuf(), ENCODER_putInputBuf(), and st_AUDIOENERGY::pFrame.

Referenced by AUDIO_start().

00059 {
00060     unsigned short i;
00061     int *          pDstLeft;
00062     int *          pDstRight;
00063     
00064     if(FALSE == ENCODER_getInputBuf(&pDstLeft, &pDstRight))
00065     {
00066         // Encoder can not keep up, out of sync.
00067         asm(" nop");
00068     }
00069     else
00070     {   
00071         len = len/2;    
00072         for (i = 0; i < len; i++)
00073         {    
00074             // put the input data into the beginning of the taps array.
00075             //FIRMicTaps[0] = *pSrcLeft++;
00076             FIRMicTaps[2] = *pcmBuf++;
00077                     
00078             // apply LPF filter
00079             *pDstLeft = *pDstRight++ = CODEC_micLPF(&FIRMicRecord);
00080             LeftInputEnergy.pFrame =
00081             RightInputEnergy.pFrame = pDstLeft++;
00082             AUDIO_energy(&LeftInputEnergy);
00083             AUDIO_energy(&RightInputEnergy);
00084         }
00085         ENCODER_putInputBuf();
00086     }
00087 }

Here is the call graph for this function:

void CODEC_myfiPcmPut int *  pcmBuf,
int  len
 

Function serves as the MyFi playback PCM data put handle.

Parameters:
pcmBuf PCM data buffer.
len Pending PCM data length in words.

Definition at line 144 of file CODEC_playHdl.c.

References st_PCM::decode, st_PCM::flag, GEN_zeroOut(), and st_PCM::sampleRate.

Referenced by AUDIO_start().

00145 {
00146     int     i;
00147     int *   pData;
00148     int *   pDstLeft;
00149     int *   pDstRight;
00150 
00151     if (XMIT_CompressBuffer( &EncoderBuffer ))
00152     // if the input buffer has less than the required number of samples
00153     // and the output buffer has less than 64 samples ready to go, we need
00154     // to decode more MP3 and perform SRC on it.
00155     // For the input buffer, there are always 11 extra samples left over
00156     // from the previous frame for the taps of the FIR filter.
00157     {
00158         pDstLeft = EncoderBuffer.pSumInput;
00159         pDstRight = EncoderBuffer.pDiffInput;               
00160         
00161         /* Setup sample rate conversion output buffer. */
00162         SRC_setOutput(&LeftSRC, pDstLeft);
00163         SRC_setOutput(&RightSRC, pDstRight);       
00164 
00165         /* check for a change in sample rate and reset SRC if needed */
00166         if (Pcm.flag&SAMPLE_RATE_CHANGED) 
00167         {
00168             /* set sample rate */
00169             SRC_setInputRate(&LeftSRC, Pcm.sampleRate);
00170             SRC_setInputRate(&RightSRC, Pcm.sampleRate);
00171             PCM_samplerateNotChanged();
00172         }
00173         
00174         /* loop over sample rate converter until output buffers are filled */
00175         while (SRC_isOutputBufferFull(&LeftSRC) == 0) 
00176         {
00177             /* get another input block if needed */
00178             if (SRC_isInputBufferEmpty(&LeftSRC)) 
00179             {
00180                 pData = Pcm.decode();
00181     
00182                 if( NULL == pData)
00183                 {
00184                     // Decoder data is not ready, 
00185                     // Zero sending out.
00186                     GEN_zeroOut((UINT16*)pcmBuf, len);
00187                     return;
00188                 }
00189                 else
00190                 {
00191                     SRC_setInput(&LeftSRC, pData);
00192                     SRC_setInput(&RightSRC, pData + SRC_inputBufferSize());
00193                 }
00194             }
00195     
00196             /* run the left and right channels */
00197             SRC_apply(&LeftSRC);
00198             SRC_apply(&RightSRC);
00199         }
00200         
00201         EncoderBuffer.Samples += PCM_CHANNEL_BUFLEN;                    
00202     }
00203 
00204     // by the time we get here, we should have at least 26 samples (+11 previous samples)
00205     // available in the input buffers.
00206     DifSRCData.Input = EncoderBuffer.pDiffOutput;
00207     SumSRCData.Input = EncoderBuffer.pSumOutput;
00208     DifSRCData.Output = SRCBuffer.pDiffInput;
00209     SumSRCData.Output = SRCBuffer.pSumInput;
00210 
00211     while (SRCBuffer.Samples < PCM_CHANNEL_BUFLEN)
00212     /* If there are not enough samples after the SRC, then
00213      * we need to run the SRC until there are enough samples */
00214     {
00215         /* SRC Automatically updates the input and output pointers. */
00216         XMIT_SRC(&SumSRCData);
00217         XMIT_SRC(&DifSRCData);
00218         SRCBuffer.Samples += XMIT_OUTPUT;
00219         EncoderBuffer.Samples -= XMIT_SAMPLES;
00220     }
00221 
00222     /* Update pointers */           
00223     EncoderBuffer.pDiffOutput = DifSRCData.Input;
00224     EncoderBuffer.pSumOutput = SumSRCData.Input;
00225     SRCBuffer.pDiffInput = DifSRCData.Output;
00226     SRCBuffer.pSumInput = SumSRCData.Output;
00227     /* Now, enough up-sampled data is in the SRC Output buffers.
00228     * we can not process the data and put it in the output buffer.
00229     * Then, we need to compress the SRC Output Buffers. */
00230     EnergyInputLeft.pInput =  StereoMod.pSum = SRCBuffer.pSumOutput;
00231     EnergyInputRight.pInput = StereoMod.pDiff = SRCBuffer.pDiffOutput;
00232             
00233     SRCBuffer.pSumOutput += PCM_CHANNEL_BUFLEN;         
00234     SRCBuffer.pDiffOutput += PCM_CHANNEL_BUFLEN;
00235     SRCBuffer.Samples -= PCM_CHANNEL_BUFLEN;
00236 
00237     pDstLeft = pcmBuf;
00238     pDstRight = pcmBuf + len/2;
00239 
00240     //' Now, let's take this data and put it into the EncoderBuffers
00241     //' Apply all filters (15kHz and pre-emphasis here)
00242     //' Also apply all summing of the left and right channels
00243     //' and the difference of the left and right channels.
00244     StereoMod.OutputRight = pDstRight;
00245     StereoMod.OutputLeft = pDstLeft;
00246     
00247     #ifdef MIXER_SUPPORT
00248     {
00249         int     ii,
00250                *pL,
00251                *pR;
00252                        
00253         pL = StereoMod.pDiff;
00254         pR = StereoMod.pSum;
00255         for (ii = 0; ii < PCM_CHANNEL_BUFLEN; ii++)
00256         {
00257             *pL = (*pL+*leftChannel)/2;
00258             *pR = (*pR+*rightChannel)/2;
00259             pL++;
00260             pR++;
00261             leftChannel++;
00262             rightChannel++;
00263         }
00264     }
00265     #endif
00266 
00267 
00268     for (i = 0; i < PCM_CHANNEL_BUFLEN; i++)
00269     {
00270         // Not enought mips for this.
00271         //XMIT_Energy(&EnergyInputLeft);
00272         //XMIT_Energy(&EnergyInputRight);
00273         #if 0   // 11/13/02
00274             FIRPremphasisLeftTaps[0] = *pSrcLeft;
00275             FIRPremphasisRightTaps[0] = *pSrcRight;
00276             *pSrcLeft++ = XMIT_PreemphasisFIR(&FIRPremphasisLeft);
00277             *pSrcRight++ = XMIT_PreemphasisFIR(&FIRPremphasisRight);
00278         #endif
00279 
00280         CarrierGen(&Carrier);
00281         //XMIT_SumDiff(&StereoMod);
00282         XMIT_Modulator(&StereoMod);
00283     }
00284                 
00285     XMIT_CompressBuffer(&SRCBuffer);
00286                 
00287     /*remove the EQ apply for MIPs limit*/
00288     /* Let's apply EQ here. */
00289     /*
00290     EQ_apply(&LeftEQ, pDstLeft, pDstLeft);
00291     EQ_apply(&RightEQ, pDstRight, pDstRight);
00292     */
00293 }

Here is the call graph for this function:

void CODEC_playPcmPut int *  pcmBuf,
int  len
 

Function serves as the normal playback PCM data put handle.

Parameters:
pcmBuf PCM data buffer.
len Pending PCM data length in words.

Definition at line 50 of file CODEC_playHdl.c.

References AUDIO_speedIsOutputBufferFull(), st_PCM::decode, st_PCM::flag, GEN_zeroOut(), and st_PCM::sampleRate.

Referenced by AUDIO_start().

00051 {
00052     int * pData;
00053     int * pRight = pcmBuf+len/2;
00054 
00055     #ifdef DJ_SUPPORT
00056     // loop over speed control.
00057     while(1)
00058     #endif
00059     {   
00060         #ifdef DJ_SUPPORT
00061         if(AUDIO_speedIsOutputBufferFull()) break;
00062         #endif
00063 
00064         /* Setup sample rate conversion output buffer. */
00065         // This could be opted out in the future, to have PCM put to a buffer at fixed 
00066         // position.
00067         SRC_setOutput(&LeftSRC, pcmBuf);                
00068         SRC_setOutput(&RightSRC, pRight);       
00069     
00070         /* check for a change in sample rate and reset SRC if needed */
00071         if (Pcm.flag&SAMPLE_RATE_CHANGED) 
00072         {
00073             /* set sample rate */
00074             SRC_setInputRate(&LeftSRC, Pcm.sampleRate);
00075             SRC_setInputRate(&RightSRC, Pcm.sampleRate);
00076             PCM_samplerateNotChanged();
00077         }
00078             
00079         /* loop over sample rate converter until output buffers are filled */
00080         while (SRC_isOutputBufferFull(&LeftSRC) == 0) 
00081         {
00082             /* get another input block if needed */
00083             if (SRC_isInputBufferEmpty(&LeftSRC)) 
00084             {
00085                 pData = Pcm.decode();
00086                 
00087                 if( NULL == pData)
00088                 {
00089                     // Decoder data is not ready, 
00090                     // Zero sending out.
00091                     GEN_zeroOut((UINT16*)pcmBuf, len);
00092                     return;
00093                 }
00094                 else
00095                 {
00096                     SRC_setInput(&LeftSRC, pData);
00097                     SRC_setInput(&RightSRC, pData + SRC_inputBufferSize());
00098                 }
00099             }
00100     
00101             /* run the left and right channels */
00102             SRC_apply(&LeftSRC);
00103             SRC_apply(&RightSRC);
00104         }
00105         
00106         #ifdef DJ_SUPPORT
00107         if(AUDIO_speedFIR(pcmBuf, pRight)) break;
00108         #endif
00109 
00110     }
00111     
00112     #ifdef DJ_SUPPORT
00113     AUDIO_speedGetSample(pcmBuf, pRight);
00114     #endif
00115     
00116     EQ_apply(&LeftEQ,  pcmBuf,  pcmBuf);
00117     EQ_apply(&RightEQ, pRight,  pRight);
00118     
00119     #ifdef MIXER_SUPPORT
00120     {
00121         unsigned short ii;
00122         for (ii = 0; ii < PCM_CHANNEL_BUFLEN; ii++)
00123         {
00124             *pcmBuf = (*pcmBuf+*leftChannel)/2;
00125             *pRight = (*pRight+*rightChannel)/2;
00126             pcmBuf++;
00127             pRight++;
00128             leftChannel++;
00129             rightChannel++;
00130         }
00131     }
00132     #endif
00133 }

Here is the call graph for this function:

void CODEC_power COP_MODE  eMode  ) 
 

Function controls the power ON/OFF of the codec DAC and ADC.

Parameters:
eMode New Codec operation mode.

Definition at line 334 of file CODEC_config.c.

References CODEC__spiWrite(), COP_AUTOSCAN, COP_FM_RECORD, COP_FMXMIT, COP_ILINK, COP_LINE_RECORD, COP_MIC_RECORD, COP_MUSIC, COP_POWERDOWN, COP_TUNER, and COP_TUNER_MIC.

Referenced by CODEC_config().

00335 {
00336     // Shut down DMA before Codec to prevent "pops".
00337     CODEC_setActiveState(COP_POWERDOWN);
00338     
00339     if(eMode & COP_POWERDOWN)
00340     {
00341         // Turn off DSP clock out, disable codec clock.
00342         CPLD_CODECClk(2);
00343     }
00344     
00345     else if( eMode & (COP_ILINK|COP_FMXMIT) )
00346     {
00347         /* Choose to use internal clock. */
00348         CPLD_CODECClk(1);
00349     }
00350     
00351     // Always use external clock else, thus to disable clock out pin and 
00352     // conserve power.
00353     else
00354     {
00355         /* Choose to use external clock. */
00356         CPLD_CODECClk(0);
00357     }
00358 
00359     switch(eMode)
00360     {
00361         //case COP_POWERDOWN:
00362             // Do NOT power down codec, thus to prevent power up pop.
00363         //  break;
00364 
00365         case COP_MIC_RECORD:
00366             //CODEC__spiWrite(AIC23REG_RESET);
00367             CODEC__spiWrite(AIC23REG_PWRDOWN | 0x069);
00368             CODEC__spiWrite(AIC23REG_APATH | 0x004);
00369             CODEC__spiWrite(AIC23REG_DPATH | 0x000);
00370             CODEC__spiWrite(AIC23REG_SRC | 0x23);
00371             CODEC__spiWrite(AIC23REG_DAUDIOI | 0x63);
00372             CODEC__spiWrite(AIC23REG_DIACTV | 0x01);
00373 
00374             //SYS_delayMicrosecond(200000);
00375             break; 
00376 
00377         case COP_TUNER_MIC:
00378             //CODEC__spiWrite(AIC23REG_RESET);
00379             CODEC__spiWrite(AIC23REG_PWRDOWN | 0x060);
00380             CODEC__spiWrite(AIC23REG_APATH | 0x0015);
00381             CODEC__spiWrite(AIC23REG_DPATH | 0x0001);
00382             CODEC__spiWrite(AIC23REG_SRC | 0x23);
00383             CODEC__spiWrite(AIC23REG_DAUDIOI | 0x63);
00384             CODEC__spiWrite(AIC23REG_DIACTV | 0x01);
00385             break;          
00386 
00387         case COP_AUTOSCAN:
00388             //CODEC__spiWrite(AIC23REG_RESET);
00389             CODEC__spiWrite(AIC23REG_PWRDOWN | 0x062);
00390             CODEC__spiWrite(AIC23REG_APATH | 0x012);
00391             CODEC__spiWrite(AIC23REG_DPATH | 0x000);
00392             CODEC__spiWrite(AIC23REG_SRC | 0x23);
00393             CODEC__spiWrite(AIC23REG_DAUDIOI | 0x63);
00394             CODEC__spiWrite(AIC23REG_LLNVOL | 0x11f);           
00395             // 0dB headphone output.
00396             CODEC__spiWrite(AIC23REG_LHDPHONE | 0x100 | 0x079);
00397             CODEC__spiWrite(AIC23REG_DIACTV | 0x01);
00398             break;
00399             
00400         case COP_TUNER:     
00401             //CODEC__spiWrite(AIC23REG_RESET);
00402             CODEC__spiWrite(AIC23REG_PWRDOWN | 0x062);
00403             CODEC__spiWrite(AIC23REG_APATH | 0x012);
00404             CODEC__spiWrite(AIC23REG_DPATH | 0x000);
00405             CODEC__spiWrite(AIC23REG_SRC | 0x23);
00406             CODEC__spiWrite(AIC23REG_DAUDIOI | 0x63);
00407             CODEC__spiWrite(AIC23REG_LLNVOL | 0x11f);           
00408             CODEC__spiWrite(AIC23REG_DIACTV | 0x01);
00409             break;
00410             
00411         case COP_LINE_RECORD:
00412             //CODEC__spiWrite(AIC23REG_RESET);
00413             CODEC__spiWrite(AIC23REG_PWRDOWN | 0x062);
00414             CODEC__spiWrite(AIC23REG_APATH | 0x012);
00415             CODEC__spiWrite(AIC23REG_DPATH | 0x000);
00416             CODEC__spiWrite(AIC23REG_SRC | 0x23);
00417             CODEC__spiWrite(AIC23REG_DAUDIOI | 0x63);
00418             CODEC__spiWrite(AIC23REG_LLNVOL | 0x117);           
00419             CODEC__spiWrite(AIC23REG_RLNVOL | 0x117);           
00420             // 0dB headphone output.
00421             CODEC__spiWrite(AIC23REG_LHDPHONE | 0x100 | 0x079);
00422             CODEC__spiWrite(AIC23REG_DIACTV | 0x01);
00423             break;
00424             
00425         case COP_FM_RECORD:
00426             //CODEC__spiWrite(AIC23REG_RESET);
00427             CODEC__spiWrite(AIC23REG_PWRDOWN | 0x062);
00428             CODEC__spiWrite(AIC23REG_APATH | 0x012);
00429             CODEC__spiWrite(AIC23REG_DPATH | 0x000);
00430             CODEC__spiWrite(AIC23REG_SRC | 0x23);
00431             CODEC__spiWrite(AIC23REG_DAUDIOI | 0x63);
00432             CODEC__spiWrite(AIC23REG_LLNVOL | 0x11f);           
00433             CODEC__spiWrite(AIC23REG_RLNVOL | 0x11f);           
00434             CODEC__spiWrite(AIC23REG_DIACTV | 0x01);
00435             break; 
00436             
00437         case COP_MUSIC:  
00438             //CODEC__spiWrite(AIC23REG_RESET);
00439             #ifdef MIXER_SUPPORT
00440             CODEC__spiWrite(AIC23REG_PWRDOWN | 0x061);
00441             CODEC__spiWrite(AIC23REG_APATH | 0x015);
00442             CODEC__spiWrite(AIC23REG_DPATH | 0x000);
00443             CODEC__spiWrite(AIC23REG_SRC | 0x23);
00444             CODEC__spiWrite(AIC23REG_DAUDIOI | 0x63);
00445             CODEC__spiWrite(AIC23REG_DIACTV | 0x01);
00446             #else
00447             CODEC__spiWrite(AIC23REG_PWRDOWN | 0x067);
00448             CODEC__spiWrite(AIC23REG_APATH | 0x012);
00449             CODEC__spiWrite(AIC23REG_DPATH | 0x000);
00450             CODEC__spiWrite(AIC23REG_SRC | 0x23);
00451             CODEC__spiWrite(AIC23REG_DAUDIOI | 0x63);
00452             CODEC__spiWrite(AIC23REG_DIACTV | 0x01);
00453             #endif
00454             break;
00455         
00456         case COP_ILINK:
00457             CODEC__spiWrite(AIC23REG_RESET);
00458             CODEC__spiWrite(AIC23REG_PWRDOWN | 0x062);
00459             CODEC__spiWrite(AIC23REG_APATH | 0x012);
00460             CODEC__spiWrite(AIC23REG_DPATH | 0x001);
00461             CODEC__spiWrite(AIC23REG_SRC | 0x3f);
00462             CODEC__spiWrite(AIC23REG_DAUDIOI | 0x43);
00463             CODEC__spiWrite(AIC23REG_LLNVOL | 0x17);            
00464             CODEC__spiWrite(AIC23REG_RLNVOL | 0x17);        
00465             CODEC__spiWrite(AIC23REG_DIACTV | 0x01);
00466             break;
00467                     
00468         case COP_FMXMIT:
00469             #ifdef MIXER_SUPPORT
00470             CODEC__spiWrite(AIC23REG_RESET);
00471             CODEC__spiWrite(AIC23REG_PWRDOWN | 0x061);
00472             CODEC__spiWrite(AIC23REG_APATH | 0x014);
00473             CODEC__spiWrite(AIC23REG_DPATH | 0x001);
00474             CODEC__spiWrite(AIC23REG_SRC | 0x3f);
00475             CODEC__spiWrite(AIC23REG_DAUDIOI | 0x43);
00476             CODEC__spiWrite(AIC23REG_LLNVOL | 0x17);            
00477             CODEC__spiWrite(AIC23REG_RLNVOL | 0x17);        
00478             CODEC__spiWrite(AIC23REG_LHDPHONE | 0x100);         
00479             CODEC__spiWrite(AIC23REG_RHDPHONE | 0x100);     
00480             CODEC__spiWrite(AIC23REG_DIACTV | 0x01);
00481             #else
00482             CODEC__spiWrite(AIC23REG_RESET);
00483             CODEC__spiWrite(AIC23REG_PWRDOWN | 0x062);
00484             CODEC__spiWrite(AIC23REG_APATH | 0x012);
00485             CODEC__spiWrite(AIC23REG_DPATH | 0x001);
00486             CODEC__spiWrite(AIC23REG_SRC | 0x3f);
00487             CODEC__spiWrite(AIC23REG_DAUDIOI | 0x43);
00488             CODEC__spiWrite(AIC23REG_LLNVOL | 0x17);            
00489             CODEC__spiWrite(AIC23REG_RLNVOL | 0x17);        
00490             CODEC__spiWrite(AIC23REG_LHDPHONE | 0x100);         
00491             CODEC__spiWrite(AIC23REG_RHDPHONE | 0x100);     
00492             CODEC__spiWrite(AIC23REG_DIACTV | 0x01);
00493             #endif
00494             break;
00495     }   
00496 }

Here is the call graph for this function:

void CODEC_setHandle PFPCMGET  getHdl,
PFPCMPUT  putHdl,
PFPCMDEC  decode,
PFPCMENC  encode
 

Function sets up the PCM get/put handle.

Parameters:
getHdl PCM get handle.
putHdl PCM put handle.
decode PCM decoder handle.
encode PCM encoder handle.

Definition at line 313 of file CODEC_config.c.

References st_PCM::decode, st_PCM::encode, st_PCM::newGetFunc, and st_PCM::newPutFunc.

Referenced by AUDIO_start().

00317 {
00318     if(getHdl)  Pcm.newGetFunc = getHdl;
00319     else        Pcm.newGetFunc = CODEC__defaultPcmGet;
00320     if(putHdl)  Pcm.newPutFunc = putHdl;
00321     else        Pcm.newPutFunc = CODEC__defaultPcmPut;
00322     if(decode)  Pcm.decode = decode;
00323     if(encode)  Pcm.encode = encode;
00324 }

void CODEC_tunerPcmGet int *  pcmBuf,
int  len
 

Function serves as the FM radio PCM data get handle.

Parameters:
pcmBuf PCM data buffer.
len Available PCM data length in words.

Definition at line 112 of file CODEC_radioHdl.c.

Referenced by AUDIO_start().

00113 {
00114     leftChannel  = pcmBuf;
00115     rightChannel = pcmBuf + len/2;
00116 }

void CODEC_tunerPcmPut int *  pcmBuf,
int  len
 

Function serves as the FM radio PCM data put handle.

Parameters:
pcmBuf PCM data buffer.
len Pending PCM data length in words.

Definition at line 46 of file CODEC_radioHdl.c.

References st_PCM::codecMode, COP_FM_RECORD, ENCODER_getInputBuf(), ENCODER_putInputBuf(), and st_AUDIOENERGY::pFrame.

Referenced by AUDIO_start().

00047 {
00048     unsigned int i;
00049     int          dataLen = len/2;
00050     int *        pSrcLeft;
00051     int *        pSrcRight;
00052     int *        pDstLeft;
00053     int *        pDstRight;
00054     int *        pEncDstLeft;
00055     int *        pEncDstRight;
00056     
00057     pSrcLeft  = leftChannel;
00058     pSrcRight = rightChannel;
00059     pDstLeft  = pcmBuf;
00060     pDstRight = pcmBuf + dataLen;
00061     
00062     if(COP_FM_RECORD&Pcm.codecMode)
00063     {
00064         if(FALSE == ENCODER_getInputBuf(&pEncDstLeft, &pEncDstRight))
00065         {
00066             // Encoder can not catch up.
00067             asm(" nop");
00068         }
00069     }
00070     else pEncDstLeft = NULL;
00071 
00072     for (i = 0; i < dataLen; i++)
00073     {
00074         FIRDeemphasisLeftTaps[0] = *pSrcLeft++;
00075         FIRDeemphasisRightTaps[0] = *pSrcRight++;
00076         // apply demphasis filter
00077         *pDstLeft = TUNER_deemphasisFIR(&FIRDeemphasisLeft);
00078         *pDstRight = TUNER_deemphasisFIR(&FIRDeemphasisRight);
00079         
00080         if(pEncDstLeft)
00081         {
00082             *pEncDstLeft++  = *pDstLeft;
00083             *pEncDstRight++ = *pDstRight;
00084             LeftInputEnergy.pFrame  = pDstRight;
00085             RightInputEnergy.pFrame = pDstLeft;
00086             AUDIO_energy(&LeftInputEnergy);
00087             AUDIO_energy(&RightInputEnergy);
00088         }       
00089         
00090         pDstLeft++;
00091         pDstRight++;
00092     }
00093     
00094     if(pEncDstLeft) ENCODER_putInputBuf();
00095     else
00096     {                   
00097         EQ_apply(&LeftEQ,  pcmBuf,  pcmBuf);
00098         pcmBuf += dataLen;
00099         EQ_apply(&RightEQ, pcmBuf,  pcmBuf);
00100     }
00101 }

Here is the call graph for this function:


Generated on Wed Jan 19 01:12:48 2005 for neuros-firmware by  doxygen 1.3.9.1