]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[ALSA] hda-codec - Add auto-mute function to Sony VAIO with STAC9872
authorTakashi Iwai <tiwai@suse.de>
Thu, 16 Aug 2007 15:33:55 +0000 (17:33 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 16 Oct 2007 13:59:09 +0000 (15:59 +0200)
Added auto-mute function with HP jack to Sony VAIO laptop with STAC9872
codec.  The patch taken from ALSA bug#3275.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
sound/pci/hda/patch_sigmatel.c

index e096a48899c826945623a8f084e86e76e0ba041c..76ec32a375c098d1dd0242105741bd460ac3d11f 100644 (file)
@@ -2411,6 +2411,7 @@ static struct hda_input_mux vaio_mux = {
 
 static struct hda_verb vaio_init[] = {
        {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
+       {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
        {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
        {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
        {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
@@ -2507,6 +2508,49 @@ static struct hda_codec_ops stac9872_patch_ops = {
 #endif
 };
 
+static int stac9872_vaio_init(struct hda_codec *codec)
+{
+       int err;
+
+       err = stac92xx_init(codec);
+       if (err < 0)
+               return err;
+       if (codec->patch_ops.unsol_event)
+               codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
+       return 0;
+}
+
+static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
+{
+       if (get_pin_presence(codec, 0x0a)) {
+               stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
+               stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
+       } else {
+               stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
+               stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
+       }
+} 
+
+static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
+{
+       switch (res >> 26) {
+       case STAC_HP_EVENT:
+               stac9872_vaio_hp_detect(codec, res);
+               break;
+       }
+}
+
+static struct hda_codec_ops stac9872_vaio_patch_ops = {
+       .build_controls = stac92xx_build_controls,
+       .build_pcms = stac92xx_build_pcms,
+       .init = stac9872_vaio_init,
+       .free = stac92xx_free,
+       .unsol_event = stac9872_vaio_unsol_event,
+#ifdef CONFIG_PM
+       .resume = stac92xx_resume,
+#endif
+};
+
 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
        CXD9872RD_VAIO,
        /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
@@ -2562,6 +2606,7 @@ static int patch_stac9872(struct hda_codec *codec)
                spec->adc_nids = vaio_adcs;
                spec->input_mux = &vaio_mux;
                spec->mux_nids = vaio_mux_nids;
+               codec->patch_ops = stac9872_vaio_patch_ops;
                break;
        
        case CXD9872AKD_VAIO:
@@ -2575,10 +2620,10 @@ static int patch_stac9872(struct hda_codec *codec)
                spec->adc_nids = vaio_adcs;
                spec->input_mux = &vaio_mux;
                spec->mux_nids = vaio_mux_nids;
+               codec->patch_ops = stac9872_patch_ops;
                break;
        }
 
-       codec->patch_ops = stac9872_patch_ops;
        return 0;
 }