diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-07-05 10:54:51 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-07-05 19:46:10 -0400 |
commit | db059c0f6edec0b1deba665e5853f4ed829003b7 (patch) | |
tree | b30bede340908df84d915051cbe59f4256bf1417 /sound | |
parent | afd6d36a0ded1691c6710ebddabae06e5bb9583b (diff) |
ASoC: Automatically manage ALC coefficients for WM8960
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/wm8960.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index 743d9a708a22..3c6ee61f6c95 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c | |||
@@ -487,6 +487,21 @@ static int wm8960_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
487 | return 0; | 487 | return 0; |
488 | } | 488 | } |
489 | 489 | ||
490 | static struct { | ||
491 | int rate; | ||
492 | unsigned int val; | ||
493 | } alc_rates[] = { | ||
494 | { 48000, 0 }, | ||
495 | { 44100, 0 }, | ||
496 | { 32000, 1 }, | ||
497 | { 22050, 2 }, | ||
498 | { 24000, 2 }, | ||
499 | { 16000, 3 }, | ||
500 | { 11250, 4 }, | ||
501 | { 12000, 4 }, | ||
502 | { 8000, 5 }, | ||
503 | }; | ||
504 | |||
490 | static int wm8960_hw_params(struct snd_pcm_substream *substream, | 505 | static int wm8960_hw_params(struct snd_pcm_substream *substream, |
491 | struct snd_pcm_hw_params *params, | 506 | struct snd_pcm_hw_params *params, |
492 | struct snd_soc_dai *dai) | 507 | struct snd_soc_dai *dai) |
@@ -496,6 +511,7 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, | |||
496 | struct snd_soc_codec *codec = socdev->card->codec; | 511 | struct snd_soc_codec *codec = socdev->card->codec; |
497 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); | 512 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); |
498 | u16 iface = snd_soc_read(codec, WM8960_IFACE1) & 0xfff3; | 513 | u16 iface = snd_soc_read(codec, WM8960_IFACE1) & 0xfff3; |
514 | int i; | ||
499 | 515 | ||
500 | /* bit size */ | 516 | /* bit size */ |
501 | switch (params_format(params)) { | 517 | switch (params_format(params)) { |
@@ -513,6 +529,12 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, | |||
513 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 529 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
514 | wm8960->playback_fs = params_rate(params); | 530 | wm8960->playback_fs = params_rate(params); |
515 | wm8960_set_deemph(codec); | 531 | wm8960_set_deemph(codec); |
532 | } else { | ||
533 | for (i = 0; i < ARRAY_SIZE(alc_rates); i++) | ||
534 | if (alc_rates[i].rate == params_rate(params)) | ||
535 | snd_soc_update_bits(codec, | ||
536 | WM8960_ADDCTL3, 0x7, | ||
537 | alc_rates[i].val); | ||
516 | } | 538 | } |
517 | 539 | ||
518 | /* set iface */ | 540 | /* set iface */ |