ASoC: codecs: es8316: Fix HW rate calculation for 48Mhz MCLK

BugLink: https://bugs.launchpad.net/bugs/2109640

[ Upstream commit 85c9ac7a56f731ecd59317c822cb6295464444cc ]

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 <posteuca@mutex.one>
Link: https://patch.msgid.link/20241227202751.244954-1-posteuca@mutex.one
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
Marian Postevca
2024-12-27 22:27:51 +02:00
committed by Stefan Bader
parent e6e885cb9f
commit 338aced5ee
+9 -1
View File
@@ -39,7 +39,9 @@ struct es8316_priv {
struct snd_soc_jack *jack;
int irq;
unsigned int sysclk;
unsigned int allowed_rates[ARRAY_SIZE(supported_mclk_lrck_ratios)];
/* ES83xx supports halving the MCLK so it supports twice as many rates
*/
unsigned int allowed_rates[ARRAY_SIZE(supported_mclk_lrck_ratios) * 2];
struct snd_pcm_hw_constraint_list sysclk_constraints;
bool jd_inverted;
};
@@ -386,6 +388,12 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai,
if (freq % ratio == 0)
es8316->allowed_rates[count++] = freq / ratio;
/* We also check if the halved MCLK produces a valid rate
* since the codec supports halving the MCLK.
*/
if ((freq / ratio) % 2 == 0)
es8316->allowed_rates[count++] = freq / ratio / 2;
}
if (count) {