Skip to content

Commit 85c9ac7

Browse files
Marian Postevcabroonie
authored andcommitted
ASoC: codecs: es8316: Fix HW rate calculation for 48Mhz MCLK
For 48Mhz MCLK systems the calculation of the HW rate is broken, and will not produce even one sane rate. Since es83xx supports the option to halve MCLK, calculate also rates with MCLK/2. Signed-off-by: Marian Postevca <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 5ed0115 commit 85c9ac7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sound/soc/codecs/es8316.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ struct es8316_priv {
3939
struct snd_soc_jack *jack;
4040
int irq;
4141
unsigned int sysclk;
42-
unsigned int allowed_rates[ARRAY_SIZE(supported_mclk_lrck_ratios)];
42+
/* ES83xx supports halving the MCLK so it supports twice as many rates
43+
*/
44+
unsigned int allowed_rates[ARRAY_SIZE(supported_mclk_lrck_ratios) * 2];
4345
struct snd_pcm_hw_constraint_list sysclk_constraints;
4446
bool jd_inverted;
4547
};
@@ -386,6 +388,12 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai,
386388

387389
if (freq % ratio == 0)
388390
es8316->allowed_rates[count++] = freq / ratio;
391+
392+
/* We also check if the halved MCLK produces a valid rate
393+
* since the codec supports halving the MCLK.
394+
*/
395+
if ((freq / ratio) % 2 == 0)
396+
es8316->allowed_rates[count++] = freq / ratio / 2;
389397
}
390398

391399
if (count) {

0 commit comments

Comments
 (0)