* [PATCH] ASoC: fsl_sai: Fix sync error in consumer mode
@ 2025-10-24 13:57 Maarten Zanders
2025-10-27 5:39 ` Shengjiu Wang
2025-10-28 16:42 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Maarten Zanders @ 2025-10-24 13:57 UTC (permalink / raw)
To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Zidan Wang
Cc: Maarten Zanders, linux-sound, linuxppc-dev, linux-kernel
When configured for default synchronisation (Rx syncs to Tx) and the
SAI operates in consumer mode (clocks provided externally to Tx), a
synchronisation error occurs on Tx on the first attempt after device
initialisation when the playback stream is started while a capture
stream is already active. This results in channel shift/swap on the
playback stream.
Subsequent streams (ie after that first failing one) always work
correctly, no matter the order, with or without the other stream active.
This issue was observed (and fix tested) on an i.MX6UL board connected
to an ADAU1761 codec, where the codec provides both frame and bit clock
(connected to TX pins).
To fix this, always initialize the 'other' xCR4 and xCR5 registers when
we're starting a stream which is synced to the opposite one, irregardless
of the producer/consumer status.
Fixes: 51659ca069ce ("ASoC: fsl-sai: set xCR4/xCR5/xMR for SAI master mode")
Signed-off-by: Maarten Zanders <maarten@zanders.be>
---
sound/soc/fsl/fsl_sai.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 757e7868e322..178a6e8fbe2c 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -653,12 +653,12 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
val_cr4 |= FSL_SAI_CR4_CHMOD;
/*
- * For SAI provider mode, when Tx(Rx) sync with Rx(Tx) clock, Rx(Tx) will
- * generate bclk and frame clock for Tx(Rx), we should set RCR4(TCR4),
- * RCR5(TCR5) for playback(capture), or there will be sync error.
+ * When Tx(Rx) sync with Rx(Tx) clock, Rx(Tx) will provide bclk and
+ * frame clock for Tx(Rx). We should set RCR4(TCR4), RCR5(TCR5)
+ * for playback(capture), or there will be sync error.
*/
- if (!sai->is_consumer_mode[tx] && fsl_sai_dir_is_synced(sai, adir)) {
+ if (fsl_sai_dir_is_synced(sai, adir)) {
regmap_update_bits(sai->regmap, FSL_SAI_xCR4(!tx, ofs),
FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK |
FSL_SAI_CR4_CHMOD_MASK,
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ASoC: fsl_sai: Fix sync error in consumer mode
2025-10-24 13:57 [PATCH] ASoC: fsl_sai: Fix sync error in consumer mode Maarten Zanders
@ 2025-10-27 5:39 ` Shengjiu Wang
2025-10-28 16:42 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Shengjiu Wang @ 2025-10-27 5:39 UTC (permalink / raw)
To: Maarten Zanders
Cc: Xiubo Li, Fabio Estevam, Nicolin Chen, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, Zidan Wang, linux-sound,
linuxppc-dev, linux-kernel
On Fri, Oct 24, 2025 at 9:58 PM Maarten Zanders <maarten@zanders.be> wrote:
>
> When configured for default synchronisation (Rx syncs to Tx) and the
> SAI operates in consumer mode (clocks provided externally to Tx), a
> synchronisation error occurs on Tx on the first attempt after device
> initialisation when the playback stream is started while a capture
> stream is already active. This results in channel shift/swap on the
> playback stream.
> Subsequent streams (ie after that first failing one) always work
> correctly, no matter the order, with or without the other stream active.
>
> This issue was observed (and fix tested) on an i.MX6UL board connected
> to an ADAU1761 codec, where the codec provides both frame and bit clock
> (connected to TX pins).
>
> To fix this, always initialize the 'other' xCR4 and xCR5 registers when
> we're starting a stream which is synced to the opposite one, irregardless
> of the producer/consumer status.
>
> Fixes: 51659ca069ce ("ASoC: fsl-sai: set xCR4/xCR5/xMR for SAI master mode")
>
> Signed-off-by: Maarten Zanders <maarten@zanders.be>
Reviewed-by: Shengjiu Wang <shengjiu.wang@gmail.com>
Best regards
Shengjiu wang
> ---
> sound/soc/fsl/fsl_sai.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
> index 757e7868e322..178a6e8fbe2c 100644
> --- a/sound/soc/fsl/fsl_sai.c
> +++ b/sound/soc/fsl/fsl_sai.c
> @@ -653,12 +653,12 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
> val_cr4 |= FSL_SAI_CR4_CHMOD;
>
> /*
> - * For SAI provider mode, when Tx(Rx) sync with Rx(Tx) clock, Rx(Tx) will
> - * generate bclk and frame clock for Tx(Rx), we should set RCR4(TCR4),
> - * RCR5(TCR5) for playback(capture), or there will be sync error.
> + * When Tx(Rx) sync with Rx(Tx) clock, Rx(Tx) will provide bclk and
> + * frame clock for Tx(Rx). We should set RCR4(TCR4), RCR5(TCR5)
> + * for playback(capture), or there will be sync error.
> */
>
> - if (!sai->is_consumer_mode[tx] && fsl_sai_dir_is_synced(sai, adir)) {
> + if (fsl_sai_dir_is_synced(sai, adir)) {
> regmap_update_bits(sai->regmap, FSL_SAI_xCR4(!tx, ofs),
> FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK |
> FSL_SAI_CR4_CHMOD_MASK,
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ASoC: fsl_sai: Fix sync error in consumer mode
2025-10-24 13:57 [PATCH] ASoC: fsl_sai: Fix sync error in consumer mode Maarten Zanders
2025-10-27 5:39 ` Shengjiu Wang
@ 2025-10-28 16:42 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2025-10-28 16:42 UTC (permalink / raw)
To: Shengjiu Wang, Xiubo Li, Fabio Estevam, Nicolin Chen,
Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Zidan Wang,
Maarten Zanders
Cc: linux-sound, linuxppc-dev, linux-kernel
On Fri, 24 Oct 2025 15:57:15 +0200, Maarten Zanders wrote:
> When configured for default synchronisation (Rx syncs to Tx) and the
> SAI operates in consumer mode (clocks provided externally to Tx), a
> synchronisation error occurs on Tx on the first attempt after device
> initialisation when the playback stream is started while a capture
> stream is already active. This results in channel shift/swap on the
> playback stream.
> Subsequent streams (ie after that first failing one) always work
> correctly, no matter the order, with or without the other stream active.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: fsl_sai: Fix sync error in consumer mode
commit: b2dd1d0d322dce5f331961c927e775b84014d5ab
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-28 16:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-24 13:57 [PATCH] ASoC: fsl_sai: Fix sync error in consumer mode Maarten Zanders
2025-10-27 5:39 ` Shengjiu Wang
2025-10-28 16:42 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).