aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@bootlin.com>2019-08-19 15:25:13 -0400
committerMark Brown <broonie@kernel.org>2019-08-20 13:26:31 -0400
commit8bcf62b73e5421df94deca95d7d7c152997fe5b4 (patch)
tree047fe6934ff19486c5a797191812e8a9b11b5f96 /sound
parentc7dd0828c088a71f30de8d249f63b2fa9f0d322d (diff)
ASoC: sun4i-i2s: Rework MCLK divider calculation
The MCLK divider calculation is currently computing the ideal divider using the oversample rate, the sample rate and the parent rate. However, since we have access to the frequency is supposed to be running at already, and as it turns out we're using it to compute the oversample rate, we can just use the ratio between the parent rate and the MCLK rate to simplify a bit the formula. Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://lore.kernel.org/r/dcc5deb2eb650758d268bddd20f60ba58856d024.1566242458.git-series.maxime.ripard@bootlin.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/sunxi/sun4i-i2s.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 77b7b81daf74..0a5fb9d4b289 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -240,11 +240,10 @@ static int sun4i_i2s_get_bclk_div(struct sun4i_i2s *i2s,
240} 240}
241 241
242static int sun4i_i2s_get_mclk_div(struct sun4i_i2s *i2s, 242static int sun4i_i2s_get_mclk_div(struct sun4i_i2s *i2s,
243 unsigned int oversample_rate, 243 unsigned long parent_rate,
244 unsigned int module_rate, 244 unsigned long mclk_rate)
245 unsigned int sampling_rate)
246{ 245{
247 int div = module_rate / sampling_rate / oversample_rate; 246 int div = parent_rate / mclk_rate;
248 int i; 247 int i;
249 248
250 for (i = 0; i < ARRAY_SIZE(sun4i_i2s_mclk_div); i++) { 249 for (i = 0; i < ARRAY_SIZE(sun4i_i2s_mclk_div); i++) {
@@ -323,8 +322,7 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai,
323 return -EINVAL; 322 return -EINVAL;
324 } 323 }
325 324
326 mclk_div = sun4i_i2s_get_mclk_div(i2s, oversample_rate, 325 mclk_div = sun4i_i2s_get_mclk_div(i2s, clk_rate, i2s->mclk_freq);
327 clk_rate, rate);
328 if (mclk_div < 0) { 326 if (mclk_div < 0) {
329 dev_err(dai->dev, "Unsupported MCLK divider: %d\n", mclk_div); 327 dev_err(dai->dev, "Unsupported MCLK divider: %d\n", mclk_div);
330 return -EINVAL; 328 return -EINVAL;