Devicetree
 help / color / mirror / Atom feed
From: Robert Hancock <robert.hancock@calian.com>
To: alsa-devel@alsa-project.org
Cc: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org,
	perex@perex.cz, tiwai@suse.com, michal.simek@xilinx.com,
	kuninori.morimoto.gx@renesas.com,
	maruthi.srinivas.bayyavarapu@xilinx.com,
	devicetree@vger.kernel.org,
	Robert Hancock <robert.hancock@calian.com>
Subject: [PATCH v3 4/6] ASoC: simple-card-utils: Set sysclk on all components
Date: Thu, 20 Jan 2022 13:58:30 -0600	[thread overview]
Message-ID: <20220120195832.1742271-5-robert.hancock@calian.com> (raw)
In-Reply-To: <20220120195832.1742271-1-robert.hancock@calian.com>

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: f48dcbb6d47d ("ASoC: simple-card-utils: share asoc_simple_hw_param()")
Signed-off-by: Robert Hancock <robert.hancock@calian.com>
---
 sound/soc/generic/simple-card-utils.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index a81323d1691d..9736102e6808 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -275,6 +275,7 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream,
 		mclk_fs = props->mclk_fs;
 
 	if (mclk_fs) {
+		struct snd_soc_component *component;
 		mclk = params_rate(params) * mclk_fs;
 
 		for_each_prop_dai_codec(props, i, pdai) {
@@ -282,16 +283,30 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream,
 			if (ret < 0)
 				return ret;
 		}
+
 		for_each_prop_dai_cpu(props, i, pdai) {
 			ret = asoc_simple_set_clk_rate(pdai, mclk);
 			if (ret < 0)
 				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) {
 			ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_IN);
 			if (ret && ret != -ENOTSUPP)
 				return ret;
 		}
+
 		for_each_rtd_cpu_dais(rtd, i, sdai) {
 			ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_OUT);
 			if (ret && ret != -ENOTSUPP)
-- 
2.31.1


  parent reply	other threads:[~2022-01-20 19:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20 19:58 [PATCH v3 0/6] ASoC: Xilinx fixes Robert Hancock
2022-01-20 19:58 ` [PATCH v3 1/6] ASoC: xilinx: xlnx_formatter_pcm: Handle sysclk setting Robert Hancock
2022-01-20 19:58 ` [PATCH v3 2/6] ASoC: xilinx: xlnx_i2s: create drvdata structure Robert Hancock
2022-01-21  9:06   ` Amadeusz Sławiński
2022-01-21 17:26     ` Robert Hancock
2022-01-20 19:58 ` [PATCH v3 3/6] ASoC: xilinx: xlnx_i2s: Handle sysclk setting Robert Hancock
2022-01-20 19:58 ` Robert Hancock [this message]
2022-01-21  0:24   ` [PATCH v3 4/6] ASoC: simple-card-utils: Set sysclk on all components Kuninori Morimoto
2022-01-20 19:58 ` [PATCH v3 5/6] ASoC: dt-bindings: simple-card: document new system-clock-fixed flag Robert Hancock
2022-01-20 19:58 ` [PATCH v3 6/6] ASoC: simple-card-utils: Add " Robert Hancock
2022-01-25 10:20 ` [PATCH v3 0/6] ASoC: Xilinx fixes Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220120195832.1742271-5-robert.hancock@calian.com \
    --to=robert.hancock@calian.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=maruthi.srinivas.bayyavarapu@xilinx.com \
    --cc=michal.simek@xilinx.com \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox