aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/ep93xx/ep93xx-i2s.c
diff options
context:
space:
mode:
authorAlexander Sverdlin <subaparts@yandex.ru>2011-03-07 12:30:36 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-03-09 08:08:36 -0500
commit5cbf7e49de3276c82705fc303d305ce170793ef6 (patch)
tree7ce2eb217095f0df26bd030d00c9e1a6dc6f6233 /sound/soc/ep93xx/ep93xx-i2s.c
parent6d33cd771b779abd8faeaf63821c200ba36a63b1 (diff)
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: Alexander Sverdlin <subaparts@yandex.ru> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/ep93xx/ep93xx-i2s.c')
-rw-r--r--sound/soc/ep93xx/ep93xx-i2s.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/sound/soc/ep93xx/ep93xx-i2s.c b/sound/soc/ep93xx/ep93xx-i2s.c
index 4d3c1389d3da..207d5893d97f 100644
--- a/sound/soc/ep93xx/ep93xx-i2s.c
+++ b/sound/soc/ep93xx/ep93xx-i2s.c
@@ -242,7 +242,7 @@ static int ep93xx_i2s_hw_params(struct snd_pcm_substream *substream,
242{ 242{
243 struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); 243 struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai);
244 unsigned word_len, div, sdiv, lrdiv; 244 unsigned word_len, div, sdiv, lrdiv;
245 int found = 0, err; 245 int err;
246 246
247 switch (params_format(params)) { 247 switch (params_format(params)) {
248 case SNDRV_PCM_FORMAT_S16_LE: 248 case SNDRV_PCM_FORMAT_S16_LE:
@@ -275,15 +275,14 @@ static int ep93xx_i2s_hw_params(struct snd_pcm_substream *substream,
275 * the codec uses. 275 * the codec uses.
276 */ 276 */
277 div = clk_get_rate(info->mclk) / params_rate(params); 277 div = clk_get_rate(info->mclk) / params_rate(params);
278 for (sdiv = 2; sdiv <= 4; sdiv += 2) 278 sdiv = 4;
279 for (lrdiv = 64; lrdiv <= 128; lrdiv <<= 1) 279 if (div > (256 + 512) / 2) {
280 if (sdiv * lrdiv == div) { 280 lrdiv = 128;
281 found = 1; 281 } else {
282 goto out; 282 lrdiv = 64;
283 } 283 if (div < (128 + 256) / 2)
284out: 284 sdiv = 2;
285 if (!found) 285 }
286 return -EINVAL;
287 286
288 err = clk_set_rate(info->sclk, clk_get_rate(info->mclk) / sdiv); 287 err = clk_set_rate(info->sclk, clk_get_rate(info->mclk) / sdiv);
289 if (err) 288 if (err)