diff mbox series

ASoC: es8328: Use rounded rate for es8328_set_sysclk()

Message ID 20231020171539.65513-1-macroalpha82@gmail.com
State New
Headers show
Series ASoC: es8328: Use rounded rate for es8328_set_sysclk() | expand

Commit Message

Chris Morgan Oct. 20, 2023, 5:15 p.m. UTC
From: Chris Morgan <macromorgan@hotmail.com>

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>
---
 sound/soc/codecs/es8328.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Mark Brown Oct. 24, 2023, 1:55 p.m. UTC | #1
On Fri, 20 Oct 2023 12:15:39 -0500, Chris Morgan wrote:
> 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.
> 
> [...]

Applied to

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

Thanks!

[1/1] ASoC: es8328: Use rounded rate for es8328_set_sysclk()
      commit: 18562fc36c21d572582049e6259c43bf1a01f3e0

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
diff mbox series

Patch

diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c
index 0bd9ba5a11b4..22e7a9312732 100644
--- a/sound/soc/codecs/es8328.c
+++ b/sound/soc/codecs/es8328.c
@@ -557,8 +557,15 @@  static int es8328_set_sysclk(struct snd_soc_dai *codec_dai,
 	struct snd_soc_component *component = codec_dai->component;
 	struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component);
 	int mclkdiv2 = 0;
+	unsigned int round_freq;
 
-	switch (freq) {
+	/*
+	 * Allow a small tolerance for frequencies within 100hz. Note
+	 * this value is chosen arbitrarily.
+	 */
+	round_freq = DIV_ROUND_CLOSEST(freq, 100) * 100;
+
+	switch (round_freq) {
 	case 0:
 		es8328->sysclk_constraints = NULL;
 		es8328->mclk_ratios = NULL;