Skip to content

Commit ed1220d

Browse files
TE-N-ShengjiuWangbroonie
authored andcommitted
ASoC: fsl_ssi: Fix bclk calculation for mono channel
For mono channel, SSI will switch to Normal mode. In Normal mode and Network mode, the Word Length Control bits control the word length divider in clock generator, which is different with I2S Master mode (the word length is fixed to 32bit), it should be the value of params_width(hw_params). The condition "slots == 2" is not good for I2S Master mode, because for Network mode and Normal mode, the slots can also be 2. Then we need to use (ssi->i2s_net & SSI_SCR_I2S_MODE_MASK) to check if it is I2S Master mode. So we refine the formula for mono channel, otherwise there will be sound issue for S24_LE. Fixes: b0a7043 ("ASoC: fsl_ssi: Caculate bit clock rate using slot number and width") Signed-off-by: Shengjiu Wang <[email protected]> Reviewed-by: Nicolin Chen <[email protected]> Link: https://lore.kernel.org/r/034eff1435ff6ce300b6c781130cefd9db22ab9a.1592276147.git.shengjiu.wang@nxp.com Signed-off-by: Mark Brown <[email protected]>
1 parent 4036d05 commit ed1220d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

sound/soc/fsl/fsl_ssi.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,9 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
678678
struct regmap *regs = ssi->regs;
679679
u32 pm = 999, div2, psr, stccr, mask, afreq, factor, i;
680680
unsigned long clkrate, baudrate, tmprate;
681-
unsigned int slots = params_channels(hw_params);
682-
unsigned int slot_width = 32;
681+
unsigned int channels = params_channels(hw_params);
682+
unsigned int slot_width = params_width(hw_params);
683+
unsigned int slots = 2;
683684
u64 sub, savesub = 100000;
684685
unsigned int freq;
685686
bool baudclk_is_used;
@@ -688,10 +689,14 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
688689
/* Override slots and slot_width if being specifically set... */
689690
if (ssi->slots)
690691
slots = ssi->slots;
691-
/* ...but keep 32 bits if slots is 2 -- I2S Master mode */
692-
if (ssi->slot_width && slots != 2)
692+
if (ssi->slot_width)
693693
slot_width = ssi->slot_width;
694694

695+
/* ...but force 32 bits for stereo audio using I2S Master Mode */
696+
if (channels == 2 &&
697+
(ssi->i2s_net & SSI_SCR_I2S_MODE_MASK) == SSI_SCR_I2S_MODE_MASTER)
698+
slot_width = 32;
699+
695700
/* Generate bit clock based on the slot number and slot width */
696701
freq = slots * slot_width * params_rate(hw_params);
697702

0 commit comments

Comments
 (0)