static int mtk_capture_pcm_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; int ret = 0; AudDrv_Clk_On(); AudDrv_ADC_Clk_On(); VUL_Control_context = Get_Mem_ControlT(Soc_Aud_Digital_Block_MEM_VUL); // can allocate sram_dbg AfeControlSramLock(); if (GetSramState() == SRAM_STATE_FREE ) { printk("mtk_capture_pcm_open use sram \n"); mtk_capture_hardware.buffer_bytes_max = GetCaptureSramSize(); SetSramState(SRAM_STATE_CAPTURE); mCaptureUseSram = true; } else { printk("mtk_capture_pcm_open use dram \n"); mtk_capture_hardware.buffer_bytes_max = UL1_MAX_BUFFER_SIZE; } AfeControlSramUnLock(); runtime->hw = mtk_capture_hardware; memcpy((void *)(&(runtime->hw)), (void *)&mtk_capture_hardware , sizeof(struct snd_pcm_hardware)); ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_sample_rates); ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) { printk("snd_pcm_hw_constraint_integer failed\n"); } if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { } else { } if (ret < 0) { printk("mtk_capture_pcm_close\n"); mtk_capture_pcm_close(substream); return ret; } if(mCaptureUseSram == false) { AudDrv_Emi_Clk_On(); } printk("mtk_capture_pcm_open return\n"); return 0; }
static int mtk_voice_extint_pcm_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; int err = 0; int ret = 0; AudDrv_Clk_On(); AudDrv_ADC_Clk_On(); printk("mtk_voice_extint_pcm_open\n"); if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { printk("%s with SNDRV_PCM_STREAM_CAPTURE \n",__func__); runtime->rate = 16000; if(Voice_ExtInt_Status != 0) { return 0; } } runtime->hw = mtk_pcm_hardware; memcpy((void *)(&(runtime->hw)), (void *)&mtk_pcm_hardware , sizeof(struct snd_pcm_hardware)); ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_sample_rates); ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) { printk("snd_pcm_hw_constraint_integer failed\n"); } //print for hw pcm information printk("mtk_voice_extint_pcm_open runtime rate = %d channels = %d \n", runtime->rate, runtime->channels); runtime->hw.info |= SNDRV_PCM_INFO_INTERLEAVED; runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { printk("SNDRV_PCM_STREAM_PLAYBACK mtkalsa_voice_extint_constraints\n"); runtime->rate = 16000; } else { } if (err < 0) { printk("mtk_voice_extint_close\n"); mtk_voice_extint_close(substream); return err; } printk("mtk_voice_extint_pcm_open return\n"); return 0; }