CHROMIUM: ALSA: hda/ca0132: Turn on headphone amp only when a headphone is plugged.
authorChih-Chung Chang <chihchung@chromium.org>
Thu, 11 Oct 2012 02:24:30 +0000 (10:24 +0800)
committerGerrit <chrome-bot@google.com>
Thu, 11 Oct 2012 05:21:26 +0000 (22:21 -0700)
The patch is provided by Creative.

BUG=none
TEST=plug/unplug a headphone and verify the AMP pin is high only when a
headphone is plugged.

Change-Id: I0d8a3113d9fcfe7ffddd69cfc7c0b0b9ce728ae3
Signed-off-by: Chih-Chung Chang <chihchung@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/35234
Reviewed-by: Dylan Reid <dgreid@chromium.org>
sound/pci/hda/patch_ca0132.c

index 959e53a..7e317ef 100644 (file)
@@ -3130,26 +3130,28 @@ static int ca0132_select_out(struct hda_codec *codec)
                if (err < 0)
                        goto exit;
 
+               /* Setup EAPD */
+               snd_hda_codec_write(codec, spec->out_pins[1], 0,
+                                   VENDOR_CHIPIO_EAPD_SEL_SET, 0x02);
+               snd_hda_codec_write(codec, spec->out_pins[0], 0,
+                                   AC_VERB_SET_EAPD_BTLENABLE, 0x00);
+               snd_hda_codec_write(codec, spec->out_pins[0], 0,
+                                   VENDOR_CHIPIO_EAPD_SEL_SET, 0x00);
+               snd_hda_codec_write(codec, spec->out_pins[0], 0,
+                                   AC_VERB_SET_EAPD_BTLENABLE, 0x02);
+
                /* disable headphone node */
                pin_ctl = snd_hda_codec_read(codec, spec->out_pins[1], 0,
                                        AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
                snd_hda_codec_write(codec, spec->out_pins[1], 0,
                                    AC_VERB_SET_PIN_WIDGET_CONTROL,
                                    pin_ctl & 0xBF);
-               /* disable headphone EAPD */
-               snd_hda_codec_write(codec, spec->out_pins[0], 0,
-                                   AC_VERB_SET_EAPD_BTLENABLE, 0x00);
                /* enable speaker node */
                pin_ctl = snd_hda_codec_read(codec, spec->out_pins[0], 0,
                                             AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
                snd_hda_codec_write(codec, spec->out_pins[0], 0,
                                    AC_VERB_SET_PIN_WIDGET_CONTROL,
                                    pin_ctl | 0x40);
-               /* enable speaker EAPD */
-               snd_hda_codec_write(codec, spec->out_pins[0], 0,
-                                   VENDOR_CHIPIO_EAPD_SEL_SET, 0x00);
-               snd_hda_codec_write(codec, spec->out_pins[0], 0,
-                                   AC_VERB_SET_EAPD_BTLENABLE, 0x02);
        } else {
                CA0132_LOG("ca0132_select_out hp\n");
                /*headphone out config*/
@@ -3165,26 +3167,28 @@ static int ca0132_select_out(struct hda_codec *codec)
                if (err < 0)
                        goto exit;
 
+               /* Setup EAPD */
+               snd_hda_codec_write(codec, spec->out_pins[0], 0,
+                                   VENDOR_CHIPIO_EAPD_SEL_SET, 0x00);
+               snd_hda_codec_write(codec, spec->out_pins[0], 0,
+                                   AC_VERB_SET_EAPD_BTLENABLE, 0x00);
+               snd_hda_codec_write(codec, spec->out_pins[1], 0,
+                                   VENDOR_CHIPIO_EAPD_SEL_SET, 0x02);
+               snd_hda_codec_write(codec, spec->out_pins[0], 0,
+                                   AC_VERB_SET_EAPD_BTLENABLE, 0x02);
+
                /* disable speaker*/
                pin_ctl = snd_hda_codec_read(codec, spec->out_pins[0], 0,
                                        AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
                snd_hda_codec_write(codec, spec->out_pins[0], 0,
                                    AC_VERB_SET_PIN_WIDGET_CONTROL,
                                    pin_ctl & 0xBF);
-               /* disable speaker EAPD */
-               snd_hda_codec_write(codec, spec->out_pins[0], 0,
-                                   AC_VERB_SET_EAPD_BTLENABLE, 0x00);
                /* enable headphone*/
                pin_ctl = snd_hda_codec_read(codec, spec->out_pins[1], 0,
                                        AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
                snd_hda_codec_write(codec, spec->out_pins[1], 0,
                                    AC_VERB_SET_PIN_WIDGET_CONTROL,
                                    pin_ctl | 0x40);
-               /* enable headphone EAPD */
-               snd_hda_codec_write(codec, spec->out_pins[1], 0,
-                                   VENDOR_CHIPIO_EAPD_SEL_SET, 0x02);
-               snd_hda_codec_write(codec, spec->out_pins[0], 0,
-                                   AC_VERB_SET_EAPD_BTLENABLE, 0x02);
        }
 
 exit: