Skip to contentSkip to conversation

ASoC: simple-card-utils: add sysclk ordering support

PATCH In review Stefano Radaelli 3 participants 3 messages Feb 13 – Feb 25

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 ASoC: simple-card-utils: add sysclk ordering support

From: Stefano Radaelli <[email protected]>

When simple-audio-card programs sysclk for CPU and codec DAIs during hw_params, the ordering of these calls may matter on some platforms.

Some CPU DAIs finalize or adjust the MCLK rate as part of their set_sysclk() callback (for example by calling clk_set_rate()). If the codec sysclk is configured before the CPU DAI applies the final MCLK rate, the codec may configure its internal clocking based on a non-final MCLK value.

Such situations can arise depending on the clock provider/consumer relationship between the CPU DAI and the codec.

Introduce an explicit sysclk ordering enum in simple-card-utils and use it to control the order of snd_soc_dai_set_sysclk() calls in the mclk-fs handling path. The default behaviour remains unchanged (codec-first) to avoid regressions.

---
v4:
- Removed SIMPLE_SYSCLK_ORDER_UNSPEC enum

v3:
- DT flag not applicable, not a hardware configuration
- Introduced enum to support order configuration

v2:
- Do not change the default sysclk ordering
- Make the ordering selectable via DT flag
- Add DT binding documentation

v1:
- Changed sysclk order, cpu first, then codec

 include/sound/simple_card_utils.h     |  6 ++++
 sound/soc/generic/simple-card-utils.c | 41 ++++++++++++++++++++-------
 2 files changed, 36 insertions(+), 11 deletions(-)
include/sound/simple_card_utils.h +6 -0
index 69a9c9c4d0e9..915e6ae5f68d 100644
@@ -54,6 +54,11 @@ struct prop_nums {
 	int platforms;
 };
 
+enum simple_util_sysclk_order {
+	SIMPLE_SYSCLK_ORDER_CODEC_FIRST = 0,
+	SIMPLE_SYSCLK_ORDER_CPU_FIRST,
+};
+
 struct simple_util_priv {
 	struct snd_soc_card snd_card;
 	struct simple_dai_props {
@@ -63,6 +68,7 @@ struct simple_util_priv {
 		struct snd_soc_codec_conf *codec_conf;
 		struct prop_nums num;
 		unsigned int mclk_fs;
+		enum simple_util_sysclk_order sysclk_order;
 	} *dai_props;
 	struct simple_util_jack hp_jack;
 	struct simple_util_jack mic_jack;
sound/soc/generic/simple-card-utils.c +30 -11

54 lines not on this page · raw message

base-commit: b7ff7151e653aa296ab6c5495b2c1ab7c21eb250

Signature · 1 line
2.47.3
maintainer Acked-by on v4 1/1
#1 lore raw

Hi Stefano

Quoted 14 lines

From: Stefano Radaelli <[email protected]>

When simple-audio-card programs sysclk for CPU and codec DAIs during hw_params, the ordering of these calls may matter on some platforms.

Some CPU DAIs finalize or adjust the MCLK rate as part of their set_sysclk() callback (for example by calling clk_set_rate()). If the codec sysclk is configured before the CPU DAI applies the final MCLK rate, the codec may configure its internal clocking based on a non-final MCLK value.

Such situations can arise depending on the clock provider/consumer relationship between the CPU DAI and the codec.

Quoted 7 lines

Introduce an explicit sysclk ordering enum in simple-card-utils and use it to control the order of snd_soc_dai_set_sysclk() calls in the mclk-fs handling path. The default behaviour remains unchanged (codec-first) to avoid regressions.

---

Thank you for your help !!

Best regards
---
Kuninori Morimoto

maintainer
#2 lore raw
In reply to Stefano Radaelli
Quoted 10 lines · Stefano Radaelli

When simple-audio-card programs sysclk for CPU and codec DAIs during hw_params, the ordering of these calls may matter on some platforms.

Some CPU DAIs finalize or adjust the MCLK rate as part of their set_sysclk() callback (for example by calling clk_set_rate()). If the codec sysclk is configured before the CPU DAI applies the final MCLK rate, the codec may configure its internal clocking based on a non-final MCLK value.

[...]

Applied to

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

Thanks!

[1/1] ASoC: simple-card-utils: add sysclk ordering support

      commit: d075cef4af6327a5de4bee7bf77591e3201e54f4

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