ASoC: TWL4030: Make the enum filter generic for twl4030
authorPeter Ujfalusi <peter.ujfalusi@nokia.com>
Wed, 31 Dec 2008 08:08:37 +0000 (10:08 +0200)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 31 Dec 2008 13:11:59 +0000 (13:11 +0000)
Modify the enum filter to more generic that it will filter
out the enums with text "Invalid".
The enum filter also required for the capture path.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/twl4030.c

index 51848880504a38e6051072873422b94396fbd364..2c279cd8deb520677026a2b9b69cffd087ef4212 100644 (file)
@@ -298,25 +298,23 @@ static const struct soc_enum twl4030_handsfreer_enum =
 static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control =
 SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum);
 
-static int outmixer_event(struct snd_soc_dapm_widget *w,
+/*
+ * This function filters out the non valid mux settings, named as "Invalid"
+ * in the enum texts.
+ * Just refuse to set an invalid mux mode.
+ */
+static int twl4030_enum_event(struct snd_soc_dapm_widget *w,
        struct snd_kcontrol *kcontrol, int event)
 {
        struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
        int ret = 0;
        int val;
 
-       switch (e->reg) {
-       case TWL4030_REG_PREDL_CTL:
-       case TWL4030_REG_PREDR_CTL:
-       case TWL4030_REG_EAR_CTL:
-               val = w->value >> e->shift_l;
-               if (val == 3) {
-                       printk(KERN_WARNING
-                       "Invalid MUX setting for register 0x%02x (%d)\n",
-                             e->reg, val);
-                       ret = -1;
-               }
-               break;
+       val = w->value >> e->shift_l;
+       if (!strcmp("Invalid", e->texts[val])) {
+               printk(KERN_WARNING "Invalid MUX setting on 0x%02x (%d)\n",
+                       e->reg, val);
+               ret = -1;
        }
 
        return ret;
@@ -810,14 +808,14 @@ static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
        /* Output MUX controls */
        /* Earpiece */
        SND_SOC_DAPM_MUX_E("Earpiece Mux", SND_SOC_NOPM, 0, 0,
-               &twl4030_dapm_earpiece_control, outmixer_event,
+               &twl4030_dapm_earpiece_control, twl4030_enum_event,
                SND_SOC_DAPM_PRE_REG),
        /* PreDrivL/R */
        SND_SOC_DAPM_MUX_E("PredriveL Mux", SND_SOC_NOPM, 0, 0,
-               &twl4030_dapm_predrivel_control, outmixer_event,
+               &twl4030_dapm_predrivel_control, twl4030_enum_event,
                SND_SOC_DAPM_PRE_REG),
        SND_SOC_DAPM_MUX_E("PredriveR Mux", SND_SOC_NOPM, 0, 0,
-               &twl4030_dapm_predriver_control, outmixer_event,
+               &twl4030_dapm_predriver_control, twl4030_enum_event,
                SND_SOC_DAPM_PRE_REG),
        /* HeadsetL/R */
        SND_SOC_DAPM_MUX("HeadsetL Mux", SND_SOC_NOPM, 0, 0,