Skip to contentSkip to conversation

ASoC: fsl_sai: Constrain sample rates from audio PLLs only in master mode

PATCH In review Chancel Liu 3 participants 3 messages Dec 10, 2025 – Dec 15, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: fsl_sai: Constrain sample rates from audio PLLs only in master mode

If SAI works in master mode it will generate clocks for external codec from audio PLLs. Thus sample rates should be constrained according to audio PLL clocks. While SAI works in slave mode which means clocks are generated externally then constraints are independent of audio PLLs.

Fixes 4edc98598be4 ("ASoC: fsl_sai: Add sample rate constraint")
---
 sound/soc/fsl/fsl_sai.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/soc/fsl/fsl_sai.c +8 -2
index 72bfc91e21b9..86730c214914 100644
@@ -917,8 +917,14 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream,
 					   tx ? sai->dma_params_tx.maxburst :
 					   sai->dma_params_rx.maxburst);
 
-	ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
-					 SNDRV_PCM_HW_PARAM_RATE, &sai->constraint_rates);
+	if (sai->is_consumer_mode[tx])
+		ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
+						 SNDRV_PCM_HW_PARAM_RATE,
+						 &fsl_sai_rate_constraints);
+	else
+		ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
+						 SNDRV_PCM_HW_PARAM_RATE,
+						 &sai->constraint_rates);
 
 	return ret;
 }
Signature · 1 line
2.50.1
maintainer
#1 lore raw
Quoted 17 lines · Chancel Liu

If SAI works in master mode it will generate clocks for external codec from audio PLLs. Thus sample rates should be constrained according to audio PLL clocks. While SAI works in slave mode which means clocks are generated externally then constraints are independent of audio PLLs.

Fixes 4edc98598be4 ("ASoC: fsl_sai: Add sample rate constraint")
---
 sound/soc/fsl/fsl_sai.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
sound/soc/fsl/fsl_sai.c +0 -0
index 72bfc91e21b9..86730c214914 100644

sound/soc/fsl/fsl_sai.c static int fsl_sai_startup(struct snd_pcm_substream *substream, · line 920

Quoted 6 lines
sound/soc/fsl/fsl_sai.c +1 -2
@@ -917,8 +917,14 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream,
                                           tx ? sai->dma_params_tx.maxburst :
                                           sai->dma_params_rx.maxburst);
 
-       ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
-                                        SNDRV_PCM_HW_PARAM_RATE, &sai->constraint_rates);
+       if (sai->is_consumer_mode[tx])

The sai->is_consumer_mode[tx] can be changed after startup(), then there may be an issue for the constraint.

It looks like there is no perfect solution here.

Best regards
Shengjiu Wang

Quoted 13 lines
sound/soc/fsl/fsl_sai.c +7 -1
+               ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
+                                                SNDRV_PCM_HW_PARAM_RATE,
+                                                &fsl_sai_rate_constraints);
+       else
+               ret = snd_pcm_hw_constraint_list(substream->runtime, 0,
+                                                SNDRV_PCM_HW_PARAM_RATE,
+                                                &sai->constraint_rates);
 
        return ret;
 }
--

2.50.1

maintainer
#2 lore raw
In reply to Chancel Liu
Quoted 6 lines · Chancel Liu

If SAI works in master mode it will generate clocks for external codec from audio PLLs. Thus sample rates should be constrained according to audio PLL clocks. While SAI works in slave mode which means clocks are generated externally then constraints are independent of audio PLLs.

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: fsl_sai: Constrain sample rates from audio PLLs only in master mode

      commit: 9f4d0899efd9892fc7514c9488270e1bb7dedd2b

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