[PATCH] ASoC: pcm3168a: Require an exact SCKI ratio in provider mode
From: Haowen Tu
Date: Tue Dec 01 2026 - 21:48:11 EST
pcm3168a_hw_params() divides the configured system clock by the sample
rate and uses the truncated quotient to select the hardware divider.
For example, 12.3 MHz and 48 kHz give a quotient of 256, so the driver
accepts the parameters and selects a divider that produces 48046.875 Hz.
Match the system clock against the sample rate multiplied by each
supported divider so that fractional ratios are rejected before the
interface register is programmed.
Fixes: a9b17a638af5 ("ASoC: pcm3168a: Add driver for pcm3168a codec")
Signed-off-by: Haowen Tu <tuhaowen@xxxxxxxxxxxxx>
---
sound/soc/codecs/pcm3168a.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c
index 11fd948ecd27..8049daa3a876 100644
--- a/sound/soc/codecs/pcm3168a.c
+++ b/sound/soc/codecs/pcm3168a.c
@@ -441,7 +441,7 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream,
struct pcm3168a_io_params *io_params = &pcm3168a->io_params[dai->id];
bool provider_mode, tdm_mode;
unsigned int format;
- unsigned int reg, mask, ms, ms_shift, fmt, fmt_shift, ratio, tdm_slots;
+ unsigned int reg, mask, ms, ms_shift, fmt, fmt_shift, tdm_slots;
int i, num_scki_ratios, slot_width;
if (dai->id == PCM3168A_DAI_DAC) {
@@ -461,10 +461,10 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream,
provider_mode = io_params->provider_mode;
if (provider_mode) {
- ratio = pcm3168a->sysclk / params_rate(params);
+ unsigned int rate = params_rate(params);
for (i = 0; i < num_scki_ratios; i++) {
- if (pcm3168a_scki_ratios[i] == ratio)
+ if (pcm3168a->sysclk == pcm3168a_scki_ratios[i] * rate)
break;
}
--
2.50.1