[ALSA] Fix a typo in the last patch_realtek.c change
[firefly-linux-kernel-4.4.55.git] / sound / pci / hda / patch_realtek.c
index fb961448db199701271a4688840b8a1e300f983f..d3d6e61abc0834268af207c5edef9b71477a47cd 100644 (file)
 #include "hda_codec.h"
 #include "hda_local.h"
 
+#define ALC880_FRONT_EVENT             0x01
+#define ALC880_DCVOL_EVENT             0x02
+#define ALC880_HP_EVENT                        0x04
+#define ALC880_MIC_EVENT               0x08
 
 /* ALC880 board config type */
 enum {
@@ -49,6 +53,8 @@ enum {
        ALC880_ASUS_W1V,
        ALC880_ASUS_DIG2,
        ALC880_UNIWILL_DIG,
+       ALC880_UNIWILL,
+       ALC880_UNIWILL_P53,
        ALC880_CLEVO,
        ALC880_TCL_S700,
        ALC880_LG,
@@ -77,6 +83,8 @@ enum {
 /* ALC262 models */
 enum {
        ALC262_BASIC,
+       ALC262_HIPPO,
+       ALC262_HIPPO_1,
        ALC262_FUJITSU,
        ALC262_HP_BPC,
        ALC262_BENQ_ED8,
@@ -91,6 +99,9 @@ enum {
        ALC861_3ST_DIG,
        ALC861_6ST_DIG,
        ALC861_UNIWILL_M31,
+       ALC861_TOSHIBA,
+       ALC861_ASUS,
+       ALC861_ASUS_LAPTOP,
        ALC861_AUTO,
        ALC861_MODEL_LAST,
 };
@@ -101,6 +112,7 @@ enum {
        ALC882_6ST_DIG,
        ALC882_ARIMA,
        ALC882_AUTO,
+       ALC885_MACPRO,
        ALC882_MODEL_LAST,
 };
 
@@ -110,8 +122,12 @@ enum {
        ALC883_3ST_6ch_DIG,
        ALC883_3ST_6ch,
        ALC883_6ST_DIG,
+       ALC883_TARGA_DIG,
+       ALC883_TARGA_2ch_DIG,
        ALC888_DEMO_BOARD,
        ALC883_ACER,
+       ALC883_MEDION,
+       ALC883_LAPTOP_EAPD,
        ALC883_AUTO,
        ALC883_MODEL_LAST,
 };
@@ -271,7 +287,7 @@ static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
        int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
                                      spec->num_channel_mode,
                                      &spec->multiout.max_channels);
-       if (! err && spec->need_dac_fix)
+       if (err >= 0 && spec->need_dac_fix)
                spec->multiout.num_dacs = spec->multiout.max_channels / 2;
        return err;
 }
@@ -1015,6 +1031,46 @@ static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
        { } /* end */
 };
 
+/* Uniwill */
+static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
+       HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
+       HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
+       HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Channel Mode",
+               .info = alc_ch_mode_info,
+               .get = alc_ch_mode_get,
+               .put = alc_ch_mode_put,
+       },
+       { } /* end */
+};
+
+static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
+       HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       { } /* end */
+};
+
 /*
  * build control elements
  */
@@ -1248,6 +1304,154 @@ static struct hda_verb alc880_pin_6stack_init_verbs[] = {
        { }
 };
 
+/*
+ * Uniwill pin configuration:
+ * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
+ * line = 0x1a
+ */
+static struct hda_verb alc880_uniwill_init_verbs[] = {
+       {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
+
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
+       /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
+       {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+
+       {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
+
+       { }
+};
+
+/*
+* Uniwill P53
+* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, 
+ */
+static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
+       {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
+
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
+
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+
+       {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
+
+       { }
+};
+
+/* toggle speaker-output according to the hp-jack state */
+static void alc880_uniwill_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+
+       present = snd_hda_codec_read(codec, 0x14, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+
+       present = snd_hda_codec_read(codec, 0x18, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
+                           0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
+}
+
+static void alc880_uniwill_unsol_event(struct hda_codec *codec,
+                                      unsigned int res)
+{
+       /* Looks like the unsol event is incompatible with the standard
+        * definition.  4bit tag is placed at 28 bit!
+        */
+       if ((res >> 28) == ALC880_HP_EVENT ||
+           (res >> 28) == ALC880_MIC_EVENT)
+               alc880_uniwill_automute(codec);
+}
+
+static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+
+       present = snd_hda_codec_read(codec, 0x14, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+
+       snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
+                                0x80, present ? 0x80 : 0);
+}
+
+static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+       
+       present = snd_hda_codec_read(codec, 0x21, 0,
+                                    AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
+
+       snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
+                                0x7f, present);
+       snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
+                                0x7f,  present);
+
+       snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
+                                0x7f,  present);
+       snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
+                                0x7f, present);
+
+}
+static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
+                                          unsigned int res)
+{
+       /* Looks like the unsol event is incompatible with the standard
+        * definition.  4bit tag is placed at 28 bit!
+        */
+       if ((res >> 28) == ALC880_HP_EVENT)
+               alc880_uniwill_p53_hp_automute(codec);
+       if ((res >> 28) == ALC880_DCVOL_EVENT) 
+               alc880_uniwill_p53_dcvol_automute(codec);
+}
+
 /* FIXME! */
 /*
  * F1734 pin configuration:
@@ -2125,159 +2329,109 @@ static struct hda_verb alc880_test_init_verbs[] = {
 /*
  */
 
-static struct hda_board_config alc880_cfg_tbl[] = {
-       /* Back 3 jack, front 2 jack */
-       { .modelname = "3stack", .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
-       /* TCL S700 */
-       { .modelname = "tcl", .config = ALC880_TCL_S700 },
-       { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
-
-       /* Back 3 jack, front 2 jack (Internal add Aux-In) */
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, 
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
-
-       /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
-       { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
-
-       /* Clevo laptops */
-       { .modelname = "clevo", .config = ALC880_CLEVO },
-       { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
-         .config = ALC880_CLEVO }, /* Clevo m520G NB */
-       { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
-         .config = ALC880_CLEVO }, /* Clevo m665n */
-
-       /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
-
-       /* Back 5 jack, front 2 jack */
-       { .modelname = "5stack", .config = ALC880_5ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
-       { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
-
-       /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
-       { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
-       { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
-         .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
-       /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
-       { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
-       /* note subvendor = 0 below */
-       /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
-
-       { .modelname = "w810", .config = ALC880_W810 },
-       { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
-
-       { .modelname = "z71v", .config = ALC880_Z71V },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
-
-       { .modelname = "6stack", .config = ALC880_6ST },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
-       { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
-       { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
-
-       { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
-       { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
-       { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
-       { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
-
-       { .modelname = "asus", .config = ALC880_ASUS },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
-       { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
-       { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
-       { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
-       { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
-
-       { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
-       { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },     
-
-       { .modelname = "F1734", .config = ALC880_F1734 },
-       { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
-       { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
-
-       { .modelname = "lg", .config = ALC880_LG },
-       { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
-       { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
-
-       { .modelname = "lg-lw", .config = ALC880_LG_LW },
-       { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
-       { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW },
-
+static const char *alc880_models[ALC880_MODEL_LAST] = {
+       [ALC880_3ST]            = "3stack",
+       [ALC880_TCL_S700]       = "tcl",
+       [ALC880_3ST_DIG]        = "3stack-digout",
+       [ALC880_CLEVO]          = "clevo",
+       [ALC880_5ST]            = "5stack",
+       [ALC880_5ST_DIG]        = "5stack-digout",
+       [ALC880_W810]           = "w810",
+       [ALC880_Z71V]           = "z71v",
+       [ALC880_6ST]            = "6stack",
+       [ALC880_6ST_DIG]        = "6stack-digout",
+       [ALC880_ASUS]           = "asus",
+       [ALC880_ASUS_W1V]       = "asus-w1v",
+       [ALC880_ASUS_DIG]       = "asus-dig",
+       [ALC880_ASUS_DIG2]      = "asus-dig2",
+       [ALC880_UNIWILL_DIG]    = "uniwill",
+       [ALC880_F1734]          = "F1734",
+       [ALC880_LG]             = "lg",
+       [ALC880_LG_LW]          = "lg-lw",
 #ifdef CONFIG_SND_DEBUG
-       { .modelname = "test", .config = ALC880_TEST },
+       [ALC880_TEST]           = "test",
 #endif
-       { .modelname = "auto", .config = ALC880_AUTO },
+       [ALC880_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc880_cfg_tbl[] = {
+       /* Broken BIOS configuration */
+       SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
+
+       SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
+       SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
+       SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
+       SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
+       SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
+
+       SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
+
+       SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
+       SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
+       /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
+       SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
+       SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
+       SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
+       SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
+       SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
+
+       SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
+       SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
+       SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
+       SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
+       SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
+       SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
+       SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
+       SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
+       SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
+       SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
+       SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
+
+       SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
+       SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
+       SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
+       SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
+
+       SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
+       SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
+
+       SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
+       SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
+       SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
+       SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
+
+       SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
+       SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
 
        {}
 };
@@ -2438,7 +2592,8 @@ static struct alc_config_preset alc880_presets[] = {
        },
        [ALC880_UNIWILL_DIG] = {
                .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
-               .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
+               .init_verbs = { alc880_volume_init_verbs,
+                               alc880_pin_asus_init_verbs },
                .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
                .dac_nids = alc880_asus_dac_nids,
                .dig_out_nid = ALC880_DIGOUT_NID,
@@ -2447,6 +2602,32 @@ static struct alc_config_preset alc880_presets[] = {
                .need_dac_fix = 1,
                .input_mux = &alc880_capture_source,
        },
+       [ALC880_UNIWILL] = {
+               .mixers = { alc880_uniwill_mixer },
+               .init_verbs = { alc880_volume_init_verbs,
+                               alc880_uniwill_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
+               .dac_nids = alc880_asus_dac_nids,
+               .dig_out_nid = ALC880_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
+               .channel_mode = alc880_threestack_modes,
+               .need_dac_fix = 1,
+               .input_mux = &alc880_capture_source,
+               .unsol_event = alc880_uniwill_unsol_event,
+               .init_hook = alc880_uniwill_automute,
+       },
+       [ALC880_UNIWILL_P53] = {
+               .mixers = { alc880_uniwill_p53_mixer },
+               .init_verbs = { alc880_volume_init_verbs,
+                               alc880_uniwill_p53_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
+               .dac_nids = alc880_asus_dac_nids,
+               .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
+               .channel_mode = alc880_w810_modes,
+               .input_mux = &alc880_capture_source,
+               .unsol_event = alc880_uniwill_p53_unsol_event,
+               .init_hook = alc880_uniwill_p53_hp_automute,
+       },
        [ALC880_CLEVO] = {
                .mixers = { alc880_three_stack_mixer },
                .init_verbs = { alc880_volume_init_verbs,
@@ -2841,8 +3022,10 @@ static int patch_alc880(struct hda_codec *codec)
 
        codec->spec = spec;
 
-       board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
-       if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
+       board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
+                                                 alc880_models,
+                                                 alc880_cfg_tbl);
+       if (board_config < 0) {
                printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
                       "trying auto-probe from BIOS...\n");
                board_config = ALC880_AUTO;
@@ -3090,11 +3273,20 @@ static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  * and the output jack.  If this turns out to be the case for all such
  * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  * to ALC_PIN_DIR_INOUT_NOMICBIAS.
+ *
+ * The C20x Tablet series have a mono internal speaker which is controlled
+ * via the chip's Mono sum widget and pin complex, so include the necessary
+ * controls for such models.  On models without a "mono speaker" the control
+ * won't do anything.
  */
 static struct snd_kcontrol_new alc260_acer_mixer[] = {
        HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
        HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
        ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
+       HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
+                             HDA_OUTPUT),
+       HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
+                          HDA_INPUT),
        HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
        HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
@@ -3409,11 +3601,11 @@ static struct hda_verb alc260_acer_init_verbs[] = {
        {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
        /* Line In jack is connected to Line1 pin */
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
+       {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
        /* Ensure all other unused pins are disabled and muted. */
        {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
        {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
-       {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
-       {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
        {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
        {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
@@ -3441,6 +3633,8 @@ static struct hda_verb alc260_acer_init_verbs[] = {
 
        /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
        {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
+       {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
        /* Unmute Mic1 and Line1 pin widget input buffers since they start as
         * inputs. If the pin mode is changed by the user the pin mode control
         * will take care of enabling the pin's input/output buffers as needed.
@@ -3928,33 +4122,33 @@ static void alc260_auto_init(struct hda_codec *codec)
 /*
  * ALC260 configurations
  */
-static struct hda_board_config alc260_cfg_tbl[] = {
-       { .modelname = "basic", .config = ALC260_BASIC },
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
-         .config = ALC260_BASIC }, /* Sony VAIO */
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
-         .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
-       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
-         .config = ALC260_BASIC }, /* Sony VAIO */
-       { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
-         .config = ALC260_BASIC }, /* CTL Travel Master U553W */
-       { .modelname = "hp", .config = ALC260_HP },
-       { .modelname = "hp-3013", .config = ALC260_HP_3013 },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
-       { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
-       { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
-       { .modelname = "acer", .config = ALC260_ACER },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
+static const char *alc260_models[ALC260_MODEL_LAST] = {
+       [ALC260_BASIC]          = "basic",
+       [ALC260_HP]             = "hp",
+       [ALC260_HP_3013]        = "hp-3013",
+       [ALC260_FUJITSU_S702X]  = "fujitsu",
+       [ALC260_ACER]           = "acer",
 #ifdef CONFIG_SND_DEBUG
-       { .modelname = "test", .config = ALC260_TEST },
+       [ALC260_TEST]           = "test",
 #endif
-       { .modelname = "auto", .config = ALC260_AUTO },
+       [ALC260_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc260_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
+       SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
+       SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
+       SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
+       SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
+       SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
+       SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
+       SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
+       SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
+       SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
+       SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
+       SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
+       SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
+       SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
        {}
 };
 
@@ -4053,8 +4247,10 @@ static int patch_alc260(struct hda_codec *codec)
 
        codec->spec = spec;
 
-       board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
-       if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
+       board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
+                                                 alc260_models,
+                                                 alc260_cfg_tbl);
+       if (board_config < 0) {
                snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
                           "trying auto-probe from BIOS...\n");
                board_config = ALC260_AUTO;
@@ -4313,6 +4509,100 @@ static struct hda_verb alc882_eapd_verbs[] = {
        { } 
 };
 
+/* Mac Pro test */
+static struct snd_kcontrol_new alc882_macpro_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
+       HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       { } /* end */
+};
+
+static struct hda_verb alc882_macpro_init_verbs[] = {
+       /* Front mixer: unmute input/output amp left and right (volume = 0) */
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+       /* Front Pin: output 0 (0x0c) */
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* Front Mic pin: input vref at 80% */
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       /* Speaker:  output */
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
+       /* Headphone output (output 0 - 0x0c) */
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
+
+       /* FIXME: use matrix-type input source selection */
+       /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
+       /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
+       /* Input mixer2 */
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
+       {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
+       /* Input mixer3 */
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
+       /* ADC1: mute amp left and right */
+       {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* ADC2: mute amp left and right */
+       {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* ADC3: mute amp left and right */
+       {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
+
+       { }
+};
+static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
+{
+       unsigned int gpiostate, gpiomask, gpiodir;
+
+       gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
+                                      AC_VERB_GET_GPIO_DATA, 0);
+
+       if (!muted)
+               gpiostate |= (1 << pin);
+       else
+               gpiostate &= ~(1 << pin);
+
+       gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
+                                     AC_VERB_GET_GPIO_MASK, 0);
+       gpiomask |= (1 << pin);
+
+       gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
+                                    AC_VERB_GET_GPIO_DIRECTION, 0);
+       gpiodir |= (1 << pin);
+
+
+       snd_hda_codec_write(codec, codec->afg, 0,
+                           AC_VERB_SET_GPIO_MASK, gpiomask);
+       snd_hda_codec_write(codec, codec->afg, 0,
+                           AC_VERB_SET_GPIO_DIRECTION, gpiodir);
+
+       msleep(1);
+
+       snd_hda_codec_write(codec, codec->afg, 0,
+                           AC_VERB_SET_GPIO_DATA, gpiostate);
+}
+
 /*
  * generic initialization of ADC, input mixers and output mixers
  */
@@ -4435,19 +4725,20 @@ static struct snd_kcontrol_new alc882_capture_mixer[] = {
 /*
  * configuration and preset
  */
-static struct hda_board_config alc882_cfg_tbl[] = {
-       { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
-       { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
-       { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
-         .config = ALC882_6ST_DIG }, /* MSI  */
-       { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
-         .config = ALC882_6ST_DIG }, /* Foxconn */
-       { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
-         .config = ALC882_6ST_DIG }, /* ECS to Intel*/
-       { .modelname = "arima", .config = ALC882_ARIMA },
-       { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
-         .config = ALC882_ARIMA }, /* Arima W820Di1 */
-       { .modelname = "auto", .config = ALC882_AUTO },
+static const char *alc882_models[ALC882_MODEL_LAST] = {
+       [ALC882_3ST_DIG]        = "3stack-dig",
+       [ALC882_6ST_DIG]        = "6stack-dig",
+       [ALC882_ARIMA]          = "arima",
+       [ALC885_MACPRO]         = "macpro",
+       [ALC882_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc882_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
+       SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
+       SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
+       SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
        {}
 };
 
@@ -4484,6 +4775,17 @@ static struct alc_config_preset alc882_presets[] = {
                .channel_mode = alc882_sixstack_modes,
                .input_mux = &alc882_capture_source,
        },
+       [ALC885_MACPRO] = {
+               .mixers = { alc882_macpro_mixer },
+               .init_verbs = { alc882_macpro_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc882_dac_nids),
+               .dac_nids = alc882_dac_nids,
+               .dig_out_nid = ALC882_DIGOUT_NID,
+               .dig_in_nid = ALC882_DIGIN_NID,
+               .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
+               .channel_mode = alc882_ch_modes,
+               .input_mux = &alc882_capture_source,
+       },
 };
 
 
@@ -4584,7 +4886,9 @@ static int patch_alc882(struct hda_codec *codec)
 
        codec->spec = spec;
 
-       board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
+       board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
+                                                 alc882_models,
+                                                 alc882_cfg_tbl);
 
        if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
                printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
@@ -4609,6 +4913,11 @@ static int patch_alc882(struct hda_codec *codec)
        if (board_config != ALC882_AUTO)
                setup_preset(spec, &alc882_presets[board_config]);
 
+       if (board_config == ALC885_MACPRO) {
+               alc882_gpio_mute(codec, 0, 0);
+               alc882_gpio_mute(codec, 1, 0);
+       }
+
        spec->stream_name_analog = "ALC882 Analog";
        spec->stream_analog_playback = &alc882_pcm_analog_playback;
        spec->stream_analog_capture = &alc882_pcm_analog_capture;
@@ -4767,6 +5076,13 @@ static struct hda_channel_mode alc883_sixstack_modes[2] = {
        { 8, alc883_sixstack_ch8_init },
 };
 
+static struct hda_verb alc883_medion_eapd_verbs[] = {
+        /* eanable EAPD on medion laptop */
+       {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
+       {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
+       { }
+};
+
 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  *                 Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  */
@@ -4875,30 +5191,121 @@ static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
        { } /* end */
 };
 
-static struct snd_kcontrol_new alc883_chmode_mixer[] = {
+static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
+       HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
+       HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
+
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "Channel Mode",
-               .info = alc_ch_mode_info,
-               .get = alc_ch_mode_get,
-               .put = alc_ch_mode_put,
+               /* .name = "Capture Source", */
+               .name = "Input Source",
+               .count = 1,
+               .info = alc883_mux_enum_info,
+               .get = alc883_mux_enum_get,
+               .put = alc883_mux_enum_put,
        },
        { } /* end */
 };
 
-static struct hda_verb alc883_init_verbs[] = {
-       /* ADC1: mute amp left and right */
-       {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
-       {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
-       /* ADC2: mute amp left and right */
-       {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
-       {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
-       /* Front mixer: unmute input/output amp left and right (volume = 0) */
-       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
-       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
-       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
-       /* Rear mixer */
-       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+static struct snd_kcontrol_new alc883_tagra_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
+       HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               /* .name = "Capture Source", */
+               .name = "Input Source",
+               .count = 2,
+               .info = alc883_mux_enum_info,
+               .get = alc883_mux_enum_get,
+               .put = alc883_mux_enum_put,
+       },
+       { } /* end */
+};     
+
+static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               /* .name = "Capture Source", */
+               .name = "Input Source",
+               .count = 2,
+               .info = alc883_mux_enum_info,
+               .get = alc883_mux_enum_get,
+               .put = alc883_mux_enum_put,
+       },
+       { } /* end */
+};     
+
+static struct snd_kcontrol_new alc883_chmode_mixer[] = {
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Channel Mode",
+               .info = alc_ch_mode_info,
+               .get = alc_ch_mode_get,
+               .put = alc_ch_mode_put,
+       },
+       { } /* end */
+};
+
+static struct hda_verb alc883_init_verbs[] = {
+       /* ADC1: mute amp left and right */
+       {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* ADC2: mute amp left and right */
+       {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* Front mixer: unmute input/output amp left and right (volume = 0) */
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+       /* Rear mixer */
+       {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
        {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
        /* CLFE mixer */
@@ -4963,6 +5370,45 @@ static struct hda_verb alc883_init_verbs[] = {
        { }
 };
 
+static struct hda_verb alc883_tagra_verbs[] = {
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       
+       {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
+       {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
+       {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
+
+       {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
+       {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, 
+       {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, 
+       {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, 
+
+       { } /* end */
+};
+
+/* toggle speaker-output according to the hp-jack state */
+static void alc883_tagra_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+
+       present = snd_hda_codec_read(codec, 0x14, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
+}
+
+static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
+{
+       if ((res >> 26) == ALC880_HP_EVENT)
+               alc883_tagra_automute(codec);
+}
+
 /*
  * generic initialization of ADC, input mixers and output mixers
  */
@@ -5057,30 +5503,42 @@ static struct snd_kcontrol_new alc883_capture_mixer[] = {
 /*
  * configuration and preset
  */
-static struct hda_board_config alc883_cfg_tbl[] = {
-       { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
-       { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
-       { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
-         .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
-       { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
-       { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
-         .config = ALC883_3ST_6ch },
-        { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
-          .config = ALC883_3ST_6ch }, /* D102GGC */
-       { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
-       { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
-         .config = ALC883_6ST_DIG }, /* MSI  */
-       { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
-         .config = ALC883_6ST_DIG }, /* Foxconn */
-       { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
-       { .modelname = "acer", .config = ALC883_ACER },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/,
-         .config = ALC883_ACER },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x0102,
-         .config = ALC883_ACER },
-       { .pci_subvendor = 0x1025, .pci_subdevice = 0x009f,
-         .config = ALC883_ACER },
-       { .modelname = "auto", .config = ALC883_AUTO },
+static const char *alc883_models[ALC883_MODEL_LAST] = {
+       [ALC883_3ST_2ch_DIG]    = "3stack-dig",
+       [ALC883_3ST_6ch_DIG]    = "3stack-6ch-dig",
+       [ALC883_3ST_6ch]        = "3stack-6ch",
+       [ALC883_6ST_DIG]        = "6stack-dig",
+       [ALC883_TARGA_DIG]      = "targa-dig",
+       [ALC883_TARGA_2ch_DIG]  = "targa-2ch-dig",
+       [ALC888_DEMO_BOARD]     = "6stack-dig-demo",
+       [ALC883_ACER]           = "acer",
+       [ALC883_MEDION]         = "medion",
+       [ALC883_LAPTOP_EAPD]    = "laptop-eapd",
+       [ALC883_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc883_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
+       SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
+       SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
+       SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
+       SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
+       SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
+       SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
+       SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
+       SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
+       SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
        {}
 };
 
@@ -5137,6 +5595,35 @@ static struct alc_config_preset alc883_presets[] = {
                .channel_mode = alc883_sixstack_modes,
                .input_mux = &alc883_capture_source,
        },
+       [ALC883_TARGA_DIG] = {
+               .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
+               .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
+               .num_dacs = ARRAY_SIZE(alc883_dac_nids),
+               .dac_nids = alc883_dac_nids,
+               .dig_out_nid = ALC883_DIGOUT_NID,
+               .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
+               .adc_nids = alc883_adc_nids,
+               .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
+               .channel_mode = alc883_3ST_6ch_modes,
+               .need_dac_fix = 1,
+               .input_mux = &alc883_capture_source,
+               .unsol_event = alc883_tagra_unsol_event,
+               .init_hook = alc883_tagra_automute,
+       },
+       [ALC883_TARGA_2ch_DIG] = {
+               .mixers = { alc883_tagra_2ch_mixer},
+               .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
+               .num_dacs = ARRAY_SIZE(alc883_dac_nids),
+               .dac_nids = alc883_dac_nids,
+               .dig_out_nid = ALC883_DIGOUT_NID,
+               .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
+               .adc_nids = alc883_adc_nids,
+               .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
+               .channel_mode = alc883_3ST_2ch_modes,
+               .input_mux = &alc883_capture_source,
+               .unsol_event = alc883_tagra_unsol_event,
+               .init_hook = alc883_tagra_automute,
+       },
        [ALC888_DEMO_BOARD] = {
                .mixers = { alc883_base_mixer, alc883_chmode_mixer },
                .init_verbs = { alc883_init_verbs },
@@ -5167,6 +5654,31 @@ static struct alc_config_preset alc883_presets[] = {
                .channel_mode = alc883_3ST_2ch_modes,
                .input_mux = &alc883_capture_source,
        },
+       [ALC883_MEDION] = {
+               .mixers = { alc883_fivestack_mixer,
+                           alc883_chmode_mixer },
+               .init_verbs = { alc883_init_verbs,
+                               alc883_medion_eapd_verbs },
+               .num_dacs = ARRAY_SIZE(alc883_dac_nids),
+               .dac_nids = alc883_dac_nids,
+               .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
+               .adc_nids = alc883_adc_nids,
+               .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
+               .channel_mode = alc883_sixstack_modes,
+               .input_mux = &alc883_capture_source,
+       },
+       [ALC883_LAPTOP_EAPD] = {
+               .mixers = { alc883_base_mixer,
+                           alc883_chmode_mixer },
+               .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
+               .num_dacs = ARRAY_SIZE(alc883_dac_nids),
+               .dac_nids = alc883_dac_nids,
+               .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
+               .adc_nids = alc883_adc_nids,
+               .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
+               .channel_mode = alc883_3ST_2ch_modes,
+               .input_mux = &alc883_capture_source,
+       },
 };
 
 
@@ -5275,8 +5787,10 @@ static int patch_alc883(struct hda_codec *codec)
 
        codec->spec = spec;
 
-       board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
-       if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
+       board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
+                                                 alc883_models,
+                                                 alc883_cfg_tbl);
+       if (board_config < 0) {
                printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
                       "trying auto-probe from BIOS...\n");
                board_config = ALC883_AUTO;
@@ -5353,6 +5867,24 @@ static struct snd_kcontrol_new alc262_base_mixer[] = {
        { } /* end */
 };
 
+static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
+       /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
+          HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
+       /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+       { } /* end */
+};
+
 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
@@ -5457,6 +5989,103 @@ static struct hda_verb alc262_init_verbs[] = {
        { }
 };
 
+static struct hda_verb alc262_hippo_unsol_verbs[] = {
+       {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {}
+};
+
+static struct hda_verb alc262_hippo1_unsol_verbs[] = {
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
+       {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
+
+       {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {}
+};
+
+/* mute/unmute internal speaker according to the hp jack and mute state */
+static void alc262_hippo_automute(struct hda_codec *codec, int force)
+{
+       struct alc_spec *spec = codec->spec;
+       unsigned int mute;
+
+       if (force || ! spec->sense_updated) {
+               unsigned int present;
+               /* need to execute and sync at first */
+               snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
+               present = snd_hda_codec_read(codec, 0x15, 0,
+                                        AC_VERB_GET_PIN_SENSE, 0);
+               spec->jack_present = (present & 0x80000000) != 0;
+               spec->sense_updated = 1;
+       }
+       if (spec->jack_present) {
+               /* mute internal speaker */
+               snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
+                                        0x80, 0x80);
+               snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
+                                        0x80, 0x80);
+       } else {
+               /* unmute internal speaker if necessary */
+               mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
+                                        0x80, mute & 0x80);
+               mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
+                                        0x80, mute & 0x80);
+       }
+}
+
+/* unsolicited event for HP jack sensing */
+static void alc262_hippo_unsol_event(struct hda_codec *codec,
+                                      unsigned int res)
+{
+       if ((res >> 26) != ALC880_HP_EVENT)
+               return;
+       alc262_hippo_automute(codec, 1);
+}
+
+static void alc262_hippo1_automute(struct hda_codec *codec, int force)
+{
+       struct alc_spec *spec = codec->spec;
+       unsigned int mute;
+
+       if (force || ! spec->sense_updated) {
+               unsigned int present;
+               /* need to execute and sync at first */
+               snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
+               present = snd_hda_codec_read(codec, 0x1b, 0,
+                                        AC_VERB_GET_PIN_SENSE, 0);
+               spec->jack_present = (present & 0x80000000) != 0;
+               spec->sense_updated = 1;
+       }
+       if (spec->jack_present) {
+               /* mute internal speaker */
+               snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
+                                        0x80, 0x80);
+               snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
+                                        0x80, 0x80);
+       } else {
+               /* unmute internal speaker if necessary */
+               mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
+                                        0x80, mute & 0x80);
+               mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
+                                        0x80, mute & 0x80);
+       }
+}
+
+/* unsolicited event for HP jack sensing */
+static void alc262_hippo1_unsol_event(struct hda_codec *codec,
+                                      unsigned int res)
+{
+       if ((res >> 26) != ALC880_HP_EVENT)
+               return;
+       alc262_hippo1_automute(codec, 1);
+}
+
 /*
  * fujitsu model
  *  0x14 = headphone/spdif-out, 0x15 = internal speaker
@@ -5864,24 +6493,27 @@ static void alc262_auto_init(struct hda_codec *codec)
 /*
  * configuration and preset
  */
-static struct hda_board_config alc262_cfg_tbl[] = {
-       { .modelname = "basic", .config = ALC262_BASIC },
-       { .modelname = "fujitsu", .config = ALC262_FUJITSU },
-       { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
-         .config = ALC262_FUJITSU },
-       { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x280c,
-         .config = ALC262_HP_BPC }, /* xw4400 */
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
-         .config = ALC262_HP_BPC }, /* xw6400 */
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
-         .config = ALC262_HP_BPC }, /* xw8400 */
-       { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
-         .config = ALC262_HP_BPC }, /* xw9400 */
-       { .modelname = "benq", .config = ALC262_BENQ_ED8 },
-       { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
-         .config = ALC262_BENQ_ED8 },
-       { .modelname = "auto", .config = ALC262_AUTO },
+static const char *alc262_models[ALC262_MODEL_LAST] = {
+       [ALC262_BASIC]          = "basic",
+       [ALC262_HIPPO]          = "hippo",
+       [ALC262_HIPPO_1]        = "hippo_1",
+       [ALC262_FUJITSU]        = "fujitsu",
+       [ALC262_HP_BPC]         = "hp-bpc",
+       [ALC262_BENQ_ED8]       = "benq",
+       [ALC262_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc262_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
+       SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
+       SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
+       SND_PCI_QUIRK(0x103c, 0x2801, "HP q954", ALC262_HP_BPC),
+       SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
+       SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
+       SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
+       SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
+       SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
+       SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
        {}
 };
 
@@ -5896,6 +6528,30 @@ static struct alc_config_preset alc262_presets[] = {
                .channel_mode = alc262_modes,
                .input_mux = &alc262_capture_source,
        },
+       [ALC262_HIPPO] = {
+               .mixers = { alc262_base_mixer },
+               .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
+               .num_dacs = ARRAY_SIZE(alc262_dac_nids),
+               .dac_nids = alc262_dac_nids,
+               .hp_nid = 0x03,
+               .dig_out_nid = ALC262_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc262_modes),
+               .channel_mode = alc262_modes,
+               .input_mux = &alc262_capture_source,
+               .unsol_event = alc262_hippo_unsol_event,
+       },
+       [ALC262_HIPPO_1] = {
+               .mixers = { alc262_hippo1_mixer },
+               .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
+               .num_dacs = ARRAY_SIZE(alc262_dac_nids),
+               .dac_nids = alc262_dac_nids,
+               .hp_nid = 0x02,
+               .dig_out_nid = ALC262_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc262_modes),
+               .channel_mode = alc262_modes,
+               .input_mux = &alc262_capture_source,
+               .unsol_event = alc262_hippo1_unsol_event,
+       },
        [ALC262_FUJITSU] = {
                .mixers = { alc262_fujitsu_mixer },
                .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
@@ -5936,7 +6592,7 @@ static int patch_alc262(struct hda_codec *codec)
        int board_config;
        int err;
 
-       spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
+       spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
                return -ENOMEM;
 
@@ -5952,9 +6608,11 @@ static int patch_alc262(struct hda_codec *codec)
        }
 #endif
 
-       board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
+       board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
+                                                 alc262_models,
+                                                 alc262_cfg_tbl);
        
-       if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
+       if (board_config < 0) {
                printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
                       "trying auto-probe from BIOS...\n");
                board_config = ALC262_AUTO;
@@ -6074,6 +6732,44 @@ static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
        { 4, alc861_uniwill_m31_ch4_init },
 };
 
+/* Set mic1 and line-in as input and unmute the mixer */
+static struct hda_verb alc861_asus_ch2_init[] = {
+       /* set pin widget 1Ah (line in) for input */
+       { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
+       /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
+       { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
+
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
+#if 0
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
+#endif
+       { } /* end */
+};
+/* Set mic1 nad line-in as output and mute mixer */
+static struct hda_verb alc861_asus_ch6_init[] = {
+       /* set pin widget 1Ah (line in) for output (Back Surround)*/
+       { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
+       /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
+       /* set pin widget 18h (mic1) for output (CLFE)*/
+       { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
+       /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
+       { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
+       { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
+
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
+#if 0
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
+#endif
+       { } /* end */
+};
+
+static struct hda_channel_mode alc861_asus_modes[2] = {
+       { 2, alc861_asus_ch2_init },
+       { 6, alc861_asus_ch6_init },
+};
+
 /* patch-ALC861 */
 
 static struct snd_kcontrol_new alc861_base_mixer[] = {
@@ -6150,7 +6846,29 @@ static struct snd_kcontrol_new alc861_3ST_mixer[] = {
                 .private_value = ARRAY_SIZE(alc861_threestack_modes),
        },
        { } /* end */
-};                     
+};
+
+static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
+        /* output mixer control */
+       HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
+       
+        /*Capture mixer control */
+       HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Capture Source",
+               .count = 1,
+               .info = alc_mux_enum_info,
+               .get = alc_mux_enum_get,
+               .put = alc_mux_enum_put,
+       },
+
+       { } /* end */
+};     
+
 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
         /* output mixer control */
        HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
@@ -6192,7 +6910,58 @@ static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
        },
        { } /* end */
 };                     
-       
+
+static struct snd_kcontrol_new alc861_asus_mixer[] = {
+        /* output mixer control */
+       HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
+
+       /* Input mixer control */
+       HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
+       /* Capture mixer control */
+       HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Capture Source",
+               .count = 1,
+               .info = alc_mux_enum_info,
+               .get = alc_mux_enum_get,
+               .put = alc_mux_enum_put,
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Channel Mode",
+               .info = alc_ch_mode_info,
+               .get = alc_ch_mode_get,
+               .put = alc_ch_mode_put,
+                .private_value = ARRAY_SIZE(alc861_asus_modes),
+       },
+       { }
+};
+
+/* additional mixer */
+static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
+       HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
+       { }
+};
+
 /*
  * generic initialization of ADC, input mixers and output mixers
  */
@@ -6213,7 +6982,7 @@ static struct hda_verb alc861_base_init_verbs[] = {
        /* port-E for HP out (front panel) */
        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
        /* route front PCM to HP */
-       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
        /* port-F for mic-in (front panel) with vref */
        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
        /* port-G for CLFE (rear panel) */
@@ -6277,7 +7046,7 @@ static struct hda_verb alc861_threestack_init_verbs[] = {
        /* port-E for HP out (front panel) */
        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
        /* route front PCM to HP */
-       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
        /* port-F for mic-in (front panel) with vref */
        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
        /* port-G for CLFE (rear panel) */
@@ -6337,7 +7106,7 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
        /* port-E for HP out (front panel) */
        { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
        /* route front PCM to HP */
-       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
        /* port-F for mic-in (front panel) with vref */
        { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
        /* port-G for CLFE (rear panel) */
@@ -6381,6 +7150,74 @@ static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
        { }
 };
 
+static struct hda_verb alc861_asus_init_verbs[] = {
+       /*
+        * Unmute ADC0 and set the default input to mic-in
+        */
+       /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
+       { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
+       /* route front PCM to HP */
+       { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
+       /* port-B for mic-in (rear panel) with vref */
+       { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
+       /* port-C for line-in (rear panel) */
+       { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
+       /* port-D for Front */
+       { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
+       { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
+       /* port-E for HP out (front panel) */
+       { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
+       /* route front PCM to HP */
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
+       /* port-F for mic-in (front panel) with vref */
+       { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
+       /* port-G for CLFE (rear panel) */
+       { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
+       /* port-H for side (rear panel) */
+       { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
+       /* CD-in */
+       { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
+       /* route front mic to ADC1*/
+       {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       /* Unmute DAC0~3 & spdif out*/
+       {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       /* Unmute Mixer 14 (mic) 1c (Line in)*/
+       {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+        {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+        {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       
+       /* Unmute Stereo Mixer 15 */
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c          }, /* Output 0~12 step */
+
+       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
+       { }
+};
+
+/* additional init verbs for ASUS laptops */
+static struct hda_verb alc861_asus_laptop_init_verbs[] = {
+       { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
+       { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
+       { }
+};
+
 /*
  * generic initialization of ADC, input mixers and output mixers
  */
@@ -6433,6 +7270,39 @@ static struct hda_verb alc861_auto_init_verbs[] = {
        { }
 };
 
+static struct hda_verb alc861_toshiba_init_verbs[] = {
+       {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+        
+       { }
+};
+
+/* toggle speaker-output according to the hp-jack state */
+static void alc861_toshiba_automute(struct hda_codec *codec)
+{
+       unsigned int present;
+
+       present = snd_hda_codec_read(codec, 0x0f, 0,
+                                    AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+       snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
+                                0x80, present ? 0 : 0x80);
+       snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
+                                0x80, present ? 0 : 0x80);
+}
+
+static void alc861_toshiba_unsol_event(struct hda_codec *codec,
+                                      unsigned int res)
+{
+       /* Looks like the unsol event is incompatible with the standard
+        * definition.  6bit tag is placed at 26 bit!
+        */
+       if ((res >> 26) == ALC880_HP_EVENT)
+               alc861_toshiba_automute(codec);
+}
+
 /* pcm configuration: identiacal with ALC880 */
 #define alc861_pcm_analog_playback     alc880_pcm_analog_playback
 #define alc861_pcm_analog_capture      alc880_pcm_analog_capture
@@ -6706,19 +7576,28 @@ static void alc861_auto_init(struct hda_codec *codec)
 /*
  * configuration and preset
  */
-static struct hda_board_config alc861_cfg_tbl[] = {
-       { .modelname = "3stack", .config = ALC861_3ST },
-       { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
-         .config = ALC861_3ST },
-       { .modelname = "3stack-660", .config = ALC660_3ST },
-       { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
-         .config = ALC660_3ST },
-       { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
-       { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
-       { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
-       { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
-         .config = ALC861_UNIWILL_M31 },
-       { .modelname = "auto", .config = ALC861_AUTO },
+static const char *alc861_models[ALC861_MODEL_LAST] = {
+       [ALC861_3ST]            = "3stack",
+       [ALC660_3ST]            = "3stack-660",
+       [ALC861_3ST_DIG]        = "3stack-dig",
+       [ALC861_6ST_DIG]        = "6stack-dig",
+       [ALC861_UNIWILL_M31]    = "uniwill-m31",
+       [ALC861_TOSHIBA]        = "toshiba",
+       [ALC861_ASUS]           = "asus",
+       [ALC861_ASUS_LAPTOP]    = "asus-laptop",
+       [ALC861_AUTO]           = "auto",
+};
+
+static struct snd_pci_quirk alc861_cfg_tbl[] = {
+       SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
+       SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
+       SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
+       SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
+       SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
+       SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
+       SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
+       SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
+       SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
        {}
 };
 
@@ -6785,8 +7664,48 @@ static struct alc_config_preset alc861_presets[] = {
                .adc_nids = alc861_adc_nids,
                .input_mux = &alc861_capture_source,
        },
-
-};     
+       [ALC861_TOSHIBA] = {
+               .mixers = { alc861_toshiba_mixer },
+               .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc861_dac_nids),
+               .dac_nids = alc861_dac_nids,
+               .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
+               .channel_mode = alc883_3ST_2ch_modes,
+               .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
+               .adc_nids = alc861_adc_nids,
+               .input_mux = &alc861_capture_source,
+               .unsol_event = alc861_toshiba_unsol_event,
+               .init_hook = alc861_toshiba_automute,
+       },
+       [ALC861_ASUS] = {
+               .mixers = { alc861_asus_mixer },
+               .init_verbs = { alc861_asus_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc861_dac_nids),
+               .dac_nids = alc861_dac_nids,
+               .dig_out_nid = ALC861_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
+               .channel_mode = alc861_asus_modes,
+               .need_dac_fix = 1,
+               .hp_nid = 0x06,
+               .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
+               .adc_nids = alc861_adc_nids,
+               .input_mux = &alc861_capture_source,
+       },
+       [ALC861_ASUS_LAPTOP] = {
+               .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
+               .init_verbs = { alc861_asus_init_verbs,
+                               alc861_asus_laptop_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc861_dac_nids),
+               .dac_nids = alc861_dac_nids,
+               .dig_out_nid = ALC861_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
+               .channel_mode = alc883_3ST_2ch_modes,
+               .need_dac_fix = 1,
+               .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
+               .adc_nids = alc861_adc_nids,
+               .input_mux = &alc861_capture_source,
+       },
+};
 
 
 static int patch_alc861(struct hda_codec *codec)
@@ -6795,15 +7714,17 @@ static int patch_alc861(struct hda_codec *codec)
        int board_config;
        int err;
 
-       spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
+       spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
                return -ENOMEM;
 
        codec->spec = spec;     
 
-        board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
+        board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
+                                                 alc861_models,
+                                                 alc861_cfg_tbl);
 
-       if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
+       if (board_config < 0) {
                printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
                       "trying auto-probe from BIOS...\n");
                board_config = ALC861_AUTO;
@@ -6854,7 +7775,8 @@ struct hda_codec_preset snd_hda_preset_realtek[] = {
        { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
        { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
          .patch = patch_alc861 },
-        { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
+       { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
          .patch = patch_alc861 },
+       { .id = 0x10ec0660, .name = "ALC660", .patch = patch_alc861 },
        {} /* terminator */
 };