asoc: codec: aic325x: Unmute headphone of aic3033
Fred Zhou [Mon, 20 May 2013 09:42:05 +0000 (17:42 +0800)]
The headphone of aic3033 is connected to earpiece on atlantis.
And it is always muted. So when power up headphone it power up
timeout. This change unmute the headphone when power it up and
mute it when power it down.

Bug 1290309

Change-Id: I329db7fc20b21268c1b618734ea4f81173a54caa
Signed-off-by: Fred Zhou <fzhou@nvidia.com>
Reviewed-on: http://git-master/r/231024
Reviewed-by: Yunfan Zhang <yunfanz@nvidia.com>
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Sumit Bhattacharya <sumitb@nvidia.com>

include/linux/mfd/tlv320aic3256-registers.h
sound/soc/codecs/tlv320aic325x.c

index 2262f07..22622c5 100644 (file)
 /*HPR Driver Gain*/
 #define        AIC3256_HPR_GAIN                        MAKE_REG(1, 17)
 
+/*HPL Driver Mute Control*/
+#define AIC3256_HPL_MUTE_CTRL                  MAKE_REG(1, 16)
+/*HPR Driver Mute Control*/
+#define AIC3256_HPR_MUTE_CTRL                  MAKE_REG(1, 17)
+/*HP Driver Mute Mask*/
+#define AIC3256_HP_MUTE_MASK                   (1 << 6)
+/*HP Driver Mute Enable*/
+#define AIC3256_HP_MUTE_ENABLE                 (1 << 6)
+/*HP Driver Mute Disable*/
+#define AIC3256_HP_MUTE_DISABLE                        (0 << 6)
+
 #ifndef AIC3253_CODEC_SUPPORT
 /*LOL Driver Gain*/
 #define        AIC3256_LOL_GAIN                        MAKE_REG(1, 18)
index e0ee34a..edb1908 100644 (file)
@@ -463,7 +463,8 @@ static const struct snd_soc_dapm_widget aic325x_dapm_widgets[] = {
 
        /* dapm widget for Left Head phone Power */
        SND_SOC_DAPM_PGA_E("HPL PGA", AIC3256_OUT_PWR_CTRL, 5, 0, NULL, 0,
-                               aic325x_hp_event, SND_SOC_DAPM_PRE_PMU),
+                               aic325x_hp_event, SND_SOC_DAPM_PRE_PMU |
+                               SND_SOC_DAPM_PRE_PMD),
 
        /* dapm widget (path domain) for Left Line-out Output Mixer */
        SND_SOC_DAPM_MIXER("LOL Output Mixer", SND_SOC_NOPM, 0, 0,
@@ -477,7 +478,8 @@ static const struct snd_soc_dapm_widget aic325x_dapm_widgets[] = {
 
        /* dapm widget for Right Head phone Power */
        SND_SOC_DAPM_PGA_E("HPR PGA", AIC3256_OUT_PWR_CTRL, 4, 0, NULL, 0,
-                               aic325x_hp_event, SND_SOC_DAPM_POST_PMU),
+                               aic325x_hp_event, SND_SOC_DAPM_POST_PMU |
+                               SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD),
 
        /* dapm widget for (path domain) Right Line-out Output Mixer */
        SND_SOC_DAPM_MIXER("LOR Output Mixer", SND_SOC_NOPM, 0, 0,
@@ -919,6 +921,39 @@ static int aic325x_hp_event(struct snd_soc_dapm_widget *w,
                snd_soc_update_bits(codec, AIC3256_CM_CTRL_REG,
                                        GCHP_HPL_STATUS, 0x0);
        }
+
+       /* UnMute HP when HP powerup */
+       if (event & SND_SOC_DAPM_PRE_PMU) {
+               /* HPL */
+               if (w->shift == 5) {
+                       snd_soc_update_bits(codec, AIC3256_HPL_MUTE_CTRL,
+                                               AIC3256_HP_MUTE_MASK,
+                                               AIC3256_HP_MUTE_DISABLE);
+               }
+               /* HPR */
+               if (w->shift == 4) {
+                       snd_soc_update_bits(codec, AIC3256_HPR_MUTE_CTRL,
+                                               AIC3256_HP_MUTE_MASK,
+                                               AIC3256_HP_MUTE_DISABLE);
+               }
+       }
+
+       /* Mute HP when power down */
+       if (event & SND_SOC_DAPM_PRE_PMD) {
+               /* HPL */
+               if (w->shift == 5) {
+                       snd_soc_update_bits(codec, AIC3256_HPL_MUTE_CTRL,
+                                               AIC3256_HP_MUTE_MASK,
+                                               AIC3256_HP_MUTE_ENABLE);
+               }
+               /* HPR */
+               if (w->shift == 4) {
+                       snd_soc_update_bits(codec, AIC3256_HPR_MUTE_CTRL,
+                                               AIC3256_HP_MUTE_MASK,
+                                               AIC3256_HP_MUTE_ENABLE);
+               }
+       }
+
        /* Wait for HP power on */
        if (event & SND_SOC_DAPM_POST_PMU) {