diff options
author | Ian Molton <ian@mnementh.co.uk> | 2009-01-08 19:23:21 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-01-09 05:39:49 -0500 |
commit | 3e8e1952e3a3dd59b11233a532ca68e6471742d9 (patch) | |
tree | 3dff59c0b09cbcbc0e4b80a00cecd507219a821c /sound | |
parent | a6ba2b2dabb583e7820e567fb309d771b50cb9ff (diff) |
ASoC: cleanup duplicated code.
Many codec drivers were implementing cookie-cutter copies of the function
that adds kcontrols to the codec.
This patch moves this code to a common function snd_soc_add_controls() in
soc-core.c and updates all drivers using copies of this function to use the
new common version.
[Edited to raise priority of error log message and document parameters.
-- broonie]
Signed-off-by: Ian Molton <ian@mnementh.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/ad1980.c | 17 | ||||
-rw-r--r-- | sound/soc/codecs/ak4535.c | 18 | ||||
-rw-r--r-- | sound/soc/codecs/ssm2602.c | 18 | ||||
-rw-r--r-- | sound/soc/codecs/tlv320aic23.c | 21 | ||||
-rw-r--r-- | sound/soc/codecs/tlv320aic3x.c | 19 | ||||
-rw-r--r-- | sound/soc/codecs/twl4030.c | 19 | ||||
-rw-r--r-- | sound/soc/codecs/uda134x.c | 50 | ||||
-rw-r--r-- | sound/soc/codecs/uda1380.c | 18 | ||||
-rw-r--r-- | sound/soc/codecs/wm8350.c | 18 | ||||
-rw-r--r-- | sound/soc/codecs/wm8510.c | 19 | ||||
-rw-r--r-- | sound/soc/codecs/wm8580.c | 17 | ||||
-rw-r--r-- | sound/soc/codecs/wm8728.c | 18 | ||||
-rw-r--r-- | sound/soc/codecs/wm8731.c | 19 | ||||
-rw-r--r-- | sound/soc/codecs/wm8750.c | 18 | ||||
-rw-r--r-- | sound/soc/codecs/wm8753.c | 18 | ||||
-rw-r--r-- | sound/soc/codecs/wm8900.c | 19 | ||||
-rw-r--r-- | sound/soc/codecs/wm8903.c | 18 | ||||
-rw-r--r-- | sound/soc/codecs/wm8971.c | 18 | ||||
-rw-r--r-- | sound/soc/codecs/wm8990.c | 18 | ||||
-rw-r--r-- | sound/soc/codecs/wm9712.c | 18 | ||||
-rw-r--r-- | sound/soc/codecs/wm9713.c | 18 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 31 |
22 files changed, 87 insertions, 360 deletions
diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c index 73fdbb4d4a3d..c3c5d0eee37a 100644 --- a/sound/soc/codecs/ad1980.c +++ b/sound/soc/codecs/ad1980.c | |||
@@ -93,20 +93,6 @@ SOC_ENUM("Capture Source", ad1980_cap_src), | |||
93 | SOC_SINGLE("Mic Boost Switch", AC97_MIC, 6, 1, 0), | 93 | SOC_SINGLE("Mic Boost Switch", AC97_MIC, 6, 1, 0), |
94 | }; | 94 | }; |
95 | 95 | ||
96 | /* add non dapm controls */ | ||
97 | static int ad1980_add_controls(struct snd_soc_codec *codec) | ||
98 | { | ||
99 | int err, i; | ||
100 | |||
101 | for (i = 0; i < ARRAY_SIZE(ad1980_snd_ac97_controls); i++) { | ||
102 | err = snd_ctl_add(codec->card, snd_soc_cnew( | ||
103 | &ad1980_snd_ac97_controls[i], codec, NULL)); | ||
104 | if (err < 0) | ||
105 | return err; | ||
106 | } | ||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static unsigned int ac97_read(struct snd_soc_codec *codec, | 96 | static unsigned int ac97_read(struct snd_soc_codec *codec, |
111 | unsigned int reg) | 97 | unsigned int reg) |
112 | { | 98 | { |
@@ -269,7 +255,8 @@ static int ad1980_soc_probe(struct platform_device *pdev) | |||
269 | ext_status = ac97_read(codec, AC97_EXTENDED_STATUS); | 255 | ext_status = ac97_read(codec, AC97_EXTENDED_STATUS); |
270 | ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); | 256 | ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); |
271 | 257 | ||
272 | ad1980_add_controls(codec); | 258 | snd_soc_add_controls(codec, ad1980_snd_ac97_controls, |
259 | ARRAY_SIZE(ad1980_snd_ac97_controls)); | ||
273 | ret = snd_soc_init_card(socdev); | 260 | ret = snd_soc_init_card(socdev); |
274 | if (ret < 0) { | 261 | if (ret < 0) { |
275 | printk(KERN_ERR "ad1980: failed to register card\n"); | 262 | printk(KERN_ERR "ad1980: failed to register card\n"); |
diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c index 81300d8d42ca..f17c363cb1db 100644 --- a/sound/soc/codecs/ak4535.c +++ b/sound/soc/codecs/ak4535.c | |||
@@ -155,21 +155,6 @@ static const struct snd_kcontrol_new ak4535_snd_controls[] = { | |||
155 | SOC_SINGLE("Mic Sidetone Volume", AK4535_VOL, 4, 7, 0), | 155 | SOC_SINGLE("Mic Sidetone Volume", AK4535_VOL, 4, 7, 0), |
156 | }; | 156 | }; |
157 | 157 | ||
158 | /* add non dapm controls */ | ||
159 | static int ak4535_add_controls(struct snd_soc_codec *codec) | ||
160 | { | ||
161 | int err, i; | ||
162 | |||
163 | for (i = 0; i < ARRAY_SIZE(ak4535_snd_controls); i++) { | ||
164 | err = snd_ctl_add(codec->card, | ||
165 | snd_soc_cnew(&ak4535_snd_controls[i], codec, NULL)); | ||
166 | if (err < 0) | ||
167 | return err; | ||
168 | } | ||
169 | |||
170 | return 0; | ||
171 | } | ||
172 | |||
173 | /* Mono 1 Mixer */ | 158 | /* Mono 1 Mixer */ |
174 | static const struct snd_kcontrol_new ak4535_mono1_mixer_controls[] = { | 159 | static const struct snd_kcontrol_new ak4535_mono1_mixer_controls[] = { |
175 | SOC_DAPM_SINGLE("Mic Sidetone Switch", AK4535_SIG1, 4, 1, 0), | 160 | SOC_DAPM_SINGLE("Mic Sidetone Switch", AK4535_SIG1, 4, 1, 0), |
@@ -510,7 +495,8 @@ static int ak4535_init(struct snd_soc_device *socdev) | |||
510 | /* power on device */ | 495 | /* power on device */ |
511 | ak4535_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 496 | ak4535_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
512 | 497 | ||
513 | ak4535_add_controls(codec); | 498 | snd_soc_add_controls(codec, ak4535_snd_controls, |
499 | ARRAY_SIZE(ak4535_snd_controls)); | ||
514 | ak4535_add_widgets(codec); | 500 | ak4535_add_widgets(codec); |
515 | ret = snd_soc_init_card(socdev); | 501 | ret = snd_soc_init_card(socdev); |
516 | if (ret < 0) { | 502 | if (ret < 0) { |
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index cac373616768..ec7fe3b7b0cb 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c | |||
@@ -151,21 +151,6 @@ SOC_ENUM("Capture Source", ssm2602_enum[0]), | |||
151 | SOC_ENUM("Playback De-emphasis", ssm2602_enum[1]), | 151 | SOC_ENUM("Playback De-emphasis", ssm2602_enum[1]), |
152 | }; | 152 | }; |
153 | 153 | ||
154 | /* add non dapm controls */ | ||
155 | static int ssm2602_add_controls(struct snd_soc_codec *codec) | ||
156 | { | ||
157 | int err, i; | ||
158 | |||
159 | for (i = 0; i < ARRAY_SIZE(ssm2602_snd_controls); i++) { | ||
160 | err = snd_ctl_add(codec->card, | ||
161 | snd_soc_cnew(&ssm2602_snd_controls[i], codec, NULL)); | ||
162 | if (err < 0) | ||
163 | return err; | ||
164 | } | ||
165 | |||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | /* Output Mixer */ | 154 | /* Output Mixer */ |
170 | static const struct snd_kcontrol_new ssm2602_output_mixer_controls[] = { | 155 | static const struct snd_kcontrol_new ssm2602_output_mixer_controls[] = { |
171 | SOC_DAPM_SINGLE("Line Bypass Switch", SSM2602_APANA, 3, 1, 0), | 156 | SOC_DAPM_SINGLE("Line Bypass Switch", SSM2602_APANA, 3, 1, 0), |
@@ -622,7 +607,8 @@ static int ssm2602_init(struct snd_soc_device *socdev) | |||
622 | APANA_ENABLE_MIC_BOOST); | 607 | APANA_ENABLE_MIC_BOOST); |
623 | ssm2602_write(codec, SSM2602_PWR, 0); | 608 | ssm2602_write(codec, SSM2602_PWR, 0); |
624 | 609 | ||
625 | ssm2602_add_controls(codec); | 610 | snd_soc_add_controls(codec, ssm2602_snd_controls, |
611 | ARRAY_SIZE(ssm2602_snd_controls)); | ||
626 | ssm2602_add_widgets(codec); | 612 | ssm2602_add_widgets(codec); |
627 | ret = snd_soc_init_card(socdev); | 613 | ret = snd_soc_init_card(socdev); |
628 | if (ret < 0) { | 614 | if (ret < 0) { |
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index cfdea007c4cb..a0e47c1dcd64 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c | |||
@@ -183,24 +183,6 @@ static const struct snd_kcontrol_new tlv320aic23_snd_controls[] = { | |||
183 | SOC_ENUM("Playback De-emphasis", tlv320aic23_deemph), | 183 | SOC_ENUM("Playback De-emphasis", tlv320aic23_deemph), |
184 | }; | 184 | }; |
185 | 185 | ||
186 | /* add non dapm controls */ | ||
187 | static int tlv320aic23_add_controls(struct snd_soc_codec *codec) | ||
188 | { | ||
189 | |||
190 | int err, i; | ||
191 | |||
192 | for (i = 0; i < ARRAY_SIZE(tlv320aic23_snd_controls); i++) { | ||
193 | err = snd_ctl_add(codec->card, | ||
194 | snd_soc_cnew(&tlv320aic23_snd_controls[i], | ||
195 | codec, NULL)); | ||
196 | if (err < 0) | ||
197 | return err; | ||
198 | } | ||
199 | |||
200 | return 0; | ||
201 | |||
202 | } | ||
203 | |||
204 | /* PGA Mixer controls for Line and Mic switch */ | 186 | /* PGA Mixer controls for Line and Mic switch */ |
205 | static const struct snd_kcontrol_new tlv320aic23_output_mixer_controls[] = { | 187 | static const struct snd_kcontrol_new tlv320aic23_output_mixer_controls[] = { |
206 | SOC_DAPM_SINGLE("Line Bypass Switch", TLV320AIC23_ANLG, 3, 1, 0), | 188 | SOC_DAPM_SINGLE("Line Bypass Switch", TLV320AIC23_ANLG, 3, 1, 0), |
@@ -718,7 +700,8 @@ static int tlv320aic23_init(struct snd_soc_device *socdev) | |||
718 | 700 | ||
719 | tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x1); | 701 | tlv320aic23_write(codec, TLV320AIC23_ACTIVE, 0x1); |
720 | 702 | ||
721 | tlv320aic23_add_controls(codec); | 703 | snd_soc_add_controls(codec, tlv320aic23_snd_controls, |
704 | ARRAY_SIZE(tlv320aic23_snd_controls)); | ||
722 | tlv320aic23_add_widgets(codec); | 705 | tlv320aic23_add_widgets(codec); |
723 | ret = snd_soc_init_card(socdev); | 706 | ret = snd_soc_init_card(socdev); |
724 | if (ret < 0) { | 707 | if (ret < 0) { |
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index b47a749c5ea2..36ab0198ca3f 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
@@ -311,22 +311,6 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { | |||
311 | SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]), | 311 | SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]), |
312 | }; | 312 | }; |
313 | 313 | ||
314 | /* add non dapm controls */ | ||
315 | static int aic3x_add_controls(struct snd_soc_codec *codec) | ||
316 | { | ||
317 | int err, i; | ||
318 | |||
319 | for (i = 0; i < ARRAY_SIZE(aic3x_snd_controls); i++) { | ||
320 | err = snd_ctl_add(codec->card, | ||
321 | snd_soc_cnew(&aic3x_snd_controls[i], | ||
322 | codec, NULL)); | ||
323 | if (err < 0) | ||
324 | return err; | ||
325 | } | ||
326 | |||
327 | return 0; | ||
328 | } | ||
329 | |||
330 | /* Left DAC Mux */ | 314 | /* Left DAC Mux */ |
331 | static const struct snd_kcontrol_new aic3x_left_dac_mux_controls = | 315 | static const struct snd_kcontrol_new aic3x_left_dac_mux_controls = |
332 | SOC_DAPM_ENUM("Route", aic3x_enum[LDAC_ENUM]); | 316 | SOC_DAPM_ENUM("Route", aic3x_enum[LDAC_ENUM]); |
@@ -1224,7 +1208,8 @@ static int aic3x_init(struct snd_soc_device *socdev) | |||
1224 | aic3x_write(codec, AIC3X_GPIO1_REG, (setup->gpio_func[0] & 0xf) << 4); | 1208 | aic3x_write(codec, AIC3X_GPIO1_REG, (setup->gpio_func[0] & 0xf) << 4); |
1225 | aic3x_write(codec, AIC3X_GPIO2_REG, (setup->gpio_func[1] & 0xf) << 4); | 1209 | aic3x_write(codec, AIC3X_GPIO2_REG, (setup->gpio_func[1] & 0xf) << 4); |
1226 | 1210 | ||
1227 | aic3x_add_controls(codec); | 1211 | snd_soc_add_controls(codec, aic3x_snd_controls, |
1212 | ARRAY_SIZE(aic3x_snd_controls)); | ||
1228 | aic3x_add_widgets(codec); | 1213 | aic3x_add_widgets(codec); |
1229 | ret = snd_soc_init_card(socdev); | 1214 | ret = snd_soc_init_card(socdev); |
1230 | if (ret < 0) { | 1215 | if (ret < 0) { |
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index fd0f338374a7..253063fd319a 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -670,22 +670,6 @@ static const struct snd_kcontrol_new twl4030_snd_controls[] = { | |||
670 | 0, 3, 5, 0, input_gain_tlv), | 670 | 0, 3, 5, 0, input_gain_tlv), |
671 | }; | 671 | }; |
672 | 672 | ||
673 | /* add non dapm controls */ | ||
674 | static int twl4030_add_controls(struct snd_soc_codec *codec) | ||
675 | { | ||
676 | int err, i; | ||
677 | |||
678 | for (i = 0; i < ARRAY_SIZE(twl4030_snd_controls); i++) { | ||
679 | err = snd_ctl_add(codec->card, | ||
680 | snd_soc_cnew(&twl4030_snd_controls[i], | ||
681 | codec, NULL)); | ||
682 | if (err < 0) | ||
683 | return err; | ||
684 | } | ||
685 | |||
686 | return 0; | ||
687 | } | ||
688 | |||
689 | static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { | 673 | static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = { |
690 | /* Left channel inputs */ | 674 | /* Left channel inputs */ |
691 | SND_SOC_DAPM_INPUT("MAINMIC"), | 675 | SND_SOC_DAPM_INPUT("MAINMIC"), |
@@ -1233,7 +1217,8 @@ static int twl4030_init(struct snd_soc_device *socdev) | |||
1233 | /* power on device */ | 1217 | /* power on device */ |
1234 | twl4030_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1218 | twl4030_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
1235 | 1219 | ||
1236 | twl4030_add_controls(codec); | 1220 | snd_soc_add_controls(codec, twl4030_snd_controls, |
1221 | ARRAY_SIZE(twl4030_snd_controls)); | ||
1237 | twl4030_add_widgets(codec); | 1222 | twl4030_add_widgets(codec); |
1238 | 1223 | ||
1239 | ret = snd_soc_init_card(socdev); | 1224 | ret = snd_soc_init_card(socdev); |
diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index a2c5064a774b..277825d155a6 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c | |||
@@ -431,39 +431,6 @@ SOC_ENUM("PCM Playback De-emphasis", uda134x_mixer_enum[1]), | |||
431 | SOC_SINGLE("DC Filter Enable Switch", UDA134X_STATUS0, 0, 1, 0), | 431 | SOC_SINGLE("DC Filter Enable Switch", UDA134X_STATUS0, 0, 1, 0), |
432 | }; | 432 | }; |
433 | 433 | ||
434 | static int uda134x_add_controls(struct snd_soc_codec *codec) | ||
435 | { | ||
436 | int err, i, n; | ||
437 | const struct snd_kcontrol_new *ctrls; | ||
438 | struct uda134x_platform_data *pd = codec->control_data; | ||
439 | |||
440 | switch (pd->model) { | ||
441 | case UDA134X_UDA1340: | ||
442 | case UDA134X_UDA1344: | ||
443 | n = ARRAY_SIZE(uda1340_snd_controls); | ||
444 | ctrls = uda1340_snd_controls; | ||
445 | break; | ||
446 | case UDA134X_UDA1341: | ||
447 | n = ARRAY_SIZE(uda1341_snd_controls); | ||
448 | ctrls = uda1341_snd_controls; | ||
449 | break; | ||
450 | default: | ||
451 | printk(KERN_ERR "%s unkown codec type: %d", | ||
452 | __func__, pd->model); | ||
453 | return -EINVAL; | ||
454 | } | ||
455 | |||
456 | for (i = 0; i < n; i++) { | ||
457 | err = snd_ctl_add(codec->card, | ||
458 | snd_soc_cnew(&ctrls[i], | ||
459 | codec, NULL)); | ||
460 | if (err < 0) | ||
461 | return err; | ||
462 | } | ||
463 | |||
464 | return 0; | ||
465 | } | ||
466 | |||
467 | struct snd_soc_dai uda134x_dai = { | 434 | struct snd_soc_dai uda134x_dai = { |
468 | .name = "UDA134X", | 435 | .name = "UDA134X", |
469 | /* playback capabilities */ | 436 | /* playback capabilities */ |
@@ -572,7 +539,22 @@ static int uda134x_soc_probe(struct platform_device *pdev) | |||
572 | goto pcm_err; | 539 | goto pcm_err; |
573 | } | 540 | } |
574 | 541 | ||
575 | ret = uda134x_add_controls(codec); | 542 | switch (pd->model) { |
543 | case UDA134X_UDA1340: | ||
544 | case UDA134X_UDA1344: | ||
545 | ret = snd_soc_add_controls(codec, uda1340_snd_controls, | ||
546 | ARRAY_SIZE(uda1340_snd_controls)); | ||
547 | break; | ||
548 | case UDA134X_UDA1341: | ||
549 | ret = snd_soc_add_controls(codec, uda1341_snd_controls, | ||
550 | ARRAY_SIZE(uda1341_snd_controls)); | ||
551 | break; | ||
552 | default: | ||
553 | printk(KERN_ERR "%s unkown codec type: %d", | ||
554 | __func__, pd->model); | ||
555 | return -EINVAL; | ||
556 | } | ||
557 | |||
576 | if (ret < 0) { | 558 | if (ret < 0) { |
577 | printk(KERN_ERR "UDA134X: failed to register controls\n"); | 559 | printk(KERN_ERR "UDA134X: failed to register controls\n"); |
578 | goto pcm_err; | 560 | goto pcm_err; |
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index e6bf0844fbf3..a957b4365b9d 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c | |||
@@ -271,21 +271,6 @@ static const struct snd_kcontrol_new uda1380_snd_controls[] = { | |||
271 | SOC_SINGLE("AGC Switch", UDA1380_AGC, 0, 1, 0), | 271 | SOC_SINGLE("AGC Switch", UDA1380_AGC, 0, 1, 0), |
272 | }; | 272 | }; |
273 | 273 | ||
274 | /* add non dapm controls */ | ||
275 | static int uda1380_add_controls(struct snd_soc_codec *codec) | ||
276 | { | ||
277 | int err, i; | ||
278 | |||
279 | for (i = 0; i < ARRAY_SIZE(uda1380_snd_controls); i++) { | ||
280 | err = snd_ctl_add(codec->card, | ||
281 | snd_soc_cnew(&uda1380_snd_controls[i], codec, NULL)); | ||
282 | if (err < 0) | ||
283 | return err; | ||
284 | } | ||
285 | |||
286 | return 0; | ||
287 | } | ||
288 | |||
289 | /* Input mux */ | 274 | /* Input mux */ |
290 | static const struct snd_kcontrol_new uda1380_input_mux_control = | 275 | static const struct snd_kcontrol_new uda1380_input_mux_control = |
291 | SOC_DAPM_ENUM("Route", uda1380_input_sel_enum); | 276 | SOC_DAPM_ENUM("Route", uda1380_input_sel_enum); |
@@ -675,7 +660,8 @@ static int uda1380_init(struct snd_soc_device *socdev, int dac_clk) | |||
675 | } | 660 | } |
676 | 661 | ||
677 | /* uda1380 init */ | 662 | /* uda1380 init */ |
678 | uda1380_add_controls(codec); | 663 | snd_soc_add_controls(codec, uda1380_snd_controls, |
664 | ARRAY_SIZE(uda1380_snd_controls)); | ||
679 | uda1380_add_widgets(codec); | 665 | uda1380_add_widgets(codec); |
680 | ret = snd_soc_init_card(socdev); | 666 | ret = snd_soc_init_card(socdev); |
681 | if (ret < 0) { | 667 | if (ret < 0) { |
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 47a9dabb5235..2e0db29b4998 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c | |||
@@ -782,21 +782,6 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
782 | {"Beep", NULL, "IN3R PGA"}, | 782 | {"Beep", NULL, "IN3R PGA"}, |
783 | }; | 783 | }; |
784 | 784 | ||
785 | static int wm8350_add_controls(struct snd_soc_codec *codec) | ||
786 | { | ||
787 | int err, i; | ||
788 | |||
789 | for (i = 0; i < ARRAY_SIZE(wm8350_snd_controls); i++) { | ||
790 | err = snd_ctl_add(codec->card, | ||
791 | snd_soc_cnew(&wm8350_snd_controls[i], | ||
792 | codec, NULL)); | ||
793 | if (err < 0) | ||
794 | return err; | ||
795 | } | ||
796 | |||
797 | return 0; | ||
798 | } | ||
799 | |||
800 | static int wm8350_add_widgets(struct snd_soc_codec *codec) | 785 | static int wm8350_add_widgets(struct snd_soc_codec *codec) |
801 | { | 786 | { |
802 | int ret; | 787 | int ret; |
@@ -1490,7 +1475,8 @@ static int wm8350_probe(struct platform_device *pdev) | |||
1490 | return ret; | 1475 | return ret; |
1491 | } | 1476 | } |
1492 | 1477 | ||
1493 | wm8350_add_controls(codec); | 1478 | snd_soc_add_controls(codec, wm8350_snd_controls, |
1479 | ARRAY_SIZE(wm8350_snd_controls)); | ||
1494 | wm8350_add_widgets(codec); | 1480 | wm8350_add_widgets(codec); |
1495 | 1481 | ||
1496 | wm8350_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1482 | wm8350_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index 40f8238df717..abe7cce87714 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c | |||
@@ -171,22 +171,6 @@ SOC_SINGLE("Capture Boost(+20dB)", WM8510_ADCBOOST, 8, 1, 0), | |||
171 | SOC_SINGLE("Mono Playback Switch", WM8510_MONOMIX, 6, 1, 1), | 171 | SOC_SINGLE("Mono Playback Switch", WM8510_MONOMIX, 6, 1, 1), |
172 | }; | 172 | }; |
173 | 173 | ||
174 | /* add non dapm controls */ | ||
175 | static int wm8510_add_controls(struct snd_soc_codec *codec) | ||
176 | { | ||
177 | int err, i; | ||
178 | |||
179 | for (i = 0; i < ARRAY_SIZE(wm8510_snd_controls); i++) { | ||
180 | err = snd_ctl_add(codec->card, | ||
181 | snd_soc_cnew(&wm8510_snd_controls[i], codec, | ||
182 | NULL)); | ||
183 | if (err < 0) | ||
184 | return err; | ||
185 | } | ||
186 | |||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | /* Speaker Output Mixer */ | 174 | /* Speaker Output Mixer */ |
191 | static const struct snd_kcontrol_new wm8510_speaker_mixer_controls[] = { | 175 | static const struct snd_kcontrol_new wm8510_speaker_mixer_controls[] = { |
192 | SOC_DAPM_SINGLE("Line Bypass Switch", WM8510_SPKMIX, 1, 1, 0), | 176 | SOC_DAPM_SINGLE("Line Bypass Switch", WM8510_SPKMIX, 1, 1, 0), |
@@ -656,7 +640,8 @@ static int wm8510_init(struct snd_soc_device *socdev) | |||
656 | /* power on device */ | 640 | /* power on device */ |
657 | codec->bias_level = SND_SOC_BIAS_OFF; | 641 | codec->bias_level = SND_SOC_BIAS_OFF; |
658 | wm8510_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 642 | wm8510_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
659 | wm8510_add_controls(codec); | 643 | snd_soc_add_controls(codec, wm8510_snd_controls, |
644 | ARRAY_SIZE(wm8510_snd_controls)); | ||
660 | wm8510_add_widgets(codec); | 645 | wm8510_add_widgets(codec); |
661 | ret = snd_soc_init_card(socdev); | 646 | ret = snd_soc_init_card(socdev); |
662 | if (ret < 0) { | 647 | if (ret < 0) { |
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index d004e5845298..9b75a377453e 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c | |||
@@ -330,20 +330,6 @@ SOC_DOUBLE("ADC Mute Switch", WM8580_ADC_CONTROL1, 0, 1, 1, 0), | |||
330 | SOC_SINGLE("ADC High-Pass Filter Switch", WM8580_ADC_CONTROL1, 4, 1, 0), | 330 | SOC_SINGLE("ADC High-Pass Filter Switch", WM8580_ADC_CONTROL1, 4, 1, 0), |
331 | }; | 331 | }; |
332 | 332 | ||
333 | /* Add non-DAPM controls */ | ||
334 | static int wm8580_add_controls(struct snd_soc_codec *codec) | ||
335 | { | ||
336 | int err, i; | ||
337 | |||
338 | for (i = 0; i < ARRAY_SIZE(wm8580_snd_controls); i++) { | ||
339 | err = snd_ctl_add(codec->card, | ||
340 | snd_soc_cnew(&wm8580_snd_controls[i], | ||
341 | codec, NULL)); | ||
342 | if (err < 0) | ||
343 | return err; | ||
344 | } | ||
345 | return 0; | ||
346 | } | ||
347 | static const struct snd_soc_dapm_widget wm8580_dapm_widgets[] = { | 333 | static const struct snd_soc_dapm_widget wm8580_dapm_widgets[] = { |
348 | SND_SOC_DAPM_DAC("DAC1", "Playback", WM8580_PWRDN1, 2, 1), | 334 | SND_SOC_DAPM_DAC("DAC1", "Playback", WM8580_PWRDN1, 2, 1), |
349 | SND_SOC_DAPM_DAC("DAC2", "Playback", WM8580_PWRDN1, 3, 1), | 335 | SND_SOC_DAPM_DAC("DAC2", "Playback", WM8580_PWRDN1, 3, 1), |
@@ -866,7 +852,8 @@ static int wm8580_init(struct snd_soc_device *socdev) | |||
866 | goto pcm_err; | 852 | goto pcm_err; |
867 | } | 853 | } |
868 | 854 | ||
869 | wm8580_add_controls(codec); | 855 | snd_soc_add_controls(codec, wm8580_snd_controls, |
856 | ARRAY_SIZE(wm8580_snd_controls)); | ||
870 | wm8580_add_widgets(codec); | 857 | wm8580_add_widgets(codec); |
871 | 858 | ||
872 | ret = snd_soc_init_card(socdev); | 859 | ret = snd_soc_init_card(socdev); |
diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c index 80b11983e137..defa310bc7d9 100644 --- a/sound/soc/codecs/wm8728.c +++ b/sound/soc/codecs/wm8728.c | |||
@@ -92,21 +92,6 @@ SOC_DOUBLE_R_TLV("Digital Playback Volume", WM8728_DACLVOL, WM8728_DACRVOL, | |||
92 | SOC_SINGLE("Deemphasis", WM8728_DACCTL, 1, 1, 0), | 92 | SOC_SINGLE("Deemphasis", WM8728_DACCTL, 1, 1, 0), |
93 | }; | 93 | }; |
94 | 94 | ||
95 | static int wm8728_add_controls(struct snd_soc_codec *codec) | ||
96 | { | ||
97 | int err, i; | ||
98 | |||
99 | for (i = 0; i < ARRAY_SIZE(wm8728_snd_controls); i++) { | ||
100 | err = snd_ctl_add(codec->card, | ||
101 | snd_soc_cnew(&wm8728_snd_controls[i], | ||
102 | codec, NULL)); | ||
103 | if (err < 0) | ||
104 | return err; | ||
105 | } | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | /* | 95 | /* |
111 | * DAPM controls. | 96 | * DAPM controls. |
112 | */ | 97 | */ |
@@ -330,7 +315,8 @@ static int wm8728_init(struct snd_soc_device *socdev) | |||
330 | /* power on device */ | 315 | /* power on device */ |
331 | wm8728_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 316 | wm8728_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
332 | 317 | ||
333 | wm8728_add_controls(codec); | 318 | snd_soc_add_controls(codec, wm8728_snd_controls, |
319 | ARRAY_SIZE(wm8728_snd_controls)); | ||
334 | wm8728_add_widgets(codec); | 320 | wm8728_add_widgets(codec); |
335 | ret = snd_soc_init_card(socdev); | 321 | ret = snd_soc_init_card(socdev); |
336 | if (ret < 0) { | 322 | if (ret < 0) { |
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index c444b9f2701e..96d6e1aeaf43 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c | |||
@@ -129,22 +129,6 @@ SOC_SINGLE("Store DC Offset Switch", WM8731_APDIGI, 4, 1, 0), | |||
129 | SOC_ENUM("Playback De-emphasis", wm8731_enum[1]), | 129 | SOC_ENUM("Playback De-emphasis", wm8731_enum[1]), |
130 | }; | 130 | }; |
131 | 131 | ||
132 | /* add non dapm controls */ | ||
133 | static int wm8731_add_controls(struct snd_soc_codec *codec) | ||
134 | { | ||
135 | int err, i; | ||
136 | |||
137 | for (i = 0; i < ARRAY_SIZE(wm8731_snd_controls); i++) { | ||
138 | err = snd_ctl_add(codec->card, | ||
139 | snd_soc_cnew(&wm8731_snd_controls[i], | ||
140 | codec, NULL)); | ||
141 | if (err < 0) | ||
142 | return err; | ||
143 | } | ||
144 | |||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | /* Output Mixer */ | 132 | /* Output Mixer */ |
149 | static const struct snd_kcontrol_new wm8731_output_mixer_controls[] = { | 133 | static const struct snd_kcontrol_new wm8731_output_mixer_controls[] = { |
150 | SOC_DAPM_SINGLE("Line Bypass Switch", WM8731_APANA, 3, 1, 0), | 134 | SOC_DAPM_SINGLE("Line Bypass Switch", WM8731_APANA, 3, 1, 0), |
@@ -543,7 +527,8 @@ static int wm8731_init(struct snd_soc_device *socdev) | |||
543 | reg = wm8731_read_reg_cache(codec, WM8731_RINVOL); | 527 | reg = wm8731_read_reg_cache(codec, WM8731_RINVOL); |
544 | wm8731_write(codec, WM8731_RINVOL, reg & ~0x0100); | 528 | wm8731_write(codec, WM8731_RINVOL, reg & ~0x0100); |
545 | 529 | ||
546 | wm8731_add_controls(codec); | 530 | snd_soc_add_controls(codec, wm8731_snd_controls, |
531 | ARRAY_SIZE(wm8731_snd_controls)); | ||
547 | wm8731_add_widgets(codec); | 532 | wm8731_add_widgets(codec); |
548 | ret = snd_soc_init_card(socdev); | 533 | ret = snd_soc_init_card(socdev); |
549 | if (ret < 0) { | 534 | if (ret < 0) { |
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 5997fa68e0d5..1578569793a2 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c | |||
@@ -231,21 +231,6 @@ SOC_SINGLE("Mono Playback Volume", WM8750_MOUTV, 0, 127, 0), | |||
231 | 231 | ||
232 | }; | 232 | }; |
233 | 233 | ||
234 | /* add non dapm controls */ | ||
235 | static int wm8750_add_controls(struct snd_soc_codec *codec) | ||
236 | { | ||
237 | int err, i; | ||
238 | |||
239 | for (i = 0; i < ARRAY_SIZE(wm8750_snd_controls); i++) { | ||
240 | err = snd_ctl_add(codec->card, | ||
241 | snd_soc_cnew(&wm8750_snd_controls[i], | ||
242 | codec, NULL)); | ||
243 | if (err < 0) | ||
244 | return err; | ||
245 | } | ||
246 | return 0; | ||
247 | } | ||
248 | |||
249 | /* | 234 | /* |
250 | * DAPM Controls | 235 | * DAPM Controls |
251 | */ | 236 | */ |
@@ -816,7 +801,8 @@ static int wm8750_init(struct snd_soc_device *socdev) | |||
816 | reg = wm8750_read_reg_cache(codec, WM8750_RINVOL); | 801 | reg = wm8750_read_reg_cache(codec, WM8750_RINVOL); |
817 | wm8750_write(codec, WM8750_RINVOL, reg | 0x0100); | 802 | wm8750_write(codec, WM8750_RINVOL, reg | 0x0100); |
818 | 803 | ||
819 | wm8750_add_controls(codec); | 804 | snd_soc_add_controls(codec, wm8750_snd_controls, |
805 | ARRAY_SIZE(wm8750_snd_controls)); | ||
820 | wm8750_add_widgets(codec); | 806 | wm8750_add_widgets(codec); |
821 | ret = snd_soc_init_card(socdev); | 807 | ret = snd_soc_init_card(socdev); |
822 | if (ret < 0) { | 808 | if (ret < 0) { |
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 6c21b50c9375..7283178e0eb5 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c | |||
@@ -339,21 +339,6 @@ SOC_ENUM("ADC Data Select", wm8753_enum[27]), | |||
339 | SOC_ENUM("ROUT2 Phase", wm8753_enum[28]), | 339 | SOC_ENUM("ROUT2 Phase", wm8753_enum[28]), |
340 | }; | 340 | }; |
341 | 341 | ||
342 | /* add non dapm controls */ | ||
343 | static int wm8753_add_controls(struct snd_soc_codec *codec) | ||
344 | { | ||
345 | int err, i; | ||
346 | |||
347 | for (i = 0; i < ARRAY_SIZE(wm8753_snd_controls); i++) { | ||
348 | err = snd_ctl_add(codec->card, | ||
349 | snd_soc_cnew(&wm8753_snd_controls[i], | ||
350 | codec, NULL)); | ||
351 | if (err < 0) | ||
352 | return err; | ||
353 | } | ||
354 | return 0; | ||
355 | } | ||
356 | |||
357 | /* | 342 | /* |
358 | * _DAPM_ Controls | 343 | * _DAPM_ Controls |
359 | */ | 344 | */ |
@@ -1603,7 +1588,8 @@ static int wm8753_init(struct snd_soc_device *socdev) | |||
1603 | reg = wm8753_read_reg_cache(codec, WM8753_RINVOL); | 1588 | reg = wm8753_read_reg_cache(codec, WM8753_RINVOL); |
1604 | wm8753_write(codec, WM8753_RINVOL, reg | 0x0100); | 1589 | wm8753_write(codec, WM8753_RINVOL, reg | 0x0100); |
1605 | 1590 | ||
1606 | wm8753_add_controls(codec); | 1591 | snd_soc_add_controls(codec, wm8753_snd_controls, |
1592 | ARRAY_SIZE(wm8753_snd_controls)); | ||
1607 | wm8753_add_widgets(codec); | 1593 | wm8753_add_widgets(codec); |
1608 | ret = snd_soc_init_card(socdev); | 1594 | ret = snd_soc_init_card(socdev); |
1609 | if (ret < 0) { | 1595 | if (ret < 0) { |
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index 6767de10ded0..1e08d4f065f2 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c | |||
@@ -517,22 +517,6 @@ SOC_SINGLE("LINEOUT2 LP -12dB", WM8900_REG_LOUTMIXCTL1, | |||
517 | 517 | ||
518 | }; | 518 | }; |
519 | 519 | ||
520 | /* add non dapm controls */ | ||
521 | static int wm8900_add_controls(struct snd_soc_codec *codec) | ||
522 | { | ||
523 | int err, i; | ||
524 | |||
525 | for (i = 0; i < ARRAY_SIZE(wm8900_snd_controls); i++) { | ||
526 | err = snd_ctl_add(codec->card, | ||
527 | snd_soc_cnew(&wm8900_snd_controls[i], | ||
528 | codec, NULL)); | ||
529 | if (err < 0) | ||
530 | return err; | ||
531 | } | ||
532 | |||
533 | return 0; | ||
534 | } | ||
535 | |||
536 | static const struct snd_kcontrol_new wm8900_dapm_loutput2_control = | 520 | static const struct snd_kcontrol_new wm8900_dapm_loutput2_control = |
537 | SOC_DAPM_SINGLE("LINEOUT2L Switch", WM8900_REG_POWER3, 6, 1, 0); | 521 | SOC_DAPM_SINGLE("LINEOUT2L Switch", WM8900_REG_POWER3, 6, 1, 0); |
538 | 522 | ||
@@ -1439,7 +1423,8 @@ static int wm8900_probe(struct platform_device *pdev) | |||
1439 | goto pcm_err; | 1423 | goto pcm_err; |
1440 | } | 1424 | } |
1441 | 1425 | ||
1442 | wm8900_add_controls(codec); | 1426 | snd_soc_add_controls(codec, wm8900_snd_controls, |
1427 | ARRAY_SIZE(wm8900_snd_controls)); | ||
1443 | wm8900_add_widgets(codec); | 1428 | wm8900_add_widgets(codec); |
1444 | 1429 | ||
1445 | ret = snd_soc_init_card(socdev); | 1430 | ret = snd_soc_init_card(socdev); |
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index bde74546db4a..6ff34b957dce 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c | |||
@@ -744,21 +744,6 @@ SOC_DOUBLE_R_TLV("Speaker Volume", | |||
744 | 0, 63, 0, out_tlv), | 744 | 0, 63, 0, out_tlv), |
745 | }; | 745 | }; |
746 | 746 | ||
747 | static int wm8903_add_controls(struct snd_soc_codec *codec) | ||
748 | { | ||
749 | int err, i; | ||
750 | |||
751 | for (i = 0; i < ARRAY_SIZE(wm8903_snd_controls); i++) { | ||
752 | err = snd_ctl_add(codec->card, | ||
753 | snd_soc_cnew(&wm8903_snd_controls[i], | ||
754 | codec, NULL)); | ||
755 | if (err < 0) | ||
756 | return err; | ||
757 | } | ||
758 | |||
759 | return 0; | ||
760 | } | ||
761 | |||
762 | static const struct snd_kcontrol_new linput_mode_mux = | 747 | static const struct snd_kcontrol_new linput_mode_mux = |
763 | SOC_DAPM_ENUM("Left Input Mode Mux", linput_mode_enum); | 748 | SOC_DAPM_ENUM("Left Input Mode Mux", linput_mode_enum); |
764 | 749 | ||
@@ -1737,7 +1722,8 @@ static int wm8903_probe(struct platform_device *pdev) | |||
1737 | goto err; | 1722 | goto err; |
1738 | } | 1723 | } |
1739 | 1724 | ||
1740 | wm8903_add_controls(socdev->codec); | 1725 | snd_soc_add_controls(socdev->codec, wm8903_snd_controls, |
1726 | ARRAY_SIZE(wm8903_snd_controls)); | ||
1741 | wm8903_add_widgets(socdev->codec); | 1727 | wm8903_add_widgets(socdev->codec); |
1742 | 1728 | ||
1743 | ret = snd_soc_init_card(socdev); | 1729 | ret = snd_soc_init_card(socdev); |
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 88ead7f8dd98..c8bd9b06f330 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 */ | ||
199 | static 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 | */ |
@@ -745,7 +730,8 @@ static int wm8971_init(struct snd_soc_device *socdev) | |||
745 | reg = wm8971_read_reg_cache(codec, WM8971_RINVOL); | 730 | reg = wm8971_read_reg_cache(codec, WM8971_RINVOL); |
746 | wm8971_write(codec, WM8971_RINVOL, reg | 0x0100); | 731 | wm8971_write(codec, WM8971_RINVOL, reg | 0x0100); |
747 | 732 | ||
748 | wm8971_add_controls(codec); | 733 | snd_soc_add_controls(codec, wm8971_snd_controls, |
734 | ARRAY_SIZE(wm8971_snd_controls)); | ||
749 | wm8971_add_widgets(codec); | 735 | wm8971_add_widgets(codec); |
750 | ret = snd_soc_init_card(socdev); | 736 | ret = snd_soc_init_card(socdev); |
751 | if (ret < 0) { | 737 | if (ret < 0) { |
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index 5b5afc144478..6b2778632d5e 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c | |||
@@ -417,21 +417,6 @@ SOC_SINGLE("RIN34 Mute Switch", WM8990_RIGHT_LINE_INPUT_3_4_VOLUME, | |||
417 | 417 | ||
418 | }; | 418 | }; |
419 | 419 | ||
420 | /* add non dapm controls */ | ||
421 | static int wm8990_add_controls(struct snd_soc_codec *codec) | ||
422 | { | ||
423 | int err, i; | ||
424 | |||
425 | for (i = 0; i < ARRAY_SIZE(wm8990_snd_controls); i++) { | ||
426 | err = snd_ctl_add(codec->card, | ||
427 | snd_soc_cnew(&wm8990_snd_controls[i], codec, | ||
428 | NULL)); | ||
429 | if (err < 0) | ||
430 | return err; | ||
431 | } | ||
432 | return 0; | ||
433 | } | ||
434 | |||
435 | /* | 420 | /* |
436 | * _DAPM_ Controls | 421 | * _DAPM_ Controls |
437 | */ | 422 | */ |
@@ -1460,7 +1445,8 @@ static int wm8990_init(struct snd_soc_device *socdev) | |||
1460 | wm8990_write(codec, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); | 1445 | wm8990_write(codec, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); |
1461 | wm8990_write(codec, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); | 1446 | wm8990_write(codec, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); |
1462 | 1447 | ||
1463 | wm8990_add_controls(codec); | 1448 | snd_soc_add_controls(codec, wm8990_snd_controls, |
1449 | ARRAY_SIZE(wm8990_snd_controls)); | ||
1464 | wm8990_add_widgets(codec); | 1450 | wm8990_add_widgets(codec); |
1465 | ret = snd_soc_init_card(socdev); | 1451 | ret = snd_soc_init_card(socdev); |
1466 | if (ret < 0) { | 1452 | if (ret < 0) { |
diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index af83d629078a..1b0ace0f4dca 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c | |||
@@ -154,21 +154,6 @@ SOC_SINGLE("Mic 2 Volume", AC97_MIC, 0, 31, 1), | |||
154 | SOC_SINGLE("Mic 20dB Boost Switch", AC97_MIC, 7, 1, 0), | 154 | SOC_SINGLE("Mic 20dB Boost Switch", AC97_MIC, 7, 1, 0), |
155 | }; | 155 | }; |
156 | 156 | ||
157 | /* add non dapm controls */ | ||
158 | static int wm9712_add_controls(struct snd_soc_codec *codec) | ||
159 | { | ||
160 | int err, i; | ||
161 | |||
162 | for (i = 0; i < ARRAY_SIZE(wm9712_snd_ac97_controls); i++) { | ||
163 | err = snd_ctl_add(codec->card, | ||
164 | snd_soc_cnew(&wm9712_snd_ac97_controls[i], | ||
165 | codec, NULL)); | ||
166 | if (err < 0) | ||
167 | return err; | ||
168 | } | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | /* We have to create a fake left and right HP mixers because | 157 | /* We have to create a fake left and right HP mixers because |
173 | * the codec only has a single control that is shared by both channels. | 158 | * the codec only has a single control that is shared by both channels. |
174 | * This makes it impossible to determine the audio path. | 159 | * This makes it impossible to determine the audio path. |
@@ -698,7 +683,8 @@ static int wm9712_soc_probe(struct platform_device *pdev) | |||
698 | ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000); | 683 | ac97_write(codec, AC97_VIDEO, ac97_read(codec, AC97_VIDEO) | 0x3000); |
699 | 684 | ||
700 | wm9712_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 685 | wm9712_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
701 | wm9712_add_controls(codec); | 686 | snd_soc_add_controls(codec, wm9712_snd_ac97_controls, |
687 | ARRAY_SIZE(wm9712_snd_ac97_controls)); | ||
702 | wm9712_add_widgets(codec); | 688 | wm9712_add_widgets(codec); |
703 | ret = snd_soc_init_card(socdev); | 689 | ret = snd_soc_init_card(socdev); |
704 | if (ret < 0) { | 690 | if (ret < 0) { |
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index f3ca8aaf0139..a45622620db7 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c | |||
@@ -190,21 +190,6 @@ SOC_SINGLE("3D Lower Cut-off Switch", AC97_REC_GAIN_MIC, 4, 1, 0), | |||
190 | SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1), | 190 | SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1), |
191 | }; | 191 | }; |
192 | 192 | ||
193 | /* add non dapm controls */ | ||
194 | static int wm9713_add_controls(struct snd_soc_codec *codec) | ||
195 | { | ||
196 | int err, i; | ||
197 | |||
198 | for (i = 0; i < ARRAY_SIZE(wm9713_snd_ac97_controls); i++) { | ||
199 | err = snd_ctl_add(codec->card, | ||
200 | snd_soc_cnew(&wm9713_snd_ac97_controls[i], | ||
201 | codec, NULL)); | ||
202 | if (err < 0) | ||
203 | return err; | ||
204 | } | ||
205 | return 0; | ||
206 | } | ||
207 | |||
208 | /* We have to create a fake left and right HP mixers because | 193 | /* We have to create a fake left and right HP mixers because |
209 | * the codec only has a single control that is shared by both channels. | 194 | * the codec only has a single control that is shared by both channels. |
210 | * This makes it impossible to determine the audio path using the current | 195 | * This makes it impossible to determine the audio path using the current |
@@ -1245,7 +1230,8 @@ static int wm9713_soc_probe(struct platform_device *pdev) | |||
1245 | reg = ac97_read(codec, AC97_CD) & 0x7fff; | 1230 | reg = ac97_read(codec, AC97_CD) & 0x7fff; |
1246 | ac97_write(codec, AC97_CD, reg); | 1231 | ac97_write(codec, AC97_CD, reg); |
1247 | 1232 | ||
1248 | wm9713_add_controls(codec); | 1233 | snd_soc_add_controls(codec, wm9713_snd_ac97_controls, |
1234 | ARRAY_SIZE(wm9713_snd_ac97_controls)); | ||
1249 | wm9713_add_widgets(codec); | 1235 | wm9713_add_widgets(codec); |
1250 | ret = snd_soc_init_card(socdev); | 1236 | ret = snd_soc_init_card(socdev); |
1251 | if (ret < 0) | 1237 | if (ret < 0) |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 6cbe7e82f238..d3b97a7542e0 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -1495,6 +1495,37 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, | |||
1495 | EXPORT_SYMBOL_GPL(snd_soc_cnew); | 1495 | EXPORT_SYMBOL_GPL(snd_soc_cnew); |
1496 | 1496 | ||
1497 | /** | 1497 | /** |
1498 | * snd_soc_add_controls - add an array of controls to a codec. | ||
1499 | * Convienience function to add a list of controls. Many codecs were | ||
1500 | * duplicating this code. | ||
1501 | * | ||
1502 | * @codec: codec to add controls to | ||
1503 | * @controls: array of controls to add | ||
1504 | * @num_controls: number of elements in the array | ||
1505 | * | ||
1506 | * Return 0 for success, else error. | ||
1507 | */ | ||
1508 | int snd_soc_add_controls(struct snd_soc_codec *codec, | ||
1509 | const struct snd_kcontrol_new *controls, int num_controls) | ||
1510 | { | ||
1511 | struct snd_card *card = codec->card; | ||
1512 | int err, i; | ||
1513 | |||
1514 | for (i = 0; i < num_controls; i++) { | ||
1515 | const struct snd_kcontrol_new *control = &controls[i]; | ||
1516 | err = snd_ctl_add(card, snd_soc_cnew(control, codec, NULL)); | ||
1517 | if (err < 0) { | ||
1518 | dev_err(codec->dev, "%s: Failed to add %s\n", | ||
1519 | codec->name, control->name); | ||
1520 | return err; | ||
1521 | } | ||
1522 | } | ||
1523 | |||
1524 | return 0; | ||
1525 | } | ||
1526 | EXPORT_SYMBOL_GPL(snd_soc_add_controls); | ||
1527 | |||
1528 | /** | ||
1498 | * snd_soc_info_enum_double - enumerated double mixer info callback | 1529 | * snd_soc_info_enum_double - enumerated double mixer info callback |
1499 | * @kcontrol: mixer control | 1530 | * @kcontrol: mixer control |
1500 | * @uinfo: control element information | 1531 | * @uinfo: control element information |