ASoC: fsl_ssi: Fix channel swap on playback start
Subsystems (3)
Fabio Estevam
reviewerPATCH 1/1 ASoC: fsl_ssi: Fix channel swap on playback start
From: Fabio Estevam <[email protected]>
Commit f8fdf5375e2005f2 ("ASoC: fsl-ssi: add SSIEN errata work around") implemented the workaround for the following erratum found on i.MX35 errata document:
ENGcm06222: SSI:Transmission does not take place in bit length early frame sync configuration
and also for ENGcm06222 from the same document.
However it has been only applied for AC97 mode. Apply it to I2S mode as well so that it can fix audio channel swap during playback start.
The channel swap can be noticed in about 10% of the times an audio track starts.
With the recommended workaround in place no more channel swap happened after running audio start/stop sequence in more than 2000 times.
Tested on a mx6dl-wandboard.
--- sound/soc/fsl/fsl_ssi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/fsl/fsl_ssi.c +6 -3
@@ -93,6 +93,9 @@ CCSR_SSI_SIER_TLS_EN | CCSR_SSI_SIER_TFS_EN | \ CCSR_SSI_SIER_TUE0_EN | CCSR_SSI_SIER_TFRC_EN) +#define FSLSSI_SSIEN_WORKAROUND (CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE | \ + CCSR_SSI_SCR_RE) +enum fsl_ssi_type {FSL_SSI_MCP8610 ,FSL_SSI_MX21 ,
@@ -559,7 +562,8 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,int i;int max_loop =100 ;regmap_update_bits (regs,CCSR_SSI_SCR , -CCSR_SSI_SCR_SSIEN ,CCSR_SSI_SCR_SSIEN ); +FSLSSI_SSIEN_WORKAROUND , +FSLSSI_SSIEN_WORKAROUND );for (i =0 ; i < max_loop; i++) {u32 sfcsr;regmap_read (regs,CCSR_SSI_SFCSR , &sfcsr);
@@ -650,8 +654,7 @@ static void fsl_ssi_setup_ac97(struct fsl_ssi_private *ssi_private)* codec before a stream is started. */ regmap_update_bits (regs,CCSR_SSI_SCR , -CCSR_SSI_SCR_SSIEN |CCSR_SSI_SCR_TE |CCSR_SSI_SCR_RE , -CCSR_SSI_SCR_SSIEN |CCSR_SSI_SCR_TE |CCSR_SSI_SCR_RE ); +FSLSSI_SSIEN_WORKAROUND ,FSLSSI_SSIEN_WORKAROUND );regmap_write (regs,CCSR_SSI_SOR ,CCSR_SSI_SOR_WAIT (3 )); }
Signature · 1 line
2.7.4
Nicolin Chen
reviewerQuoted 14 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Commit
f8fdf5375e2005f2("ASoC: fsl-ssi: add SSIEN errata work around") implemented the workaround for the following erratum found on i.MX35 errata document:ENGcm06222: SSI:Transmission does not take place in bit length early frame sync configuration
and also for ENGcm06222 from the same document.
However it has been only applied for AC97 mode. Apply it to I2S mode as well so that it can fix audio channel swap during playback start.
Quoted 8 lines
The channel swap can be noticed in about 10% of the times an audio track starts.
With the recommended workaround in place no more channel swap happened after running audio start/stop sequence in more than 2000 times.
Tested on a mx6dl-wandboard.
Hmm..so this bug also exists for imx6? I googled it and found that only imx25 and imx35 ring the bell. I forgot if they keep the same version for imx6 though.
Quoted 10 lines
Signed-off-by Fabio Estevam <[email protected]>--- sound/soc/fsl/fsl_ssi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)sound/soc/fsl/fsl_ssi.c +0
-0
sound/soc/fsl/fsl_ssi.c line 97
Quoted 5 lines
sound/soc/fsl/fsl_ssi.c +2
-0@@ -93,6 +93,9 @@ CCSR_SSI_SIER_TLS_EN | CCSR_SSI_SIER_TFS_EN | \ CCSR_SSI_SIER_TUE0_EN | CCSR_SSI_SIER_TFRC_EN) +#define FSLSSI_SSIEN_WORKAROUND (CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE | \ + CCSR_SSI_SCR_RE)
Enable RE??
sound/soc/fsl/fsl_ssi.c static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, · line 569
Quoted 13 lines
sound/soc/fsl/fsl_ssi.c +2
-1enum fsl_ssi_type {FSL_SSI_MCP8610 ,FSL_SSI_MX21 ,@@ -559,7 +562,8 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,int i;int max_loop =100 ;regmap_update_bits (regs,CCSR_SSI_SCR , -CCSR_SSI_SCR_SSIEN ,CCSR_SSI_SCR_SSIEN ); +FSLSSI_SSIEN_WORKAROUND , +FSLSSI_SSIEN_WORKAROUND );for (i =0 ; i < max_loop; i++) {u32 sfcsr;regmap_read (regs,CCSR_SSI_SFCSR , &sfcsr);
If this change is made, the whole "if (enable)" part here seems to be meaningless (or even worse) as it aimed to set TE later than SSIEN so as to offset the delay from DMA TX.
Check: https://patchwork.kernel.org/patch/9091051/
If this errata is mandatory, we probably should revert that the commit and find other solution/workaround for Arnaud and Caleb.
Fabio Estevam
reviewerHi Nicolin,
Quoted 4 lines · Nicolin Chen
sound/soc/fsl/fsl_ssi.c line 97
Quoted 2 lines
sound/soc/fsl/fsl_ssi.c +2
-0+#define FSLSSI_SSIEN_WORKAROUND (CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE | \ + CCSR_SSI_SCR_RE)Enable RE??
Yes, same idea as in f8fdf5375e2005f2 ("ASoC: fsl-ssi: add SSIEN errata work around").
The idea here was not to restrict the erratum to AC97 mode only.
Quoted 19 lines
Quoted 5 lines
enum fsl_ssi_type { FSL_SSI_MCP8610, FSL_SSI_MX21,sound/soc/fsl/fsl_ssi.c static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, · line 569
Quoted 9 lines
sound/soc/fsl/fsl_ssi.c +2
-1@@ -559,7 +562,8 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,int i;int max_loop =100 ;regmap_update_bits (regs,CCSR_SSI_SCR , -CCSR_SSI_SCR_SSIEN ,CCSR_SSI_SCR_SSIEN ); +FSLSSI_SSIEN_WORKAROUND , +FSLSSI_SSIEN_WORKAROUND );for (i =0 ; i < max_loop; i++) {u32 sfcsr;regmap_read (regs,CCSR_SSI_SFCSR , &sfcsr);If this change is made, the whole "if (enable)" part here seems to be meaningless (or even worse) as it aimed to set TE later than SSIEN so as to offset the delay from DMA TX.
Quoted 4 lines
Check: https://patchwork.kernel.org/patch/9091051/
If this errata is mandatory, we probably should revert that the commit and find other solution/workaround for Arnaud and Caleb.
Reverting 61fcf10a0ee44763e0 ("ASoC: fsl_ssi: Fix channel slipping in Playback at startup") still causes channel swaps on my tests, so better not to revert it.
Nicolin Chen
reviewerHi
Quoted 9 lines · Fabio Estevam
Quoted 4 lines
sound/soc/fsl/fsl_ssi.c line 97
Quoted 2 lines
sound/soc/fsl/fsl_ssi.c +2
-0+#define FSLSSI_SSIEN_WORKAROUND (CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE | \ + CCSR_SSI_SCR_RE)Enable RE??
Yes, same idea as in
f8fdf5375e2005f2("ASoC: fsl-ssi: add SSIEN errata work around").The idea here was not to restrict the erratum to AC97 mode only.
I understood. Just enabling RE anyway (for I2S) had confused me.
Quoted 15 lines
Quoted 15 lines
sound/soc/fsl/fsl_ssi.c static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable, · line 569
Quoted 10 lines
sound/soc/fsl/fsl_ssi.c +2
-1@@ -559,7 +562,8 @@ static void fsl_ssi_config(struct fsl_ssi_private *ssi_private, bool enable,int i;int max_loop =100 ;regmap_update_bits (regs,CCSR_SSI_SCR , -CCSR_SSI_SCR_SSIEN ,CCSR_SSI_SCR_SSIEN ); +FSLSSI_SSIEN_WORKAROUND , +FSLSSI_SSIEN_WORKAROUND );for (i =0 ; i < max_loop; i++) {u32 sfcsr;regmap_read (regs,CCSR_SSI_SFCSR , &sfcsr);If this change is made, the whole "if (enable)" part here seems to be meaningless (or even worse) as it aimed to set TE later than SSIEN so as to offset the delay from DMA TX.
Quoted 8 lines
Quoted 4 lines
Check: https://patchwork.kernel.org/patch/9091051/
If this errata is mandatory, we probably should revert that the commit and find other solution/workaround for Arnaud and Caleb.
Reverting
61fcf10a0ee44763e0("ASoC:fsl_ssi: Fix channel slipping in Playback at startup") still causes channel swaps on my tests, so better not to revert it.
That sounds weird to me. Prior to that commit, the code was setting SSIEN and TE at the same time if I am not wrong. You could try to revert it and check the SCR value before/after the last line:
regmap_update_bits(regs, CCSR_SSI_SCR, vals->scr, vals->scr);