ASoC: twl4030: Use virtual DAPM mixer controls
authorLars-Peter Clausen <lars@metafoo.de>
Sun, 6 Oct 2013 11:43:50 +0000 (13:43 +0200)
committerMark Brown <broonie@linaro.org>
Mon, 7 Oct 2013 10:49:32 +0000 (11:49 +0100)
By using the new virtual DAPM mixer controls it is possible to remove the
twl4030 specific implementation of virtual controls.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
sound/soc/codecs/twl4030.c

index 1e3884d6b3fbc7202cedb6fe478e5d00e71da49b..dfc51bb425da93b5dc6e2ac55af8ea3125b9e1b9 100644 (file)
 /* TWL4030 PMBR1 Register GPIO6 mux bits */
 #define TWL4030_GPIO6_PWM0_MUTE(value) ((value & 0x03) << 2)
 
-/* Shadow register used by the audio driver */
-#define TWL4030_REG_SW_SHADOW          0x4A
-#define TWL4030_CACHEREGNUM    (TWL4030_REG_SW_SHADOW + 1)
-
-/* TWL4030_REG_SW_SHADOW (0x4A) Fields */
-#define TWL4030_HFL_EN                 0x01
-#define TWL4030_HFR_EN                 0x02
+#define TWL4030_CACHEREGNUM    (TWL4030_REG_MISC_SET_2 + 1)
 
 /*
  * twl4030 register cache & default register settings
@@ -132,7 +126,6 @@ static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = {
        0x00, /* REG_VIBRA_PWM_SET      (0x47)  */
        0x00, /* REG_ANAMIC_GAIN        (0x48)  */
        0x00, /* REG_MISC_SET_2         (0x49)  */
-       0x00, /* REG_SW_SHADOW          (0x4A)  - Shadow, non HW register */
 };
 
 /* codec private data */
@@ -198,42 +191,41 @@ static int twl4030_write(struct snd_soc_codec *codec,
        int write_to_reg = 0;
 
        twl4030_write_reg_cache(codec, reg, value);
-       if (likely(reg < TWL4030_REG_SW_SHADOW)) {
-               /* Decide if the given register can be written */
-               switch (reg) {
-               case TWL4030_REG_EAR_CTL:
-                       if (twl4030->earpiece_enabled)
-                               write_to_reg = 1;
-                       break;
-               case TWL4030_REG_PREDL_CTL:
-                       if (twl4030->predrivel_enabled)
-                               write_to_reg = 1;
-                       break;
-               case TWL4030_REG_PREDR_CTL:
-                       if (twl4030->predriver_enabled)
-                               write_to_reg = 1;
-                       break;
-               case TWL4030_REG_PRECKL_CTL:
-                       if (twl4030->carkitl_enabled)
-                               write_to_reg = 1;
-                       break;
-               case TWL4030_REG_PRECKR_CTL:
-                       if (twl4030->carkitr_enabled)
-                               write_to_reg = 1;
-                       break;
-               case TWL4030_REG_HS_GAIN_SET:
-                       if (twl4030->hsl_enabled || twl4030->hsr_enabled)
-                               write_to_reg = 1;
-                       break;
-               default:
-                       /* All other register can be written */
+       /* Decide if the given register can be written */
+       switch (reg) {
+       case TWL4030_REG_EAR_CTL:
+               if (twl4030->earpiece_enabled)
                        write_to_reg = 1;
-                       break;
-               }
-               if (write_to_reg)
-                       return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
-                                                   value, reg);
+               break;
+       case TWL4030_REG_PREDL_CTL:
+               if (twl4030->predrivel_enabled)
+                       write_to_reg = 1;
+               break;
+       case TWL4030_REG_PREDR_CTL:
+               if (twl4030->predriver_enabled)
+                       write_to_reg = 1;
+               break;
+       case TWL4030_REG_PRECKL_CTL:
+               if (twl4030->carkitl_enabled)
+                       write_to_reg = 1;
+               break;
+       case TWL4030_REG_PRECKR_CTL:
+               if (twl4030->carkitr_enabled)
+                       write_to_reg = 1;
+               break;
+       case TWL4030_REG_HS_GAIN_SET:
+               if (twl4030->hsl_enabled || twl4030->hsr_enabled)
+                       write_to_reg = 1;
+               break;
+       default:
+               /* All other register can be written */
+               write_to_reg = 1;
+               break;
        }
+       if (write_to_reg)
+               return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
+                                           value, reg);
+
        return 0;
 }
 
@@ -532,7 +524,7 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreel_enum);
 
 /* Handsfree Left virtual mute */
 static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control =
-       SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 0, 1, 0);
+       SOC_DAPM_SINGLE_VIRT("Switch", 1);
 
 /* Handsfree Right */
 static const char *twl4030_handsfreer_texts[] =
@@ -548,7 +540,7 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum);
 
 /* Handsfree Right virtual mute */
 static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control =
-       SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 1, 1, 0);
+       SOC_DAPM_SINGLE_VIRT("Switch", 1);
 
 /* Vibra */
 /* Vibra audio path selection */