diff mbox series

ASoC: fsl_sai: sw reset consumer on pause/stop

Message ID 20230921084808.840381-1-emas@bang-olufsen.dk
State New
Headers show
Series ASoC: fsl_sai: sw reset consumer on pause/stop | expand

Commit Message

Emil Abildgaard Svendsen Sept. 21, 2023, 8:48 a.m. UTC
When in consumer mode with BCLK disabled (FSL_SAI_CSR_BCE = 0) the
FIFO's can still contain data when resumed. It might also be possible
with BCLK enabled but just less likely.

When the FIFO's still contain data on resume it can cause channel
shifting on e.g. XRUNS. A Software Reset will reset the FIFO's and make
sure channels are aligned.

Fixes: 269f399dc19f ("ASoC: fsl_sai: Disable bit clock with transmitter")
Signed-off-by: Emil Svendsen <emas@bang-olufsen.dk>
---
 sound/soc/fsl/fsl_sai.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

Comments

Fabio Estevam Sept. 21, 2023, 2 p.m. UTC | #1
On Thu, Sep 21, 2023 at 5:48 AM Emil Abildgaard Svendsen
<EMAS@bang-olufsen.dk> wrote:
>
> When in consumer mode with BCLK disabled (FSL_SAI_CSR_BCE = 0) the
> FIFO's can still contain data when resumed. It might also be possible
> with BCLK enabled but just less likely.
>
> When the FIFO's still contain data on resume it can cause channel
> shifting on e.g. XRUNS. A Software Reset will reset the FIFO's and make
> sure channels are aligned.
>
> Fixes: 269f399dc19f ("ASoC: fsl_sai: Disable bit clock with transmitter")
> Signed-off-by: Emil Svendsen <emas@bang-olufsen.dk>

Reviewed-by: Fabio Estevam <festevam@gmail.com>
diff mbox series

Patch

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 1e4020fae05a..1da5c17cd329 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -730,13 +730,18 @@  static void fsl_sai_config_disable(struct fsl_sai *sai, int dir)
 	 * anymore. Add software reset to fix this issue.
 	 * This is a hardware bug, and will be fix in the
 	 * next sai version.
+	 *
+	 * When in consumer mode with BCLK disabled
+	 * (FSL_SAI_CSR_BCE = 0) the FIFO's can still contain
+	 * data when resumed. This can cause channel shifting
+	 * on e.g. XRUNS. A Software Reset will reset the
+	 * FIFO's and make sure the channels aren't shifted.
 	 */
-	if (!sai->is_consumer_mode) {
-		/* Software Reset */
-		regmap_write(sai->regmap, FSL_SAI_xCSR(tx, ofs), FSL_SAI_CSR_SR);
-		/* Clear SR bit to finish the reset */
-		regmap_write(sai->regmap, FSL_SAI_xCSR(tx, ofs), 0);
-	}
+
+	/* Software Reset */
+	regmap_write(sai->regmap, FSL_SAI_xCSR(tx, ofs), FSL_SAI_CSR_SR);
+	/* Clear SR bit to finish the reset */
+	regmap_write(sai->regmap, FSL_SAI_xCSR(tx, ofs), 0);
 }
 
 static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,