From 057ecfb8c695e32044a171a6ee30652f4b5a265a Mon Sep 17 00:00:00 2001 From: Zidan Wang Date: Thu, 19 Mar 2015 13:01:16 +0800 Subject: MLK-10442 ASoC: imx-wm8960: PLL should be disable only when no stream playback or capture The second stream will disable PLL, and will affect the first stream. Signed-off-by: Zidan Wang --- sound/soc/fsl/imx-wm8960.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'sound') diff --git a/sound/soc/fsl/imx-wm8960.c b/sound/soc/fsl/imx-wm8960.c index e0aa9399470a..e41114222d0c 100644 --- a/sound/soc/fsl/imx-wm8960.c +++ b/sound/soc/fsl/imx-wm8960.c @@ -35,6 +35,7 @@ struct imx_wm8960_data { struct clk *codec_clk; unsigned int clk_frequency; bool is_codec_master; + bool stream[2]; }; struct imx_priv { @@ -42,6 +43,7 @@ struct imx_priv { struct platform_device *pdev; struct snd_card *snd_card; }; + static struct imx_priv card_priv; /* -1 for reserved value */ @@ -64,6 +66,7 @@ static int imx_hifi_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_card *card = codec_dai->codec->card; struct imx_wm8960_data *data = snd_soc_card_get_drvdata(card); + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; struct device *dev = card->dev; unsigned int sample_rate = params_rate(params); unsigned int sysclk, pll_out; @@ -73,6 +76,11 @@ static int imx_hifi_hw_params(struct snd_pcm_substream *substream, if (params_channels(params) == 1) bclk *= 2; + data->stream[tx] = true; + + if (data->stream[tx] && data->stream[!tx]) + return 0; + /* set cpu DAI configuration */ ret = snd_soc_dai_set_fmt(cpu_dai, data->dai.dai_fmt); if (ret) { @@ -174,9 +182,12 @@ static int imx_hifi_hw_free(struct snd_pcm_substream *substream) struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_card *card = codec_dai->codec->card; struct imx_wm8960_data *data = snd_soc_card_get_drvdata(card); + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; + + data->stream[tx] = false; /* Power down PLL to save power*/ - if (data->is_codec_master) + if (data->is_codec_master && !data->stream[tx] && !data->stream[!tx]) snd_soc_dai_set_pll(codec_dai, 0, 0, 0, 0); return 0; -- cgit v1.2.3