aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2008-05-06 10:57:55 -0400
committerJiri Kosina <jkosina@suse.cz>2008-05-06 10:57:55 -0400
commit7022b15e2a9f878fd5184586064c63352c3dd225 (patch)
tree5365c2f5bc82ae1946636ee8d5cd5d3b7e804f1b /sound/soc/codecs
parentaaad2b0c757f3e6e02552cb0bdcd91a5ec0d6305 (diff)
parenta15306365a16380f3bafee9e181ba01231d4acd7 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r--sound/soc/codecs/Kconfig4
-rw-r--r--sound/soc/codecs/Makefile2
-rw-r--r--sound/soc/codecs/ac97.c16
-rw-r--r--sound/soc/codecs/cs4270.c2
-rw-r--r--sound/soc/codecs/tlv320aic3x.c22
-rw-r--r--sound/soc/codecs/wm8731.c23
-rw-r--r--sound/soc/codecs/wm8750.c27
-rw-r--r--sound/soc/codecs/wm8753.c39
-rw-r--r--sound/soc/codecs/wm9712.c70
-rw-r--r--sound/soc/codecs/wm9713.c1300
-rw-r--r--sound/soc/codecs/wm9713.h53
11 files changed, 1465 insertions, 93 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 898a7d363284..3903ab7dfa4a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -18,6 +18,10 @@ config SND_SOC_WM9712
18 tristate 18 tristate
19 depends on SND_SOC 19 depends on SND_SOC
20 20
21config SND_SOC_WM9713
22 tristate
23 depends on SND_SOC
24
21# Cirrus Logic CS4270 Codec 25# Cirrus Logic CS4270 Codec
22config SND_SOC_CS4270 26config SND_SOC_CS4270
23 tristate 27 tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index c6e5338c2666..4e1314c9d3ec 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -3,6 +3,7 @@ snd-soc-wm8731-objs := wm8731.o
3snd-soc-wm8750-objs := wm8750.o 3snd-soc-wm8750-objs := wm8750.o
4snd-soc-wm8753-objs := wm8753.o 4snd-soc-wm8753-objs := wm8753.o
5snd-soc-wm9712-objs := wm9712.o 5snd-soc-wm9712-objs := wm9712.o
6snd-soc-wm9713-objs := wm9713.o
6snd-soc-cs4270-objs := cs4270.o 7snd-soc-cs4270-objs := cs4270.o
7snd-soc-tlv320aic3x-objs := tlv320aic3x.o 8snd-soc-tlv320aic3x-objs := tlv320aic3x.o
8 9
@@ -11,5 +12,6 @@ obj-$(CONFIG_SND_SOC_WM8731) += snd-soc-wm8731.o
11obj-$(CONFIG_SND_SOC_WM8750) += snd-soc-wm8750.o 12obj-$(CONFIG_SND_SOC_WM8750) += snd-soc-wm8750.o
12obj-$(CONFIG_SND_SOC_WM8753) += snd-soc-wm8753.o 13obj-$(CONFIG_SND_SOC_WM8753) += snd-soc-wm8753.o
13obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o 14obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o
15obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o
14obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o 16obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o
15obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o 17obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c
index 242130cf1abd..2a1ffe396908 100644
--- a/sound/soc/codecs/ac97.c
+++ b/sound/soc/codecs/ac97.c
@@ -40,7 +40,8 @@ static int ac97_prepare(struct snd_pcm_substream *substream)
40} 40}
41 41
42#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 42#define STD_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
43 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) 43 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\
44 SNDRV_PCM_RATE_48000)
44 45
45struct snd_soc_codec_dai ac97_dai = { 46struct snd_soc_codec_dai ac97_dai = {
46 .name = "AC97 HiFi", 47 .name = "AC97 HiFi",
@@ -86,7 +87,7 @@ static int ac97_soc_probe(struct platform_device *pdev)
86 printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION); 87 printk(KERN_INFO "AC97 SoC Audio Codec %s\n", AC97_VERSION);
87 88
88 socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); 89 socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
89 if (socdev->codec == NULL) 90 if (!socdev->codec)
90 return -ENOMEM; 91 return -ENOMEM;
91 codec = socdev->codec; 92 codec = socdev->codec;
92 mutex_init(&codec->mutex); 93 mutex_init(&codec->mutex);
@@ -102,17 +103,17 @@ static int ac97_soc_probe(struct platform_device *pdev)
102 103
103 /* register pcms */ 104 /* register pcms */
104 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); 105 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
105 if(ret < 0) 106 if (ret < 0)
106 goto err; 107 goto err;
107 108
108 /* add codec as bus device for standard ac97 */ 109 /* add codec as bus device for standard ac97 */
109 ret = snd_ac97_bus(codec->card, 0, &soc_ac97_ops, NULL, &ac97_bus); 110 ret = snd_ac97_bus(codec->card, 0, &soc_ac97_ops, NULL, &ac97_bus);
110 if(ret < 0) 111 if (ret < 0)
111 goto bus_err; 112 goto bus_err;
112 113
113 memset(&ac97_template, 0, sizeof(struct snd_ac97_template)); 114 memset(&ac97_template, 0, sizeof(struct snd_ac97_template));
114 ret = snd_ac97_mixer(ac97_bus, &ac97_template, &codec->ac97); 115 ret = snd_ac97_mixer(ac97_bus, &ac97_template, &codec->ac97);
115 if(ret < 0) 116 if (ret < 0)
116 goto bus_err; 117 goto bus_err;
117 118
118 ret = snd_soc_register_card(socdev); 119 ret = snd_soc_register_card(socdev);
@@ -135,7 +136,7 @@ static int ac97_soc_remove(struct platform_device *pdev)
135 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 136 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
136 struct snd_soc_codec *codec = socdev->codec; 137 struct snd_soc_codec *codec = socdev->codec;
137 138
138 if(codec == NULL) 139 if (!codec)
139 return 0; 140 return 0;
140 141
141 snd_soc_free_pcms(socdev); 142 snd_soc_free_pcms(socdev);
@@ -145,11 +146,10 @@ static int ac97_soc_remove(struct platform_device *pdev)
145 return 0; 146 return 0;
146} 147}
147 148
148struct snd_soc_codec_device soc_codec_dev_ac97= { 149struct snd_soc_codec_device soc_codec_dev_ac97 = {
149 .probe = ac97_soc_probe, 150 .probe = ac97_soc_probe,
150 .remove = ac97_soc_remove, 151 .remove = ac97_soc_remove,
151}; 152};
152
153EXPORT_SYMBOL_GPL(soc_codec_dev_ac97); 153EXPORT_SYMBOL_GPL(soc_codec_dev_ac97);
154 154
155MODULE_DESCRIPTION("Soc Generic AC97 driver"); 155MODULE_DESCRIPTION("Soc Generic AC97 driver");
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index bf2ab72d49bf..e73fcfd9f5cd 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -372,7 +372,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
372 struct snd_soc_device *socdev = rtd->socdev; 372 struct snd_soc_device *socdev = rtd->socdev;
373 struct snd_soc_codec *codec = socdev->codec; 373 struct snd_soc_codec *codec = socdev->codec;
374 struct cs4270_private *cs4270 = codec->private_data; 374 struct cs4270_private *cs4270 = codec->private_data;
375 unsigned int ret = 0; 375 int ret;
376 unsigned int i; 376 unsigned int i;
377 unsigned int rate; 377 unsigned int rate;
378 unsigned int ratio; 378 unsigned int ratio;
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 889a897d41ac..630684f4a0bc 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -660,33 +660,53 @@ struct aic3x_rate_divs {
660/* AIC3X codec mclk clock divider coefficients */ 660/* AIC3X codec mclk clock divider coefficients */
661static const struct aic3x_rate_divs aic3x_divs[] = { 661static const struct aic3x_rate_divs aic3x_divs[] = {
662 /* 8k */ 662 /* 8k */
663 {12000000, 8000, 48000, 0xa, 16, 3840},
664 {19200000, 8000, 48000, 0xa, 10, 2400},
663 {22579200, 8000, 48000, 0xa, 8, 7075}, 665 {22579200, 8000, 48000, 0xa, 8, 7075},
664 {33868800, 8000, 48000, 0xa, 5, 8049}, 666 {33868800, 8000, 48000, 0xa, 5, 8049},
665 /* 11.025k */ 667 /* 11.025k */
668 {12000000, 11025, 44100, 0x6, 15, 528},
669 {19200000, 11025, 44100, 0x6, 9, 4080},
666 {22579200, 11025, 44100, 0x6, 8, 0}, 670 {22579200, 11025, 44100, 0x6, 8, 0},
667 {33868800, 11025, 44100, 0x6, 5, 3333}, 671 {33868800, 11025, 44100, 0x6, 5, 3333},
668 /* 16k */ 672 /* 16k */
673 {12000000, 16000, 48000, 0x4, 16, 3840},
674 {19200000, 16000, 48000, 0x4, 10, 2400},
669 {22579200, 16000, 48000, 0x4, 8, 7075}, 675 {22579200, 16000, 48000, 0x4, 8, 7075},
670 {33868800, 16000, 48000, 0x4, 5, 8049}, 676 {33868800, 16000, 48000, 0x4, 5, 8049},
671 /* 22.05k */ 677 /* 22.05k */
678 {12000000, 22050, 44100, 0x2, 15, 528},
679 {19200000, 22050, 44100, 0x2, 9, 4080},
672 {22579200, 22050, 44100, 0x2, 8, 0}, 680 {22579200, 22050, 44100, 0x2, 8, 0},
673 {33868800, 22050, 44100, 0x2, 5, 3333}, 681 {33868800, 22050, 44100, 0x2, 5, 3333},
674 /* 32k */ 682 /* 32k */
683 {12000000, 32000, 48000, 0x1, 16, 3840},
684 {19200000, 32000, 48000, 0x1, 10, 2400},
675 {22579200, 32000, 48000, 0x1, 8, 7075}, 685 {22579200, 32000, 48000, 0x1, 8, 7075},
676 {33868800, 32000, 48000, 0x1, 5, 8049}, 686 {33868800, 32000, 48000, 0x1, 5, 8049},
677 /* 44.1k */ 687 /* 44.1k */
688 {12000000, 44100, 44100, 0x0, 15, 528},
689 {19200000, 44100, 44100, 0x0, 9, 4080},
678 {22579200, 44100, 44100, 0x0, 8, 0}, 690 {22579200, 44100, 44100, 0x0, 8, 0},
679 {33868800, 44100, 44100, 0x0, 5, 3333}, 691 {33868800, 44100, 44100, 0x0, 5, 3333},
680 /* 48k */ 692 /* 48k */
693 {12000000, 48000, 48000, 0x0, 16, 3840},
694 {19200000, 48000, 48000, 0x0, 10, 2400},
681 {22579200, 48000, 48000, 0x0, 8, 7075}, 695 {22579200, 48000, 48000, 0x0, 8, 7075},
682 {33868800, 48000, 48000, 0x0, 5, 8049}, 696 {33868800, 48000, 48000, 0x0, 5, 8049},
683 /* 64k */ 697 /* 64k */
698 {12000000, 64000, 96000, 0x1, 16, 3840},
699 {19200000, 64000, 96000, 0x1, 10, 2400},
684 {22579200, 64000, 96000, 0x1, 8, 7075}, 700 {22579200, 64000, 96000, 0x1, 8, 7075},
685 {33868800, 64000, 96000, 0x1, 5, 8049}, 701 {33868800, 64000, 96000, 0x1, 5, 8049},
686 /* 88.2k */ 702 /* 88.2k */
703 {12000000, 88200, 88200, 0x0, 15, 528},
704 {19200000, 88200, 88200, 0x0, 9, 4080},
687 {22579200, 88200, 88200, 0x0, 8, 0}, 705 {22579200, 88200, 88200, 0x0, 8, 0},
688 {33868800, 88200, 88200, 0x0, 5, 3333}, 706 {33868800, 88200, 88200, 0x0, 5, 3333},
689 /* 96k */ 707 /* 96k */
708 {12000000, 96000, 96000, 0x0, 16, 3840},
709 {19200000, 96000, 96000, 0x0, 10, 2400},
690 {22579200, 96000, 96000, 0x0, 8, 7075}, 710 {22579200, 96000, 96000, 0x0, 8, 7075},
691 {33868800, 96000, 96000, 0x0, 5, 8049}, 711 {33868800, 96000, 96000, 0x0, 5, 8049},
692}; 712};
@@ -807,6 +827,8 @@ static int aic3x_set_dai_sysclk(struct snd_soc_codec_dai *codec_dai,
807 struct aic3x_priv *aic3x = codec->private_data; 827 struct aic3x_priv *aic3x = codec->private_data;
808 828
809 switch (freq) { 829 switch (freq) {
830 case 12000000:
831 case 19200000:
810 case 22579200: 832 case 22579200:
811 case 33868800: 833 case 33868800:
812 aic3x->sysclk = freq; 834 aic3x->sysclk = freq;
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 9c33fe874928..0cf9265fca8f 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -110,7 +110,7 @@ static int wm8731_write(struct snd_soc_codec *codec, unsigned int reg,
110 data[0] = (reg << 1) | ((value >> 8) & 0x0001); 110 data[0] = (reg << 1) | ((value >> 8) & 0x0001);
111 data[1] = value & 0x00ff; 111 data[1] = value & 0x00ff;
112 112
113 wm8731_write_reg_cache (codec, reg, value); 113 wm8731_write_reg_cache(codec, reg, value);
114 if (codec->hw_write(codec->control_data, data, 2) == 2) 114 if (codec->hw_write(codec->control_data, data, 2) == 2)
115 return 0; 115 return 0;
116 else 116 else
@@ -154,8 +154,10 @@ static int wm8731_add_controls(struct snd_soc_codec *codec)
154 int err, i; 154 int err, i;
155 155
156 for (i = 0; i < ARRAY_SIZE(wm8731_snd_controls); i++) { 156 for (i = 0; i < ARRAY_SIZE(wm8731_snd_controls); i++) {
157 if ((err = snd_ctl_add(codec->card, 157 err = snd_ctl_add(codec->card,
158 snd_soc_cnew(&wm8731_snd_controls[i],codec, NULL))) < 0) 158 snd_soc_cnew(&wm8731_snd_controls[i],
159 codec, NULL));
160 if (err < 0)
159 return err; 161 return err;
160 } 162 }
161 163
@@ -221,15 +223,13 @@ static int wm8731_add_widgets(struct snd_soc_codec *codec)
221{ 223{
222 int i; 224 int i;
223 225
224 for(i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++) { 226 for (i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++)
225 snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]); 227 snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]);
226 }
227 228
228 /* set up audio path interconnects */ 229 /* set up audio path interconnects */
229 for(i = 0; intercon[i][0] != NULL; i++) { 230 for (i = 0; intercon[i][0] != NULL; i++)
230 snd_soc_dapm_connect_input(codec, intercon[i][0], 231 snd_soc_dapm_connect_input(codec, intercon[i][0],
231 intercon[i][1], intercon[i][2]); 232 intercon[i][1], intercon[i][2]);
232 }
233 233
234 snd_soc_dapm_new_widgets(codec); 234 snd_soc_dapm_new_widgets(codec);
235 return 0; 235 return 0;
@@ -589,7 +589,7 @@ pcm_err:
589 589
590static struct snd_soc_device *wm8731_socdev; 590static struct snd_soc_device *wm8731_socdev;
591 591
592#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 592#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
593 593
594/* 594/*
595 * WM8731 2 wire address is determined by GPIO5 595 * WM8731 2 wire address is determined by GPIO5
@@ -651,7 +651,7 @@ err:
651 651
652static int wm8731_i2c_detach(struct i2c_client *client) 652static int wm8731_i2c_detach(struct i2c_client *client)
653{ 653{
654 struct snd_soc_codec* codec = i2c_get_clientdata(client); 654 struct snd_soc_codec *codec = i2c_get_clientdata(client);
655 i2c_detach_client(client); 655 i2c_detach_client(client);
656 kfree(codec->reg_cache); 656 kfree(codec->reg_cache);
657 kfree(client); 657 kfree(client);
@@ -709,7 +709,7 @@ static int wm8731_probe(struct platform_device *pdev)
709 INIT_LIST_HEAD(&codec->dapm_paths); 709 INIT_LIST_HEAD(&codec->dapm_paths);
710 710
711 wm8731_socdev = socdev; 711 wm8731_socdev = socdev;
712#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 712#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
713 if (setup->i2c_address) { 713 if (setup->i2c_address) {
714 normal_i2c[0] = setup->i2c_address; 714 normal_i2c[0] = setup->i2c_address;
715 codec->hw_write = (hw_write_t)i2c_master_send; 715 codec->hw_write = (hw_write_t)i2c_master_send;
@@ -734,7 +734,7 @@ static int wm8731_remove(struct platform_device *pdev)
734 734
735 snd_soc_free_pcms(socdev); 735 snd_soc_free_pcms(socdev);
736 snd_soc_dapm_free(socdev); 736 snd_soc_dapm_free(socdev);
737#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 737#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
738 i2c_del_driver(&wm8731_i2c_driver); 738 i2c_del_driver(&wm8731_i2c_driver);
739#endif 739#endif
740 kfree(codec->private_data); 740 kfree(codec->private_data);
@@ -749,7 +749,6 @@ struct snd_soc_codec_device soc_codec_dev_wm8731 = {
749 .suspend = wm8731_suspend, 749 .suspend = wm8731_suspend,
750 .resume = wm8731_resume, 750 .resume = wm8731_resume,
751}; 751};
752
753EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731); 752EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731);
754 753
755MODULE_DESCRIPTION("ASoC WM8731 driver"); 754MODULE_DESCRIPTION("ASoC WM8731 driver");
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index 77a857b997a2..16cd5d4d5ad9 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -110,7 +110,7 @@ static int wm8750_write(struct snd_soc_codec *codec, unsigned int reg,
110 data[0] = (reg << 1) | ((value >> 8) & 0x0001); 110 data[0] = (reg << 1) | ((value >> 8) & 0x0001);
111 data[1] = value & 0x00ff; 111 data[1] = value & 0x00ff;
112 112
113 wm8750_write_reg_cache (codec, reg, value); 113 wm8750_write_reg_cache(codec, reg, value);
114 if (codec->hw_write(codec->control_data, data, 2) == 2) 114 if (codec->hw_write(codec->control_data, data, 2) == 2)
115 return 0; 115 return 0;
116 else 116 else
@@ -257,7 +257,8 @@ static int wm8750_add_controls(struct snd_soc_codec *codec)
257 257
258 for (i = 0; i < ARRAY_SIZE(wm8750_snd_controls); i++) { 258 for (i = 0; i < ARRAY_SIZE(wm8750_snd_controls); i++) {
259 err = snd_ctl_add(codec->card, 259 err = snd_ctl_add(codec->card,
260 snd_soc_cnew(&wm8750_snd_controls[i],codec, NULL)); 260 snd_soc_cnew(&wm8750_snd_controls[i],
261 codec, NULL));
261 if (err < 0) 262 if (err < 0)
262 return err; 263 return err;
263 } 264 }
@@ -478,15 +479,13 @@ static int wm8750_add_widgets(struct snd_soc_codec *codec)
478{ 479{
479 int i; 480 int i;
480 481
481 for(i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++) { 482 for (i = 0; i < ARRAY_SIZE(wm8750_dapm_widgets); i++)
482 snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]); 483 snd_soc_dapm_new_control(codec, &wm8750_dapm_widgets[i]);
483 }
484 484
485 /* set up audio path audio_mapnects */ 485 /* set up audio path audio_mapnects */
486 for(i = 0; audio_map[i][0] != NULL; i++) { 486 for (i = 0; audio_map[i][0] != NULL; i++)
487 snd_soc_dapm_connect_input(codec, audio_map[i][0], 487 snd_soc_dapm_connect_input(codec, audio_map[i][0],
488 audio_map[i][1], audio_map[i][2]); 488 audio_map[i][1], audio_map[i][2]);
489 }
490 489
491 snd_soc_dapm_new_widgets(codec); 490 snd_soc_dapm_new_widgets(codec);
492 return 0; 491 return 0;
@@ -714,8 +713,8 @@ static int wm8750_dapm_event(struct snd_soc_codec *codec, int event)
714} 713}
715 714
716#define WM8750_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 715#define WM8750_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
717 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \ 716 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \
718 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) 717 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
719 718
720#define WM8750_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 719#define WM8750_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
721 SNDRV_PCM_FMTBIT_S24_LE) 720 SNDRV_PCM_FMTBIT_S24_LE)
@@ -784,7 +783,8 @@ static int wm8750_resume(struct platform_device *pdev)
784 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) { 783 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0) {
785 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2); 784 wm8750_dapm_event(codec, SNDRV_CTL_POWER_D2);
786 codec->dapm_state = SNDRV_CTL_POWER_D0; 785 codec->dapm_state = SNDRV_CTL_POWER_D0;
787 schedule_delayed_work(&codec->delayed_work, msecs_to_jiffies(1000)); 786 schedule_delayed_work(&codec->delayed_work,
787 msecs_to_jiffies(1000));
788 } 788 }
789 789
790 return 0; 790 return 0;
@@ -864,7 +864,7 @@ pcm_err:
864 around */ 864 around */
865static struct snd_soc_device *wm8750_socdev; 865static struct snd_soc_device *wm8750_socdev;
866 866
867#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 867#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
868 868
869/* 869/*
870 * WM8731 2 wire address is determined by GPIO5 870 * WM8731 2 wire address is determined by GPIO5
@@ -979,8 +979,8 @@ static int wm8750_probe(struct platform_device *pdev)
979 INIT_LIST_HEAD(&codec->dapm_paths); 979 INIT_LIST_HEAD(&codec->dapm_paths);
980 wm8750_socdev = socdev; 980 wm8750_socdev = socdev;
981 INIT_DELAYED_WORK(&codec->delayed_work, wm8750_work); 981 INIT_DELAYED_WORK(&codec->delayed_work, wm8750_work);
982 982
983#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 983#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
984 if (setup->i2c_address) { 984 if (setup->i2c_address) {
985 normal_i2c[0] = setup->i2c_address; 985 normal_i2c[0] = setup->i2c_address;
986 codec->hw_write = (hw_write_t)i2c_master_send; 986 codec->hw_write = (hw_write_t)i2c_master_send;
@@ -1025,7 +1025,7 @@ static int wm8750_remove(struct platform_device *pdev)
1025 run_delayed_work(&codec->delayed_work); 1025 run_delayed_work(&codec->delayed_work);
1026 snd_soc_free_pcms(socdev); 1026 snd_soc_free_pcms(socdev);
1027 snd_soc_dapm_free(socdev); 1027 snd_soc_dapm_free(socdev);
1028#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 1028#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1029 i2c_del_driver(&wm8750_i2c_driver); 1029 i2c_del_driver(&wm8750_i2c_driver);
1030#endif 1030#endif
1031 kfree(codec->private_data); 1031 kfree(codec->private_data);
@@ -1040,7 +1040,6 @@ struct snd_soc_codec_device soc_codec_dev_wm8750 = {
1040 .suspend = wm8750_suspend, 1040 .suspend = wm8750_suspend,
1041 .resume = wm8750_resume, 1041 .resume = wm8750_resume,
1042}; 1042};
1043
1044EXPORT_SYMBOL_GPL(soc_codec_dev_wm8750); 1043EXPORT_SYMBOL_GPL(soc_codec_dev_wm8750);
1045 1044
1046MODULE_DESCRIPTION("ASoC WM8750 driver"); 1045MODULE_DESCRIPTION("ASoC WM8750 driver");
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index ddd9c71b3fde..fb41826c4c4c 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -150,7 +150,7 @@ static int wm8753_write(struct snd_soc_codec *codec, unsigned int reg,
150 data[0] = (reg << 1) | ((value >> 8) & 0x0001); 150 data[0] = (reg << 1) | ((value >> 8) & 0x0001);
151 data[1] = value & 0x00ff; 151 data[1] = value & 0x00ff;
152 152
153 wm8753_write_reg_cache (codec, reg, value); 153 wm8753_write_reg_cache(codec, reg, value);
154 if (codec->hw_write(codec->control_data, data, 2) == 2) 154 if (codec->hw_write(codec->control_data, data, 2) == 2)
155 return 0; 155 return 0;
156 else 156 else
@@ -198,6 +198,7 @@ static const char *wm8753_mic_sel[] = {"Mic 1", "Mic 2", "Mic 3"};
198static const char *wm8753_dai_mode[] = {"DAI 0", "DAI 1", "DAI 2", "DAI 3"}; 198static const char *wm8753_dai_mode[] = {"DAI 0", "DAI 1", "DAI 2", "DAI 3"};
199static const char *wm8753_dat_sel[] = {"Stereo", "Left ADC", "Right ADC", 199static const char *wm8753_dat_sel[] = {"Stereo", "Left ADC", "Right ADC",
200 "Channel Swap"}; 200 "Channel Swap"};
201static const char *wm8753_rout2_phase[] = {"Non Inverted", "Inverted"};
201 202
202static const struct soc_enum wm8753_enum[] = { 203static const struct soc_enum wm8753_enum[] = {
203SOC_ENUM_SINGLE(WM8753_BASS, 7, 2, wm8753_base), 204SOC_ENUM_SINGLE(WM8753_BASS, 7, 2, wm8753_base),
@@ -228,6 +229,7 @@ SOC_ENUM_SINGLE(WM8753_ADC, 4, 2, wm8753_adc_filter),
228SOC_ENUM_SINGLE(WM8753_MICBIAS, 6, 3, wm8753_mic_sel), 229SOC_ENUM_SINGLE(WM8753_MICBIAS, 6, 3, wm8753_mic_sel),
229SOC_ENUM_SINGLE(WM8753_IOCTL, 2, 4, wm8753_dai_mode), 230SOC_ENUM_SINGLE(WM8753_IOCTL, 2, 4, wm8753_dai_mode),
230SOC_ENUM_SINGLE(WM8753_ADC, 7, 4, wm8753_dat_sel), 231SOC_ENUM_SINGLE(WM8753_ADC, 7, 4, wm8753_dat_sel),
232SOC_ENUM_SINGLE(WM8753_OUTCTL, 2, 2, wm8753_rout2_phase),
231}; 233};
232 234
233 235
@@ -247,7 +249,7 @@ static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
247 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 249 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
248 int mode = wm8753_read_reg_cache(codec, WM8753_IOCTL); 250 int mode = wm8753_read_reg_cache(codec, WM8753_IOCTL);
249 251
250 if (((mode &0xc) >> 2) == ucontrol->value.integer.value[0]) 252 if (((mode & 0xc) >> 2) == ucontrol->value.integer.value[0])
251 return 0; 253 return 0;
252 254
253 mode &= 0xfff3; 255 mode &= 0xfff3;
@@ -279,7 +281,7 @@ SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8753_LOUT2V, WM8753_ROUT2V, 7, 1, 0
279 281
280SOC_SINGLE("Mono Bypass Playback Volume", WM8753_MOUTM1, 4, 7, 1), 282SOC_SINGLE("Mono Bypass Playback Volume", WM8753_MOUTM1, 4, 7, 1),
281SOC_SINGLE("Mono Sidetone Playback Volume", WM8753_MOUTM2, 4, 7, 1), 283SOC_SINGLE("Mono Sidetone Playback Volume", WM8753_MOUTM2, 4, 7, 1),
282SOC_SINGLE("Mono Voice Playback Volume", WM8753_MOUTM2, 4, 7, 1), 284SOC_SINGLE("Mono Voice Playback Volume", WM8753_MOUTM2, 0, 7, 1),
283SOC_SINGLE("Mono Playback ZC Switch", WM8753_MOUTV, 7, 1, 0), 285SOC_SINGLE("Mono Playback ZC Switch", WM8753_MOUTV, 7, 1, 0),
284 286
285SOC_ENUM("Bass Boost", wm8753_enum[0]), 287SOC_ENUM("Bass Boost", wm8753_enum[0]),
@@ -330,6 +332,7 @@ SOC_SINGLE("Mic1 Capture Volume", WM8753_INCTL1, 5, 3, 0),
330SOC_ENUM_EXT("DAI Mode", wm8753_enum[26], wm8753_get_dai, wm8753_set_dai), 332SOC_ENUM_EXT("DAI Mode", wm8753_enum[26], wm8753_get_dai, wm8753_set_dai),
331 333
332SOC_ENUM("ADC Data Select", wm8753_enum[27]), 334SOC_ENUM("ADC Data Select", wm8753_enum[27]),
335SOC_ENUM("ROUT2 Phase", wm8753_enum[28]),
333}; 336};
334 337
335/* add non dapm controls */ 338/* add non dapm controls */
@@ -339,7 +342,8 @@ static int wm8753_add_controls(struct snd_soc_codec *codec)
339 342
340 for (i = 0; i < ARRAY_SIZE(wm8753_snd_controls); i++) { 343 for (i = 0; i < ARRAY_SIZE(wm8753_snd_controls); i++) {
341 err = snd_ctl_add(codec->card, 344 err = snd_ctl_add(codec->card,
342 snd_soc_cnew(&wm8753_snd_controls[i],codec, NULL)); 345 snd_soc_cnew(&wm8753_snd_controls[i],
346 codec, NULL));
343 if (err < 0) 347 if (err < 0)
344 return err; 348 return err;
345 } 349 }
@@ -719,7 +723,7 @@ static void pll_factors(struct _pll_div *pll_div, unsigned int target,
719 723
720 if ((Ndiv < 6) || (Ndiv > 12)) 724 if ((Ndiv < 6) || (Ndiv > 12))
721 printk(KERN_WARNING 725 printk(KERN_WARNING
722 "WM8753 N value outwith recommended range! N = %d\n",Ndiv); 726 "wm8753: unsupported N = %d\n", Ndiv);
723 727
724 pll_div->n = Ndiv; 728 pll_div->n = Ndiv;
725 Nmod = target % source; 729 Nmod = target % source;
@@ -1297,8 +1301,9 @@ static int wm8753_dapm_event(struct snd_soc_codec *codec, int event)
1297} 1301}
1298 1302
1299#define WM8753_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 1303#define WM8753_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
1300 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \ 1304 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\
1301 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) 1305 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
1306 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
1302 1307
1303#define WM8753_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 1308#define WM8753_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
1304 SNDRV_PCM_FMTBIT_S24_LE) 1309 SNDRV_PCM_FMTBIT_S24_LE)
@@ -1504,9 +1509,9 @@ static int wm8753_suspend(struct platform_device *pdev, pm_message_t state)
1504 struct snd_soc_codec *codec = socdev->codec; 1509 struct snd_soc_codec *codec = socdev->codec;
1505 1510
1506 /* we only need to suspend if we are a valid card */ 1511 /* we only need to suspend if we are a valid card */
1507 if(!codec->card) 1512 if (!codec->card)
1508 return 0; 1513 return 0;
1509 1514
1510 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D3cold); 1515 wm8753_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
1511 return 0; 1516 return 0;
1512} 1517}
@@ -1520,7 +1525,7 @@ static int wm8753_resume(struct platform_device *pdev)
1520 u16 *cache = codec->reg_cache; 1525 u16 *cache = codec->reg_cache;
1521 1526
1522 /* we only need to resume if we are a valid card */ 1527 /* we only need to resume if we are a valid card */
1523 if(!codec->card) 1528 if (!codec->card)
1524 return 0; 1529 return 0;
1525 1530
1526 /* Sync reg_cache with the hardware */ 1531 /* Sync reg_cache with the hardware */
@@ -1610,9 +1615,10 @@ static int wm8753_init(struct snd_soc_device *socdev)
1610 wm8753_add_widgets(codec); 1615 wm8753_add_widgets(codec);
1611 ret = snd_soc_register_card(socdev); 1616 ret = snd_soc_register_card(socdev);
1612 if (ret < 0) { 1617 if (ret < 0) {
1613 printk(KERN_ERR "wm8753: failed to register card\n"); 1618 printk(KERN_ERR "wm8753: failed to register card\n");
1614 goto card_err; 1619 goto card_err;
1615 } 1620 }
1621
1616 return ret; 1622 return ret;
1617 1623
1618card_err: 1624card_err:
@@ -1627,7 +1633,7 @@ pcm_err:
1627 around */ 1633 around */
1628static struct snd_soc_device *wm8753_socdev; 1634static struct snd_soc_device *wm8753_socdev;
1629 1635
1630#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 1636#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1631 1637
1632/* 1638/*
1633 * WM8753 2 wire address is determined by GPIO5 1639 * WM8753 2 wire address is determined by GPIO5
@@ -1658,7 +1664,7 @@ static int wm8753_codec_probe(struct i2c_adapter *adap, int addr, int kind)
1658 client_template.addr = addr; 1664 client_template.addr = addr;
1659 1665
1660 i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL); 1666 i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL);
1661 if (i2c == NULL){ 1667 if (!i2c) {
1662 kfree(codec); 1668 kfree(codec);
1663 return -ENOMEM; 1669 return -ENOMEM;
1664 } 1670 }
@@ -1746,7 +1752,7 @@ static int wm8753_probe(struct platform_device *pdev)
1746 wm8753_socdev = socdev; 1752 wm8753_socdev = socdev;
1747 INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work); 1753 INIT_DELAYED_WORK(&codec->delayed_work, wm8753_work);
1748 1754
1749#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 1755#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1750 if (setup->i2c_address) { 1756 if (setup->i2c_address) {
1751 normal_i2c[0] = setup->i2c_address; 1757 normal_i2c[0] = setup->i2c_address;
1752 codec->hw_write = (hw_write_t)i2c_master_send; 1758 codec->hw_write = (hw_write_t)i2c_master_send;
@@ -1790,7 +1796,7 @@ static int wm8753_remove(struct platform_device *pdev)
1790 run_delayed_work(&codec->delayed_work); 1796 run_delayed_work(&codec->delayed_work);
1791 snd_soc_free_pcms(socdev); 1797 snd_soc_free_pcms(socdev);
1792 snd_soc_dapm_free(socdev); 1798 snd_soc_dapm_free(socdev);
1793#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 1799#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1794 i2c_del_driver(&wm8753_i2c_driver); 1800 i2c_del_driver(&wm8753_i2c_driver);
1795#endif 1801#endif
1796 kfree(codec->private_data); 1802 kfree(codec->private_data);
@@ -1805,7 +1811,6 @@ struct snd_soc_codec_device soc_codec_dev_wm8753 = {
1805 .suspend = wm8753_suspend, 1811 .suspend = wm8753_suspend,
1806 .resume = wm8753_resume, 1812 .resume = wm8753_resume,
1807}; 1813};
1808
1809EXPORT_SYMBOL_GPL(soc_codec_dev_wm8753); 1814EXPORT_SYMBOL_GPL(soc_codec_dev_wm8753);
1810 1815
1811MODULE_DESCRIPTION("ASoC WM8753 driver"); 1816MODULE_DESCRIPTION("ASoC WM8753 driver");
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c
index 524f7450804f..76c1e2d33e7d 100644
--- a/sound/soc/codecs/wm9712.c
+++ b/sound/soc/codecs/wm9712.c
@@ -37,23 +37,23 @@ static int ac97_write(struct snd_soc_codec *codec,
37 * WM9712 register cache 37 * WM9712 register cache
38 */ 38 */
39static const u16 wm9712_reg[] = { 39static const u16 wm9712_reg[] = {
40 0x6174, 0x8000, 0x8000, 0x8000, // 6 40 0x6174, 0x8000, 0x8000, 0x8000, /* 6 */
41 0x0f0f, 0xaaa0, 0xc008, 0x6808, // e 41 0x0f0f, 0xaaa0, 0xc008, 0x6808, /* e */
42 0xe808, 0xaaa0, 0xad00, 0x8000, // 16 42 0xe808, 0xaaa0, 0xad00, 0x8000, /* 16 */
43 0xe808, 0x3000, 0x8000, 0x0000, // 1e 43 0xe808, 0x3000, 0x8000, 0x0000, /* 1e */
44 0x0000, 0x0000, 0x0000, 0x000f, // 26 44 0x0000, 0x0000, 0x0000, 0x000f, /* 26 */
45 0x0405, 0x0410, 0xbb80, 0xbb80, // 2e 45 0x0405, 0x0410, 0xbb80, 0xbb80, /* 2e */
46 0x0000, 0xbb80, 0x0000, 0x0000, // 36 46 0x0000, 0xbb80, 0x0000, 0x0000, /* 36 */
47 0x0000, 0x2000, 0x0000, 0x0000, // 3e 47 0x0000, 0x2000, 0x0000, 0x0000, /* 3e */
48 0x0000, 0x0000, 0x0000, 0x0000, // 46 48 0x0000, 0x0000, 0x0000, 0x0000, /* 46 */
49 0x0000, 0x0000, 0xf83e, 0xffff, // 4e 49 0x0000, 0x0000, 0xf83e, 0xffff, /* 4e */
50 0x0000, 0x0000, 0x0000, 0xf83e, // 56 50 0x0000, 0x0000, 0x0000, 0xf83e, /* 56 */
51 0x0008, 0x0000, 0x0000, 0x0000, // 5e 51 0x0008, 0x0000, 0x0000, 0x0000, /* 5e */
52 0xb032, 0x3e00, 0x0000, 0x0000, // 66 52 0xb032, 0x3e00, 0x0000, 0x0000, /* 66 */
53 0x0000, 0x0000, 0x0000, 0x0000, // 6e 53 0x0000, 0x0000, 0x0000, 0x0000, /* 6e */
54 0x0000, 0x0000, 0x0000, 0x0006, // 76 54 0x0000, 0x0000, 0x0000, 0x0006, /* 76 */
55 0x0001, 0x0000, 0x574d, 0x4c12, // 7e 55 0x0001, 0x0000, 0x574d, 0x4c12, /* 7e */
56 0x0000, 0x0000 // virtual hp mixers 56 0x0000, 0x0000 /* virtual hp mixers */
57}; 57};
58 58
59/* virtual HP mixers regs */ 59/* virtual HP mixers regs */
@@ -94,7 +94,7 @@ static const struct snd_kcontrol_new wm9712_snd_ac97_controls[] = {
94SOC_DOUBLE("Speaker Playback Volume", AC97_MASTER, 8, 0, 31, 1), 94SOC_DOUBLE("Speaker Playback Volume", AC97_MASTER, 8, 0, 31, 1),
95SOC_SINGLE("Speaker Playback Switch", AC97_MASTER, 15, 1, 1), 95SOC_SINGLE("Speaker Playback Switch", AC97_MASTER, 15, 1, 1),
96SOC_DOUBLE("Headphone Playback Volume", AC97_HEADPHONE, 8, 0, 31, 1), 96SOC_DOUBLE("Headphone Playback Volume", AC97_HEADPHONE, 8, 0, 31, 1),
97SOC_SINGLE("Headphone Playback Switch", AC97_HEADPHONE,15, 1, 1), 97SOC_SINGLE("Headphone Playback Switch", AC97_HEADPHONE, 15, 1, 1),
98SOC_DOUBLE("PCM Playback Volume", AC97_PCM, 8, 0, 31, 1), 98SOC_DOUBLE("PCM Playback Volume", AC97_PCM, 8, 0, 31, 1),
99 99
100SOC_SINGLE("Speaker Playback ZC Switch", AC97_MASTER, 7, 1, 0), 100SOC_SINGLE("Speaker Playback ZC Switch", AC97_MASTER, 7, 1, 0),
@@ -165,7 +165,8 @@ static int wm9712_add_controls(struct snd_soc_codec *codec)
165 165
166 for (i = 0; i < ARRAY_SIZE(wm9712_snd_ac97_controls); i++) { 166 for (i = 0; i < ARRAY_SIZE(wm9712_snd_ac97_controls); i++) {
167 err = snd_ctl_add(codec->card, 167 err = snd_ctl_add(codec->card,
168 snd_soc_cnew(&wm9712_snd_ac97_controls[i],codec, NULL)); 168 snd_soc_cnew(&wm9712_snd_ac97_controls[i],
169 codec, NULL));
169 if (err < 0) 170 if (err < 0)
170 return err; 171 return err;
171 } 172 }
@@ -363,7 +364,6 @@ static const char *audio_map[][3] = {
363 {"Left HP Mixer", "PCM Playback Switch", "Left DAC"}, 364 {"Left HP Mixer", "PCM Playback Switch", "Left DAC"},
364 {"Left HP Mixer", "Mic Sidetone Switch", "Mic PGA"}, 365 {"Left HP Mixer", "Mic Sidetone Switch", "Mic PGA"},
365 {"Left HP Mixer", NULL, "ALC Sidetone Mux"}, 366 {"Left HP Mixer", NULL, "ALC Sidetone Mux"},
366 //{"Right HP Mixer", NULL, "HP Mixer"},
367 367
368 /* Right HP mixer */ 368 /* Right HP mixer */
369 {"Right HP Mixer", "PCBeep Bypass Switch", "PCBEEP"}, 369 {"Right HP Mixer", "PCBeep Bypass Switch", "PCBEEP"},
@@ -454,15 +454,13 @@ static int wm9712_add_widgets(struct snd_soc_codec *codec)
454{ 454{
455 int i; 455 int i;
456 456
457 for(i = 0; i < ARRAY_SIZE(wm9712_dapm_widgets); i++) { 457 for (i = 0; i < ARRAY_SIZE(wm9712_dapm_widgets); i++)
458 snd_soc_dapm_new_control(codec, &wm9712_dapm_widgets[i]); 458 snd_soc_dapm_new_control(codec, &wm9712_dapm_widgets[i]);
459 }
460 459
461 /* set up audio path audio_mapnects */ 460 /* set up audio path connects */
462 for(i = 0; audio_map[i][0] != NULL; i++) { 461 for (i = 0; audio_map[i][0] != NULL; i++)
463 snd_soc_dapm_connect_input(codec, audio_map[i][0], 462 snd_soc_dapm_connect_input(codec, audio_map[i][0],
464 audio_map[i][1], audio_map[i][2]); 463 audio_map[i][1], audio_map[i][2]);
465 }
466 464
467 snd_soc_dapm_new_widgets(codec); 465 snd_soc_dapm_new_widgets(codec);
468 return 0; 466 return 0;
@@ -540,7 +538,8 @@ static int ac97_aux_prepare(struct snd_pcm_substream *substream)
540} 538}
541 539
542#define WM9712_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ 540#define WM9712_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
543 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) 541 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\
542 SNDRV_PCM_RATE_48000)
544 543
545struct snd_soc_codec_dai wm9712_dai[] = { 544struct snd_soc_codec_dai wm9712_dai[] = {
546{ 545{
@@ -577,26 +576,16 @@ EXPORT_SYMBOL_GPL(wm9712_dai);
577 576
578static int wm9712_dapm_event(struct snd_soc_codec *codec, int event) 577static int wm9712_dapm_event(struct snd_soc_codec *codec, int event)
579{ 578{
580 u16 reg;
581
582 switch (event) { 579 switch (event) {
583 case SNDRV_CTL_POWER_D0: /* full On */ 580 case SNDRV_CTL_POWER_D0: /* full On */
584 /* liam - maybe enable thermal shutdown */
585 reg = ac97_read(codec, AC97_EXTENDED_MID) & 0xdfff;
586 ac97_write(codec, AC97_EXTENDED_MID, reg);
587 break;
588 case SNDRV_CTL_POWER_D1: /* partial On */ 581 case SNDRV_CTL_POWER_D1: /* partial On */
589 case SNDRV_CTL_POWER_D2: /* partial On */ 582 case SNDRV_CTL_POWER_D2: /* partial On */
590 break; 583 break;
591 case SNDRV_CTL_POWER_D3hot: /* Off, with power */ 584 case SNDRV_CTL_POWER_D3hot: /* Off, with power */
592 /* enable master bias and vmid */
593 reg = ac97_read(codec, AC97_EXTENDED_MID) & 0xbbff;
594 ac97_write(codec, AC97_EXTENDED_MID, reg);
595 ac97_write(codec, AC97_POWERDOWN, 0x0000); 585 ac97_write(codec, AC97_POWERDOWN, 0x0000);
596 break; 586 break;
597 case SNDRV_CTL_POWER_D3cold: /* Off, without power */ 587 case SNDRV_CTL_POWER_D3cold: /* Off, without power */
598 /* disable everything including AC link */ 588 /* disable everything including AC link */
599 ac97_write(codec, AC97_EXTENDED_MID, 0xffff);
600 ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); 589 ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
601 ac97_write(codec, AC97_POWERDOWN, 0xffff); 590 ac97_write(codec, AC97_POWERDOWN, 0xffff);
602 break; 591 break;
@@ -641,7 +630,7 @@ static int wm9712_soc_resume(struct platform_device *pdev)
641 u16 *cache = codec->reg_cache; 630 u16 *cache = codec->reg_cache;
642 631
643 ret = wm9712_reset(codec, 1); 632 ret = wm9712_reset(codec, 1);
644 if (ret < 0){ 633 if (ret < 0) {
645 printk(KERN_ERR "could not reset AC97 codec\n"); 634 printk(KERN_ERR "could not reset AC97 codec\n");
646 return ret; 635 return ret;
647 } 636 }
@@ -650,9 +639,9 @@ static int wm9712_soc_resume(struct platform_device *pdev)
650 639
651 if (ret == 0) { 640 if (ret == 0) {
652 /* Sync reg_cache with the hardware after cold reset */ 641 /* Sync reg_cache with the hardware after cold reset */
653 for (i = 2; i < ARRAY_SIZE(wm9712_reg) << 1; i+=2) { 642 for (i = 2; i < ARRAY_SIZE(wm9712_reg) << 1; i += 2) {
654 if (i == AC97_INT_PAGING || i == AC97_POWERDOWN || 643 if (i == AC97_INT_PAGING || i == AC97_POWERDOWN ||
655 (i > 0x58 && i != 0x5c)) 644 (i > 0x58 && i != 0x5c))
656 continue; 645 continue;
657 soc_ac97_ops.write(codec->ac97, i, cache[i>>1]); 646 soc_ac97_ops.write(codec->ac97, i, cache[i>>1]);
658 } 647 }
@@ -765,7 +754,6 @@ struct snd_soc_codec_device soc_codec_dev_wm9712 = {
765 .suspend = wm9712_soc_suspend, 754 .suspend = wm9712_soc_suspend,
766 .resume = wm9712_soc_resume, 755 .resume = wm9712_soc_resume,
767}; 756};
768
769EXPORT_SYMBOL_GPL(soc_codec_dev_wm9712); 757EXPORT_SYMBOL_GPL(soc_codec_dev_wm9712);
770 758
771MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver"); 759MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver");
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c
new file mode 100644
index 000000000000..1f241161445c
--- /dev/null
+++ b/sound/soc/codecs/wm9713.c
@@ -0,0 +1,1300 @@
1/*
2 * wm9713.c -- ALSA Soc WM9713 codec support
3 *
4 * Copyright 2006 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood
6 * liam.girdwood@wolfsonmicro.com or linux@wolfsonmicro.com
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Revision history
14 * 4th Feb 2006 Initial version.
15 *
16 * Features:-
17 *
18 * o Support for AC97 Codec, Voice DAC and Aux DAC
19 * o Support for DAPM
20 */
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/device.h>
25#include <sound/core.h>
26#include <sound/pcm.h>
27#include <sound/ac97_codec.h>
28#include <sound/initval.h>
29#include <sound/pcm_params.h>
30#include <sound/soc.h>
31#include <sound/soc-dapm.h>
32
33#include "wm9713.h"
34
35#define WM9713_VERSION "0.15"
36
37struct wm9713_priv {
38 u32 pll_in; /* PLL input frequency */
39 u32 pll_out; /* PLL output frequency */
40};
41
42static unsigned int ac97_read(struct snd_soc_codec *codec,
43 unsigned int reg);
44static int ac97_write(struct snd_soc_codec *codec,
45 unsigned int reg, unsigned int val);
46
47/*
48 * WM9713 register cache
49 * Reg 0x3c bit 15 is used by touch driver.
50 */
51static const u16 wm9713_reg[] = {
52 0x6174, 0x8080, 0x8080, 0x8080,
53 0xc880, 0xe808, 0xe808, 0x0808,
54 0x00da, 0x8000, 0xd600, 0xaaa0,
55 0xaaa0, 0xaaa0, 0x0000, 0x0000,
56 0x0f0f, 0x0040, 0x0000, 0x7f00,
57 0x0405, 0x0410, 0xbb80, 0xbb80,
58 0x0000, 0xbb80, 0x0000, 0x4523,
59 0x0000, 0x2000, 0x7eff, 0xffff,
60 0x0000, 0x0000, 0x0080, 0x0000,
61 0x0000, 0x0000, 0xfffe, 0xffff,
62 0x0000, 0x0000, 0x0000, 0xfffe,
63 0x4000, 0x0000, 0x0000, 0x0000,
64 0xb032, 0x3e00, 0x0000, 0x0000,
65 0x0000, 0x0000, 0x0000, 0x0000,
66 0x0000, 0x0000, 0x0000, 0x0006,
67 0x0001, 0x0000, 0x574d, 0x4c13,
68 0x0000, 0x0000, 0x0000
69};
70
71/* virtual HP mixers regs */
72#define HPL_MIXER 0x80
73#define HPR_MIXER 0x82
74#define MICB_MUX 0x82
75
76static const char *wm9713_mic_mixer[] = {"Stereo", "Mic 1", "Mic 2", "Mute"};
77static const char *wm9713_rec_mux[] = {"Stereo", "Left", "Right", "Mute"};
78static const char *wm9713_rec_src[] =
79 {"Mic 1", "Mic 2", "Line", "Mono In", "Headphone", "Speaker",
80 "Mono Out", "Zh"};
81static const char *wm9713_rec_gain[] = {"+1.5dB Steps", "+0.75dB Steps"};
82static const char *wm9713_alc_select[] = {"None", "Left", "Right", "Stereo"};
83static const char *wm9713_mono_pga[] = {"Vmid", "Zh", "Mono", "Inv",
84 "Mono Vmid", "Inv Vmid"};
85static const char *wm9713_spk_pga[] =
86 {"Vmid", "Zh", "Headphone", "Speaker", "Inv", "Headphone Vmid",
87 "Speaker Vmid", "Inv Vmid"};
88static const char *wm9713_hp_pga[] = {"Vmid", "Zh", "Headphone",
89 "Headphone Vmid"};
90static const char *wm9713_out3_pga[] = {"Vmid", "Zh", "Inv 1", "Inv 1 Vmid"};
91static const char *wm9713_out4_pga[] = {"Vmid", "Zh", "Inv 2", "Inv 2 Vmid"};
92static const char *wm9713_dac_inv[] =
93 {"Off", "Mono", "Speaker", "Left Headphone", "Right Headphone",
94 "Headphone Mono", "NC", "Vmid"};
95static const char *wm9713_bass[] = {"Linear Control", "Adaptive Boost"};
96static const char *wm9713_ng_type[] = {"Constant Gain", "Mute"};
97static const char *wm9713_mic_select[] = {"Mic 1", "Mic 2 A", "Mic 2 B"};
98static const char *wm9713_micb_select[] = {"MPB", "MPA"};
99
100static const struct soc_enum wm9713_enum[] = {
101SOC_ENUM_SINGLE(AC97_LINE, 3, 4, wm9713_mic_mixer), /* record mic mixer 0 */
102SOC_ENUM_SINGLE(AC97_VIDEO, 14, 4, wm9713_rec_mux), /* record mux hp 1 */
103SOC_ENUM_SINGLE(AC97_VIDEO, 9, 4, wm9713_rec_mux), /* record mux mono 2 */
104SOC_ENUM_SINGLE(AC97_VIDEO, 3, 8, wm9713_rec_src), /* record mux left 3 */
105SOC_ENUM_SINGLE(AC97_VIDEO, 0, 8, wm9713_rec_src), /* record mux right 4*/
106SOC_ENUM_DOUBLE(AC97_CD, 14, 6, 2, wm9713_rec_gain), /* record step size 5 */
107SOC_ENUM_SINGLE(AC97_PCI_SVID, 14, 4, wm9713_alc_select), /* alc source select 6*/
108SOC_ENUM_SINGLE(AC97_REC_GAIN, 14, 4, wm9713_mono_pga), /* mono input select 7 */
109SOC_ENUM_SINGLE(AC97_REC_GAIN, 11, 8, wm9713_spk_pga), /* speaker left input select 8 */
110SOC_ENUM_SINGLE(AC97_REC_GAIN, 8, 8, wm9713_spk_pga), /* speaker right input select 9 */
111SOC_ENUM_SINGLE(AC97_REC_GAIN, 6, 3, wm9713_hp_pga), /* headphone left input 10 */
112SOC_ENUM_SINGLE(AC97_REC_GAIN, 4, 3, wm9713_hp_pga), /* headphone right input 11 */
113SOC_ENUM_SINGLE(AC97_REC_GAIN, 2, 4, wm9713_out3_pga), /* out 3 source 12 */
114SOC_ENUM_SINGLE(AC97_REC_GAIN, 0, 4, wm9713_out4_pga), /* out 4 source 13 */
115SOC_ENUM_SINGLE(AC97_REC_GAIN_MIC, 13, 8, wm9713_dac_inv), /* dac invert 1 14 */
116SOC_ENUM_SINGLE(AC97_REC_GAIN_MIC, 10, 8, wm9713_dac_inv), /* dac invert 2 15 */
117SOC_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 15, 2, wm9713_bass), /* bass control 16 */
118SOC_ENUM_SINGLE(AC97_PCI_SVID, 5, 2, wm9713_ng_type), /* noise gate type 17 */
119SOC_ENUM_SINGLE(AC97_3D_CONTROL, 12, 3, wm9713_mic_select), /* mic selection 18 */
120SOC_ENUM_SINGLE(MICB_MUX, 0, 2, wm9713_micb_select), /* mic selection 19 */
121};
122
123static const struct snd_kcontrol_new wm9713_snd_ac97_controls[] = {
124SOC_DOUBLE("Speaker Playback Volume", AC97_MASTER, 8, 0, 31, 1),
125SOC_DOUBLE("Speaker Playback Switch", AC97_MASTER, 15, 7, 1, 1),
126SOC_DOUBLE("Headphone Playback Volume", AC97_HEADPHONE, 8, 0, 31, 1),
127SOC_DOUBLE("Headphone Playback Switch", AC97_HEADPHONE, 15, 7, 1, 1),
128SOC_DOUBLE("Line In Volume", AC97_PC_BEEP, 8, 0, 31, 1),
129SOC_DOUBLE("PCM Playback Volume", AC97_PHONE, 8, 0, 31, 1),
130SOC_SINGLE("Mic 1 Volume", AC97_MIC, 8, 31, 1),
131SOC_SINGLE("Mic 2 Volume", AC97_MIC, 0, 31, 1),
132
133SOC_SINGLE("Mic Boost (+20dB) Switch", AC97_LINE, 5, 1, 0),
134SOC_SINGLE("Mic Headphone Mixer Volume", AC97_LINE, 0, 7, 1),
135
136SOC_SINGLE("Capture Switch", AC97_CD, 15, 1, 1),
137SOC_ENUM("Capture Volume Steps", wm9713_enum[5]),
138SOC_DOUBLE("Capture Volume", AC97_CD, 8, 0, 31, 0),
139SOC_SINGLE("Capture ZC Switch", AC97_CD, 7, 1, 0),
140
141SOC_SINGLE("Capture to Headphone Volume", AC97_VIDEO, 11, 7, 1),
142SOC_SINGLE("Capture to Mono Boost (+20dB) Switch", AC97_VIDEO, 8, 1, 0),
143SOC_SINGLE("Capture ADC Boost (+20dB) Switch", AC97_VIDEO, 6, 1, 0),
144
145SOC_SINGLE("ALC Target Volume", AC97_CODEC_CLASS_REV, 12, 15, 0),
146SOC_SINGLE("ALC Hold Time", AC97_CODEC_CLASS_REV, 8, 15, 0),
147SOC_SINGLE("ALC Decay Time ", AC97_CODEC_CLASS_REV, 4, 15, 0),
148SOC_SINGLE("ALC Attack Time", AC97_CODEC_CLASS_REV, 0, 15, 0),
149SOC_ENUM("ALC Function", wm9713_enum[6]),
150SOC_SINGLE("ALC Max Volume", AC97_PCI_SVID, 11, 7, 0),
151SOC_SINGLE("ALC ZC Timeout", AC97_PCI_SVID, 9, 3, 0),
152SOC_SINGLE("ALC ZC Switch", AC97_PCI_SVID, 8, 1, 0),
153SOC_SINGLE("ALC NG Switch", AC97_PCI_SVID, 7, 1, 0),
154SOC_ENUM("ALC NG Type", wm9713_enum[17]),
155SOC_SINGLE("ALC NG Threshold", AC97_PCI_SVID, 0, 31, 0),
156
157SOC_DOUBLE("Speaker Playback ZC Switch", AC97_MASTER, 14, 6, 1, 0),
158SOC_DOUBLE("Headphone Playback ZC Switch", AC97_HEADPHONE, 14, 6, 1, 0),
159
160SOC_SINGLE("Out4 Playback Switch", AC97_MASTER_MONO, 15, 1, 1),
161SOC_SINGLE("Out4 Playback ZC Switch", AC97_MASTER_MONO, 14, 1, 0),
162SOC_SINGLE("Out4 Playback Volume", AC97_MASTER_MONO, 8, 63, 1),
163
164SOC_SINGLE("Out3 Playback Switch", AC97_MASTER_MONO, 7, 1, 1),
165SOC_SINGLE("Out3 Playback ZC Switch", AC97_MASTER_MONO, 6, 1, 0),
166SOC_SINGLE("Out3 Playback Volume", AC97_MASTER_MONO, 0, 63, 1),
167
168SOC_SINGLE("Mono Capture Volume", AC97_MASTER_TONE, 8, 31, 1),
169SOC_SINGLE("Mono Playback Switch", AC97_MASTER_TONE, 7, 1, 1),
170SOC_SINGLE("Mono Playback ZC Switch", AC97_MASTER_TONE, 6, 1, 0),
171SOC_SINGLE("Mono Playback Volume", AC97_MASTER_TONE, 0, 31, 1),
172
173SOC_SINGLE("PC Beep Playback Headphone Volume", AC97_AUX, 12, 7, 1),
174SOC_SINGLE("PC Beep Playback Speaker Volume", AC97_AUX, 8, 7, 1),
175SOC_SINGLE("PC Beep Playback Mono Volume", AC97_AUX, 4, 7, 1),
176
177SOC_SINGLE("Voice Playback Headphone Volume", AC97_PCM, 12, 7, 1),
178SOC_SINGLE("Voice Playback Master Volume", AC97_PCM, 8, 7, 1),
179SOC_SINGLE("Voice Playback Mono Volume", AC97_PCM, 4, 7, 1),
180
181SOC_SINGLE("Aux Playback Headphone Volume", AC97_REC_SEL, 12, 7, 1),
182SOC_SINGLE("Aux Playback Master Volume", AC97_REC_SEL, 8, 7, 1),
183SOC_SINGLE("Aux Playback Mono Volume", AC97_REC_SEL, 4, 7, 1),
184
185SOC_ENUM("Bass Control", wm9713_enum[16]),
186SOC_SINGLE("Bass Cut-off Switch", AC97_GENERAL_PURPOSE, 12, 1, 1),
187SOC_SINGLE("Tone Cut-off Switch", AC97_GENERAL_PURPOSE, 4, 1, 1),
188SOC_SINGLE("Playback Attenuate (-6dB) Switch", AC97_GENERAL_PURPOSE, 6, 1, 0),
189SOC_SINGLE("Bass Volume", AC97_GENERAL_PURPOSE, 8, 15, 1),
190SOC_SINGLE("Tone Volume", AC97_GENERAL_PURPOSE, 0, 15, 1),
191
192SOC_SINGLE("3D Upper Cut-off Switch", AC97_REC_GAIN_MIC, 5, 1, 0),
193SOC_SINGLE("3D Lower Cut-off Switch", AC97_REC_GAIN_MIC, 4, 1, 0),
194SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1),
195};
196
197/* add non dapm controls */
198static int wm9713_add_controls(struct snd_soc_codec *codec)
199{
200 int err, i;
201
202 for (i = 0; i < ARRAY_SIZE(wm9713_snd_ac97_controls); i++) {
203 err = snd_ctl_add(codec->card,
204 snd_soc_cnew(&wm9713_snd_ac97_controls[i],
205 codec, NULL));
206 if (err < 0)
207 return err;
208 }
209 return 0;
210}
211
212/* We have to create a fake left and right HP mixers because
213 * the codec only has a single control that is shared by both channels.
214 * This makes it impossible to determine the audio path using the current
215 * register map, thus we add a new (virtual) register to help determine the
216 * audio route within the device.
217 */
218static int mixer_event(struct snd_soc_dapm_widget *w,
219 struct snd_kcontrol *kcontrol, int event)
220{
221 u16 l, r, beep, tone, phone, rec, pcm, aux;
222
223 l = ac97_read(w->codec, HPL_MIXER);
224 r = ac97_read(w->codec, HPR_MIXER);
225 beep = ac97_read(w->codec, AC97_PC_BEEP);
226 tone = ac97_read(w->codec, AC97_MASTER_TONE);
227 phone = ac97_read(w->codec, AC97_PHONE);
228 rec = ac97_read(w->codec, AC97_REC_SEL);
229 pcm = ac97_read(w->codec, AC97_PCM);
230 aux = ac97_read(w->codec, AC97_AUX);
231
232 if (event & SND_SOC_DAPM_PRE_REG)
233 return 0;
234 if ((l & 0x1) || (r & 0x1))
235 ac97_write(w->codec, AC97_PC_BEEP, beep & 0x7fff);
236 else
237 ac97_write(w->codec, AC97_PC_BEEP, beep | 0x8000);
238
239 if ((l & 0x2) || (r & 0x2))
240 ac97_write(w->codec, AC97_MASTER_TONE, tone & 0x7fff);
241 else
242 ac97_write(w->codec, AC97_MASTER_TONE, tone | 0x8000);
243
244 if ((l & 0x4) || (r & 0x4))
245 ac97_write(w->codec, AC97_PHONE, phone & 0x7fff);
246 else
247 ac97_write(w->codec, AC97_PHONE, phone | 0x8000);
248
249 if ((l & 0x8) || (r & 0x8))
250 ac97_write(w->codec, AC97_REC_SEL, rec & 0x7fff);
251 else
252 ac97_write(w->codec, AC97_REC_SEL, rec | 0x8000);
253
254 if ((l & 0x10) || (r & 0x10))
255 ac97_write(w->codec, AC97_PCM, pcm & 0x7fff);
256 else
257 ac97_write(w->codec, AC97_PCM, pcm | 0x8000);
258
259 if ((l & 0x20) || (r & 0x20))
260 ac97_write(w->codec, AC97_AUX, aux & 0x7fff);
261 else
262 ac97_write(w->codec, AC97_AUX, aux | 0x8000);
263
264 return 0;
265}
266
267/* Left Headphone Mixers */
268static const struct snd_kcontrol_new wm9713_hpl_mixer_controls[] = {
269SOC_DAPM_SINGLE("PC Beep Playback Switch", HPL_MIXER, 5, 1, 0),
270SOC_DAPM_SINGLE("Voice Playback Switch", HPL_MIXER, 4, 1, 0),
271SOC_DAPM_SINGLE("Aux Playback Switch", HPL_MIXER, 3, 1, 0),
272SOC_DAPM_SINGLE("PCM Playback Switch", HPL_MIXER, 2, 1, 0),
273SOC_DAPM_SINGLE("MonoIn Playback Switch", HPL_MIXER, 1, 1, 0),
274SOC_DAPM_SINGLE("Bypass Playback Switch", HPL_MIXER, 0, 1, 0),
275};
276
277/* Right Headphone Mixers */
278static const struct snd_kcontrol_new wm9713_hpr_mixer_controls[] = {
279SOC_DAPM_SINGLE("PC Beep Playback Switch", HPR_MIXER, 5, 1, 0),
280SOC_DAPM_SINGLE("Voice Playback Switch", HPR_MIXER, 4, 1, 0),
281SOC_DAPM_SINGLE("Aux Playback Switch", HPR_MIXER, 3, 1, 0),
282SOC_DAPM_SINGLE("PCM Playback Switch", HPR_MIXER, 2, 1, 0),
283SOC_DAPM_SINGLE("MonoIn Playback Switch", HPR_MIXER, 1, 1, 0),
284SOC_DAPM_SINGLE("Bypass Playback Switch", HPR_MIXER, 0, 1, 0),
285};
286
287/* headphone capture mux */
288static const struct snd_kcontrol_new wm9713_hp_rec_mux_controls =
289SOC_DAPM_ENUM("Route", wm9713_enum[1]);
290
291/* headphone mic mux */
292static const struct snd_kcontrol_new wm9713_hp_mic_mux_controls =
293SOC_DAPM_ENUM("Route", wm9713_enum[0]);
294
295/* Speaker Mixer */
296static const struct snd_kcontrol_new wm9713_speaker_mixer_controls[] = {
297SOC_DAPM_SINGLE("PC Beep Playback Switch", AC97_AUX, 11, 1, 1),
298SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 11, 1, 1),
299SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 11, 1, 1),
300SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 14, 1, 1),
301SOC_DAPM_SINGLE("MonoIn Playback Switch", AC97_MASTER_TONE, 14, 1, 1),
302SOC_DAPM_SINGLE("Bypass Playback Switch", AC97_PC_BEEP, 14, 1, 1),
303};
304
305/* Mono Mixer */
306static const struct snd_kcontrol_new wm9713_mono_mixer_controls[] = {
307SOC_DAPM_SINGLE("PC Beep Playback Switch", AC97_AUX, 7, 1, 1),
308SOC_DAPM_SINGLE("Voice Playback Switch", AC97_PCM, 7, 1, 1),
309SOC_DAPM_SINGLE("Aux Playback Switch", AC97_REC_SEL, 7, 1, 1),
310SOC_DAPM_SINGLE("PCM Playback Switch", AC97_PHONE, 13, 1, 1),
311SOC_DAPM_SINGLE("MonoIn Playback Switch", AC97_MASTER_TONE, 13, 1, 1),
312SOC_DAPM_SINGLE("Bypass Playback Switch", AC97_PC_BEEP, 13, 1, 1),
313SOC_DAPM_SINGLE("Mic 1 Sidetone Switch", AC97_LINE, 7, 1, 1),
314SOC_DAPM_SINGLE("Mic 2 Sidetone Switch", AC97_LINE, 6, 1, 1),
315};
316
317/* mono mic mux */
318static const struct snd_kcontrol_new wm9713_mono_mic_mux_controls =
319SOC_DAPM_ENUM("Route", wm9713_enum[2]);
320
321/* mono output mux */
322static const struct snd_kcontrol_new wm9713_mono_mux_controls =
323SOC_DAPM_ENUM("Route", wm9713_enum[7]);
324
325/* speaker left output mux */
326static const struct snd_kcontrol_new wm9713_hp_spkl_mux_controls =
327SOC_DAPM_ENUM("Route", wm9713_enum[8]);
328
329/* speaker right output mux */
330static const struct snd_kcontrol_new wm9713_hp_spkr_mux_controls =
331SOC_DAPM_ENUM("Route", wm9713_enum[9]);
332
333/* headphone left output mux */
334static const struct snd_kcontrol_new wm9713_hpl_out_mux_controls =
335SOC_DAPM_ENUM("Route", wm9713_enum[10]);
336
337/* headphone right output mux */
338static const struct snd_kcontrol_new wm9713_hpr_out_mux_controls =
339SOC_DAPM_ENUM("Route", wm9713_enum[11]);
340
341/* Out3 mux */
342static const struct snd_kcontrol_new wm9713_out3_mux_controls =
343SOC_DAPM_ENUM("Route", wm9713_enum[12]);
344
345/* Out4 mux */
346static const struct snd_kcontrol_new wm9713_out4_mux_controls =
347SOC_DAPM_ENUM("Route", wm9713_enum[13]);
348
349/* DAC inv mux 1 */
350static const struct snd_kcontrol_new wm9713_dac_inv1_mux_controls =
351SOC_DAPM_ENUM("Route", wm9713_enum[14]);
352
353/* DAC inv mux 2 */
354static const struct snd_kcontrol_new wm9713_dac_inv2_mux_controls =
355SOC_DAPM_ENUM("Route", wm9713_enum[15]);
356
357/* Capture source left */
358static const struct snd_kcontrol_new wm9713_rec_srcl_mux_controls =
359SOC_DAPM_ENUM("Route", wm9713_enum[3]);
360
361/* Capture source right */
362static const struct snd_kcontrol_new wm9713_rec_srcr_mux_controls =
363SOC_DAPM_ENUM("Route", wm9713_enum[4]);
364
365/* mic source */
366static const struct snd_kcontrol_new wm9713_mic_sel_mux_controls =
367SOC_DAPM_ENUM("Route", wm9713_enum[18]);
368
369/* mic source B virtual control */
370static const struct snd_kcontrol_new wm9713_micb_sel_mux_controls =
371SOC_DAPM_ENUM("Route", wm9713_enum[19]);
372
373static const struct snd_soc_dapm_widget wm9713_dapm_widgets[] = {
374SND_SOC_DAPM_MUX("Capture Headphone Mux", SND_SOC_NOPM, 0, 0,
375 &wm9713_hp_rec_mux_controls),
376SND_SOC_DAPM_MUX("Sidetone Mux", SND_SOC_NOPM, 0, 0,
377 &wm9713_hp_mic_mux_controls),
378SND_SOC_DAPM_MUX("Capture Mono Mux", SND_SOC_NOPM, 0, 0,
379 &wm9713_mono_mic_mux_controls),
380SND_SOC_DAPM_MUX("Mono Out Mux", SND_SOC_NOPM, 0, 0,
381 &wm9713_mono_mux_controls),
382SND_SOC_DAPM_MUX("Left Speaker Out Mux", SND_SOC_NOPM, 0, 0,
383 &wm9713_hp_spkl_mux_controls),
384SND_SOC_DAPM_MUX("Right Speaker Out Mux", SND_SOC_NOPM, 0, 0,
385 &wm9713_hp_spkr_mux_controls),
386SND_SOC_DAPM_MUX("Left Headphone Out Mux", SND_SOC_NOPM, 0, 0,
387 &wm9713_hpl_out_mux_controls),
388SND_SOC_DAPM_MUX("Right Headphone Out Mux", SND_SOC_NOPM, 0, 0,
389 &wm9713_hpr_out_mux_controls),
390SND_SOC_DAPM_MUX("Out 3 Mux", SND_SOC_NOPM, 0, 0,
391 &wm9713_out3_mux_controls),
392SND_SOC_DAPM_MUX("Out 4 Mux", SND_SOC_NOPM, 0, 0,
393 &wm9713_out4_mux_controls),
394SND_SOC_DAPM_MUX("DAC Inv Mux 1", SND_SOC_NOPM, 0, 0,
395 &wm9713_dac_inv1_mux_controls),
396SND_SOC_DAPM_MUX("DAC Inv Mux 2", SND_SOC_NOPM, 0, 0,
397 &wm9713_dac_inv2_mux_controls),
398SND_SOC_DAPM_MUX("Left Capture Source", SND_SOC_NOPM, 0, 0,
399 &wm9713_rec_srcl_mux_controls),
400SND_SOC_DAPM_MUX("Right Capture Source", SND_SOC_NOPM, 0, 0,
401 &wm9713_rec_srcr_mux_controls),
402SND_SOC_DAPM_MUX("Mic A Source", SND_SOC_NOPM, 0, 0,
403 &wm9713_mic_sel_mux_controls),
404SND_SOC_DAPM_MUX("Mic B Source", SND_SOC_NOPM, 0, 0,
405 &wm9713_micb_sel_mux_controls),
406SND_SOC_DAPM_MIXER_E("Left HP Mixer", AC97_EXTENDED_MID, 3, 1,
407 &wm9713_hpl_mixer_controls[0], ARRAY_SIZE(wm9713_hpl_mixer_controls),
408 mixer_event, SND_SOC_DAPM_POST_REG),
409SND_SOC_DAPM_MIXER_E("Right HP Mixer", AC97_EXTENDED_MID, 2, 1,
410 &wm9713_hpr_mixer_controls[0], ARRAY_SIZE(wm9713_hpr_mixer_controls),
411 mixer_event, SND_SOC_DAPM_POST_REG),
412SND_SOC_DAPM_MIXER("Mono Mixer", AC97_EXTENDED_MID, 0, 1,
413 &wm9713_mono_mixer_controls[0], ARRAY_SIZE(wm9713_mono_mixer_controls)),
414SND_SOC_DAPM_MIXER("Speaker Mixer", AC97_EXTENDED_MID, 1, 1,
415 &wm9713_speaker_mixer_controls[0],
416 ARRAY_SIZE(wm9713_speaker_mixer_controls)),
417SND_SOC_DAPM_DAC("Left DAC", "Left HiFi Playback", AC97_EXTENDED_MID, 7, 1),
418SND_SOC_DAPM_DAC("Right DAC", "Right HiFi Playback", AC97_EXTENDED_MID, 6, 1),
419SND_SOC_DAPM_MIXER("AC97 Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
420SND_SOC_DAPM_MIXER("HP Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
421SND_SOC_DAPM_MIXER("Line Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
422SND_SOC_DAPM_MIXER("Capture Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
423SND_SOC_DAPM_DAC("Voice DAC", "Voice Playback", AC97_EXTENDED_MID, 12, 1),
424SND_SOC_DAPM_DAC("Aux DAC", "Aux Playback", AC97_EXTENDED_MID, 11, 1),
425SND_SOC_DAPM_ADC("Left ADC", "Left HiFi Capture", AC97_EXTENDED_MID, 5, 1),
426SND_SOC_DAPM_ADC("Right ADC", "Right HiFi Capture", AC97_EXTENDED_MID, 4, 1),
427SND_SOC_DAPM_PGA("Left Headphone", AC97_EXTENDED_MSTATUS, 10, 1, NULL, 0),
428SND_SOC_DAPM_PGA("Right Headphone", AC97_EXTENDED_MSTATUS, 9, 1, NULL, 0),
429SND_SOC_DAPM_PGA("Left Speaker", AC97_EXTENDED_MSTATUS, 8, 1, NULL, 0),
430SND_SOC_DAPM_PGA("Right Speaker", AC97_EXTENDED_MSTATUS, 7, 1, NULL, 0),
431SND_SOC_DAPM_PGA("Out 3", AC97_EXTENDED_MSTATUS, 11, 1, NULL, 0),
432SND_SOC_DAPM_PGA("Out 4", AC97_EXTENDED_MSTATUS, 12, 1, NULL, 0),
433SND_SOC_DAPM_PGA("Mono Out", AC97_EXTENDED_MSTATUS, 13, 1, NULL, 0),
434SND_SOC_DAPM_PGA("Left Line In", AC97_EXTENDED_MSTATUS, 6, 1, NULL, 0),
435SND_SOC_DAPM_PGA("Right Line In", AC97_EXTENDED_MSTATUS, 5, 1, NULL, 0),
436SND_SOC_DAPM_PGA("Mono In", AC97_EXTENDED_MSTATUS, 4, 1, NULL, 0),
437SND_SOC_DAPM_PGA("Mic A PGA", AC97_EXTENDED_MSTATUS, 3, 1, NULL, 0),
438SND_SOC_DAPM_PGA("Mic B PGA", AC97_EXTENDED_MSTATUS, 2, 1, NULL, 0),
439SND_SOC_DAPM_PGA("Mic A Pre Amp", AC97_EXTENDED_MSTATUS, 1, 1, NULL, 0),
440SND_SOC_DAPM_PGA("Mic B Pre Amp", AC97_EXTENDED_MSTATUS, 0, 1, NULL, 0),
441SND_SOC_DAPM_MICBIAS("Mic Bias", AC97_EXTENDED_MSTATUS, 14, 1),
442SND_SOC_DAPM_OUTPUT("MONO"),
443SND_SOC_DAPM_OUTPUT("HPL"),
444SND_SOC_DAPM_OUTPUT("HPR"),
445SND_SOC_DAPM_OUTPUT("SPKL"),
446SND_SOC_DAPM_OUTPUT("SPKR"),
447SND_SOC_DAPM_OUTPUT("OUT3"),
448SND_SOC_DAPM_OUTPUT("OUT4"),
449SND_SOC_DAPM_INPUT("LINEL"),
450SND_SOC_DAPM_INPUT("LINER"),
451SND_SOC_DAPM_INPUT("MONOIN"),
452SND_SOC_DAPM_INPUT("PCBEEP"),
453SND_SOC_DAPM_INPUT("MIC1"),
454SND_SOC_DAPM_INPUT("MIC2A"),
455SND_SOC_DAPM_INPUT("MIC2B"),
456SND_SOC_DAPM_VMID("VMID"),
457};
458
459static const char *audio_map[][3] = {
460 /* left HP mixer */
461 {"Left HP Mixer", "PC Beep Playback Switch", "PCBEEP"},
462 {"Left HP Mixer", "Voice Playback Switch", "Voice DAC"},
463 {"Left HP Mixer", "Aux Playback Switch", "Aux DAC"},
464 {"Left HP Mixer", "Bypass Playback Switch", "Left Line In"},
465 {"Left HP Mixer", "PCM Playback Switch", "Left DAC"},
466 {"Left HP Mixer", "MonoIn Playback Switch", "Mono In"},
467 {"Left HP Mixer", NULL, "Capture Headphone Mux"},
468
469 /* right HP mixer */
470 {"Right HP Mixer", "PC Beep Playback Switch", "PCBEEP"},
471 {"Right HP Mixer", "Voice Playback Switch", "Voice DAC"},
472 {"Right HP Mixer", "Aux Playback Switch", "Aux DAC"},
473 {"Right HP Mixer", "Bypass Playback Switch", "Right Line In"},
474 {"Right HP Mixer", "PCM Playback Switch", "Right DAC"},
475 {"Right HP Mixer", "MonoIn Playback Switch", "Mono In"},
476 {"Right HP Mixer", NULL, "Capture Headphone Mux"},
477
478 /* virtual mixer - mixes left & right channels for spk and mono */
479 {"AC97 Mixer", NULL, "Left DAC"},
480 {"AC97 Mixer", NULL, "Right DAC"},
481 {"Line Mixer", NULL, "Right Line In"},
482 {"Line Mixer", NULL, "Left Line In"},
483 {"HP Mixer", NULL, "Left HP Mixer"},
484 {"HP Mixer", NULL, "Right HP Mixer"},
485 {"Capture Mixer", NULL, "Left Capture Source"},
486 {"Capture Mixer", NULL, "Right Capture Source"},
487
488 /* speaker mixer */
489 {"Speaker Mixer", "PC Beep Playback Switch", "PCBEEP"},
490 {"Speaker Mixer", "Voice Playback Switch", "Voice DAC"},
491 {"Speaker Mixer", "Aux Playback Switch", "Aux DAC"},
492 {"Speaker Mixer", "Bypass Playback Switch", "Line Mixer"},
493 {"Speaker Mixer", "PCM Playback Switch", "AC97 Mixer"},
494 {"Speaker Mixer", "MonoIn Playback Switch", "Mono In"},
495
496 /* mono mixer */
497 {"Mono Mixer", "PC Beep Playback Switch", "PCBEEP"},
498 {"Mono Mixer", "Voice Playback Switch", "Voice DAC"},
499 {"Mono Mixer", "Aux Playback Switch", "Aux DAC"},
500 {"Mono Mixer", "Bypass Playback Switch", "Line Mixer"},
501 {"Mono Mixer", "PCM Playback Switch", "AC97 Mixer"},
502 {"Mono Mixer", "Mic 1 Sidetone Switch", "Mic A PGA"},
503 {"Mono Mixer", "Mic 2 Sidetone Switch", "Mic B PGA"},
504 {"Mono Mixer", NULL, "Capture Mono Mux"},
505
506 /* DAC inv mux 1 */
507 {"DAC Inv Mux 1", "Mono", "Mono Mixer"},
508 {"DAC Inv Mux 1", "Speaker", "Speaker Mixer"},
509 {"DAC Inv Mux 1", "Left Headphone", "Left HP Mixer"},
510 {"DAC Inv Mux 1", "Right Headphone", "Right HP Mixer"},
511 {"DAC Inv Mux 1", "Headphone Mono", "HP Mixer"},
512
513 /* DAC inv mux 2 */
514 {"DAC Inv Mux 2", "Mono", "Mono Mixer"},
515 {"DAC Inv Mux 2", "Speaker", "Speaker Mixer"},
516 {"DAC Inv Mux 2", "Left Headphone", "Left HP Mixer"},
517 {"DAC Inv Mux 2", "Right Headphone", "Right HP Mixer"},
518 {"DAC Inv Mux 2", "Headphone Mono", "HP Mixer"},
519
520 /* headphone left mux */
521 {"Left Headphone Out Mux", "Headphone", "Left HP Mixer"},
522
523 /* headphone right mux */
524 {"Right Headphone Out Mux", "Headphone", "Right HP Mixer"},
525
526 /* speaker left mux */
527 {"Left Speaker Out Mux", "Headphone", "Left HP Mixer"},
528 {"Left Speaker Out Mux", "Speaker", "Speaker Mixer"},
529 {"Left Speaker Out Mux", "Inv", "DAC Inv Mux 1"},
530
531 /* speaker right mux */
532 {"Right Speaker Out Mux", "Headphone", "Right HP Mixer"},
533 {"Right Speaker Out Mux", "Speaker", "Speaker Mixer"},
534 {"Right Speaker Out Mux", "Inv", "DAC Inv Mux 2"},
535
536 /* mono mux */
537 {"Mono Out Mux", "Mono", "Mono Mixer"},
538 {"Mono Out Mux", "Inv", "DAC Inv Mux 1"},
539
540 /* out 3 mux */
541 {"Out 3 Mux", "Inv 1", "DAC Inv Mux 1"},
542
543 /* out 4 mux */
544 {"Out 4 Mux", "Inv 2", "DAC Inv Mux 2"},
545
546 /* output pga */
547 {"HPL", NULL, "Left Headphone"},
548 {"Left Headphone", NULL, "Left Headphone Out Mux"},
549 {"HPR", NULL, "Right Headphone"},
550 {"Right Headphone", NULL, "Right Headphone Out Mux"},
551 {"OUT3", NULL, "Out 3"},
552 {"Out 3", NULL, "Out 3 Mux"},
553 {"OUT4", NULL, "Out 4"},
554 {"Out 4", NULL, "Out 4 Mux"},
555 {"SPKL", NULL, "Left Speaker"},
556 {"Left Speaker", NULL, "Left Speaker Out Mux"},
557 {"SPKR", NULL, "Right Speaker"},
558 {"Right Speaker", NULL, "Right Speaker Out Mux"},
559 {"MONO", NULL, "Mono Out"},
560 {"Mono Out", NULL, "Mono Out Mux"},
561
562 /* input pga */
563 {"Left Line In", NULL, "LINEL"},
564 {"Right Line In", NULL, "LINER"},
565 {"Mono In", NULL, "MONOIN"},
566 {"Mic A PGA", NULL, "Mic A Pre Amp"},
567 {"Mic B PGA", NULL, "Mic B Pre Amp"},
568
569 /* left capture select */
570 {"Left Capture Source", "Mic 1", "Mic A Pre Amp"},
571 {"Left Capture Source", "Mic 2", "Mic B Pre Amp"},
572 {"Left Capture Source", "Line", "LINEL"},
573 {"Left Capture Source", "Mono In", "MONOIN"},
574 {"Left Capture Source", "Headphone", "Left HP Mixer"},
575 {"Left Capture Source", "Speaker", "Speaker Mixer"},
576 {"Left Capture Source", "Mono Out", "Mono Mixer"},
577
578 /* right capture select */
579 {"Right Capture Source", "Mic 1", "Mic A Pre Amp"},
580 {"Right Capture Source", "Mic 2", "Mic B Pre Amp"},
581 {"Right Capture Source", "Line", "LINER"},
582 {"Right Capture Source", "Mono In", "MONOIN"},
583 {"Right Capture Source", "Headphone", "Right HP Mixer"},
584 {"Right Capture Source", "Speaker", "Speaker Mixer"},
585 {"Right Capture Source", "Mono Out", "Mono Mixer"},
586
587 /* left ADC */
588 {"Left ADC", NULL, "Left Capture Source"},
589
590 /* right ADC */
591 {"Right ADC", NULL, "Right Capture Source"},
592
593 /* mic */
594 {"Mic A Pre Amp", NULL, "Mic A Source"},
595 {"Mic A Source", "Mic 1", "MIC1"},
596 {"Mic A Source", "Mic 2 A", "MIC2A"},
597 {"Mic A Source", "Mic 2 B", "Mic B Source"},
598 {"Mic B Pre Amp", "MPB", "Mic B Source"},
599 {"Mic B Source", NULL, "MIC2B"},
600
601 /* headphone capture */
602 {"Capture Headphone Mux", "Stereo", "Capture Mixer"},
603 {"Capture Headphone Mux", "Left", "Left Capture Source"},
604 {"Capture Headphone Mux", "Right", "Right Capture Source"},
605
606 /* mono capture */
607 {"Capture Mono Mux", "Stereo", "Capture Mixer"},
608 {"Capture Mono Mux", "Left", "Left Capture Source"},
609 {"Capture Mono Mux", "Right", "Right Capture Source"},
610
611 {NULL, NULL, NULL},
612};
613
614static int wm9713_add_widgets(struct snd_soc_codec *codec)
615{
616 int i;
617
618 for (i = 0; i < ARRAY_SIZE(wm9713_dapm_widgets); i++)
619 snd_soc_dapm_new_control(codec, &wm9713_dapm_widgets[i]);
620
621 /* set up audio path audio_mapnects */
622 for (i = 0; audio_map[i][0] != NULL; i++)
623 snd_soc_dapm_connect_input(codec, audio_map[i][0],
624 audio_map[i][1], audio_map[i][2]);
625
626 snd_soc_dapm_new_widgets(codec);
627 return 0;
628}
629
630static unsigned int ac97_read(struct snd_soc_codec *codec,
631 unsigned int reg)
632{
633 u16 *cache = codec->reg_cache;
634
635 if (reg == AC97_RESET || reg == AC97_GPIO_STATUS ||
636 reg == AC97_VENDOR_ID1 || reg == AC97_VENDOR_ID2 ||
637 reg == AC97_CD)
638 return soc_ac97_ops.read(codec->ac97, reg);
639 else {
640 reg = reg >> 1;
641
642 if (reg > (ARRAY_SIZE(wm9713_reg)))
643 return -EIO;
644
645 return cache[reg];
646 }
647}
648
649static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
650 unsigned int val)
651{
652 u16 *cache = codec->reg_cache;
653 if (reg < 0x7c)
654 soc_ac97_ops.write(codec->ac97, reg, val);
655 reg = reg >> 1;
656 if (reg <= (ARRAY_SIZE(wm9713_reg)))
657 cache[reg] = val;
658
659 return 0;
660}
661
662/* PLL divisors */
663struct _pll_div {
664 u32 divsel:1;
665 u32 divctl:1;
666 u32 lf:1;
667 u32 n:4;
668 u32 k:24;
669};
670
671/* The size in bits of the PLL divide multiplied by 10
672 * to allow rounding later */
673#define FIXED_PLL_SIZE ((1 << 22) * 10)
674
675static void pll_factors(struct _pll_div *pll_div, unsigned int source)
676{
677 u64 Kpart;
678 unsigned int K, Ndiv, Nmod, target;
679
680 /* The the PLL output is always 98.304MHz. */
681 target = 98304000;
682
683 /* If the input frequency is over 14.4MHz then scale it down. */
684 if (source > 14400000) {
685 source >>= 1;
686 pll_div->divsel = 1;
687
688 if (source > 14400000) {
689 source >>= 1;
690 pll_div->divctl = 1;
691 } else
692 pll_div->divctl = 0;
693
694 } else {
695 pll_div->divsel = 0;
696 pll_div->divctl = 0;
697 }
698
699 /* Low frequency sources require an additional divide in the
700 * loop.
701 */
702 if (source < 8192000) {
703 pll_div->lf = 1;
704 target >>= 2;
705 } else
706 pll_div->lf = 0;
707
708 Ndiv = target / source;
709 if ((Ndiv < 5) || (Ndiv > 12))
710 printk(KERN_WARNING
711 "WM9713 PLL N value %d out of recommended range!\n",
712 Ndiv);
713
714 pll_div->n = Ndiv;
715 Nmod = target % source;
716 Kpart = FIXED_PLL_SIZE * (long long)Nmod;
717
718 do_div(Kpart, source);
719
720 K = Kpart & 0xFFFFFFFF;
721
722 /* Check if we need to round */
723 if ((K % 10) >= 5)
724 K += 5;
725
726 /* Move down to proper range now rounding is done */
727 K /= 10;
728
729 pll_div->k = K;
730}
731
732/**
733 * Please note that changing the PLL input frequency may require
734 * resynchronisation with the AC97 controller.
735 */
736static int wm9713_set_pll(struct snd_soc_codec *codec,
737 int pll_id, unsigned int freq_in, unsigned int freq_out)
738{
739 struct wm9713_priv *wm9713 = codec->private_data;
740 u16 reg, reg2;
741 struct _pll_div pll_div;
742
743 /* turn PLL off ? */
744 if (freq_in == 0 || freq_out == 0) {
745 /* disable PLL power and select ext source */
746 reg = ac97_read(codec, AC97_HANDSET_RATE);
747 ac97_write(codec, AC97_HANDSET_RATE, reg | 0x0080);
748 reg = ac97_read(codec, AC97_EXTENDED_MID);
749 ac97_write(codec, AC97_EXTENDED_MID, reg | 0x0200);
750 wm9713->pll_out = 0;
751 return 0;
752 }
753
754 pll_factors(&pll_div, freq_in);
755
756 if (pll_div.k == 0) {
757 reg = (pll_div.n << 12) | (pll_div.lf << 11) |
758 (pll_div.divsel << 9) | (pll_div.divctl << 8);
759 ac97_write(codec, AC97_LINE1_LEVEL, reg);
760 } else {
761 /* write the fractional k to the reg 0x46 pages */
762 reg2 = (pll_div.n << 12) | (pll_div.lf << 11) | (1 << 10) |
763 (pll_div.divsel << 9) | (pll_div.divctl << 8);
764
765 /* K [21:20] */
766 reg = reg2 | (0x5 << 4) | (pll_div.k >> 20);
767 ac97_write(codec, AC97_LINE1_LEVEL, reg);
768
769 /* K [19:16] */
770 reg = reg2 | (0x4 << 4) | ((pll_div.k >> 16) & 0xf);
771 ac97_write(codec, AC97_LINE1_LEVEL, reg);
772
773 /* K [15:12] */
774 reg = reg2 | (0x3 << 4) | ((pll_div.k >> 12) & 0xf);
775 ac97_write(codec, AC97_LINE1_LEVEL, reg);
776
777 /* K [11:8] */
778 reg = reg2 | (0x2 << 4) | ((pll_div.k >> 8) & 0xf);
779 ac97_write(codec, AC97_LINE1_LEVEL, reg);
780
781 /* K [7:4] */
782 reg = reg2 | (0x1 << 4) | ((pll_div.k >> 4) & 0xf);
783 ac97_write(codec, AC97_LINE1_LEVEL, reg);
784
785 reg = reg2 | (0x0 << 4) | (pll_div.k & 0xf); /* K [3:0] */
786 ac97_write(codec, AC97_LINE1_LEVEL, reg);
787 }
788
789 /* turn PLL on and select as source */
790 reg = ac97_read(codec, AC97_EXTENDED_MID);
791 ac97_write(codec, AC97_EXTENDED_MID, reg & 0xfdff);
792 reg = ac97_read(codec, AC97_HANDSET_RATE);
793 ac97_write(codec, AC97_HANDSET_RATE, reg & 0xff7f);
794 wm9713->pll_out = freq_out;
795 wm9713->pll_in = freq_in;
796
797 /* wait 10ms AC97 link frames for the link to stabilise */
798 schedule_timeout_interruptible(msecs_to_jiffies(10));
799 return 0;
800}
801
802static int wm9713_set_dai_pll(struct snd_soc_codec_dai *codec_dai,
803 int pll_id, unsigned int freq_in, unsigned int freq_out)
804{
805 struct snd_soc_codec *codec = codec_dai->codec;
806 return wm9713_set_pll(codec, pll_id, freq_in, freq_out);
807}
808
809/*
810 * Tristate the PCM DAI lines, tristate can be disabled by calling
811 * wm9713_set_dai_fmt()
812 */
813static int wm9713_set_dai_tristate(struct snd_soc_codec_dai *codec_dai,
814 int tristate)
815{
816 struct snd_soc_codec *codec = codec_dai->codec;
817 u16 reg = ac97_read(codec, AC97_CENTER_LFE_MASTER) & 0x9fff;
818
819 if (tristate)
820 ac97_write(codec, AC97_CENTER_LFE_MASTER, reg);
821
822 return 0;
823}
824
825/*
826 * Configure WM9713 clock dividers.
827 * Voice DAC needs 256 FS
828 */
829static int wm9713_set_dai_clkdiv(struct snd_soc_codec_dai *codec_dai,
830 int div_id, int div)
831{
832 struct snd_soc_codec *codec = codec_dai->codec;
833 u16 reg;
834
835 switch (div_id) {
836 case WM9713_PCMCLK_DIV:
837 reg = ac97_read(codec, AC97_HANDSET_RATE) & 0xf0ff;
838 ac97_write(codec, AC97_HANDSET_RATE, reg | div);
839 break;
840 case WM9713_CLKA_MULT:
841 reg = ac97_read(codec, AC97_HANDSET_RATE) & 0xfffd;
842 ac97_write(codec, AC97_HANDSET_RATE, reg | div);
843 break;
844 case WM9713_CLKB_MULT:
845 reg = ac97_read(codec, AC97_HANDSET_RATE) & 0xfffb;
846 ac97_write(codec, AC97_HANDSET_RATE, reg | div);
847 break;
848 case WM9713_HIFI_DIV:
849 reg = ac97_read(codec, AC97_HANDSET_RATE) & 0x8fff;
850 ac97_write(codec, AC97_HANDSET_RATE, reg | div);
851 break;
852 case WM9713_PCMBCLK_DIV:
853 reg = ac97_read(codec, AC97_CENTER_LFE_MASTER) & 0xf1ff;
854 ac97_write(codec, AC97_CENTER_LFE_MASTER, reg | div);
855 break;
856 case WM9713_PCMCLK_PLL_DIV:
857 reg = ac97_read(codec, AC97_LINE1_LEVEL) & 0xff80;
858 ac97_write(codec, AC97_LINE1_LEVEL, reg | 0x60 | div);
859 break;
860 case WM9713_HIFI_PLL_DIV:
861 reg = ac97_read(codec, AC97_LINE1_LEVEL) & 0xff80;
862 ac97_write(codec, AC97_LINE1_LEVEL, reg | 0x70 | div);
863 break;
864 default:
865 return -EINVAL;
866 }
867
868 return 0;
869}
870
871static int wm9713_set_dai_fmt(struct snd_soc_codec_dai *codec_dai,
872 unsigned int fmt)
873{
874 struct snd_soc_codec *codec = codec_dai->codec;
875 u16 gpio = ac97_read(codec, AC97_GPIO_CFG) & 0xffc5;
876 u16 reg = 0x8000;
877
878 /* clock masters */
879 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
880 case SND_SOC_DAIFMT_CBM_CFM:
881 reg |= 0x4000;
882 gpio |= 0x0010;
883 break;
884 case SND_SOC_DAIFMT_CBM_CFS:
885 reg |= 0x6000;
886 gpio |= 0x0018;
887 break;
888 case SND_SOC_DAIFMT_CBS_CFS:
889 reg |= 0x0200;
890 gpio |= 0x001a;
891 break;
892 case SND_SOC_DAIFMT_CBS_CFM:
893 gpio |= 0x0012;
894 break;
895 }
896
897 /* clock inversion */
898 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
899 case SND_SOC_DAIFMT_IB_IF:
900 reg |= 0x00c0;
901 break;
902 case SND_SOC_DAIFMT_IB_NF:
903 reg |= 0x0080;
904 break;
905 case SND_SOC_DAIFMT_NB_IF:
906 reg |= 0x0040;
907 break;
908 }
909
910 /* DAI format */
911 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
912 case SND_SOC_DAIFMT_I2S:
913 reg |= 0x0002;
914 break;
915 case SND_SOC_DAIFMT_RIGHT_J:
916 break;
917 case SND_SOC_DAIFMT_LEFT_J:
918 reg |= 0x0001;
919 break;
920 case SND_SOC_DAIFMT_DSP_A:
921 reg |= 0x0003;
922 break;
923 case SND_SOC_DAIFMT_DSP_B:
924 reg |= 0x0043;
925 break;
926 }
927
928 ac97_write(codec, AC97_GPIO_CFG, gpio);
929 ac97_write(codec, AC97_CENTER_LFE_MASTER, reg);
930 return 0;
931}
932
933static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream,
934 struct snd_pcm_hw_params *params)
935{
936 struct snd_soc_pcm_runtime *rtd = substream->private_data;
937 struct snd_soc_device *socdev = rtd->socdev;
938 struct snd_soc_codec *codec = socdev->codec;
939 u16 reg = ac97_read(codec, AC97_CENTER_LFE_MASTER) & 0xfff3;
940
941 switch (params_format(params)) {
942 case SNDRV_PCM_FORMAT_S16_LE:
943 break;
944 case SNDRV_PCM_FORMAT_S20_3LE:
945 reg |= 0x0004;
946 break;
947 case SNDRV_PCM_FORMAT_S24_LE:
948 reg |= 0x0008;
949 break;
950 case SNDRV_PCM_FORMAT_S32_LE:
951 reg |= 0x000c;
952 break;
953 }
954
955 /* enable PCM interface in master mode */
956 ac97_write(codec, AC97_CENTER_LFE_MASTER, reg);
957 return 0;
958}
959
960static void wm9713_voiceshutdown(struct snd_pcm_substream *substream)
961{
962 struct snd_soc_pcm_runtime *rtd = substream->private_data;
963 struct snd_soc_device *socdev = rtd->socdev;
964 struct snd_soc_codec *codec = socdev->codec;
965 u16 status;
966
967 /* Gracefully shut down the voice interface. */
968 status = ac97_read(codec, AC97_EXTENDED_STATUS) | 0x1000;
969 ac97_write(codec, AC97_HANDSET_RATE, 0x0280);
970 schedule_timeout_interruptible(msecs_to_jiffies(1));
971 ac97_write(codec, AC97_HANDSET_RATE, 0x0F80);
972 ac97_write(codec, AC97_EXTENDED_MID, status);
973}
974
975static int ac97_hifi_prepare(struct snd_pcm_substream *substream)
976{
977 struct snd_pcm_runtime *runtime = substream->runtime;
978 struct snd_soc_pcm_runtime *rtd = substream->private_data;
979 struct snd_soc_device *socdev = rtd->socdev;
980 struct snd_soc_codec *codec = socdev->codec;
981 int reg;
982 u16 vra;
983
984 vra = ac97_read(codec, AC97_EXTENDED_STATUS);
985 ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1);
986
987 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
988 reg = AC97_PCM_FRONT_DAC_RATE;
989 else
990 reg = AC97_PCM_LR_ADC_RATE;
991
992 return ac97_write(codec, reg, runtime->rate);
993}
994
995static int ac97_aux_prepare(struct snd_pcm_substream *substream)
996{
997 struct snd_pcm_runtime *runtime = substream->runtime;
998 struct snd_soc_pcm_runtime *rtd = substream->private_data;
999 struct snd_soc_device *socdev = rtd->socdev;
1000 struct snd_soc_codec *codec = socdev->codec;
1001 u16 vra, xsle;
1002
1003 vra = ac97_read(codec, AC97_EXTENDED_STATUS);
1004 ac97_write(codec, AC97_EXTENDED_STATUS, vra | 0x1);
1005 xsle = ac97_read(codec, AC97_PCI_SID);
1006 ac97_write(codec, AC97_PCI_SID, xsle | 0x8000);
1007
1008 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
1009 return -ENODEV;
1010
1011 return ac97_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate);
1012}
1013
1014#define WM9713_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
1015 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 |\
1016 SNDRV_PCM_RATE_48000)
1017
1018#define WM9713_PCM_FORMATS \
1019 (SNDRV_PCM_FORMAT_S16_LE | SNDRV_PCM_FORMAT_S20_3LE | \
1020 SNDRV_PCM_FORMAT_S24_LE)
1021
1022struct snd_soc_codec_dai wm9713_dai[] = {
1023{
1024 .name = "AC97 HiFi",
1025 .type = SND_SOC_DAI_AC97_BUS,
1026 .playback = {
1027 .stream_name = "HiFi Playback",
1028 .channels_min = 1,
1029 .channels_max = 2,
1030 .rates = WM9713_RATES,
1031 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
1032 .capture = {
1033 .stream_name = "HiFi Capture",
1034 .channels_min = 1,
1035 .channels_max = 2,
1036 .rates = WM9713_RATES,
1037 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
1038 .ops = {
1039 .prepare = ac97_hifi_prepare,},
1040 .dai_ops = {
1041 .set_clkdiv = wm9713_set_dai_clkdiv,
1042 .set_pll = wm9713_set_dai_pll,},
1043 },
1044 {
1045 .name = "AC97 Aux",
1046 .playback = {
1047 .stream_name = "Aux Playback",
1048 .channels_min = 1,
1049 .channels_max = 1,
1050 .rates = WM9713_RATES,
1051 .formats = SNDRV_PCM_FMTBIT_S16_LE,},
1052 .ops = {
1053 .prepare = ac97_aux_prepare,},
1054 .dai_ops = {
1055 .set_clkdiv = wm9713_set_dai_clkdiv,
1056 .set_pll = wm9713_set_dai_pll,},
1057 },
1058 {
1059 .name = "WM9713 Voice",
1060 .playback = {
1061 .stream_name = "Voice Playback",
1062 .channels_min = 1,
1063 .channels_max = 1,
1064 .rates = WM9713_RATES,
1065 .formats = WM9713_PCM_FORMATS,},
1066 .capture = {
1067 .stream_name = "Voice Capture",
1068 .channels_min = 1,
1069 .channels_max = 2,
1070 .rates = WM9713_RATES,
1071 .formats = WM9713_PCM_FORMATS,},
1072 .ops = {
1073 .hw_params = wm9713_pcm_hw_params,
1074 .shutdown = wm9713_voiceshutdown,},
1075 .dai_ops = {
1076 .set_clkdiv = wm9713_set_dai_clkdiv,
1077 .set_pll = wm9713_set_dai_pll,
1078 .set_fmt = wm9713_set_dai_fmt,
1079 .set_tristate = wm9713_set_dai_tristate,
1080 },
1081 },
1082};
1083EXPORT_SYMBOL_GPL(wm9713_dai);
1084
1085int wm9713_reset(struct snd_soc_codec *codec, int try_warm)
1086{
1087 if (try_warm && soc_ac97_ops.warm_reset) {
1088 soc_ac97_ops.warm_reset(codec->ac97);
1089 if (!(ac97_read(codec, 0) & 0x8000))
1090 return 1;
1091 }
1092
1093 soc_ac97_ops.reset(codec->ac97);
1094 if (ac97_read(codec, 0) & 0x8000)
1095 return -EIO;
1096 return 0;
1097}
1098EXPORT_SYMBOL_GPL(wm9713_reset);
1099
1100static int wm9713_dapm_event(struct snd_soc_codec *codec, int event)
1101{
1102 u16 reg;
1103
1104 switch (event) {
1105 case SNDRV_CTL_POWER_D0: /* full On */
1106 /* enable thermal shutdown */
1107 reg = ac97_read(codec, AC97_EXTENDED_MID) & 0x1bff;
1108 ac97_write(codec, AC97_EXTENDED_MID, reg);
1109 break;
1110 case SNDRV_CTL_POWER_D1: /* partial On */
1111 case SNDRV_CTL_POWER_D2: /* partial On */
1112 break;
1113 case SNDRV_CTL_POWER_D3hot: /* Off, with power */
1114 /* enable master bias and vmid */
1115 reg = ac97_read(codec, AC97_EXTENDED_MID) & 0x3bff;
1116 ac97_write(codec, AC97_EXTENDED_MID, reg);
1117 ac97_write(codec, AC97_POWERDOWN, 0x0000);
1118 break;
1119 case SNDRV_CTL_POWER_D3cold: /* Off, without power */
1120 /* disable everything including AC link */
1121 ac97_write(codec, AC97_EXTENDED_MID, 0xffff);
1122 ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
1123 ac97_write(codec, AC97_POWERDOWN, 0xffff);
1124 break;
1125 }
1126 codec->dapm_state = event;
1127 return 0;
1128}
1129
1130static int wm9713_soc_suspend(struct platform_device *pdev,
1131 pm_message_t state)
1132{
1133 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1134 struct snd_soc_codec *codec = socdev->codec;
1135 u16 reg;
1136
1137 /* Disable everything except touchpanel - that will be handled
1138 * by the touch driver and left disabled if touch is not in
1139 * use. */
1140 reg = ac97_read(codec, AC97_EXTENDED_MID);
1141 ac97_write(codec, AC97_EXTENDED_MID, reg | 0x7fff);
1142 ac97_write(codec, AC97_EXTENDED_MSTATUS, 0xffff);
1143 ac97_write(codec, AC97_POWERDOWN, 0x6f00);
1144 ac97_write(codec, AC97_POWERDOWN, 0xffff);
1145
1146 return 0;
1147}
1148
1149static int wm9713_soc_resume(struct platform_device *pdev)
1150{
1151 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1152 struct snd_soc_codec *codec = socdev->codec;
1153 struct wm9713_priv *wm9713 = codec->private_data;
1154 int i, ret;
1155 u16 *cache = codec->reg_cache;
1156
1157 ret = wm9713_reset(codec, 1);
1158 if (ret < 0) {
1159 printk(KERN_ERR "could not reset AC97 codec\n");
1160 return ret;
1161 }
1162
1163 wm9713_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
1164
1165 /* do we need to re-start the PLL ? */
1166 if (wm9713->pll_out)
1167 wm9713_set_pll(codec, 0, wm9713->pll_in, wm9713->pll_out);
1168
1169 /* only synchronise the codec if warm reset failed */
1170 if (ret == 0) {
1171 for (i = 2; i < ARRAY_SIZE(wm9713_reg) << 1; i += 2) {
1172 if (i == AC97_POWERDOWN || i == AC97_EXTENDED_MID ||
1173 i == AC97_EXTENDED_MSTATUS || i > 0x66)
1174 continue;
1175 soc_ac97_ops.write(codec->ac97, i, cache[i>>1]);
1176 }
1177 }
1178
1179 if (codec->suspend_dapm_state == SNDRV_CTL_POWER_D0)
1180 wm9713_dapm_event(codec, SNDRV_CTL_POWER_D0);
1181
1182 return ret;
1183}
1184
1185static int wm9713_soc_probe(struct platform_device *pdev)
1186{
1187 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1188 struct snd_soc_codec *codec;
1189 int ret = 0, reg;
1190
1191 printk(KERN_INFO "WM9713/WM9714 SoC Audio Codec %s\n", WM9713_VERSION);
1192
1193 socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
1194 if (socdev->codec == NULL)
1195 return -ENOMEM;
1196 codec = socdev->codec;
1197 mutex_init(&codec->mutex);
1198
1199 codec->reg_cache = kmemdup(wm9713_reg, sizeof(wm9713_reg), GFP_KERNEL);
1200 if (codec->reg_cache == NULL) {
1201 ret = -ENOMEM;
1202 goto cache_err;
1203 }
1204 codec->reg_cache_size = sizeof(wm9713_reg);
1205 codec->reg_cache_step = 2;
1206
1207 codec->private_data = kzalloc(sizeof(struct wm9713_priv), GFP_KERNEL);
1208 if (codec->private_data == NULL) {
1209 ret = -ENOMEM;
1210 goto priv_err;
1211 }
1212
1213 codec->name = "WM9713";
1214 codec->owner = THIS_MODULE;
1215 codec->dai = wm9713_dai;
1216 codec->num_dai = ARRAY_SIZE(wm9713_dai);
1217 codec->write = ac97_write;
1218 codec->read = ac97_read;
1219 codec->dapm_event = wm9713_dapm_event;
1220 INIT_LIST_HEAD(&codec->dapm_widgets);
1221 INIT_LIST_HEAD(&codec->dapm_paths);
1222
1223 ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0);
1224 if (ret < 0)
1225 goto codec_err;
1226
1227 /* register pcms */
1228 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
1229 if (ret < 0)
1230 goto pcm_err;
1231
1232 /* do a cold reset for the controller and then try
1233 * a warm reset followed by an optional cold reset for codec */
1234 wm9713_reset(codec, 0);
1235 ret = wm9713_reset(codec, 1);
1236 if (ret < 0) {
1237 printk(KERN_ERR "AC97 link error\n");
1238 goto reset_err;
1239 }
1240
1241 wm9713_dapm_event(codec, SNDRV_CTL_POWER_D3hot);
1242
1243 /* unmute the adc - move to kcontrol */
1244 reg = ac97_read(codec, AC97_CD) & 0x7fff;
1245 ac97_write(codec, AC97_CD, reg);
1246
1247 wm9713_add_controls(codec);
1248 wm9713_add_widgets(codec);
1249 ret = snd_soc_register_card(socdev);
1250 if (ret < 0)
1251 goto reset_err;
1252 return 0;
1253
1254reset_err:
1255 snd_soc_free_pcms(socdev);
1256
1257pcm_err:
1258 snd_soc_free_ac97_codec(codec);
1259
1260codec_err:
1261 kfree(codec->private_data);
1262
1263priv_err:
1264 kfree(codec->reg_cache);
1265
1266cache_err:
1267 kfree(socdev->codec);
1268 socdev->codec = NULL;
1269 return ret;
1270}
1271
1272static int wm9713_soc_remove(struct platform_device *pdev)
1273{
1274 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
1275 struct snd_soc_codec *codec = socdev->codec;
1276
1277 if (codec == NULL)
1278 return 0;
1279
1280 snd_soc_dapm_free(socdev);
1281 snd_soc_free_pcms(socdev);
1282 snd_soc_free_ac97_codec(codec);
1283 kfree(codec->private_data);
1284 kfree(codec->reg_cache);
1285 kfree(codec->dai);
1286 kfree(codec);
1287 return 0;
1288}
1289
1290struct snd_soc_codec_device soc_codec_dev_wm9713 = {
1291 .probe = wm9713_soc_probe,
1292 .remove = wm9713_soc_remove,
1293 .suspend = wm9713_soc_suspend,
1294 .resume = wm9713_soc_resume,
1295};
1296EXPORT_SYMBOL_GPL(soc_codec_dev_wm9713);
1297
1298MODULE_DESCRIPTION("ASoC WM9713/WM9714 driver");
1299MODULE_AUTHOR("Liam Girdwood");
1300MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm9713.h b/sound/soc/codecs/wm9713.h
new file mode 100644
index 000000000000..d357b6c8134b
--- /dev/null
+++ b/sound/soc/codecs/wm9713.h
@@ -0,0 +1,53 @@
1/*
2 * wm9713.h -- WM9713 Soc Audio driver
3 */
4
5#ifndef _WM9713_H
6#define _WM9713_H
7
8/* clock inputs */
9#define WM9713_CLKA_PIN 0
10#define WM9713_CLKB_PIN 1
11
12/* clock divider ID's */
13#define WM9713_PCMCLK_DIV 0
14#define WM9713_CLKA_MULT 1
15#define WM9713_CLKB_MULT 2
16#define WM9713_HIFI_DIV 3
17#define WM9713_PCMBCLK_DIV 4
18#define WM9713_PCMCLK_PLL_DIV 5
19#define WM9713_HIFI_PLL_DIV 6
20
21/* Calculate the appropriate bit mask for the external PCM clock divider */
22#define WM9713_PCMDIV(x) ((x - 1) << 8)
23
24/* Calculate the appropriate bit mask for the external HiFi clock divider */
25#define WM9713_HIFIDIV(x) ((x - 1) << 12)
26
27/* MCLK clock mulitipliers */
28#define WM9713_CLKA_X1 (0 << 1)
29#define WM9713_CLKA_X2 (1 << 1)
30#define WM9713_CLKB_X1 (0 << 2)
31#define WM9713_CLKB_X2 (1 << 2)
32
33/* MCLK clock MUX */
34#define WM9713_CLK_MUX_A (0 << 0)
35#define WM9713_CLK_MUX_B (1 << 0)
36
37/* Voice DAI BCLK divider */
38#define WM9713_PCMBCLK_DIV_1 (0 << 9)
39#define WM9713_PCMBCLK_DIV_2 (1 << 9)
40#define WM9713_PCMBCLK_DIV_4 (2 << 9)
41#define WM9713_PCMBCLK_DIV_8 (3 << 9)
42#define WM9713_PCMBCLK_DIV_16 (4 << 9)
43
44#define WM9713_DAI_AC97_HIFI 0
45#define WM9713_DAI_AC97_AUX 1
46#define WM9713_DAI_PCM_VOICE 2
47
48extern struct snd_soc_codec_device soc_codec_dev_wm9713;
49extern struct snd_soc_codec_dai wm9713_dai[3];
50
51int wm9713_reset(struct snd_soc_codec *codec, int try_warm);
52
53#endif