Commit 485372dc authored by Bard Liao's avatar Bard Liao Committed by Mark Brown

ASoC: rt5670: Check sysclk source by private data

Currently, is_sys_clk_from_pll check sysclk source by reading codec
register value. And it will be invoked before updating dapm widget
power. In some machine driver, snd_soc_dai_set_sysclk is called in
dapm event to switch codec sysclk to RC clock in idle mode. And in
some use cases (such as syspend/resume) hw_params will not be called
when the dapm widget is powered up. As a result, is_sys_clk_from_pll
will return 0 although it is supposed to be 1.
To solve this, we let is_sys_clk_from_pll check sysclk sysclk_src
which is stored in private data and don't change the value of sysclk_src
when codec sysclk is switched to internal clock. The internal clock
can only be used in idle mode, so it sould be fine if we don't set
sysclk_src to internal clock.
Signed-off-by: default avatarBard Liao <bardliao@realtek.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent bd22f9d4
...@@ -517,11 +517,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, ...@@ -517,11 +517,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink) struct snd_soc_dapm_widget *sink)
{ {
unsigned int val; struct snd_soc_codec *codec = source->codec;
struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec);
val = snd_soc_read(source->codec, RT5670_GLB_CLK); if (rt5670->sysclk_src == RT5670_SCLK_S_PLL1)
val &= RT5670_SCLK_SRC_MASK;
if (val == RT5670_SCLK_SRC_PLL1)
return 1; return 1;
else else
return 0; return 0;
...@@ -2270,9 +2269,6 @@ static int rt5670_set_dai_sysclk(struct snd_soc_dai *dai, ...@@ -2270,9 +2269,6 @@ static int rt5670_set_dai_sysclk(struct snd_soc_dai *dai,
struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec);
unsigned int reg_val = 0; unsigned int reg_val = 0;
if (freq == rt5670->sysclk && clk_id == rt5670->sysclk_src)
return 0;
switch (clk_id) { switch (clk_id) {
case RT5670_SCLK_S_MCLK: case RT5670_SCLK_S_MCLK:
reg_val |= RT5670_SCLK_SRC_MCLK; reg_val |= RT5670_SCLK_SRC_MCLK;
...@@ -2290,6 +2286,7 @@ static int rt5670_set_dai_sysclk(struct snd_soc_dai *dai, ...@@ -2290,6 +2286,7 @@ static int rt5670_set_dai_sysclk(struct snd_soc_dai *dai,
snd_soc_update_bits(codec, RT5670_GLB_CLK, snd_soc_update_bits(codec, RT5670_GLB_CLK,
RT5670_SCLK_SRC_MASK, reg_val); RT5670_SCLK_SRC_MASK, reg_val);
rt5670->sysclk = freq; rt5670->sysclk = freq;
if (clk_id != RT5670_SCLK_S_RCCLK)
rt5670->sysclk_src = clk_id; rt5670->sysclk_src = clk_id;
dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment