Commit 07541396 authored by Stephen Warren's avatar Stephen Warren Committed by Mark Brown

ASoC: Tegra: Don't return mclk_changed from utils_set_rate

Only the clock programming code needs to know whether the clocks changed,
and that is encapsulated within tegra_asoc_utils_set_rate(). The machine
driver's call to snd_soc_dai_set_sysclk(codec_dai, ...) is safe
irrespective of whether the clocks changed.

(Applying Mark's TrimSlice review comments to the existing driver)
Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
Acked-by: default avatarLiam Girdwood <lrg@ti.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent acb8303f
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
#include "tegra_asoc_utils.h" #include "tegra_asoc_utils.h"
int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
int mclk, int *mclk_change) int mclk)
{ {
int new_baseclock; int new_baseclock;
bool clk_change;
int err; int err;
switch (srate) { switch (srate) {
...@@ -52,10 +53,10 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, ...@@ -52,10 +53,10 @@ int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
return -EINVAL; return -EINVAL;
} }
*mclk_change = ((new_baseclock != data->set_baseclock) || clk_change = ((new_baseclock != data->set_baseclock) ||
(mclk != data->set_mclk)); (mclk != data->set_mclk));
if (!*mclk_change) if (!clk_change)
return 0; return 0;
data->set_baseclock = 0; data->set_baseclock = 0;
data->set_mclk = 0; data->set_mclk = 0;
......
...@@ -36,7 +36,7 @@ struct tegra_asoc_utils_data { ...@@ -36,7 +36,7 @@ struct tegra_asoc_utils_data {
}; };
int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate, int tegra_asoc_utils_set_rate(struct tegra_asoc_utils_data *data, int srate,
int mclk, int *mclk_change); int mclk);
int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data,
struct device *dev); struct device *dev);
void tegra_asoc_utils_fini(struct tegra_asoc_utils_data *data); void tegra_asoc_utils_fini(struct tegra_asoc_utils_data *data);
......
...@@ -72,7 +72,7 @@ static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream, ...@@ -72,7 +72,7 @@ static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_codec *codec = rtd->codec;
struct snd_soc_card *card = codec->card; struct snd_soc_card *card = codec->card;
struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
int srate, mclk, mclk_change; int srate, mclk;
int err; int err;
srate = params_rate(params); srate = params_rate(params);
...@@ -90,8 +90,7 @@ static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream, ...@@ -90,8 +90,7 @@ static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream,
while (mclk < 6000000) while (mclk < 6000000)
mclk *= 2; mclk *= 2;
err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk, err = tegra_asoc_utils_set_rate(&machine->util_data, srate, mclk);
&mclk_change);
if (err < 0) { if (err < 0) {
dev_err(card->dev, "Can't configure clocks\n"); dev_err(card->dev, "Can't configure clocks\n");
return err; return err;
...@@ -115,13 +114,11 @@ static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream, ...@@ -115,13 +114,11 @@ static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream,
return err; return err;
} }
if (mclk_change) { err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, SND_SOC_CLOCK_IN);
SND_SOC_CLOCK_IN); if (err < 0) {
if (err < 0) { dev_err(card->dev, "codec_dai clock not set\n");
dev_err(card->dev, "codec_dai clock not set\n"); return err;
return err;
}
} }
return 0; return 0;
......
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