From 59f87e44a8faaef59969daadd1a7d295adbda3a0 Mon Sep 17 00:00:00 2001 From: Chen Liangjun Date: Thu, 16 Aug 2012 21:11:46 +0800 Subject: ENGR00220595 ESAI ASRC: add support for 'aplay *' When play audio in the way of aplay *, shutdown function would not be called and ASRC configuration would not be reconfigured. In this case, playback would sound noise. In this patch, put ASRC release operation into hw_free(). Signed-off-by: Chen Liangjun --- sound/soc/imx/imx-cs42888.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'sound') diff --git a/sound/soc/imx/imx-cs42888.c b/sound/soc/imx/imx-cs42888.c index c372587ecce9..11ba16511ce2 100644 --- a/sound/soc/imx/imx-cs42888.c +++ b/sound/soc/imx/imx-cs42888.c @@ -133,6 +133,14 @@ static void imx_3stack_shutdown(struct snd_pcm_substream *substream) struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct imx_pcm_runtime_data *iprtd = substream->runtime->private_data; + if (!cpu_dai->active) + hw_state.hw = 0; +} + +static int imx_3stack_surround_hw_free(struct snd_pcm_substream *substream) +{ + struct imx_pcm_runtime_data *iprtd = substream->runtime->private_data; + if (iprtd->asrc_enable) { if (iprtd->asrc_index != -1) { asrc_release_pair(iprtd->asrc_index); @@ -141,10 +149,8 @@ static void imx_3stack_shutdown(struct snd_pcm_substream *substream) iprtd->asrc_index = -1; } - if (!cpu_dai->active) - hw_state.hw = 0; + return 0; } - static int imx_3stack_surround_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -157,16 +163,17 @@ static int imx_3stack_surround_hw_params(struct snd_pcm_substream *substream, unsigned int lrclk_ratio = 0; int err = 0; - if (hw_state.hw) - return 0; - hw_state.hw = 1; - if (iprtd->asrc_enable) { err = config_asrc(substream, params); if (err < 0) return err; rate = iprtd->p2p->p2p_rate; } + + if (hw_state.hw) + return 0; + hw_state.hw = 1; + if (cpu_is_mx53() || machine_is_mx6q_sabreauto()) { switch (rate) { case 32000: @@ -276,6 +283,7 @@ static struct snd_soc_ops imx_3stack_surround_ops = { .startup = imx_3stack_startup, .shutdown = imx_3stack_shutdown, .hw_params = imx_3stack_surround_hw_params, + .hw_free = imx_3stack_surround_hw_free, }; static const struct snd_soc_dapm_widget imx_3stack_dapm_widgets[] = { -- cgit v1.2.3