aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8971.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2009-03-28 16:29:51 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-03-28 16:29:51 -0400
commited40d0c472b136682b2fcba05f89762859c7374f (patch)
tree076b83a26bcd63d6158463735dd34c10bbc591dc /sound/soc/codecs/wm8971.c
parent9e495834e59ca9b29f1a1f63b9f5533bb022ac49 (diff)
parent5d80f8e5a9dc9c9a94d4aeaa567e219a808b8a4a (diff)
Merge branch 'origin' into devel
Conflicts: sound/soc/pxa/pxa2xx-i2s.c
Diffstat (limited to 'sound/soc/codecs/wm8971.c')
-rw-r--r--sound/soc/codecs/wm8971.c46
1 files changed, 17 insertions, 29 deletions
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c
index 88ead7f8dd98..032dca22dbd3 100644
--- a/sound/soc/codecs/wm8971.c
+++ b/sound/soc/codecs/wm8971.c
@@ -195,21 +195,6 @@ static const struct snd_kcontrol_new wm8971_snd_controls[] = {
195 SOC_DOUBLE_R("Mic Boost", WM8971_LADCIN, WM8971_RADCIN, 4, 3, 0), 195 SOC_DOUBLE_R("Mic Boost", WM8971_LADCIN, WM8971_RADCIN, 4, 3, 0),
196}; 196};
197 197
198/* add non-DAPM controls */
199static int wm8971_add_controls(struct snd_soc_codec *codec)
200{
201 int err, i;
202
203 for (i = 0; i < ARRAY_SIZE(wm8971_snd_controls); i++) {
204 err = snd_ctl_add(codec->card,
205 snd_soc_cnew(&wm8971_snd_controls[i],
206 codec, NULL));
207 if (err < 0)
208 return err;
209 }
210 return 0;
211}
212
213/* 198/*
214 * DAPM Controls 199 * DAPM Controls
215 */ 200 */
@@ -546,7 +531,7 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream,
546{ 531{
547 struct snd_soc_pcm_runtime *rtd = substream->private_data; 532 struct snd_soc_pcm_runtime *rtd = substream->private_data;
548 struct snd_soc_device *socdev = rtd->socdev; 533 struct snd_soc_device *socdev = rtd->socdev;
549 struct snd_soc_codec *codec = socdev->codec; 534 struct snd_soc_codec *codec = socdev->card->codec;
550 struct wm8971_priv *wm8971 = codec->private_data; 535 struct wm8971_priv *wm8971 = codec->private_data;
551 u16 iface = wm8971_read_reg_cache(codec, WM8971_IFACE) & 0x1f3; 536 u16 iface = wm8971_read_reg_cache(codec, WM8971_IFACE) & 0x1f3;
552 u16 srate = wm8971_read_reg_cache(codec, WM8971_SRATE) & 0x1c0; 537 u16 srate = wm8971_read_reg_cache(codec, WM8971_SRATE) & 0x1c0;
@@ -619,6 +604,13 @@ static int wm8971_set_bias_level(struct snd_soc_codec *codec,
619#define WM8971_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 604#define WM8971_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
620 SNDRV_PCM_FMTBIT_S24_LE) 605 SNDRV_PCM_FMTBIT_S24_LE)
621 606
607static struct snd_soc_dai_ops wm8971_dai_ops = {
608 .hw_params = wm8971_pcm_hw_params,
609 .digital_mute = wm8971_mute,
610 .set_fmt = wm8971_set_dai_fmt,
611 .set_sysclk = wm8971_set_dai_sysclk,
612};
613
622struct snd_soc_dai wm8971_dai = { 614struct snd_soc_dai wm8971_dai = {
623 .name = "WM8971", 615 .name = "WM8971",
624 .playback = { 616 .playback = {
@@ -633,12 +625,7 @@ struct snd_soc_dai wm8971_dai = {
633 .channels_max = 2, 625 .channels_max = 2,
634 .rates = WM8971_RATES, 626 .rates = WM8971_RATES,
635 .formats = WM8971_FORMATS,}, 627 .formats = WM8971_FORMATS,},
636 .ops = { 628 .ops = &wm8971_dai_ops,
637 .hw_params = wm8971_pcm_hw_params,
638 .digital_mute = wm8971_mute,
639 .set_fmt = wm8971_set_dai_fmt,
640 .set_sysclk = wm8971_set_dai_sysclk,
641 },
642}; 629};
643EXPORT_SYMBOL_GPL(wm8971_dai); 630EXPORT_SYMBOL_GPL(wm8971_dai);
644 631
@@ -652,7 +639,7 @@ static void wm8971_work(struct work_struct *work)
652static int wm8971_suspend(struct platform_device *pdev, pm_message_t state) 639static int wm8971_suspend(struct platform_device *pdev, pm_message_t state)
653{ 640{
654 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 641 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
655 struct snd_soc_codec *codec = socdev->codec; 642 struct snd_soc_codec *codec = socdev->card->codec;
656 643
657 wm8971_set_bias_level(codec, SND_SOC_BIAS_OFF); 644 wm8971_set_bias_level(codec, SND_SOC_BIAS_OFF);
658 return 0; 645 return 0;
@@ -661,7 +648,7 @@ static int wm8971_suspend(struct platform_device *pdev, pm_message_t state)
661static int wm8971_resume(struct platform_device *pdev) 648static int wm8971_resume(struct platform_device *pdev)
662{ 649{
663 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 650 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
664 struct snd_soc_codec *codec = socdev->codec; 651 struct snd_soc_codec *codec = socdev->card->codec;
665 int i; 652 int i;
666 u8 data[2]; 653 u8 data[2];
667 u16 *cache = codec->reg_cache; 654 u16 *cache = codec->reg_cache;
@@ -692,7 +679,7 @@ static int wm8971_resume(struct platform_device *pdev)
692 679
693static int wm8971_init(struct snd_soc_device *socdev) 680static int wm8971_init(struct snd_soc_device *socdev)
694{ 681{
695 struct snd_soc_codec *codec = socdev->codec; 682 struct snd_soc_codec *codec = socdev->card->codec;
696 int reg, ret = 0; 683 int reg, ret = 0;
697 684
698 codec->name = "WM8971"; 685 codec->name = "WM8971";
@@ -745,7 +732,8 @@ static int wm8971_init(struct snd_soc_device *socdev)
745 reg = wm8971_read_reg_cache(codec, WM8971_RINVOL); 732 reg = wm8971_read_reg_cache(codec, WM8971_RINVOL);
746 wm8971_write(codec, WM8971_RINVOL, reg | 0x0100); 733 wm8971_write(codec, WM8971_RINVOL, reg | 0x0100);
747 734
748 wm8971_add_controls(codec); 735 snd_soc_add_controls(codec, wm8971_snd_controls,
736 ARRAY_SIZE(wm8971_snd_controls));
749 wm8971_add_widgets(codec); 737 wm8971_add_widgets(codec);
750 ret = snd_soc_init_card(socdev); 738 ret = snd_soc_init_card(socdev);
751 if (ret < 0) { 739 if (ret < 0) {
@@ -772,7 +760,7 @@ static int wm8971_i2c_probe(struct i2c_client *i2c,
772 const struct i2c_device_id *id) 760 const struct i2c_device_id *id)
773{ 761{
774 struct snd_soc_device *socdev = wm8971_socdev; 762 struct snd_soc_device *socdev = wm8971_socdev;
775 struct snd_soc_codec *codec = socdev->codec; 763 struct snd_soc_codec *codec = socdev->card->codec;
776 int ret; 764 int ret;
777 765
778 i2c_set_clientdata(i2c, codec); 766 i2c_set_clientdata(i2c, codec);
@@ -873,7 +861,7 @@ static int wm8971_probe(struct platform_device *pdev)
873 } 861 }
874 862
875 codec->private_data = wm8971; 863 codec->private_data = wm8971;
876 socdev->codec = codec; 864 socdev->card->codec = codec;
877 mutex_init(&codec->mutex); 865 mutex_init(&codec->mutex);
878 INIT_LIST_HEAD(&codec->dapm_widgets); 866 INIT_LIST_HEAD(&codec->dapm_widgets);
879 INIT_LIST_HEAD(&codec->dapm_paths); 867 INIT_LIST_HEAD(&codec->dapm_paths);
@@ -908,7 +896,7 @@ static int wm8971_probe(struct platform_device *pdev)
908static int wm8971_remove(struct platform_device *pdev) 896static int wm8971_remove(struct platform_device *pdev)
909{ 897{
910 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 898 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
911 struct snd_soc_codec *codec = socdev->codec; 899 struct snd_soc_codec *codec = socdev->card->codec;
912 900
913 if (codec->control_data) 901 if (codec->control_data)
914 wm8971_set_bias_level(codec, SND_SOC_BIAS_OFF); 902 wm8971_set_bias_level(codec, SND_SOC_BIAS_OFF);