Skip to content

Commit 18562fc

Browse files
macromorganbroonie
authored andcommitted
ASoC: es8328: Use rounded rate for es8328_set_sysclk()
I have a board (RK3588 based) that sets the sysclk to 12287999. The es8328 driver fails to match this to the 12288000 rate and fails to load. Allow the rate comparison to work if the frequency is within 100hz by dividing it by 100 and rounding it, then multiplying it back by 100. Note the 100hz value was chosen arbitrarily by me, but it has only been tested with a 1hz difference. Signed-off-by: Chris Morgan <macromorgan@hotmail.com> Link: https://lore.kernel.org/r/20231020171539.65513-1-macroalpha82@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f1c4068 commit 18562fc

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

sound/soc/codecs/es8328.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,15 @@ static int es8328_set_sysclk(struct snd_soc_dai *codec_dai,
556556
struct snd_soc_component *component = codec_dai->component;
557557
struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component);
558558
int mclkdiv2 = 0;
559+
unsigned int round_freq;
559560

560-
switch (freq) {
561+
/*
562+
* Allow a small tolerance for frequencies within 100hz. Note
563+
* this value is chosen arbitrarily.
564+
*/
565+
round_freq = DIV_ROUND_CLOSEST(freq, 100) * 100;
566+
567+
switch (round_freq) {
561568
case 0:
562569
es8328->sysclk_constraints = NULL;
563570
es8328->mclk_ratios = NULL;

0 commit comments

Comments
 (0)