Commit ce2f7b8d authored by Robert Hancock's avatar Robert Hancock Committed by Mark Brown

ASoC: simple-card-utils: Set sysclk on all components

If an mclk-fs value was provided in the device tree configuration, the
calculated MCLK was fed into the downstream codec DAI and CPU DAI,
however set_sysclk was not being called on the platform device. Some
platform devices such as the Xilinx Audio Formatter need to know the MCLK
as well.

Call snd_soc_component_set_sysclk on each component in the stream to set
the proper sysclk value in addition to the existing call of
snd_soc_dai_set_sysclk on the codec DAI and CPU DAI. This may end up
resulting in redundant calls if one of the snd_soc_dai_set_sysclk calls
ends up calling snd_soc_component_set_sysclk itself, but that isn't
expected to cause any significant harm.

Fixes: f48dcbb6 ("ASoC: simple-card-utils: share asoc_simple_hw_param()")
Signed-off-by: default avatarRobert Hancock <robert.hancock@calian.com>
Reviewed-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/20220120195832.1742271-5-robert.hancock@calian.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent c47aef89
...@@ -275,6 +275,7 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream, ...@@ -275,6 +275,7 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream,
mclk_fs = props->mclk_fs; mclk_fs = props->mclk_fs;
if (mclk_fs) { if (mclk_fs) {
struct snd_soc_component *component;
mclk = params_rate(params) * mclk_fs; mclk = params_rate(params) * mclk_fs;
for_each_prop_dai_codec(props, i, pdai) { for_each_prop_dai_codec(props, i, pdai) {
...@@ -282,16 +283,30 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream, ...@@ -282,16 +283,30 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream,
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
for_each_prop_dai_cpu(props, i, pdai) { for_each_prop_dai_cpu(props, i, pdai) {
ret = asoc_simple_set_clk_rate(pdai, mclk); ret = asoc_simple_set_clk_rate(pdai, mclk);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
/* Ensure sysclk is set on all components in case any
* (such as platform components) are missed by calls to
* snd_soc_dai_set_sysclk.
*/
for_each_rtd_components(rtd, i, component) {
ret = snd_soc_component_set_sysclk(component, 0, 0,
mclk, SND_SOC_CLOCK_IN);
if (ret && ret != -ENOTSUPP)
return ret;
}
for_each_rtd_codec_dais(rtd, i, sdai) { for_each_rtd_codec_dais(rtd, i, sdai) {
ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_IN); ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_IN);
if (ret && ret != -ENOTSUPP) if (ret && ret != -ENOTSUPP)
return ret; return ret;
} }
for_each_rtd_cpu_dais(rtd, i, sdai) { for_each_rtd_cpu_dais(rtd, i, sdai) {
ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_OUT); ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_OUT);
if (ret && ret != -ENOTSUPP) if (ret && ret != -ENOTSUPP)
......
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