]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00220595 ESAI ASRC: add support for 'aplay *'
authorChen Liangjun <b36089@freescale.com>
Thu, 16 Aug 2012 13:11:46 +0000 (21:11 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:35:15 +0000 (08:35 +0200)
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 <b36089@freescale.com>
sound/soc/imx/imx-cs42888.c

index c372587ecce97359190bcc335ce8b19fc171053a..11ba16511ce2881d2b7747ad7f92b9b806cea18b 100644 (file)
@@ -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[] = {