ALSA: hda - Create Capture controls dynamically
[pandora-kernel.git] / sound / pci / hda / patch_sigmatel.c
index d2fd8ef..be6cf2c 100644 (file)
@@ -100,6 +100,7 @@ enum {
        STAC_HP_M4,
        STAC_HP_DV5,
        STAC_HP_HDX,
+       STAC_HP_DV4_1222NR,
        STAC_92HD71BXX_MODELS
 };
 
@@ -193,6 +194,7 @@ struct sigmatel_spec {
        unsigned int gpio_dir;
        unsigned int gpio_data;
        unsigned int gpio_mute;
+       unsigned int gpio_led;
 
        /* stream */
        unsigned int stream_delay;
@@ -236,6 +238,11 @@ struct sigmatel_spec {
        unsigned int num_dmuxes;
        hda_nid_t *smux_nids;
        unsigned int num_smuxes;
+
+       unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
+       unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
+       unsigned int num_caps; /* number of capture volume/switch elements */
+
        const char **spdif_labels;
 
        hda_nid_t dig_in_nid;
@@ -332,6 +339,13 @@ static hda_nid_t stac92hd73xx_smux_nids[2] = {
        0x22, 0x23,
 };
 
+#define STAC92HD73XX_NUM_CAPS  2
+static unsigned long stac92hd73xx_capvols[] = {
+       HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
+       HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
+};
+#define stac92hd73xx_capsws    stac92hd73xx_capvols
+
 #define STAC92HD83XXX_NUM_DMICS        2
 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
        0x11, 0x12, 0
@@ -363,6 +377,13 @@ static hda_nid_t stac92hd83xxx_amp_nids[1] = {
        0xc,
 };
 
+#define STAC92HD83XXX_NUM_CAPS 2
+static unsigned long stac92hd83xxx_capvols[] = {
+       HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
+       HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
+};
+#define stac92hd83xxx_capsws   stac92hd83xxx_capvols
+
 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
        0x0a, 0x0d, 0x0f
 };
@@ -392,6 +413,13 @@ static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
        0x22, 0
 };
 
+#define STAC92HD71BXX_NUM_CAPS         2
+static unsigned long stac92hd71bxx_capvols[] = {
+       HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
+       HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
+};
+#define stac92hd71bxx_capsws   stac92hd71bxx_capvols
+
 static hda_nid_t stac925x_adc_nids[1] = {
         0x03,
 };
@@ -413,6 +441,13 @@ static hda_nid_t stac925x_dmux_nids[1] = {
        0x14,
 };
 
+static unsigned long stac925x_capvols[] = {
+       HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
+};
+static unsigned long stac925x_capsws[] = {
+       HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
+};
+
 static hda_nid_t stac922x_adc_nids[2] = {
         0x06, 0x07,
 };
@@ -421,6 +456,13 @@ static hda_nid_t stac922x_mux_nids[2] = {
         0x12, 0x13,
 };
 
+#define STAC922X_NUM_CAPS      2
+static unsigned long stac922x_capvols[] = {
+       HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
+       HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
+};
+#define stac922x_capsws                stac922x_capvols
+
 static hda_nid_t stac927x_slave_dig_outs[2] = {
        0x1f, 0,
 };
@@ -450,6 +492,18 @@ static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
        0x13, 0x14, 0
 };
 
+#define STAC927X_NUM_CAPS      3
+static unsigned long stac927x_capvols[] = {
+       HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
+       HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
+       HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
+};
+static unsigned long stac927x_capsws[] = {
+       HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
+       HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
+       HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
+};
+
 static const char *stac927x_spdif_labels[5] = {
        "Digital Playback", "ADAT", "Analog Mux 1",
        "Analog Mux 2", "Analog Mux 3"
@@ -476,6 +530,16 @@ static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
         0x17, 0x18, 0
 };
 
+#define STAC9205_NUM_CAPS      2
+static unsigned long stac9205_capvols[] = {
+       HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
+       HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
+};
+static unsigned long stac9205_capsws[] = {
+       HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
+       HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
+};
+
 static hda_nid_t stac9200_pin_nids[8] = {
        0x08, 0x09, 0x0d, 0x0e, 
        0x0f, 0x10, 0x11, 0x12,
@@ -634,6 +698,40 @@ static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
+static unsigned int stac92xx_vref_set(struct hda_codec *codec,
+                                       hda_nid_t nid, unsigned int new_vref)
+{
+       int error;
+       unsigned int pincfg;
+       pincfg = snd_hda_codec_read(codec, nid, 0,
+                               AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
+
+       pincfg &= 0xff;
+       pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
+       pincfg |= new_vref;
+
+       if (new_vref == AC_PINCTL_VREF_HIZ)
+               pincfg |= AC_PINCTL_OUT_EN;
+       else
+               pincfg |= AC_PINCTL_IN_EN;
+
+       error = snd_hda_codec_write_cache(codec, nid, 0,
+                                       AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
+       if (error < 0)
+               return error;
+       else
+               return 1;
+}
+
+static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
+{
+       unsigned int vref;
+       vref = snd_hda_codec_read(codec, nid, 0,
+                               AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
+       vref &= AC_PINCTL_VREFEN;
+       return vref;
+}
+
 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
@@ -995,6 +1093,17 @@ static struct hda_verb stac9205_core_init[] = {
                .private_value = verb_read | (verb_write << 16), \
        }
 
+#define DC_BIAS(xname, idx, nid) \
+       { \
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+               .name = xname, \
+               .index = idx, \
+               .info = stac92xx_dc_bias_info, \
+               .get = stac92xx_dc_bias_get, \
+               .put = stac92xx_dc_bias_put, \
+               .private_value = nid, \
+       }
+
 static struct snd_kcontrol_new stac9200_mixer[] = {
        HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
@@ -1022,12 +1131,6 @@ static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
        HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
        HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
 
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
-
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
-
        { } /* end */
 };
 
@@ -1047,12 +1150,6 @@ static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
 };
 
 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
-
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
-
        HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
 
@@ -1071,12 +1168,6 @@ static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
 };
 
 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
-
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
-
        HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
 
@@ -1096,12 +1187,6 @@ static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
 
 
 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
-
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
-
        HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
        HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
 
@@ -1122,17 +1207,6 @@ static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
 };
 
 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
-
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
-       /* analog pc-beep replaced with digital beep support */
-       /*
-       HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
-       HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
-       */
-
        HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
 
@@ -1151,29 +1225,9 @@ static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
        STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
 };
 
-static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
-
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
-       { } /* end */
-};
-
 static struct snd_kcontrol_new stac925x_mixer[] = {
        HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
-       HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
-       HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
-       { } /* end */
-};
-
-static struct snd_kcontrol_new stac9205_mixer[] = {
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
-
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
        { } /* end */
 };
 
@@ -1182,29 +1236,6 @@ static struct snd_kcontrol_new stac9205_loopback[] = {
        {}
 };
 
-/* This needs to be generated dynamically based on sequence */
-static struct snd_kcontrol_new stac922x_mixer[] = {
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
-
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
-       { } /* end */
-};
-
-
-static struct snd_kcontrol_new stac927x_mixer[] = {
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
-
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
-
-       HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
-       HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
-       { } /* end */
-};
-
 static struct snd_kcontrol_new stac927x_loopback[] = {
        STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
        {}
@@ -1262,9 +1293,11 @@ static int stac92xx_build_controls(struct hda_codec *codec)
        int err;
        int i;
 
-       err = snd_hda_add_new_ctls(codec, spec->mixer);
-       if (err < 0)
-               return err;
+       if (spec->mixer) {
+               err = snd_hda_add_new_ctls(codec, spec->mixer);
+               if (err < 0)
+                       return err;
+       }
 
        for (i = 0; i < spec->num_mixers; i++) {
                err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
@@ -1837,6 +1870,7 @@ static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
        [STAC_HP_M4]            = NULL,
        [STAC_HP_DV5]           = NULL,
        [STAC_HP_HDX]           = NULL,
+       [STAC_HP_DV4_1222NR]    = NULL,
 };
 
 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
@@ -1848,6 +1882,7 @@ static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
        [STAC_HP_M4] = "hp-m4",
        [STAC_HP_DV5] = "hp-dv5",
        [STAC_HP_HDX] = "hp-hdx",
+       [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
 };
 
 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
@@ -1856,6 +1891,8 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
                      "DFI LanParty", STAC_92HD71BXX_REF),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
                      "DFI LanParty", STAC_92HD71BXX_REF),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
+                     "HP dv4-1222nr", STAC_HP_DV4_1222NR),
        SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
                      "HP", STAC_HP_DV5),
        SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
@@ -2291,6 +2328,8 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
        /* SigmaTel reference board */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
                      "DFI LanParty", STAC_9205_REF),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
+                     "SigmaTel", STAC_9205_REF),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
                      "DFI LanParty", STAC_9205_REF),
        /* Dell */
@@ -2325,6 +2364,7 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
                      "Dell Vostro 1500", STAC_9205_DELL_M42),
        /* Gateway */
+       SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
        SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
        {} /* terminator */
 };
@@ -2545,7 +2585,8 @@ static int stac92xx_build_pcms(struct hda_codec *codec)
        return 0;
 }
 
-static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
+static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
+                                       hda_nid_t nid)
 {
        unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
        pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
@@ -2599,15 +2640,108 @@ static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
        return 1;
 }
 
-#define stac92xx_io_switch_info                snd_ctl_boolean_mono_info
+static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_info *uinfo)
+{
+       int i;
+       static char *texts[] = {
+               "Mic In", "Line In", "Line Out"
+       };
+
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+       hda_nid_t nid = kcontrol->private_value;
+
+       if (nid == spec->mic_switch || nid == spec->line_switch)
+               i = 3;
+       else
+               i = 2;
+
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+       uinfo->value.enumerated.items = i;
+       uinfo->count = 1;
+       if (uinfo->value.enumerated.item >= i)
+               uinfo->value.enumerated.item = i-1;
+       strcpy(uinfo->value.enumerated.name,
+               texts[uinfo->value.enumerated.item]);
+
+       return 0;
+}
+
+static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       hda_nid_t nid = kcontrol->private_value;
+       unsigned int vref = stac92xx_vref_get(codec, nid);
+
+       if (vref == stac92xx_get_default_vref(codec, nid))
+               ucontrol->value.enumerated.item[0] = 0;
+       else if (vref == AC_PINCTL_VREF_GRD)
+               ucontrol->value.enumerated.item[0] = 1;
+       else if (vref == AC_PINCTL_VREF_HIZ)
+               ucontrol->value.enumerated.item[0] = 2;
+
+       return 0;
+}
+
+static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       unsigned int new_vref = 0;
+       int error;
+       hda_nid_t nid = kcontrol->private_value;
+
+       if (ucontrol->value.enumerated.item[0] == 0)
+               new_vref = stac92xx_get_default_vref(codec, nid);
+       else if (ucontrol->value.enumerated.item[0] == 1)
+               new_vref = AC_PINCTL_VREF_GRD;
+       else if (ucontrol->value.enumerated.item[0] == 2)
+               new_vref = AC_PINCTL_VREF_HIZ;
+       else
+               return 0;
+
+       if (new_vref != stac92xx_vref_get(codec, nid)) {
+               error = stac92xx_vref_set(codec, nid, new_vref);
+               return error;
+       }
+
+       return 0;
+}
+
+static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_info *uinfo)
+{
+       static char *texts[2];
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+
+       if (kcontrol->private_value == spec->line_switch)
+               texts[0] = "Line In";
+       else
+               texts[0] = "Mic In";
+       texts[1] = "Line Out";
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+       uinfo->value.enumerated.items = 2;
+       uinfo->count = 1;
+
+       if (uinfo->value.enumerated.item >= 2)
+               uinfo->value.enumerated.item = 1;
+       strcpy(uinfo->value.enumerated.name,
+               texts[uinfo->value.enumerated.item]);
+
+       return 0;
+}
 
 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct sigmatel_spec *spec = codec->spec;
-       int io_idx = kcontrol-> private_value & 0xff;
+       hda_nid_t nid = kcontrol->private_value;
+       int io_idx = (nid == spec->mic_switch) ? 1 : 0;
 
-       ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
+       ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
        return 0;
 }
 
@@ -2615,9 +2749,9 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
 {
         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct sigmatel_spec *spec = codec->spec;
-        hda_nid_t nid = kcontrol->private_value >> 8;
-       int io_idx = kcontrol-> private_value & 0xff;
-       unsigned short val = !!ucontrol->value.integer.value[0];
+       hda_nid_t nid = kcontrol->private_value;
+       int io_idx = (nid == spec->mic_switch) ? 1 : 0;
+       unsigned short val = !!ucontrol->value.enumerated.item[0];
 
        spec->io_switch[io_idx] = val;
 
@@ -2626,7 +2760,7 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
        else {
                unsigned int pinctl = AC_PINCTL_IN_EN;
                if (io_idx) /* set VREF for mic */
-                       pinctl |= stac92xx_get_vref(codec, nid);
+                       pinctl |= stac92xx_get_default_vref(codec, nid);
                stac92xx_auto_set_pinctl(codec, nid, pinctl);
        }
 
@@ -2707,7 +2841,8 @@ enum {
        STAC_CTL_WIDGET_AMP_VOL,
        STAC_CTL_WIDGET_HP_SWITCH,
        STAC_CTL_WIDGET_IO_SWITCH,
-       STAC_CTL_WIDGET_CLFE_SWITCH
+       STAC_CTL_WIDGET_CLFE_SWITCH,
+       STAC_CTL_WIDGET_DC_BIAS
 };
 
 static struct snd_kcontrol_new stac92xx_control_templates[] = {
@@ -2719,6 +2854,7 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
        STAC_CODEC_HP_SWITCH(NULL),
        STAC_CODEC_IO_SWITCH(NULL, 0),
        STAC_CODEC_CLFE_SWITCH(NULL, 0),
+       DC_BIAS(NULL, 0, 0),
 };
 
 /* add dynamic controls */
@@ -2782,6 +2918,34 @@ static struct snd_kcontrol_new stac_input_src_temp = {
        .put = stac92xx_mux_enum_put,
 };
 
+static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
+                                               hda_nid_t nid, int idx)
+{
+       int def_conf = snd_hda_codec_get_pincfg(codec, nid);
+       int control = 0;
+       struct sigmatel_spec *spec = codec->spec;
+       char name[22];
+
+       if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
+               if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
+                       && nid == spec->line_switch)
+                       control = STAC_CTL_WIDGET_IO_SWITCH;
+               else if (snd_hda_query_pin_caps(codec, nid)
+                       & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
+                       control = STAC_CTL_WIDGET_DC_BIAS;
+               else if (nid == spec->mic_switch)
+                       control = STAC_CTL_WIDGET_IO_SWITCH;
+       }
+
+       if (control) {
+               strcpy(name, auto_pin_cfg_labels[idx]);
+               return stac92xx_add_control(codec->spec, control,
+                                       strcat(name, " Jack Mode"), nid);
+       }
+
+       return 0;
+}
+
 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
 {
        struct snd_kcontrol_new *knew;
@@ -2880,7 +3044,7 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
                                           HDA_MAX_CONNECTIONS);
        for (j = 0; j < conn_len; j++) {
                wcaps = get_wcaps(codec, conn[j]);
-               wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
+               wtype = get_wcaps_type(wcaps);
                /* we check only analog outputs */
                if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
                        continue;
@@ -3139,12 +3303,29 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
        return 0;
 }
 
+static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
+                                   unsigned long sw, int idx)
+{
+       int err;
+       err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
+                                      "Captuer Volume", vol);
+       if (err < 0)
+               return err;
+       err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
+                                      "Captuer Switch", sw);
+       if (err < 0)
+               return err;
+       return 0;
+}
+
 /* add playback controls from the parsed DAC table */
 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
                                               const struct auto_pin_cfg *cfg)
 {
        struct sigmatel_spec *spec = codec->spec;
+       hda_nid_t nid;
        int err;
+       int idx;
 
        err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
                                    spec->multiout.dac_nids,
@@ -3161,20 +3342,13 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
                        return err;
        }
 
-       if (spec->line_switch) {
-               err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
-                                          "Line In as Output Switch",
-                                          spec->line_switch << 8);
-               if (err < 0)
-                       return err;
-       }
-
-       if (spec->mic_switch) {
-               err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH,
-                                          "Mic as Output Switch",
-                                          (spec->mic_switch << 8) | 1);
-               if (err < 0)
-                       return err;
+       for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
+               nid = cfg->input_pins[idx];
+               if (nid) {
+                       err = stac92xx_add_jack_mode_control(codec, nid, idx);
+                       if (err < 0)
+                               return err;
+               }
        }
 
        return 0;
@@ -3217,7 +3391,7 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
                                spec->mono_nid,
                                con_lst,
                                HDA_MAX_NUM_INPUTS);
-       if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
+       if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
                return -EINVAL;
 
        for (i = 0; i < num_cons; i++) {
@@ -3363,7 +3537,7 @@ static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
                                spec->smux_nids[0],
                                con_lst,
                                HDA_MAX_NUM_INPUTS);
-       if (!num_cons)
+       if (num_cons <= 0)
                return -EINVAL;
 
        if (!labels)
@@ -3530,7 +3704,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
 {
        struct sigmatel_spec *spec = codec->spec;
        int hp_swap = 0;
-       int err;
+       int i, err;
 
        if ((err = snd_hda_parse_pin_def_config(codec,
                                                &spec->autocfg,
@@ -3570,11 +3744,10 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
                if (snd_hda_get_connections(codec,
                                spec->autocfg.mono_out_pin, conn_list, 1) &&
                                snd_hda_get_connections(codec, conn_list[0],
-                               conn_list, 1)) {
+                               conn_list, 1) > 0) {
 
                                int wcaps = get_wcaps(codec, conn_list[0]);
-                               int wid_type = (wcaps & AC_WCAP_TYPE)
-                                       >> AC_WCAP_TYPE_SHIFT;
+                               int wid_type = get_wcaps_type(wcaps);
                                /* LR swap check, some stac925x have a mux that
                                 * changes the DACs output path instead of the
                                 * mono-mux path.
@@ -3639,6 +3812,8 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
                err = snd_hda_attach_beep_device(codec, nid);
                if (err < 0)
                        return err;
+               /* IDT/STAC codecs have linear beep tone parameter */
+               codec->beep->linear_tone = 1;
                /* if no beep switch is available, make its own one */
                caps = query_amp_caps(codec, nid, HDA_OUTPUT);
                if (codec->beep &&
@@ -3663,6 +3838,13 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
                spec->autocfg.line_outs = 0;
        }
 
+       for (i = 0; i < spec->num_caps; i++) {
+               err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
+                                              spec->capsws[i], i);
+               if (err < 0)
+                       return err;
+       }
+
        err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
        if (err < 0)
                return err;
@@ -3861,7 +4043,7 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
                           AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
 }
 
-#ifdef CONFIG_SND_JACK
+#ifdef CONFIG_SND_HDA_INPUT_JACK
 static void stac92xx_free_jack_priv(struct snd_jack *jack)
 {
        struct sigmatel_jack *jacks = jack->private_data;
@@ -3873,7 +4055,7 @@ static void stac92xx_free_jack_priv(struct snd_jack *jack)
 static int stac92xx_add_jack(struct hda_codec *codec,
                hda_nid_t nid, int type)
 {
-#ifdef CONFIG_SND_JACK
+#ifdef CONFIG_SND_HDA_INPUT_JACK
        struct sigmatel_spec *spec = codec->spec;
        struct sigmatel_jack *jack;
        int def_conf = snd_hda_codec_get_pincfg(codec, nid);
@@ -3891,7 +4073,7 @@ static int stac92xx_add_jack(struct hda_codec *codec,
        jack->nid = nid;
        jack->type = type;
 
-       sprintf(name, "%s at %s %s Jack",
+       snprintf(name, sizeof(name), "%s at %s %s Jack",
                snd_hda_get_jack_type(def_conf),
                snd_hda_get_jack_connectivity(def_conf),
                snd_hda_get_jack_location(def_conf));
@@ -4082,7 +4264,7 @@ static int stac92xx_init(struct hda_codec *codec)
                        unsigned int pinctl, conf;
                        if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
                                /* for mic pins, force to initialize */
-                               pinctl = stac92xx_get_vref(codec, nid);
+                               pinctl = stac92xx_get_default_vref(codec, nid);
                                pinctl |= AC_PINCTL_IN_EN;
                                stac92xx_auto_set_pinctl(codec, nid, pinctl);
                        } else {
@@ -4162,7 +4344,7 @@ static int stac92xx_init(struct hda_codec *codec)
 
 static void stac92xx_free_jacks(struct hda_codec *codec)
 {
-#ifdef CONFIG_SND_JACK
+#ifdef CONFIG_SND_HDA_INPUT_JACK
        /* free jack instances manually when clearing/reconfiguring */
        struct sigmatel_spec *spec = codec->spec;
        if (!codec->bus->shutdown && spec->jacks.list) {
@@ -4535,17 +4717,19 @@ static int stac92xx_resume(struct hda_codec *codec)
        return 0;
 }
 
-
 /*
- * using power check for controlling mute led of HP HDX notebooks
+ * using power check for controlling mute led of HP notebooks
  * check for mute state only on Speakers (nid = 0x10)
  *
  * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
  * the LED is NOT working properly !
+ *
+ * Changed name to reflect that it now works for any designated
+ * model, not just HP HDX.
  */
 
 #ifdef CONFIG_SND_HDA_POWER_SAVE
-static int stac92xx_hp_hdx_check_power_status(struct hda_codec *codec,
+static int stac92xx_hp_check_power_status(struct hda_codec *codec,
                                              hda_nid_t nid)
 {
        struct sigmatel_spec *spec = codec->spec;
@@ -4553,9 +4737,9 @@ static int stac92xx_hp_hdx_check_power_status(struct hda_codec *codec,
        if (nid == 0x10) {
                if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
                    HDA_AMP_MUTE)
-                       spec->gpio_data &= ~0x08;  /* orange */
+                       spec->gpio_data &= ~spec->gpio_led; /* orange */
                else
-                       spec->gpio_data |= 0x08;   /* white */
+                       spec->gpio_data |= spec->gpio_led; /* white */
 
                stac_gpio_set(codec, spec->gpio_mask,
                              spec->gpio_dir,
@@ -4569,6 +4753,19 @@ static int stac92xx_hp_hdx_check_power_status(struct hda_codec *codec,
 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
 {
        struct sigmatel_spec *spec = codec->spec;
+       int i;
+       hda_nid_t nid;
+
+       /* reset each pin before powering down DAC/ADC to avoid click noise */
+       nid = codec->start_nid;
+       for (i = 0; i < codec->num_nodes; i++, nid++) {
+               unsigned int wcaps = get_wcaps(codec, nid);
+               unsigned int wid_type = get_wcaps_type(wcaps);
+               if (wid_type == AC_WID_PIN)
+                       snd_hda_codec_read(codec, nid, 0,
+                               AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
+       }
+
        if (spec->eapd_mask)
                stac_gpio_set(codec, spec->gpio_mask,
                                spec->gpio_dir, spec->gpio_data &
@@ -4605,7 +4802,8 @@ static int patch_stac9200(struct hda_codec *codec)
                                                        stac9200_models,
                                                        stac9200_cfg_tbl);
        if (spec->board_config < 0)
-               snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
+               snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
+                           codec->chip_name);
        else
                stac92xx_set_config_regs(codec,
                                         stac9200_brd_tbl[spec->board_config]);
@@ -4677,8 +4875,8 @@ static int patch_stac925x(struct hda_codec *codec)
                                                        stac925x_cfg_tbl);
  again:
        if (spec->board_config < 0)
-               snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
-                                     "using BIOS defaults\n");
+               snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
+                           codec->chip_name);
        else
                stac92xx_set_config_regs(codec,
                                         stac925x_brd_tbl[spec->board_config]);
@@ -4708,6 +4906,9 @@ static int patch_stac925x(struct hda_codec *codec)
 
        spec->init = stac925x_core_init;
        spec->mixer = stac925x_mixer;
+       spec->num_caps = 1;
+       spec->capvols = stac925x_capvols;
+       spec->capsws = stac925x_capsws;
 
        err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
        if (!err) {
@@ -4760,8 +4961,8 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
                                                        stac92hd73xx_cfg_tbl);
 again:
        if (spec->board_config < 0)
-               snd_printdd(KERN_INFO "hda_codec: Unknown model for"
-                       " STAC92HD73XX, using BIOS defaults\n");
+               snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
+                           codec->chip_name);
        else
                stac92xx_set_config_regs(codec,
                                stac92hd73xx_brd_tbl[spec->board_config]);
@@ -4811,6 +5012,10 @@ again:
        memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
                        sizeof(stac92hd73xx_dmux));
 
+       spec->num_caps = STAC92HD73XX_NUM_CAPS;
+       spec->capvols = stac92hd73xx_capvols;
+       spec->capsws = stac92hd73xx_capsws;
+
        switch (spec->board_config) {
        case STAC_DELL_EQ:
                spec->init = dell_eq_core_init;
@@ -4930,14 +5135,18 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
        spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
        spec->dinput_mux = &stac92hd83xxx_dmux;
        spec->pin_nids = stac92hd83xxx_pin_nids;
+       spec->num_caps = STAC92HD83XXX_NUM_CAPS;
+       spec->capvols = stac92hd83xxx_capvols;
+       spec->capsws = stac92hd83xxx_capsws;
+
        spec->board_config = snd_hda_check_board_config(codec,
                                                        STAC_92HD83XXX_MODELS,
                                                        stac92hd83xxx_models,
                                                        stac92hd83xxx_cfg_tbl);
 again:
        if (spec->board_config < 0)
-               snd_printdd(KERN_INFO "hda_codec: Unknown model for"
-                       " STAC92HD83XXX, using BIOS defaults\n");
+               snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
+                           codec->chip_name);
        else
                stac92xx_set_config_regs(codec,
                                stac92hd83xxx_brd_tbl[spec->board_config]);
@@ -4979,6 +5188,8 @@ again:
 
        num_dacs = snd_hda_get_connections(codec, nid,
                                conn, STAC92HD83_DAC_COUNT + 1) - 1;
+       if (num_dacs < 0)
+               num_dacs = STAC92HD83_DAC_COUNT;
 
        /* set port X to select the last DAC
         */
@@ -5100,8 +5311,8 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
                                                        stac92hd71bxx_cfg_tbl);
 again:
        if (spec->board_config < 0)
-               snd_printdd(KERN_INFO "hda_codec: Unknown model for"
-                       " STAC92HD71BXX, using BIOS defaults\n");
+               snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
+                           codec->chip_name);
        else
                stac92xx_set_config_regs(codec,
                                stac92hd71bxx_brd_tbl[spec->board_config]);
@@ -5116,6 +5327,10 @@ again:
        spec->dmic_nids = stac92hd71bxx_dmic_nids;
        spec->dmux_nids = stac92hd71bxx_dmux_nids;
 
+       spec->num_caps = STAC92HD71BXX_NUM_CAPS;
+       spec->capvols = stac92hd71bxx_capvols;
+       spec->capsws = stac92hd71bxx_capsws;
+
        switch (codec->vendor_id) {
        case 0x111d76b6: /* 4 Port without Analog Mixer */
        case 0x111d76b7:
@@ -5125,7 +5340,6 @@ again:
        case 0x111d76b5:
                memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
                       sizeof(stac92hd71bxx_dmux_nomixer));
-               spec->mixer = stac92hd71bxx_mixer;
                spec->init = stac92hd71bxx_core_init;
                codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
                spec->num_dmics = stac92hd71bxx_connected_ports(codec,
@@ -5163,7 +5377,6 @@ again:
                /* no output amps */
                spec->num_pwrs = 0;
                spec->mixer = stac92hd71bxx_analog_mixer;
-               spec->dinput_mux = &spec->private_dimux;
 
                /* disable VSW */
                spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
@@ -5174,8 +5387,11 @@ again:
                spec->num_dmics = stac92hd71bxx_connected_ports(codec,
                                        stac92hd71bxx_dmic_nids,
                                        STAC92HD71BXX_NUM_DMICS - 1);
-               spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
-               ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
+               if (spec->num_dmics) {
+                       spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
+                       spec->dinput_mux = &spec->private_dimux;
+                       ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
+               }
                break;
        case 0x111d7603: /* 6 Port with Analog Mixer */
                if ((codec->revision_id & 0xf) == 1)
@@ -5187,20 +5403,31 @@ again:
        default:
                memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
                       sizeof(stac92hd71bxx_dmux_amixer));
-               spec->dinput_mux = &spec->private_dimux;
                spec->mixer = stac92hd71bxx_analog_mixer;
                spec->init = stac92hd71bxx_analog_core_init;
                codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
                spec->num_dmics = stac92hd71bxx_connected_ports(codec,
                                        stac92hd71bxx_dmic_nids,
                                        STAC92HD71BXX_NUM_DMICS);
-               spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
-               ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
+               if (spec->num_dmics) {
+                       spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
+                       spec->dinput_mux = &spec->private_dimux;
+                       ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
+               }
        }
 
        if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
                snd_hda_sequence_write_cache(codec, unmute_init);
 
+       /* Some HP machines seem to have unstable codec communications
+        * especially with ATI fglrx driver.  For recovering from the
+        * CORB/RIRB stall, allow the BUS reset and keep always sync
+        */
+       if (spec->board_config == STAC_HP_DV5) {
+               codec->bus->sync_write = 1;
+               codec->bus->allow_bus_reset = 1;
+       }
+
        spec->aloopback_ctl = stac92hd71bxx_loopback;
        spec->aloopback_mask = 0x50;
        spec->aloopback_shift = 0;
@@ -5234,6 +5461,15 @@ again:
                spec->num_smuxes = 0;
                spec->num_dmuxes = 1;
                break;
+       case STAC_HP_DV4_1222NR:
+               spec->num_dmics = 1;
+               /* I don't know if it needs 1 or 2 smuxes - will wait for
+                * bug reports to fix if needed
+                */
+               spec->num_smuxes = 1;
+               spec->num_dmuxes = 1;
+               spec->gpio_led = 0x01;
+               /* fallthrough */
        case STAC_HP_DV5:
                snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
                stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
@@ -5242,22 +5478,21 @@ again:
                spec->num_dmics = 1;
                spec->num_dmuxes = 1;
                spec->num_smuxes = 1;
-               /*
-                * For controlling MUTE LED on HP HDX16/HDX18 notebooks,
-                * the CONFIG_SND_HDA_POWER_SAVE is needed to be set.
-                */
-#ifdef CONFIG_SND_HDA_POWER_SAVE
                /* orange/white mute led on GPIO3, orange=0, white=1 */
-               spec->gpio_mask |= 0x08;
-               spec->gpio_dir  |= 0x08;
-               spec->gpio_data |= 0x08;  /* set to white */
+               spec->gpio_led = 0x08;
+               break;
+       }
 
+#ifdef CONFIG_SND_HDA_POWER_SAVE
+       if (spec->gpio_led) {
+               spec->gpio_mask |= spec->gpio_led;
+               spec->gpio_dir |= spec->gpio_led;
+               spec->gpio_data |= spec->gpio_led;
                /* register check_power_status callback. */
                codec->patch_ops.check_power_status =
-                   stac92xx_hp_hdx_check_power_status;
+                       stac92xx_hp_check_power_status;
+       }
 #endif 
-               break;
-       };
 
        spec->multiout.dac_nids = spec->dac_nids;
        if (spec->dinput_mux)
@@ -5282,7 +5517,7 @@ again:
        codec->proc_widget_hook = stac92hd7x_proc_hook;
 
        return 0;
-};
+}
 
 static int patch_stac922x(struct hda_codec *codec)
 {
@@ -5339,8 +5574,8 @@ static int patch_stac922x(struct hda_codec *codec)
 
  again:
        if (spec->board_config < 0)
-               snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
-                       "using BIOS defaults\n");
+               snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
+                           codec->chip_name);
        else
                stac92xx_set_config_regs(codec,
                                stac922x_brd_tbl[spec->board_config]);
@@ -5353,7 +5588,10 @@ static int patch_stac922x(struct hda_codec *codec)
        spec->num_pwrs = 0;
 
        spec->init = stac922x_core_init;
-       spec->mixer = stac922x_mixer;
+
+       spec->num_caps = STAC922X_NUM_CAPS;
+       spec->capvols = stac922x_capvols;
+       spec->capsws = stac922x_capsws;
 
        spec->multiout.dac_nids = spec->dac_nids;
        
@@ -5402,8 +5640,8 @@ static int patch_stac927x(struct hda_codec *codec)
                                                        stac927x_cfg_tbl);
  again:
        if (spec->board_config < 0)
-               snd_printdd(KERN_INFO "hda_codec: Unknown model for"
-                           "STAC927x, using BIOS defaults\n");
+               snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
+                           codec->chip_name);
        else
                stac92xx_set_config_regs(codec,
                                stac927x_brd_tbl[spec->board_config]);
@@ -5428,7 +5666,6 @@ static int patch_stac927x(struct hda_codec *codec)
                spec->num_dmics = 0;
 
                spec->init = d965_core_init;
-               spec->mixer = stac927x_mixer;
                break;
        case STAC_DELL_BIOS:
                switch (codec->subsystem_id) {
@@ -5437,7 +5674,7 @@ static int patch_stac927x(struct hda_codec *codec)
                        /* correct the device field to SPDIF out */
                        snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
                        break;
-               };
+               }
                /* configure the analog microphone on some laptops */
                snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
                /* correct the front output jack as a hp out */
@@ -5453,7 +5690,6 @@ static int patch_stac927x(struct hda_codec *codec)
                spec->num_dmics = STAC927X_NUM_DMICS;
 
                spec->init = d965_core_init;
-               spec->mixer = stac927x_mixer;
                spec->dmux_nids = stac927x_dmux_nids;
                spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
                break;
@@ -5466,9 +5702,12 @@ static int patch_stac927x(struct hda_codec *codec)
                spec->num_dmics = 0;
 
                spec->init = stac927x_core_init;
-               spec->mixer = stac927x_mixer;
        }
 
+       spec->num_caps = STAC927X_NUM_CAPS;
+       spec->capvols = stac927x_capvols;
+       spec->capsws = stac927x_capsws;
+
        spec->num_pwrs = 0;
        spec->aloopback_ctl = stac927x_loopback;
        spec->aloopback_mask = 0x40;
@@ -5530,7 +5769,8 @@ static int patch_stac9205(struct hda_codec *codec)
                                                        stac9205_cfg_tbl);
  again:
        if (spec->board_config < 0)
-               snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
+               snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
+                           codec->chip_name);
        else
                stac92xx_set_config_regs(codec,
                                         stac9205_brd_tbl[spec->board_config]);
@@ -5549,9 +5789,12 @@ static int patch_stac9205(struct hda_codec *codec)
        spec->num_pwrs = 0;
 
        spec->init = stac9205_core_init;
-       spec->mixer = stac9205_mixer;
        spec->aloopback_ctl = stac9205_loopback;
 
+       spec->num_caps = STAC9205_NUM_CAPS;
+       spec->capvols = stac9205_capvols;
+       spec->capsws = stac9205_capsws;
+
        spec->aloopback_mask = 0x40;
        spec->aloopback_shift = 0;
        /* Turn on/off EAPD per HP plugging */
@@ -5626,12 +5869,6 @@ static struct hda_verb stac9872_core_init[] = {
        {}
 };
 
-static struct snd_kcontrol_new stac9872_mixer[] = {
-       HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
-       HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
-       { } /* end */
-};
-
 static hda_nid_t stac9872_pin_nids[] = {
        0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
        0x11, 0x13, 0x14,
@@ -5645,6 +5882,11 @@ static hda_nid_t stac9872_mux_nids[] = {
        0x15
 };
 
+static unsigned long stac9872_capvols[] = {
+       HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
+};
+#define stac9872_capsws                stac9872_capvols
+
 static unsigned int stac9872_vaio_pin_configs[9] = {
        0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
        0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
@@ -5661,6 +5903,8 @@ static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
 };
 
 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
+       SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
+                          "Sony VAIO F/S", STAC_9872_VAIO),
        {} /* terminator */
 };
 
@@ -5673,26 +5917,28 @@ static int patch_stac9872(struct hda_codec *codec)
        if (spec == NULL)
                return -ENOMEM;
        codec->spec = spec;
+       spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
+       spec->pin_nids = stac9872_pin_nids;
 
        spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
                                                        stac9872_models,
                                                        stac9872_cfg_tbl);
        if (spec->board_config < 0)
-               snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, "
-                           "using BIOS defaults\n");
+               snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
+                           codec->chip_name);
        else
                stac92xx_set_config_regs(codec,
                                         stac9872_brd_tbl[spec->board_config]);
 
-       spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
-       spec->pin_nids = stac9872_pin_nids;
        spec->multiout.dac_nids = spec->dac_nids;
        spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
        spec->adc_nids = stac9872_adc_nids;
        spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
        spec->mux_nids = stac9872_mux_nids;
-       spec->mixer = stac9872_mixer;
        spec->init = stac9872_core_init;
+       spec->num_caps = 1;
+       spec->capvols = stac9872_capvols;
+       spec->capsws = stac9872_capsws;
 
        err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
        if (err < 0) {
@@ -5747,6 +5993,7 @@ static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
        { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
        { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
        { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
+       { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
        { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
        { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
        { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },