Skip to content

Commit b2dd1d0

Browse files
Maarten Zandersbroonie
authored andcommitted
ASoC: fsl_sai: Fix sync error in consumer mode
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: 51659ca ("ASoC: fsl-sai: set xCR4/xCR5/xMR for SAI master mode") Signed-off-by: Maarten Zanders <[email protected]> Reviewed-by: Shengjiu Wang <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent c8b8804 commit b2dd1d0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sound/soc/fsl/fsl_sai.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,12 +652,12 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream,
652652
val_cr4 |= FSL_SAI_CR4_CHMOD;
653653

654654
/*
655-
* For SAI provider mode, when Tx(Rx) sync with Rx(Tx) clock, Rx(Tx) will
656-
* generate bclk and frame clock for Tx(Rx), we should set RCR4(TCR4),
657-
* RCR5(TCR5) for playback(capture), or there will be sync error.
655+
* When Tx(Rx) sync with Rx(Tx) clock, Rx(Tx) will provide bclk and
656+
* frame clock for Tx(Rx). We should set RCR4(TCR4), RCR5(TCR5)
657+
* for playback(capture), or there will be sync error.
658658
*/
659659

660-
if (!sai->is_consumer_mode[tx] && fsl_sai_dir_is_synced(sai, adir)) {
660+
if (fsl_sai_dir_is_synced(sai, adir)) {
661661
regmap_update_bits(sai->regmap, FSL_SAI_xCR4(!tx, ofs),
662662
FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK |
663663
FSL_SAI_CR4_CHMOD_MASK,

0 commit comments

Comments
 (0)