Skip to content

Commit 0669631

Browse files
arr-tommbroonie
authored andcommitted
ASoC: stm32_sai: fix incorrect BCLK polarity for DSP_A/B, LEFT_J
The STM32 SAI driver do not set the clock strobing bit (CKSTR) for DSP_A, DSP_B and LEFT_J formats, causing data to be sampled on the wrong BCLK edge when SND_SOC_DAIFMT_NB_NF is used. Per ALSA convention, NB_NF requires sampling on the rising BCLK edge. The STM32MP25 SAI reference manual states that CKSTR=1 is required for signals received by the SAI to be sampled on the SCK rising edge. Without setting CKSTR=1, the SAI samples on the falling edge, violating the NB_NF convention. For comparison, the NXP FSL SAI driver correctly sets FSL_SAI_CR2_BCP for DSP_A, DSP_B and LEFT_J, consistent with its I2S handling. This patch adds SAI_XCR1_CKSTR for DSP_A, DSP_B and LEFT_J in stm32_sai_set_dai_fmt which was verified empirically with a cs47l35 codec. RIGHT_J (LSB) is not investigated and addressed by this patch. Note: the STM32 I2S driver (stm32_i2s_set_dai_fmt) may have the same issue for DSP_A mode, as I2S_CGFR_CKPOL is not set. This has not been verified and is left for a separate investigation. Signed-off-by: Tomasz Merta <tommerta@gmail.com> Link: https://patch.msgid.link/20260408084056.20588-1-tommerta@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 0f71866 commit 0669631

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

sound/soc/stm/stm32_sai_sub.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,16 +802,19 @@ static int stm32_sai_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
802802
break;
803803
/* Left justified */
804804
case SND_SOC_DAIFMT_MSB:
805+
cr1 |= SAI_XCR1_CKSTR;
805806
frcr |= SAI_XFRCR_FSPOL | SAI_XFRCR_FSDEF;
806807
break;
807808
/* Right justified */
808809
case SND_SOC_DAIFMT_LSB:
809810
frcr |= SAI_XFRCR_FSPOL | SAI_XFRCR_FSDEF;
810811
break;
811812
case SND_SOC_DAIFMT_DSP_A:
813+
cr1 |= SAI_XCR1_CKSTR;
812814
frcr |= SAI_XFRCR_FSPOL | SAI_XFRCR_FSOFF;
813815
break;
814816
case SND_SOC_DAIFMT_DSP_B:
817+
cr1 |= SAI_XCR1_CKSTR;
815818
frcr |= SAI_XFRCR_FSPOL;
816819
break;
817820
default:

0 commit comments

Comments
 (0)