static int HandleControlCommand(void) { AUDCTRL_SPEAKER_t spkr; switch(sgBrcm_auddrv_TestValues[1]) { case 1:// Initialize the audio controller { DEBUG(" Audio Controller Init\n"); AUDCTRL_Init (); DEBUG(" Audio Controller Init Complete\n"); } break; case 2:// Start Hw loopback { DEBUG(" Audio Loopback start\n"); spkr = sgBrcm_auddrv_TestValues[2]; AUDCTRL_SetAudioLoopback(1,AUDCTRL_MIC_MAIN,spkr); DEBUG(" Audio loopback started\n"); } break; case 3:// Dump registers { DEBUG(" Dump registers\n"); dump_audio_registers(); DEBUG(" Dump registers done \n"); } break; case 4:// Enable telephony { DEBUG(" Enable telephony\n"); AUDCTRL_EnableTelephony(AUDIO_HW_VOICE_IN,AUDIO_HW_VOICE_OUT,AUDCTRL_MIC_MAIN,AUDCTRL_SPK_HANDSET); DEBUG(" Telephony enabled \n"); } break; case 5:// Disable telephony { DEBUG(" Disable telephony\n"); AUDCTRL_DisableTelephony(AUDIO_HW_VOICE_IN,AUDIO_HW_VOICE_OUT,AUDCTRL_MIC_MAIN,AUDCTRL_SPK_HANDSET); DEBUG(" Telephony disabled \n"); } break; case 6:// switch to EP { UInt8* ahb_au_base; ahb_au_base = (UInt8*)ahb_audio_base; DEBUG(" switch to EP\n"); *((volatile UInt16 *)(ahb_au_base+DSP_AUDIO_MIXER_INPUT_SEL_R_OFFSET)) = 0x0000; *((volatile UInt16 *)(ahb_au_base+DSP_AUDIO_MIXER_INPUT_SEL_R_OFFSET)) = 0x4003; *((volatile UInt32 *) (SYSCFG_BASE_ADDR+SYSCFG_ANACR0_OFFSET)) = 0x000060ca; DEBUG(" switch to EP done \n"); } break; case 7:// switch to speaker { UInt8* ahb_au_base; ahb_au_base = (UInt8*)ahb_audio_base; DEBUG(" switch to SP\n"); *((volatile UInt16 *)(ahb_au_base+DSP_AUDIO_MIXER_INPUT_SEL_R_OFFSET)) = 0x4000; *((volatile UInt16 *)(ahb_au_base+DSP_AUDIO_MIXER_INPUT_SEL_R_OFFSET)) = 0x0003; *((volatile UInt32 *) (SYSCFG_BASE_ADDR+SYSCFG_ANACR0_OFFSET)) = 0x000060d4; DEBUG(" switch to SP done \n"); } break; default: DEBUG(" Invalid Control Command\n"); } return 0; }
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++ * * Function Name: PcmDeviceNew * * Description: Create PCM playback and capture device * *------------------------------------------------------------ */ int __devinit PcmDeviceNew(struct snd_card *card) { struct snd_pcm *pcm; int err = 0; brcm_alsa_chip_t *pChip; struct snd_pcm_substream *substream; callMode = CALL_MODE_NONE; err = snd_pcm_new(card, "Broadcom CAPH", 0, NUM_PLAYBACK_SUBDEVICE, NUM_CAPTURE_SUBDEVICE, &pcm); if (err < 0) return err; pcm->private_data = card->private_data; strcpy(pcm->name, "Broadcom CAPH PCM"); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &brcm_alsa_omx_pcm_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &brcm_alsa_omx_pcm_capture_ops); pcm->info_flags = 0; /*pre-allocate memory for playback device */ substream = pcm->streams[0].substream; for (; substream; substream = substream->next) { err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, 0, (IS_PCM_MEM_PREALLOCATED) ? PCM_MAX_PLAYBACK_BUF_BYTES : 0, PCM_MAX_PLAYBACK_BUF_BYTES); if (err) aError ("\n Error : Error when allocate memory for" " playback device err=%d\n", err); } /*pre-allocate memory for capture device */ substream = pcm->streams[1].substream; for (; substream; substream = substream->next) { err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV, 0, (IS_PCM_MEM_PREALLOCATED) ? PCM_MAX_CAPTURE_BUF_BYTES : 0, PCM_MAX_CAPTURE_BUF_BYTES); if (err) aError ("\n Error : Error when allocate memory for" " capture device err=%d\n", err); } pChip = (brcm_alsa_chip_t *) card->private_data; /* Initialize the audio controller */ aTrace(LOG_ALSA_INTERFACE, "ALSA-CAPH PcmDeviceNew:call AUDIO_Init\n"); caph_audio_init(); #if defined(CONFIG_BCM_MODEM) DSPDRV_Init(); #endif AUDCTRL_Init(); #if defined(DYNAMIC_DMA_PLAYBACK) spin_lock_init(©_lock); #endif aTrace(LOG_ALSA_INTERFACE, "\n PcmDeviceNew : PcmDeviceNew err=%d\n", err); return err; }