Commit 5cbf7e49 authored by Alexander Sverdlin's avatar Alexander Sverdlin Committed by Mark Brown

ASoC: Improve EP93xx I2S clocks management.

Improve EP93xx I2S clocks management.
Some freqs values are set not exact as they requested for MCLK and
original code was not able to find divisors for SCLK and LRCLK.
This code just picks up nearest value from 3 possible variants.
This patch makes 44100 and 192000 rates working and fixes
capture function (by selecting SCLK/LRCLK=64 where possible).
All other rates should work as before.
Signed-off-by: default avatarAlexander Sverdlin <subaparts@yandex.ru>
Acked-by: default avatarLiam Girdwood <lrg@ti.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 6d33cd77
...@@ -242,7 +242,7 @@ static int ep93xx_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -242,7 +242,7 @@ static int ep93xx_i2s_hw_params(struct snd_pcm_substream *substream,
{ {
struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai);
unsigned word_len, div, sdiv, lrdiv; unsigned word_len, div, sdiv, lrdiv;
int found = 0, err; int err;
switch (params_format(params)) { switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S16_LE: case SNDRV_PCM_FORMAT_S16_LE:
...@@ -275,15 +275,14 @@ static int ep93xx_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -275,15 +275,14 @@ static int ep93xx_i2s_hw_params(struct snd_pcm_substream *substream,
* the codec uses. * the codec uses.
*/ */
div = clk_get_rate(info->mclk) / params_rate(params); div = clk_get_rate(info->mclk) / params_rate(params);
for (sdiv = 2; sdiv <= 4; sdiv += 2) sdiv = 4;
for (lrdiv = 64; lrdiv <= 128; lrdiv <<= 1) if (div > (256 + 512) / 2) {
if (sdiv * lrdiv == div) { lrdiv = 128;
found = 1; } else {
goto out; lrdiv = 64;
} if (div < (128 + 256) / 2)
out: sdiv = 2;
if (!found) }
return -EINVAL;
err = clk_set_rate(info->sclk, clk_get_rate(info->mclk) / sdiv); err = clk_set_rate(info->sclk, clk_get_rate(info->mclk) / sdiv);
if (err) if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment