ALSA: hda - Fix setup for ALC269vb amic and dmic models
[safe/jmp/linux-2.6] / sound / pci / hda / patch_realtek.c
index 0c22497..9b58f29 100644 (file)
@@ -209,8 +209,10 @@ enum {
        ALC882_ASUS_A7J,
        ALC882_ASUS_A7M,
        ALC885_MACPRO,
+       ALC885_MBA21,
        ALC885_MBP3,
        ALC885_MB5,
+       ALC885_MACMINI3,
        ALC885_IMAC24,
        ALC885_IMAC91,
        ALC883_3ST_2ch_DIG,
@@ -228,6 +230,7 @@ enum {
        ALC888_ACER_ASPIRE_7730G,
        ALC883_MEDION,
        ALC883_MEDION_MD2,
+       ALC883_MEDION_WIM2160,
        ALC883_LAPTOP_EAPD,
        ALC883_LENOVO_101E_2ch,
        ALC883_LENOVO_NB0763,
@@ -409,6 +412,8 @@ static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
        unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
        if (mux_idx >= spec->num_mux_defs)
                mux_idx = 0;
+       if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
+               mux_idx = 0;
        return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
 }
 
@@ -437,6 +442,8 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
 
        mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
        imux = &spec->input_mux[mux_idx];
+       if (!imux->num_items && mux_idx > 0)
+               imux = &spec->input_mux[0];
 
        type = get_wcaps_type(get_wcaps(codec, nid));
        if (type == AC_WID_AUD_MIX) {
@@ -1252,7 +1259,7 @@ static void alc_init_auto_mic(struct hda_codec *codec)
  */
 static int alc_subsystem_id(struct hda_codec *codec,
                            hda_nid_t porta, hda_nid_t porte,
-                           hda_nid_t portd)
+                           hda_nid_t portd, hda_nid_t porti)
 {
        unsigned int ass, tmp, i;
        unsigned nid;
@@ -1278,7 +1285,7 @@ static int alc_subsystem_id(struct hda_codec *codec,
        snd_printd("realtek: No valid SSID, "
                   "checking pincfg 0x%08x for NID 0x%x\n",
                   ass, nid);
-       if (!(ass & 1) && !(ass & 0x100000))
+       if (!(ass & 1))
                return 0;
        if ((ass >> 30) != 1)   /* no physical connection */
                return 0;
@@ -1338,6 +1345,8 @@ do_sku:
                        nid = porte;
                else if (tmp == 2)
                        nid = portd;
+               else if (tmp == 3)
+                       nid = porti;
                else
                        return 1;
                for (i = 0; i < spec->autocfg.line_outs; i++)
@@ -1352,9 +1361,10 @@ do_sku:
 }
 
 static void alc_ssid_check(struct hda_codec *codec,
-                          hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
+                          hda_nid_t porta, hda_nid_t porte,
+                          hda_nid_t portd, hda_nid_t porti)
 {
-       if (!alc_subsystem_id(codec, porta, porte, portd)) {
+       if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
                struct alc_spec *spec = codec->spec;
                snd_printd("realtek: "
                           "Enable default setup for auto mode as fallback\n");
@@ -1612,6 +1622,11 @@ static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
  */
 
 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
+/* Route to built-in subwoofer as well as speakers */
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
 /* Bias voltage on for external mic port */
        {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
 /* Front Mic: set to PIN_IN (empty by default) */
@@ -1623,10 +1638,12 @@ static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
 /* Enable speaker output */
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
        {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
 /* Enable headphone output */
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
        { }
 };
 
@@ -2523,8 +2540,6 @@ static int alc_build_controls(struct hda_codec *codec)
                        return err;
        }
 
-       alc_free_kctls(codec); /* no longer needed */
-
        /* assign Capture Source enums to NID */
        kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
        if (!kctl)
@@ -2593,6 +2608,9 @@ static int alc_build_controls(struct hda_codec *codec)
                        }
                }
        }
+
+       alc_free_kctls(codec); /* no longer needed */
+
        return 0;
 }
 
@@ -4857,7 +4875,7 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
        spec->num_mux_defs = 1;
        spec->input_mux = &spec->private_imux[0];
 
-       alc_ssid_check(codec, 0x15, 0x1b, 0x14);
+       alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
 
        return 1;
 }
@@ -4910,7 +4928,7 @@ static void fixup_automic_adc(struct hda_codec *codec)
 static void fixup_single_adc(struct hda_codec *codec)
 {
        struct alc_spec *spec = codec->spec;
-       hda_nid_t pin;
+       hda_nid_t pin = 0;
        int i;
 
        /* search for the input pin; there must be only one */
@@ -4974,6 +4992,70 @@ static void set_capture_mixer(struct hda_codec *codec)
        }
 }
 
+/* fill adc_nids (and capsrc_nids) containing all active input pins */
+static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
+                                int num_nids)
+{
+       struct alc_spec *spec = codec->spec;
+       int n;
+       hda_nid_t fallback_adc = 0, fallback_cap = 0;
+
+       for (n = 0; n < num_nids; n++) {
+               hda_nid_t adc, cap;
+               hda_nid_t conn[HDA_MAX_NUM_INPUTS];
+               int nconns, i, j;
+
+               adc = nids[n];
+               if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
+                       continue;
+               cap = adc;
+               nconns = snd_hda_get_connections(codec, cap, conn,
+                                                ARRAY_SIZE(conn));
+               if (nconns == 1) {
+                       cap = conn[0];
+                       nconns = snd_hda_get_connections(codec, cap, conn,
+                                                        ARRAY_SIZE(conn));
+               }
+               if (nconns <= 0)
+                       continue;
+               if (!fallback_adc) {
+                       fallback_adc = adc;
+                       fallback_cap = cap;
+               }
+               for (i = 0; i < AUTO_PIN_LAST; i++) {
+                       hda_nid_t nid = spec->autocfg.input_pins[i];
+                       if (!nid)
+                               continue;
+                       for (j = 0; j < nconns; j++) {
+                               if (conn[j] == nid)
+                                       break;
+                       }
+                       if (j >= nconns)
+                               break;
+               }
+               if (i >= AUTO_PIN_LAST) {
+                       int num_adcs = spec->num_adc_nids;
+                       spec->private_adc_nids[num_adcs] = adc;
+                       spec->private_capsrc_nids[num_adcs] = cap;
+                       spec->num_adc_nids++;
+                       spec->adc_nids = spec->private_adc_nids;
+                       if (adc != cap)
+                               spec->capsrc_nids = spec->private_capsrc_nids;
+               }
+       }
+       if (!spec->num_adc_nids) {
+               printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
+                      " using fallback 0x%x\n",
+                      codec->chip_name, fallback_adc);
+               spec->private_adc_nids[0] = fallback_adc;
+               spec->adc_nids = spec->private_adc_nids;
+               if (fallback_adc != fallback_cap) {
+                       spec->private_capsrc_nids[0] = fallback_cap;
+                       spec->capsrc_nids = spec->private_adc_nids;
+               }
+       }
+}
+
 #ifdef CONFIG_SND_HDA_INPUT_BEEP
 #define set_beep_amp(spec, nid, idx, dir) \
        ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
@@ -6391,7 +6473,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
        spec->num_mux_defs = 1;
        spec->input_mux = &spec->private_imux[0];
 
-       alc_ssid_check(codec, 0x10, 0x15, 0x0f);
+       alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
 
        return 1;
 }
@@ -6468,7 +6550,7 @@ static struct alc_config_preset alc260_presets[] = {
                .num_dacs = ARRAY_SIZE(alc260_dac_nids),
                .dac_nids = alc260_dac_nids,
                .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
-               .adc_nids = alc260_adc_nids,
+               .adc_nids = alc260_dual_adc_nids,
                .num_channel_mode = ARRAY_SIZE(alc260_modes),
                .channel_mode = alc260_modes,
                .input_mux = &alc260_capture_source,
@@ -6751,6 +6833,14 @@ static struct hda_input_mux mb5_capture_source = {
        },
 };
 
+static struct hda_input_mux macmini3_capture_source = {
+       .num_items = 2,
+       .items = {
+               { "Line", 0x2 },
+               { "CD", 0x4 },
+       },
+};
+
 static struct hda_input_mux alc883_3stack_6ch_intel = {
        .num_items = 4,
        .items = {
@@ -6939,6 +7029,13 @@ static struct hda_channel_mode alc882_sixstack_modes[2] = {
        { 8, alc882_sixstack_ch8_init },
 };
 
+
+/* Macbook Air 2,1 */
+
+static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
+      { 2, NULL },
+};
+
 /*
  * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
  */
@@ -6999,6 +7096,7 @@ static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
        { 6, alc885_mb5_ch6_init },
 };
 
+#define alc885_macmini3_6ch_modes      alc885_mb5_6ch_modes
 
 /*
  * 2ch mode
@@ -7210,6 +7308,15 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
        { } /* end */
 };
 
+/* Macbook Air 2,1 same control for HP and internal Speaker */
+
+static struct snd_kcontrol_new alc885_mba21_mixer[] = {
+      HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
+      HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
+     { }
+};
+
+
 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
        HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
        HDA_BIND_MUTE   ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
@@ -7243,6 +7350,21 @@ static struct snd_kcontrol_new alc885_mb5_mixer[] = {
        { } /* end */
 };
 
+static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
+       HDA_BIND_MUTE   ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
+       HDA_BIND_MUTE   ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
+       HDA_BIND_MUTE   ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
+       HDA_BIND_MUTE   ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
+       HDA_CODEC_MUTE  ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
+       { } /* end */
+};
+
 static struct snd_kcontrol_new alc885_imac91_mixer[] = {
        HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
        HDA_BIND_MUTE   ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
@@ -7617,6 +7739,76 @@ static struct hda_verb alc885_mb5_init_verbs[] = {
        { }
 };
 
+/* Macmini 3,1 */
+static struct hda_verb alc885_macmini3_init_verbs[] = {
+       /* DACs */
+       {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {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},
+       /* Front mixer */
+       {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)},
+       /* Surround 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)},
+       /* LFE mixer */
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+       /* HP mixer */
+       {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
+       /* Front Pin (0x0c) */
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* LFE Pin (0x0e) */
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
+       /* HP Pin (0x0f) */
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
+       {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
+       /* Line In pin */
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+
+       {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       {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)},
+       { }
+};
+
+
+static struct hda_verb alc885_mba21_init_verbs[] = {
+       /*Internal and HP Speaker Mixer*/
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+       /*Internal Speaker Pin (0x0c)*/
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
+       /* HP Pin: output 0 (0x0e) */
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
+       /* Line in (is hp when jack connected)*/
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+
+       { }
+ };
+
+
 /* Macbook Pro rev3 */
 static struct hda_verb alc885_mbp3_init_verbs[] = {
        /* Front mixer: unmute input/output amp left and right (volume = 0) */
@@ -7779,54 +7971,35 @@ static void alc885_imac24_setup(struct hda_codec *codec)
        spec->autocfg.speaker_pins[1] = 0x1a;
 }
 
-static void alc885_mbp3_setup(struct hda_codec *codec)
-{
-       struct alc_spec *spec = codec->spec;
-
-       spec->autocfg.hp_pins[0] = 0x15;
-       spec->autocfg.speaker_pins[0] = 0x14;
-}
+#define alc885_mb5_setup       alc885_imac24_setup
+#define alc885_macmini3_setup  alc885_imac24_setup
 
-static void alc885_mb5_automute(struct hda_codec *codec)
+/* Macbook Air 2,1 */
+static void alc885_mba21_setup(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_stereo(codec, 0x18, HDA_OUTPUT, 0,
-                                HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
-       snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
-                                HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
+       struct alc_spec *spec = codec->spec;
 
+       spec->autocfg.hp_pins[0] = 0x14;
+       spec->autocfg.speaker_pins[0] = 0x18;
 }
 
-static void alc885_mb5_unsol_event(struct hda_codec *codec,
-                                   unsigned int res)
-{
-       /* Headphone insertion or removal. */
-       if ((res >> 26) == ALC880_HP_EVENT)
-               alc885_mb5_automute(codec);
-}
 
-static void alc885_imac91_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_stereo(codec, 0x15, HDA_OUTPUT, 0,
-                                HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
-       snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
-                                HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
+static void alc885_mbp3_setup(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
 
+       spec->autocfg.hp_pins[0] = 0x15;
+       spec->autocfg.speaker_pins[0] = 0x14;
 }
 
-static void alc885_imac91_unsol_event(struct hda_codec *codec,
-                                   unsigned int res)
+static void alc885_imac91_setup(struct hda_codec *codec)
 {
-       /* Headphone insertion or removal. */
-       if ((res >> 26) == ALC880_HP_EVENT)
-               alc885_imac91_automute(codec);
+       struct alc_spec *spec = codec->spec;
+
+       spec->autocfg.hp_pins[0] = 0x14;
+       spec->autocfg.speaker_pins[0] = 0x15;
+       spec->autocfg.speaker_pins[1] = 0x1a;
 }
 
 static struct hda_verb alc882_targa_verbs[] = {
@@ -8283,6 +8456,42 @@ static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
        { } /* end */
 };
 
+static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
+       HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
+       { } /* end */
+};
+
+static struct hda_verb alc883_medion_wim2160_verbs[] = {
+       /* Unmute front mixer */
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+
+       /* Set speaker pin to front mixer */
+       {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
+
+       /* Init headphone pin */
+       {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
+
+       { } /* end */
+};
+
+/* toggle speaker-output according to the hp-jack state */
+static void alc883_medion_wim2160_setup(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
+
+       spec->autocfg.hp_pins[0] = 0x1a;
+       spec->autocfg.speaker_pins[0] = 0x15;
+}
+
 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
        HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -8297,9 +8506,7 @@ static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
 
 static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
        HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
-       HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
        HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
-       HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, 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("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
@@ -8974,6 +9181,8 @@ static const char *alc882_models[ALC882_MODEL_LAST] = {
        [ALC882_ASUS_A7M]       = "asus-a7m",
        [ALC885_MACPRO]         = "macpro",
        [ALC885_MB5]            = "mb5",
+       [ALC885_MACMINI3]       = "macmini3",
+       [ALC885_MBA21]          = "mba21",
        [ALC885_MBP3]           = "mbp3",
        [ALC885_IMAC24]         = "imac24",
        [ALC885_IMAC91]         = "imac91",
@@ -8992,6 +9201,7 @@ static const char *alc882_models[ALC882_MODEL_LAST] = {
        [ALC888_ACER_ASPIRE_7730G]      = "acer-aspire-7730g",
        [ALC883_MEDION]         = "medion",
        [ALC883_MEDION_MD2]     = "medion-md2",
+       [ALC883_MEDION_WIM2160] = "medion-wim2160",
        [ALC883_LAPTOP_EAPD]    = "laptop-eapd",
        [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
        [ALC883_LENOVO_NB0763]  = "lenovo-nb0763",
@@ -9093,6 +9303,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
        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, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
        SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
        SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
        SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
@@ -9102,6 +9313,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
        SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
        SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
        SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
+       SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
        SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
        SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
 
@@ -9133,7 +9345,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
        SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
        SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
        SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
-       SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
+       SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
 
        {}
 };
@@ -9157,6 +9369,7 @@ static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
         */
        SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
        SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
+       SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
        {} /* terminator */
 };
 
@@ -9208,6 +9421,18 @@ static struct alc_config_preset alc882_presets[] = {
                .input_mux = &alc882_capture_source,
                .dig_out_nid = ALC882_DIGOUT_NID,
        },
+          [ALC885_MBA21] = {
+                       .mixers = { alc885_mba21_mixer },
+                       .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
+                       .num_dacs = 2,
+                       .dac_nids = alc882_dac_nids,
+                       .channel_mode = alc885_mba21_ch_modes,
+                       .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
+                       .input_mux = &alc882_capture_source,
+                       .unsol_event = alc_automute_amp_unsol_event,
+                       .setup = alc885_mba21_setup,
+                       .init_hook = alc_automute_amp,
+       },
        [ALC885_MBP3] = {
                .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
                .init_verbs = { alc885_mbp3_init_verbs,
@@ -9235,8 +9460,24 @@ static struct alc_config_preset alc882_presets[] = {
                .input_mux = &mb5_capture_source,
                .dig_out_nid = ALC882_DIGOUT_NID,
                .dig_in_nid = ALC882_DIGIN_NID,
-               .unsol_event = alc885_mb5_unsol_event,
-               .init_hook = alc885_mb5_automute,
+               .unsol_event = alc_automute_amp_unsol_event,
+               .setup = alc885_mb5_setup,
+               .init_hook = alc_automute_amp,
+       },
+       [ALC885_MACMINI3] = {
+               .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
+               .init_verbs = { alc885_macmini3_init_verbs,
+                               alc880_gpio1_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc882_dac_nids),
+               .dac_nids = alc882_dac_nids,
+               .channel_mode = alc885_macmini3_6ch_modes,
+               .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
+               .input_mux = &macmini3_capture_source,
+               .dig_out_nid = ALC882_DIGOUT_NID,
+               .dig_in_nid = ALC882_DIGIN_NID,
+               .unsol_event = alc_automute_amp_unsol_event,
+               .setup = alc885_macmini3_setup,
+               .init_hook = alc_automute_amp,
        },
        [ALC885_MACPRO] = {
                .mixers = { alc882_macpro_mixer },
@@ -9275,8 +9516,9 @@ static struct alc_config_preset alc882_presets[] = {
                .input_mux = &alc882_capture_source,
                .dig_out_nid = ALC882_DIGOUT_NID,
                .dig_in_nid = ALC882_DIGIN_NID,
-               .unsol_event = alc885_imac91_unsol_event,
-               .init_hook = alc885_imac91_automute,
+               .unsol_event = alc_automute_amp_unsol_event,
+               .setup = alc885_imac91_setup,
+               .init_hook = alc_automute_amp,
        },
        [ALC882_TARGA] = {
                .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
@@ -9614,6 +9856,21 @@ static struct alc_config_preset alc882_presets[] = {
                .setup = alc883_medion_md2_setup,
                .init_hook = alc_automute_amp,
        },
+       [ALC883_MEDION_WIM2160] = {
+               .mixers = { alc883_medion_wim2160_mixer },
+               .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_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 = alc_automute_amp_unsol_event,
+               .setup = alc883_medion_wim2160_setup,
+               .init_hook = alc_automute_amp,
+       },
        [ALC883_LAPTOP_EAPD] = {
                .mixers = { alc883_base_mixer },
                .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
@@ -9906,6 +10163,8 @@ static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
        int idx;
 
        alc_set_pin_output(codec, nid, pin_type);
+       if (dac_idx >= spec->multiout.num_dacs)
+               return;
        if (spec->multiout.dac_nids[dac_idx] == 0x25)
                idx = 4;
        else
@@ -9977,6 +10236,8 @@ static void alc882_auto_init_input_src(struct hda_codec *codec)
                        continue;
                mux_idx = c >= spec->num_mux_defs ? 0 : c;
                imux = &spec->input_mux[mux_idx];
+               if (!imux->num_items && mux_idx > 0)
+                       imux = &spec->input_mux[0];
                for (idx = 0; idx < conns; idx++) {
                        /* if the current connection is the selected one,
                         * unmute it as default - otherwise mute it
@@ -10099,7 +10360,7 @@ static int alc882_parse_auto_config(struct hda_codec *codec)
        spec->num_mux_defs = 1;
        spec->input_mux = &spec->private_imux[0];
 
-       alc_ssid_check(codec, 0x15, 0x1b, 0x14);
+       alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
 
        err = alc_auto_add_mic_boost(codec);
        if (err < 0)
@@ -11657,7 +11918,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
        if (err < 0)
                return err;
 
-       alc_ssid_check(codec, 0x15, 0x14, 0x1b);
+       alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
 
        return 1;
 }
@@ -12319,11 +12580,11 @@ static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
        unsigned char bits;
 
        present = snd_hda_jack_detect(codec, 0x15);
-       bits = present ? AMP_IN_MUTE(0) : 0;
+       bits = present ? HDA_AMP_MUTE : 0;
        snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
        snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
 }
 
 static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
@@ -12608,7 +12869,7 @@ static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
                dac = 0x02;
                break;
        case 0x15:
-       case 0x21:
+       case 0x21: /* ALC269vb has this pin, too */
                dac = 0x03;
                break;
        default:
@@ -12829,7 +13090,7 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
        if (err < 0)
                return err;
 
-       alc_ssid_check(codec, 0x15, 0x1b, 0x14);
+       alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
 
        return 1;
 }
@@ -13074,7 +13335,7 @@ static int patch_alc268(struct hda_codec *codec)
 
        if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
                board_config = snd_hda_check_board_codec_sid_config(codec,
-                       ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
+                       ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
 
        if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
                printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
@@ -13194,9 +13455,9 @@ static hda_nid_t alc269vb_capsrc_nids[1] = {
        0x22,
 };
 
-/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
- *       not a mux!
- */
+static hda_nid_t alc269_adc_candidates[] = {
+       0x08, 0x09, 0x07,
+};
 
 #define alc269_modes           alc260_modes
 #define alc269_capture_source  alc880_lg_lw_capture_source
@@ -13343,11 +13604,11 @@ static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
        unsigned char bits;
 
        present = snd_hda_jack_detect(codec, 0x15);
-       bits = present ? AMP_IN_MUTE(0) : 0;
+       bits = present ? HDA_AMP_MUTE : 0;
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
-                       AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
-                       AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
 
        snd_hda_codec_write(codec, 0x20, 0,
                        AC_VERB_SET_COEF_INDEX, 0x0c);
@@ -13372,11 +13633,11 @@ static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
        /* Check port replicator headphone socket */
        present |= snd_hda_jack_detect(codec, 0x1a);
 
-       bits = present ? AMP_IN_MUTE(0) : 0;
+       bits = present ? HDA_AMP_MUTE : 0;
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
-                       AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
-                       AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
 
        snd_hda_codec_write(codec, 0x20, 0,
                        AC_VERB_SET_COEF_INDEX, 0x0c);
@@ -13434,6 +13695,8 @@ static void alc269_lifebook_unsol_event(struct hda_codec *codec,
 static void alc269_quanta_fl1_setup(struct hda_codec *codec)
 {
        struct alc_spec *spec = codec->spec;
+       spec->autocfg.hp_pins[0] = 0x15;
+       spec->autocfg.speaker_pins[0] = 0x14;
        spec->ext_mic.pin = 0x18;
        spec->ext_mic.mux_idx = 0;
        spec->int_mic.pin = 0x19;
@@ -13505,11 +13768,11 @@ static void alc269_speaker_automute(struct hda_codec *codec)
        unsigned char bits;
 
        present = snd_hda_jack_detect(codec, nid);
-       bits = present ? AMP_IN_MUTE(0) : 0;
+       bits = present ? HDA_AMP_MUTE : 0;
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
 }
 
 /* unsolicited event for HP jack sensing */
@@ -13526,29 +13789,35 @@ static void alc269_laptop_unsol_event(struct hda_codec *codec,
        }
 }
 
-static void alc269_laptop_dmic_setup(struct hda_codec *codec)
+static void alc269_laptop_amic_setup(struct hda_codec *codec)
 {
        struct alc_spec *spec = codec->spec;
+       spec->autocfg.hp_pins[0] = 0x15;
+       spec->autocfg.speaker_pins[0] = 0x14;
        spec->ext_mic.pin = 0x18;
        spec->ext_mic.mux_idx = 0;
-       spec->int_mic.pin = 0x12;
-       spec->int_mic.mux_idx = 5;
+       spec->int_mic.pin = 0x19;
+       spec->int_mic.mux_idx = 1;
        spec->auto_mic = 1;
 }
 
-static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
+static void alc269_laptop_dmic_setup(struct hda_codec *codec)
 {
        struct alc_spec *spec = codec->spec;
+       spec->autocfg.hp_pins[0] = 0x15;
+       spec->autocfg.speaker_pins[0] = 0x14;
        spec->ext_mic.pin = 0x18;
        spec->ext_mic.mux_idx = 0;
        spec->int_mic.pin = 0x12;
-       spec->int_mic.mux_idx = 6;
+       spec->int_mic.mux_idx = 5;
        spec->auto_mic = 1;
 }
 
-static void alc269_laptop_amic_setup(struct hda_codec *codec)
+static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
 {
        struct alc_spec *spec = codec->spec;
+       spec->autocfg.hp_pins[0] = 0x21;
+       spec->autocfg.speaker_pins[0] = 0x14;
        spec->ext_mic.pin = 0x18;
        spec->ext_mic.mux_idx = 0;
        spec->int_mic.pin = 0x19;
@@ -13556,6 +13825,18 @@ static void alc269_laptop_amic_setup(struct hda_codec *codec)
        spec->auto_mic = 1;
 }
 
+static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
+       spec->autocfg.hp_pins[0] = 0x21;
+       spec->autocfg.speaker_pins[0] = 0x14;
+       spec->ext_mic.pin = 0x18;
+       spec->ext_mic.mux_idx = 0;
+       spec->int_mic.pin = 0x12;
+       spec->int_mic.mux_idx = 6;
+       spec->auto_mic = 1;
+}
+
 static void alc269_laptop_inithook(struct hda_codec *codec)
 {
        alc269_speaker_automute(codec);
@@ -13695,7 +13976,6 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
        struct alc_spec *spec = codec->spec;
        int err;
        static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
-       hda_nid_t real_capsrc_nids;
 
        err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
                                           alc269_ignore);
@@ -13719,18 +13999,19 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
 
        if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
                add_verb(spec, alc269vb_init_verbs);
-               real_capsrc_nids = alc269vb_capsrc_nids[0];
-               alc_ssid_check(codec, 0x21, 0x1b, 0x14);
+               alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
        } else {
                add_verb(spec, alc269_init_verbs);
-               real_capsrc_nids = alc269_capsrc_nids[0];
-               alc_ssid_check(codec, 0x15, 0x1b, 0x14);
+               alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
        }
 
        spec->num_mux_defs = 1;
        spec->input_mux = &spec->private_imux[0];
+       fillup_priv_adc_nids(codec, alc269_adc_candidates,
+                            sizeof(alc269_adc_candidates));
+
        /* set default input source */
-       snd_hda_codec_write_cache(codec, real_capsrc_nids,
+       snd_hda_codec_write_cache(codec, spec->capsrc_nids[0],
                                  0, AC_VERB_SET_CONNECT_SEL,
                                  spec->input_mux->items[0].index);
 
@@ -13819,8 +14100,14 @@ static struct snd_pci_quirk alc269_cfg_tbl[] = {
                      ALC269_DMIC),
        SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
        SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
-       SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
+       SND_PCI_QUIRK(0x104d, 0x9071, "SONY XTB", ALC269_DMIC),
        SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
+       SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
+       SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
+       SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
+       SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
+       SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
+       SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
        {}
 };
 
@@ -13887,7 +14174,7 @@ static struct alc_config_preset alc269_presets[] = {
                .num_channel_mode = ARRAY_SIZE(alc269_modes),
                .channel_mode = alc269_modes,
                .unsol_event = alc269_laptop_unsol_event,
-               .setup = alc269_laptop_amic_setup,
+               .setup = alc269vb_laptop_amic_setup,
                .init_hook = alc269_laptop_inithook,
        },
        [ALC269VB_DMIC] = {
@@ -14003,14 +14290,16 @@ static int patch_alc269(struct hda_codec *codec)
        spec->stream_digital_playback = &alc269_pcm_digital_playback;
        spec->stream_digital_capture = &alc269_pcm_digital_capture;
 
-       if (!is_alc269vb) {
-               spec->adc_nids = alc269_adc_nids;
-               spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
-               spec->capsrc_nids = alc269_capsrc_nids;
-       } else {
-               spec->adc_nids = alc269vb_adc_nids;
-               spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
-               spec->capsrc_nids = alc269vb_capsrc_nids;
+       if (!spec->adc_nids) { /* wasn't filled automatically? use default */
+               if (!is_alc269vb) {
+                       spec->adc_nids = alc269_adc_nids;
+                       spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
+                       spec->capsrc_nids = alc269_capsrc_nids;
+               } else {
+                       spec->adc_nids = alc269vb_adc_nids;
+                       spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
+                       spec->capsrc_nids = alc269vb_capsrc_nids;
+               }
        }
 
        if (!spec->cap_mixer)
@@ -14888,7 +15177,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
        spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
        set_capture_mixer(codec);
 
-       alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
+       alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
 
        return 1;
 }
@@ -15779,7 +16068,7 @@ static struct alc_config_preset alc861vd_presets[] = {
 static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
                                                const struct auto_pin_cfg *cfg)
 {
-       return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x22, 0);
+       return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
 }
 
 
@@ -16015,7 +16304,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
        if (err < 0)
                return err;
 
-       alc_ssid_check(codec, 0x15, 0x1b, 0x14);
+       alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
 
        return 1;
 }
@@ -16962,9 +17251,9 @@ static void alc663_m51va_speaker_automute(struct hda_codec *codec)
        present = snd_hda_jack_detect(codec, 0x21);
        bits = present ? HDA_AMP_MUTE : 0;
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
 }
 
 static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
@@ -16975,13 +17264,13 @@ static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
        present = snd_hda_jack_detect(codec, 0x21);
        bits = present ? HDA_AMP_MUTE : 0;
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
        snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
        snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
 }
 
 static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
@@ -16992,13 +17281,13 @@ static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
        present = snd_hda_jack_detect(codec, 0x15);
        bits = present ? HDA_AMP_MUTE : 0;
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
        snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
        snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
-                               AMP_IN_MUTE(0), bits);
+                                HDA_AMP_MUTE, bits);
 }
 
 static void alc662_f5z_speaker_automute(struct hda_codec *codec)
@@ -17037,14 +17326,14 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
 
        if (present1 || present2) {
                snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
-                               AMP_IN_MUTE(0), AMP_IN_MUTE(0));
+                                        HDA_AMP_MUTE, HDA_AMP_MUTE);
                snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
-                               AMP_IN_MUTE(0), AMP_IN_MUTE(0));
+                                        HDA_AMP_MUTE, HDA_AMP_MUTE);
        } else {
                snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
-                               AMP_IN_MUTE(0), 0);
+                                        HDA_AMP_MUTE, 0);
                snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
-                               AMP_IN_MUTE(0), 0);
+                                        HDA_AMP_MUTE, 0);
        }
 }
 
@@ -17502,6 +17791,7 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = {
        SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
        SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
                      ALC662_3ST_6ch_DIG),
+       SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
        SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
        SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
        SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
@@ -18132,7 +18422,11 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
        if (err < 0)
                return err;
 
-       alc_ssid_check(codec, 0x15, 0x1b, 0x14);
+       if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
+           codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
+           alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
+       else
+           alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
 
        return 1;
 }
@@ -18282,6 +18576,7 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = {
          .patch = patch_alc662 },
        { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
        { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
+       { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
        { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
        { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
        { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },