diff mbox series

ASoC: simple-card-utils: Unify clock direction by clk_direction

Message ID 87y10lu0gx.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State Accepted
Commit 5725bce709db1c001140d79398581e067e28c031
Headers show
Series ASoC: simple-card-utils: Unify clock direction by clk_direction | expand

Commit Message

Kuninori Morimoto Dec. 12, 2024, 1:57 a.m. UTC
Original sample-card assumes SND_SOC_CLOCK_IN is used for
snd_soc_dai_set_sysclk(), but someday, Codec uses SND_SOC_CLOCK_IN
and CPU uses SND_SOC_CLOCK_OUT at hw_params(), and dai->clk_direction
is used at simple_init_dai().

There is no uniformity today. Let's use dai->clk_direction for all cases.

Fortunately, almost all DAI doesn't care about "dir"
(= SND_SOC_CLOCK_IN/OUT) in .set_sysclk callback function (which is called
in snd_soc_dai_set_sysclk()), so this patch has no effect in such DAIs.

But this patch might breaks some existing Sound Card. Use
"system-clock-direction-out" property if it needs to use SND_SOC_CLOCK_OUT

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/generic/simple-card-utils.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Mark Brown Dec. 16, 2024, 3:12 p.m. UTC | #1
On Thu, 12 Dec 2024 01:57:55 +0000, Kuninori Morimoto wrote:
> Original sample-card assumes SND_SOC_CLOCK_IN is used for
> snd_soc_dai_set_sysclk(), but someday, Codec uses SND_SOC_CLOCK_IN
> and CPU uses SND_SOC_CLOCK_OUT at hw_params(), and dai->clk_direction
> is used at simple_init_dai().
> 
> There is no uniformity today. Let's use dai->clk_direction for all cases.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: simple-card-utils: Unify clock direction by clk_direction
      commit: 5725bce709db1c001140d79398581e067e28c031

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 6c5a1c5a6b3b2..a0c3111f7e08d 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -365,8 +365,7 @@  void simple_util_shutdown(struct snd_pcm_substream *substream)
 		struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, i);
 
 		if (props->mclk_fs && !dai->clk_fixed && !snd_soc_dai_active(cpu_dai))
-			snd_soc_dai_set_sysclk(cpu_dai,
-					       0, 0, SND_SOC_CLOCK_OUT);
+			snd_soc_dai_set_sysclk(cpu_dai, 0, 0, dai->clk_direction);
 
 		simple_clk_disable(dai);
 	}
@@ -374,8 +373,7 @@  void simple_util_shutdown(struct snd_pcm_substream *substream)
 		struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, i);
 
 		if (props->mclk_fs && !dai->clk_fixed && !snd_soc_dai_active(codec_dai))
-			snd_soc_dai_set_sysclk(codec_dai,
-					       0, 0, SND_SOC_CLOCK_IN);
+			snd_soc_dai_set_sysclk(codec_dai, 0, 0, dai->clk_direction);
 
 		simple_clk_disable(dai);
 	}
@@ -483,13 +481,15 @@  int simple_util_hw_params(struct snd_pcm_substream *substream,
 		}
 
 		for_each_rtd_codec_dais(rtd, i, sdai) {
-			ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_IN);
+			pdai = simple_props_to_dai_codec(props, i);
+			ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction);
 			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);
+			pdai = simple_props_to_dai_cpu(props, i);
+			ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction);
 			if (ret && ret != -ENOTSUPP)
 				return ret;
 		}