[REBASED on r2-stable branch] audio:enable msic pll only if it is disabled
authorRamesh Babu K V <ramesh.babu@intel.com>
Fri, 11 Nov 2011 11:49:28 +0000 (17:19 +0530)
committerbuildbot <buildbot@intel.com>
Tue, 24 Jan 2012 10:35:10 +0000 (02:35 -0800)
BZ: 20940

old-BZ: 12022
MSIC PLL state needs to be checked before re-enabling it.
Disabling and re-enabling while stream is active would
cause undesirable effects/glitches.

This patch fixes the regression caused the patch:
6e50b8ed59528963db50e63e9dcf65f8a3d9adb3

old-Change-Id: Iaee8d3ea69e7bec0823123d7b919f0c7209f1812

Change-Id: I0256be9e1d3fdba946c458ab97c5581a8bf57310
Signed-off-by: Ramesh Babu K V <ramesh.babu@intel.com>
Reviewed-on: http://android.intel.com:8080/32715
Reviewed-by: M, Arulselvan <arulselvan.m@intel.com>
Tested-by: M, Arulselvan <arulselvan.m@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
sound/soc/codecs/sn95031.c
sound/soc/mid-x86/sst_platform.c

index ade0007..338da4e 100644 (file)
@@ -914,7 +914,7 @@ static int sn95031_pcm_spkr_mute(struct snd_soc_dai *dai, int mute)
 static int sn95031_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
                int source, unsigned int freq_in, unsigned int freq_out)
 {
-       int mode;
+       int mode, target_clk_src;
        struct snd_soc_codec *codec = codec_dai->codec;
        struct sn95031_priv *sn95031_ctx;
        sn95031_ctx = snd_soc_codec_get_drvdata(codec_dai->codec);
@@ -928,20 +928,21 @@ static int sn95031_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
                mutex_unlock(&codec->mutex);
                return 0;
        }
-       /* clock source is same, so don't do anything */
-       if (sn95031_ctx->clk_src == source) {
-               pr_debug("clk src is same, no action\n");
-               mutex_unlock(&codec->mutex);
-               return 0;
-       }
        mode = snd_soc_read(codec, SN95031_PCM1C3) >> 7;
        if (!mode && (!strcmp(codec_dai->name, "SN95031 Voice"))) {
-               sn95031_ctx->clk_src = SN95031_PCM1BCLK;
+               target_clk_src = SN95031_PCM1BCLK;
                snd_soc_write(codec, SN95031_PCM1C2, 0x04);
        } else {
-               sn95031_ctx->clk_src = SN95031_PLLIN;
+               target_clk_src = SN95031_PLLIN;
                snd_soc_write(codec, SN95031_PCM1C2, 0x00);
        }
+       /* clock source is same, so don't do anything */
+       if (sn95031_ctx->clk_src == target_clk_src) {
+               pr_debug("clk src is same, no action\n");
+               mutex_unlock(&codec->mutex);
+               return 0;
+       }
+       sn95031_ctx->clk_src = target_clk_src;
        if (codec->dapm.bias_level >= SND_SOC_BIAS_PREPARE) {
                pr_debug("bias_level is active, enabling pll\n");
                intel_sst_set_pll(true, SST_PLL_MSIC);
index e338dd7..1025903 100644 (file)
@@ -488,12 +488,14 @@ static int sst_platform_pcm_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_codec *codec = rtd->codec;
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
 
-       /* Force the data width to 24 bit in MSIC. Post Processing
-       algorithms in DSP enabled with 24 bit precision */
-       ret = snd_soc_codec_set_params(codec, SNDRV_PCM_FORMAT_S24_LE);
-       if (ret < 0) {
-               pr_debug("codec set_params returned error\n");
-               return ret;
+       if (strcmp(rtd->dai_link->cpu_dai_name, SST_VOICE_DAI)) {
+               /* Force the data width to 24 bit in MSIC. Post Processing
+               algorithms in DSP enabled with 24 bit precision */
+               ret = snd_soc_codec_set_params(codec, SNDRV_PCM_FORMAT_S24_LE);
+               if (ret < 0) {
+                       pr_debug("codec set_params returned error\n");
+                       return ret;
+               }
        }
        /*last two parameters have to non-zero, otherwise pll gets disabled*/
        snd_soc_dai_set_pll(codec_dai, 0, SST_CLK_UNINIT, 1,