aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@nokia.com>2009-01-05 02:54:58 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-01-05 12:47:17 -0500
commit2f42357722f7ddc1ec0236fa55ad49ea8a7ce4b0 (patch)
tree7f385fb8cc4540802f599f9d986e180e7bba1cc1 /sound/soc/codecs
parent2e72f8e3716bc3bbf4c9b5b987fb5ab3223f60bf (diff)
ASoC: TWL4030: Convert the bitfield enums to VALUE_ENUM type
Convert the bitfield coded enums to the new VALUE_ENUM type. Remove the enum check, since the VALUE_ENUM type can handle the bitfield coding and also handles the 'holes' in the bitfield. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r--sound/soc/codecs/twl4030.c118
1 files changed, 55 insertions, 63 deletions
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c
index 31e44e346dc8..fd0f338374a7 100644
--- a/sound/soc/codecs/twl4030.c
+++ b/sound/soc/codecs/twl4030.c
@@ -192,39 +192,51 @@ static void twl4030_init_chip(struct snd_soc_codec *codec)
192 192
193/* Earpiece */ 193/* Earpiece */
194static const char *twl4030_earpiece_texts[] = 194static const char *twl4030_earpiece_texts[] =
195 {"Off", "DACL1", "DACL2", "Invalid", "DACR1"}; 195 {"Off", "DACL1", "DACL2", "DACR1"};
196 196
197static const struct soc_enum twl4030_earpiece_enum = 197static const unsigned int twl4030_earpiece_values[] =
198 SOC_ENUM_SINGLE(TWL4030_REG_EAR_CTL, 1, 198 {0x0, 0x1, 0x2, 0x4};
199
200static const struct soc_value_enum twl4030_earpiece_enum =
201 SOC_VALUE_ENUM_SINGLE(TWL4030_REG_EAR_CTL, 1, 0x7,
199 ARRAY_SIZE(twl4030_earpiece_texts), 202 ARRAY_SIZE(twl4030_earpiece_texts),
200 twl4030_earpiece_texts); 203 twl4030_earpiece_texts,
204 twl4030_earpiece_values);
201 205
202static const struct snd_kcontrol_new twl4030_dapm_earpiece_control = 206static const struct snd_kcontrol_new twl4030_dapm_earpiece_control =
203SOC_DAPM_ENUM("Route", twl4030_earpiece_enum); 207SOC_DAPM_VALUE_ENUM("Route", twl4030_earpiece_enum);
204 208
205/* PreDrive Left */ 209/* PreDrive Left */
206static const char *twl4030_predrivel_texts[] = 210static const char *twl4030_predrivel_texts[] =
207 {"Off", "DACL1", "DACL2", "Invalid", "DACR2"}; 211 {"Off", "DACL1", "DACL2", "DACR2"};
212
213static const unsigned int twl4030_predrivel_values[] =
214 {0x0, 0x1, 0x2, 0x4};
208 215
209static const struct soc_enum twl4030_predrivel_enum = 216static const struct soc_value_enum twl4030_predrivel_enum =
210 SOC_ENUM_SINGLE(TWL4030_REG_PREDL_CTL, 1, 217 SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDL_CTL, 1, 0x7,
211 ARRAY_SIZE(twl4030_predrivel_texts), 218 ARRAY_SIZE(twl4030_predrivel_texts),
212 twl4030_predrivel_texts); 219 twl4030_predrivel_texts,
220 twl4030_predrivel_values);
213 221
214static const struct snd_kcontrol_new twl4030_dapm_predrivel_control = 222static const struct snd_kcontrol_new twl4030_dapm_predrivel_control =
215SOC_DAPM_ENUM("Route", twl4030_predrivel_enum); 223SOC_DAPM_VALUE_ENUM("Route", twl4030_predrivel_enum);
216 224
217/* PreDrive Right */ 225/* PreDrive Right */
218static const char *twl4030_predriver_texts[] = 226static const char *twl4030_predriver_texts[] =
219 {"Off", "DACR1", "DACR2", "Invalid", "DACL2"}; 227 {"Off", "DACR1", "DACR2", "DACL2"};
220 228
221static const struct soc_enum twl4030_predriver_enum = 229static const unsigned int twl4030_predriver_values[] =
222 SOC_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, 230 {0x0, 0x1, 0x2, 0x4};
231
232static const struct soc_value_enum twl4030_predriver_enum =
233 SOC_VALUE_ENUM_SINGLE(TWL4030_REG_PREDR_CTL, 1, 0x7,
223 ARRAY_SIZE(twl4030_predriver_texts), 234 ARRAY_SIZE(twl4030_predriver_texts),
224 twl4030_predriver_texts); 235 twl4030_predriver_texts,
236 twl4030_predriver_values);
225 237
226static const struct snd_kcontrol_new twl4030_dapm_predriver_control = 238static const struct snd_kcontrol_new twl4030_dapm_predriver_control =
227SOC_DAPM_ENUM("Route", twl4030_predriver_enum); 239SOC_DAPM_VALUE_ENUM("Route", twl4030_predriver_enum);
228 240
229/* Headset Left */ 241/* Headset Left */
230static const char *twl4030_hsol_texts[] = 242static const char *twl4030_hsol_texts[] =
@@ -300,28 +312,35 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum);
300 312
301/* Left analog microphone selection */ 313/* Left analog microphone selection */
302static const char *twl4030_analoglmic_texts[] = 314static const char *twl4030_analoglmic_texts[] =
303 {"Off", "Main mic", "Headset mic", "Invalid", "AUXL", 315 {"Off", "Main mic", "Headset mic", "AUXL", "Carkit mic"};
304 "Invalid", "Invalid", "Invalid", "Carkit mic"}; 316
317static const unsigned int twl4030_analoglmic_values[] =
318 {0x0, 0x1, 0x2, 0x4, 0x8};
305 319
306static const struct soc_enum twl4030_analoglmic_enum = 320static const struct soc_value_enum twl4030_analoglmic_enum =
307 SOC_ENUM_SINGLE(TWL4030_REG_ANAMICL, 0, 321 SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICL, 0, 0xf,
308 ARRAY_SIZE(twl4030_analoglmic_texts), 322 ARRAY_SIZE(twl4030_analoglmic_texts),
309 twl4030_analoglmic_texts); 323 twl4030_analoglmic_texts,
324 twl4030_analoglmic_values);
310 325
311static const struct snd_kcontrol_new twl4030_dapm_analoglmic_control = 326static const struct snd_kcontrol_new twl4030_dapm_analoglmic_control =
312SOC_DAPM_ENUM("Route", twl4030_analoglmic_enum); 327SOC_DAPM_VALUE_ENUM("Route", twl4030_analoglmic_enum);
313 328
314/* Right analog microphone selection */ 329/* Right analog microphone selection */
315static const char *twl4030_analogrmic_texts[] = 330static const char *twl4030_analogrmic_texts[] =
316 {"Off", "Sub mic", "Invalid", "Invalid", "AUXR"}; 331 {"Off", "Sub mic", "AUXR"};
317 332
318static const struct soc_enum twl4030_analogrmic_enum = 333static const unsigned int twl4030_analogrmic_values[] =
319 SOC_ENUM_SINGLE(TWL4030_REG_ANAMICR, 0, 334 {0x0, 0x1, 0x4};
335
336static const struct soc_value_enum twl4030_analogrmic_enum =
337 SOC_VALUE_ENUM_SINGLE(TWL4030_REG_ANAMICR, 0, 0x5,
320 ARRAY_SIZE(twl4030_analogrmic_texts), 338 ARRAY_SIZE(twl4030_analogrmic_texts),
321 twl4030_analogrmic_texts); 339 twl4030_analogrmic_texts,
340 twl4030_analogrmic_values);
322 341
323static const struct snd_kcontrol_new twl4030_dapm_analogrmic_control = 342static const struct snd_kcontrol_new twl4030_dapm_analogrmic_control =
324SOC_DAPM_ENUM("Route", twl4030_analogrmic_enum); 343SOC_DAPM_VALUE_ENUM("Route", twl4030_analogrmic_enum);
325 344
326/* TX1 L/R Analog/Digital microphone selection */ 345/* TX1 L/R Analog/Digital microphone selection */
327static const char *twl4030_micpathtx1_texts[] = 346static const char *twl4030_micpathtx1_texts[] =
@@ -347,28 +366,6 @@ static const struct soc_enum twl4030_micpathtx2_enum =
347static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control = 366static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control =
348SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum); 367SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum);
349 368
350/*
351 * This function filters out the non valid mux settings, named as "Invalid"
352 * in the enum texts.
353 * Just refuse to set an invalid mux mode.
354 */
355static int twl4030_enum_event(struct snd_soc_dapm_widget *w,
356 struct snd_kcontrol *kcontrol, int event)
357{
358 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
359 int ret = 0;
360 int val;
361
362 val = w->value >> e->shift_l;
363 if (!strcmp("Invalid", e->texts[val])) {
364 printk(KERN_WARNING "Invalid MUX setting on 0x%02x (%d)\n",
365 e->reg, val);
366 ret = -1;
367 }
368
369 return ret;
370}
371
372static int micpath_event(struct snd_soc_dapm_widget *w, 369static int micpath_event(struct snd_soc_dapm_widget *w,
373 struct snd_kcontrol *kcontrol, int event) 370 struct snd_kcontrol *kcontrol, int event)
374{ 371{
@@ -737,16 +734,13 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
737 734
738 /* Output MUX controls */ 735 /* Output MUX controls */
739 /* Earpiece */ 736 /* Earpiece */
740 SND_SOC_DAPM_MUX_E("Earpiece Mux", SND_SOC_NOPM, 0, 0, 737 SND_SOC_DAPM_VALUE_MUX("Earpiece Mux", SND_SOC_NOPM, 0, 0,
741 &twl4030_dapm_earpiece_control, twl4030_enum_event, 738 &twl4030_dapm_earpiece_control),
742 SND_SOC_DAPM_PRE_REG),
743 /* PreDrivL/R */ 739 /* PreDrivL/R */
744 SND_SOC_DAPM_MUX_E("PredriveL Mux", SND_SOC_NOPM, 0, 0, 740 SND_SOC_DAPM_VALUE_MUX("PredriveL Mux", SND_SOC_NOPM, 0, 0,
745 &twl4030_dapm_predrivel_control, twl4030_enum_event, 741 &twl4030_dapm_predrivel_control),
746 SND_SOC_DAPM_PRE_REG), 742 SND_SOC_DAPM_VALUE_MUX("PredriveR Mux", SND_SOC_NOPM, 0, 0,
747 SND_SOC_DAPM_MUX_E("PredriveR Mux", SND_SOC_NOPM, 0, 0, 743 &twl4030_dapm_predriver_control),
748 &twl4030_dapm_predriver_control, twl4030_enum_event,
749 SND_SOC_DAPM_PRE_REG),
750 /* HeadsetL/R */ 744 /* HeadsetL/R */
751 SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0, 745 SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0,
752 &twl4030_dapm_hsol_control), 746 &twl4030_dapm_hsol_control),
@@ -789,12 +783,10 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
789 SND_SOC_DAPM_POST_REG), 783 SND_SOC_DAPM_POST_REG),
790 784
791 /* Analog input muxes with power switch for the physical ADCL/R */ 785 /* Analog input muxes with power switch for the physical ADCL/R */
792 SND_SOC_DAPM_MUX_E("Analog Left Capture Route", 786 SND_SOC_DAPM_VALUE_MUX("Analog Left Capture Route",
793 TWL4030_REG_AVADC_CTL, 3, 0, &twl4030_dapm_analoglmic_control, 787 TWL4030_REG_AVADC_CTL, 3, 0, &twl4030_dapm_analoglmic_control),
794 twl4030_enum_event, SND_SOC_DAPM_PRE_REG), 788 SND_SOC_DAPM_VALUE_MUX("Analog Right Capture Route",
795 SND_SOC_DAPM_MUX_E("Analog Right Capture Route", 789 TWL4030_REG_AVADC_CTL, 1, 0, &twl4030_dapm_analogrmic_control),
796 TWL4030_REG_AVADC_CTL, 1, 0, &twl4030_dapm_analogrmic_control,
797 twl4030_enum_event, SND_SOC_DAPM_PRE_REG),
798 790
799 SND_SOC_DAPM_PGA("Analog Left Amplifier", 791 SND_SOC_DAPM_PGA("Analog Left Amplifier",
800 TWL4030_REG_ANAMICL, 4, 0, NULL, 0), 792 TWL4030_REG_ANAMICL, 4, 0, NULL, 0),