]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - sound/pci/hda/patch_sigmatel.c
ALSA: hda - Add missing terminators in patch_sigmatel.c
[linux-2.6.git] / sound / pci / hda / patch_sigmatel.c
index e1d61a035bab6fdae5d2d7091144f9b506401f0e..b77f330d2650b7c13d23d1d0f84d9344d973940a 100644 (file)
 #include <sound/asoundef.h>
 #include "hda_codec.h"
 #include "hda_local.h"
+#include "hda_patch.h"
+#include "hda_beep.h"
 
 #define NUM_CONTROL_ALLOC      32
+
+#define STAC_VREF_EVENT                0x00
+#define STAC_INSERT_EVENT      0x10
 #define STAC_PWR_EVENT         0x20
 #define STAC_HP_EVENT          0x30
 
@@ -51,6 +56,7 @@ enum {
        STAC_9200_DELL_M26,
        STAC_9200_DELL_M27,
        STAC_9200_GATEWAY,
+       STAC_9200_PANASONIC,
        STAC_9200_MODELS
 };
 
@@ -63,15 +69,26 @@ enum {
 };
 
 enum {
+       STAC_92HD73XX_NO_JD, /* no jack-detection */
        STAC_92HD73XX_REF,
-       STAC_DELL_M6,
+       STAC_DELL_M6_AMIC,
+       STAC_DELL_M6_DMIC,
+       STAC_DELL_M6_BOTH,
+       STAC_DELL_EQ,
        STAC_92HD73XX_MODELS
 };
 
+enum {
+       STAC_92HD83XXX_REF,
+       STAC_92HD83XXX_MODELS
+};
+
 enum {
        STAC_92HD71BXX_REF,
        STAC_DELL_M4_1,
        STAC_DELL_M4_2,
+       STAC_DELL_M4_3,
+       STAC_HP_M4,
        STAC_92HD71BXX_MODELS
 };
 
@@ -92,6 +109,9 @@ enum {
        STAC_INTEL_MAC_V3,
        STAC_INTEL_MAC_V4,
        STAC_INTEL_MAC_V5,
+       STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
+                             * is given, one of the above models will be
+                             * chosen according to the subsystem id. */
        /* for backward compatibility */
        STAC_MACMINI,
        STAC_MACBOOK,
@@ -99,6 +119,7 @@ enum {
        STAC_MACBOOK_PRO_V2,
        STAC_IMAC_INTEL,
        STAC_IMAC_INTEL_20,
+       STAC_ECS_202,
        STAC_922X_DELL_D81,
        STAC_922X_DELL_D82,
        STAC_922X_DELL_M81,
@@ -107,6 +128,7 @@ enum {
 };
 
 enum {
+       STAC_D965_REF_NO_JD, /* no jack-detection */
        STAC_D965_REF,
        STAC_D965_3ST,
        STAC_D965_5ST,
@@ -120,29 +142,37 @@ struct sigmatel_spec {
        unsigned int num_mixers;
 
        int board_config;
+       unsigned int eapd_switch: 1;
        unsigned int surr_switch: 1;
        unsigned int line_switch: 1;
        unsigned int mic_switch: 1;
        unsigned int alt_switch: 1;
        unsigned int hp_detect: 1;
+       unsigned int spdif_mute: 1;
 
        /* gpio lines */
+       unsigned int eapd_mask;
        unsigned int gpio_mask;
        unsigned int gpio_dir;
        unsigned int gpio_data;
        unsigned int gpio_mute;
 
+       /* stream */
+       unsigned int stream_delay;
+
        /* analog loopback */
        unsigned char aloopback_mask;
        unsigned char aloopback_shift;
 
        /* power management */
        unsigned int num_pwrs;
+       unsigned int *pwr_mapping;
        hda_nid_t *pwr_nids;
        hda_nid_t *dac_list;
 
        /* playback */
        struct hda_input_mux *mono_mux;
+       struct hda_input_mux *amp_mux;
        unsigned int cur_mmux;
        struct hda_multi_out multiout;
        hda_nid_t dac_nids[5];
@@ -156,8 +186,14 @@ struct sigmatel_spec {
        unsigned int num_dmics;
        hda_nid_t *dmux_nids;
        unsigned int num_dmuxes;
+       hda_nid_t *smux_nids;
+       unsigned int num_smuxes;
+       const char **spdif_labels;
+
        hda_nid_t dig_in_nid;
        hda_nid_t mono_nid;
+       hda_nid_t anabeep_nid;
+       hda_nid_t digbeep_nid;
 
        /* pin widgets */
        hda_nid_t *pin_nids;
@@ -174,10 +210,17 @@ struct sigmatel_spec {
        unsigned int cur_dmux[2];
        struct hda_input_mux *input_mux;
        unsigned int cur_mux[3];
+       struct hda_input_mux *sinput_mux;
+       unsigned int cur_smux[2];
+       unsigned int cur_amux;
+       hda_nid_t *amp_nids;
+       unsigned int num_amps;
+       unsigned int powerdown_adcs;
 
        /* i/o switches */
        unsigned int io_switch[2];
        unsigned int clfe_swap;
+       unsigned int hp_switch; /* NID of HP as line-out */
        unsigned int aloopback;
 
        struct hda_pcm pcm_rec[2];      /* PCM information */
@@ -188,6 +231,8 @@ struct sigmatel_spec {
        struct snd_kcontrol_new *kctl_alloc;
        struct hda_input_mux private_dimux;
        struct hda_input_mux private_imux;
+       struct hda_input_mux private_smux;
+       struct hda_input_mux private_amp_mux;
        struct hda_input_mux private_mono_mux;
 };
 
@@ -208,10 +253,19 @@ static hda_nid_t stac92hd73xx_pwr_nids[8] = {
        0x0f, 0x10, 0x11
 };
 
+static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
+       0x26, 0,
+};
+
 static hda_nid_t stac92hd73xx_adc_nids[2] = {
        0x1a, 0x1b
 };
 
+#define DELL_M6_AMP 2
+static hda_nid_t stac92hd73xx_amp_nids[3] = {
+       0x0b, 0x0c, 0x0e
+};
+
 #define STAC92HD73XX_NUM_DMICS 2
 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
        0x13, 0x14, 0
@@ -230,6 +284,41 @@ static hda_nid_t stac92hd73xx_dmux_nids[2] = {
        0x20, 0x21,
 };
 
+static hda_nid_t stac92hd73xx_smux_nids[2] = {
+       0x22, 0x23,
+};
+
+#define STAC92HD83XXX_NUM_DMICS        2
+static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
+       0x11, 0x12, 0
+};
+
+#define STAC92HD81_DAC_COUNT 2
+#define STAC92HD83_DAC_COUNT 3
+static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
+       0x13, 0x14, 0x22,
+};
+
+static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
+       0x17, 0x18,
+};
+
+static hda_nid_t stac92hd83xxx_adc_nids[2] = {
+       0x15, 0x16,
+};
+
+static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
+       0xa, 0xb, 0xd, 0xe,
+};
+
+static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
+       0x1e, 0,
+};
+
+static unsigned int stac92hd83xxx_pwr_mapping[4] = {
+       0x03, 0x0c, 0x10, 0x40,
+};
+
 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
        0x0a, 0x0d, 0x0f
 };
@@ -242,8 +331,12 @@ static hda_nid_t stac92hd71bxx_mux_nids[2] = {
        0x1a, 0x1b
 };
 
-static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
-       0x1c,
+static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
+       0x1c, 0x1d,
+};
+
+static hda_nid_t stac92hd71bxx_smux_nids[2] = {
+       0x24, 0x25,
 };
 
 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
@@ -255,6 +348,10 @@ static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
        0x18, 0x19, 0
 };
 
+static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
+       0x22, 0
+};
+
 static hda_nid_t stac925x_adc_nids[1] = {
         0x03,
 };
@@ -292,6 +389,10 @@ static hda_nid_t stac927x_mux_nids[3] = {
         0x15, 0x16, 0x17
 };
 
+static hda_nid_t stac927x_smux_nids[1] = {
+       0x21,
+};
+
 static hda_nid_t stac927x_dac_nids[6] = {
        0x02, 0x03, 0x04, 0x05, 0x06, 0
 };
@@ -305,6 +406,11 @@ static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
        0x13, 0x14, 0
 };
 
+static const char *stac927x_spdif_labels[5] = {
+       "Digital Playback", "ADAT", "Analog Mux 1",
+       "Analog Mux 2", "Analog Mux 3"
+};
+
 static hda_nid_t stac9205_adc_nids[2] = {
         0x12, 0x13
 };
@@ -317,6 +423,10 @@ static hda_nid_t stac9205_dmux_nids[1] = {
        0x1d,
 };
 
+static hda_nid_t stac9205_smux_nids[1] = {
+       0x21,
+};
+
 #define STAC9205_NUM_DMICS     2
 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
         0x17, 0x18, 0
@@ -340,12 +450,18 @@ static hda_nid_t stac922x_pin_nids[10] = {
 static hda_nid_t stac92hd73xx_pin_nids[13] = {
        0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
        0x0f, 0x10, 0x11, 0x12, 0x13,
-       0x14, 0x1e, 0x22
+       0x14, 0x22, 0x23
 };
 
-static hda_nid_t stac92hd71bxx_pin_nids[10] = {
+static hda_nid_t stac92hd83xxx_pin_nids[14] = {
+       0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
+       0x0f, 0x10, 0x11, 0x12, 0x13,
+       0x1d, 0x1e, 0x1f, 0x20
+};
+static hda_nid_t stac92hd71bxx_pin_nids[11] = {
        0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
        0x0f, 0x14, 0x18, 0x19, 0x1e,
+       0x1f,
 };
 
 static hda_nid_t stac927x_pin_nids[14] = {
@@ -360,6 +476,34 @@ static hda_nid_t stac9205_pin_nids[12] = {
        0x21, 0x22,
 };
 
+#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
+
+static int stac92xx_amp_volume_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;
+       hda_nid_t nid = spec->amp_nids[spec->cur_amux];
+
+       kcontrol->private_value ^= get_amp_nid(kcontrol);
+       kcontrol->private_value |= nid;
+
+       return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
+}
+
+static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+       hda_nid_t nid = spec->amp_nids[spec->cur_amux];
+
+       kcontrol->private_value ^= get_amp_nid(kcontrol);
+       kcontrol->private_value |= nid;
+
+       return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
+}
+
 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
                                   struct snd_ctl_elem_info *uinfo)
 {
@@ -390,6 +534,56 @@ static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
                        spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
 }
 
+static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
+                                  struct snd_ctl_elem_info *uinfo)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+       return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
+}
+
+static int stac92xx_smux_enum_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;
+       unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+
+       ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
+       return 0;
+}
+
+static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+       struct hda_input_mux *smux = &spec->private_smux;
+       unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
+       int err, val;
+       hda_nid_t nid;
+
+       err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
+                       spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
+       if (err < 0)
+               return err;
+
+       if (spec->spdif_mute) {
+               if (smux_idx == 0)
+                       nid = spec->multiout.dig_out_nid;
+               else
+                       nid = codec->slave_dig_outs[smux_idx - 1];
+               if (spec->cur_smux[smux_idx] == smux->num_items - 1)
+                       val = AMP_OUT_MUTE;
+               else
+                       val = AMP_OUT_UNMUTE;
+               /* un/mute SPDIF out */
+               snd_hda_codec_write_cache(codec, nid, 0,
+                       AC_VERB_SET_AMP_GAIN_MUTE, val);
+       }
+       return 0;
+}
+
 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
@@ -445,6 +639,41 @@ static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
                                     spec->mono_nid, &spec->cur_mmux);
 }
 
+static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_info *uinfo)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+       return snd_hda_input_mux_info(spec->amp_mux, uinfo);
+}
+
+static int stac92xx_amp_mux_enum_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;
+
+       ucontrol->value.enumerated.item[0] = spec->cur_amux;
+       return 0;
+}
+
+static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
+       struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct sigmatel_spec *spec = codec->spec;
+       struct snd_kcontrol *ctl =
+               snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
+       if (!ctl)
+               return -EINVAL;
+
+       snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
+               SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
+
+       return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
+                                    0, &spec->cur_amux);
+}
+
 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
 
 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
@@ -533,6 +762,42 @@ static struct hda_verb stac92hd73xx_6ch_core_init[] = {
        {}
 };
 
+static struct hda_verb dell_eq_core_init[] = {
+       /* set master volume to max value without distortion
+        * and direct control */
+       { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
+       /* setup audio connections */
+       { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
+       { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
+       /* setup adcs to point to mixer */
+       { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
+       { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
+       /* setup import muxs */
+       { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {}
+};
+
+static struct hda_verb dell_m6_core_init[] = {
+       { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
+       /* setup audio connections */
+       { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
+       { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
+       /* setup adcs to point to mixer */
+       { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
+       { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
+       /* setup import muxs */
+       { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
+       { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {}
+};
+
 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
        /* set master volume and direct control */
        { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
@@ -583,33 +848,49 @@ static struct hda_verb stac92hd73xx_10ch_core_init[] = {
        {}
 };
 
+static struct hda_verb stac92hd83xxx_core_init[] = {
+       /* start of config #1 */
+       { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
+
+       /* start of config #2 */
+       { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
+       { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
+       { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
+
+       /* power state controls amps */
+       { 0x01, AC_VERB_SET_EAPD, 1 << 2},
+       {}
+};
+
 static struct hda_verb stac92hd71bxx_core_init[] = {
        /* set master volume and direct control */
        { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
        /* connect headphone jack to dac1 */
        { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
-       { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
        /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
        { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {}
 };
 
+#define HD_DISABLE_PORTF 2
 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
+       /* start of config #1 */
+
+       /* connect port 0f to audio mixer */
+       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
+       /* unmute right and left channels for node 0x0f */
+       { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       /* start of config #2 */
+
        /* set master volume and direct control */
        { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
        /* connect headphone jack to dac1 */
        { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
-       /* connect ports 0d and 0f to audio mixer */
-       { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
-       { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
-       { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
-       /* unmute dac0 input in audio mixer */
-       { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
-       /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
+       /* unmute right and left channels for nodes 0x0a, 0xd */
        { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
-       { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        {}
 };
 
@@ -638,12 +919,16 @@ static struct hda_verb d965_core_init[] = {
 static struct hda_verb stac927x_core_init[] = {
        /* set master volume and direct control */      
        { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
+       /* enable analog pc beep path */
+       { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
        {}
 };
 
 static struct hda_verb stac9205_core_init[] = {
        /* set master volume and direct control */      
        { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
+       /* enable analog pc beep path */
+       { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
        {}
 };
 
@@ -657,6 +942,31 @@ static struct hda_verb stac9205_core_init[] = {
                .put = stac92xx_mono_mux_enum_put, \
        }
 
+#define STAC_AMP_MUX \
+       { \
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+               .name = "Amp Selector Capture Switch", \
+               .count = 1, \
+               .info = stac92xx_amp_mux_enum_info, \
+               .get = stac92xx_amp_mux_enum_get, \
+               .put = stac92xx_amp_mux_enum_put, \
+       }
+
+#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
+       { \
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+               .name = xname, \
+               .index = 0, \
+               .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
+                       SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
+                       SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
+               .info = stac92xx_amp_volume_info, \
+               .get = stac92xx_amp_volume_get, \
+               .put = stac92xx_amp_volume_put, \
+               .tlv = { .c = snd_hda_mixer_amp_tlv }, \
+               .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
+       }
+
 #define STAC_INPUT_SOURCE(cnt) \
        { \
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -684,33 +994,36 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
        STAC_INPUT_SOURCE(1),
        HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
-       HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
        { } /* end */
 };
 
+#define DELL_M6_MIXER 6
 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
-       STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
-
-       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),
-
+       /* start of config #1 */
        HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
 
-       HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
-       HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
-
        HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
        HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
 
+       HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
+       HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
+
+       /* start of config #2 */
+       HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
+
        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("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
-       HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
+       STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
+
+       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 */
 };
 
@@ -766,19 +1079,59 @@ static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
        { } /* end */
 };
 
+
+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, 0, HDA_INPUT),
+       HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
+       HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
+       HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
+
+       HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
+       HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
+
+       /*
+       HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
+       */
+       { } /* end */
+};
+
 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
        STAC_INPUT_SOURCE(2),
+       STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
 
        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 Mux Volume", 0x0, 0x1a, 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),
-       HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 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),
 
-       HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
-       HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
+       HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
+       HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
+
+       HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
+       HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
+
+       HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
+       HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
        { } /* end */
 };
 
@@ -788,19 +1141,16 @@ 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 Mux Volume", 0x0, 0x1a, 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),
-       HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
        { } /* end */
 };
 
 static struct snd_kcontrol_new stac925x_mixer[] = {
        STAC_INPUT_SOURCE(1),
        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
-       HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
-       HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
        { } /* end */
 };
 
@@ -810,12 +1160,9 @@ 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("Mux Capture Volume", 0x0, 0x19, 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),
-       HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
-
        { } /* end */
 };
 
@@ -824,11 +1171,9 @@ static struct snd_kcontrol_new stac922x_mixer[] = {
        STAC_INPUT_SOURCE(2),
        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("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
 
        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
        HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
-       HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
        { } /* end */
 };
 
@@ -839,15 +1184,12 @@ 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("Mux Capture Volume", 0x0, 0x15, 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("Mux Capture Volume", 0x1, 0x16, 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),
-       HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
        { } /* end */
 };
 
@@ -860,6 +1202,15 @@ static struct snd_kcontrol_new stac_dmux_mixer = {
        .put = stac92xx_dmux_enum_put,
 };
 
+static struct snd_kcontrol_new stac_smux_mixer = {
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .name = "IEC958 Playback Source",
+       /* count set later */
+       .info = stac92xx_smux_enum_info,
+       .get = stac92xx_smux_enum_get,
+       .put = stac92xx_smux_enum_put,
+};
+
 static const char *slave_vols[] = {
        "Front Playback Volume",
        "Surround Playback Volume",
@@ -911,6 +1262,22 @@ static int stac92xx_build_controls(struct hda_codec *codec)
                if (err < 0)
                        return err;
        }
+       if (spec->num_smuxes > 0) {
+               int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
+               struct hda_input_mux *smux = &spec->private_smux;
+               /* check for mute support on SPDIF out */
+               if (wcaps & AC_WCAP_OUT_AMP) {
+                       smux->items[smux->num_items].label = "Off";
+                       smux->items[smux->num_items].index = 0;
+                       smux->num_items++;
+                       spec->spdif_mute = 1;
+               }
+               stac_smux_mixer.count = spec->num_smuxes;
+               err = snd_ctl_add(codec->bus->card,
+                                 snd_ctl_new1(&stac_smux_mixer, codec));
+               if (err < 0)
+                       return err;
+       }
 
        if (spec->multiout.dig_out_nid) {
                err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
@@ -922,7 +1289,7 @@ static int stac92xx_build_controls(struct hda_codec *codec)
                        return err;
                spec->multiout.share_spdif = 1;
        }
-       if (spec->dig_in_nid) {
+       if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
                err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
                if (err < 0)
                        return err;
@@ -1083,6 +1450,7 @@ static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
        [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
        [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
        [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
+       [STAC_9200_PANASONIC] = ref9200_pin_configs,
 };
 
 static const char *stac9200_models[STAC_9200_MODELS] = {
@@ -1099,6 +1467,7 @@ static const char *stac9200_models[STAC_9200_MODELS] = {
        [STAC_9200_DELL_M26] = "dell-m26",
        [STAC_9200_DELL_M27] = "dell-m27",
        [STAC_9200_GATEWAY] = "gateway",
+       [STAC_9200_PANASONIC] = "panasonic",
 };
 
 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
@@ -1165,7 +1534,7 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
                      "unknown Dell", STAC_9200_DELL_M26),
        /* Panasonic */
-       SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
+       SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
        /* Gateway machines needs EAPD to be set on resume */
        SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
        SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
@@ -1232,19 +1601,26 @@ static unsigned int ref92hd73xx_pin_configs[13] = {
 
 static unsigned int dell_m6_pin_configs[13] = {
        0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
-       0x03a11020, 0x03011050, 0x4f0000f0, 0x4f0000f0,
+       0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
        0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
        0x4f0000f0,
 };
 
 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
        [STAC_92HD73XX_REF]     = ref92hd73xx_pin_configs,
-       [STAC_DELL_M6]  = dell_m6_pin_configs,
+       [STAC_DELL_M6_AMIC]     = dell_m6_pin_configs,
+       [STAC_DELL_M6_DMIC]     = dell_m6_pin_configs,
+       [STAC_DELL_M6_BOTH]     = dell_m6_pin_configs,
+       [STAC_DELL_EQ]  = dell_m6_pin_configs,
 };
 
 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
+       [STAC_92HD73XX_NO_JD] = "no-jd",
        [STAC_92HD73XX_REF] = "ref",
-       [STAC_DELL_M6] = "dell-m6",
+       [STAC_DELL_M6_AMIC] = "dell-m6-amic",
+       [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
+       [STAC_DELL_M6_BOTH] = "dell-m6",
+       [STAC_DELL_EQ] = "dell-eq",
 };
 
 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
@@ -1252,56 +1628,100 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
                                "DFI LanParty", STAC_92HD73XX_REF),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
-                               "unknown Dell", STAC_DELL_M6),
+                               "Dell Studio 1535", STAC_DELL_M6_DMIC),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
-                               "unknown Dell", STAC_DELL_M6),
+                               "unknown Dell", STAC_DELL_M6_DMIC),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
-                               "unknown Dell", STAC_DELL_M6),
+                               "unknown Dell", STAC_DELL_M6_BOTH),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
-                               "unknown Dell", STAC_DELL_M6),
+                               "unknown Dell", STAC_DELL_M6_BOTH),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
-                               "unknown Dell", STAC_DELL_M6),
+                               "unknown Dell", STAC_DELL_M6_AMIC),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
-                               "unknown Dell", STAC_DELL_M6),
+                               "unknown Dell", STAC_DELL_M6_AMIC),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
-                               "unknown Dell", STAC_DELL_M6),
+                               "unknown Dell", STAC_DELL_M6_DMIC),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
+                               "unknown Dell", STAC_DELL_M6_DMIC),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
+                               "Dell Studio 1537", STAC_DELL_M6_DMIC),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
+                               "Dell Studio 17", STAC_DELL_M6_DMIC),
+       {} /* terminator */
+};
+
+static unsigned int ref92hd83xxx_pin_configs[14] = {
+       0x02214030, 0x02211010, 0x02a19020, 0x02170130,
+       0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
+       0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
+       0x01451160, 0x98560170,
+};
+
+static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
+       [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
+};
+
+static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
+       [STAC_92HD83XXX_REF] = "ref",
+};
+
+static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
+       /* SigmaTel reference board */
+       SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
+                     "DFI LanParty", STAC_92HD71BXX_REF),
        {} /* terminator */
 };
 
-static unsigned int ref92hd71bxx_pin_configs[10] = {
+static unsigned int ref92hd71bxx_pin_configs[11] = {
        0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
-       0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
-       0x90a000f0, 0x01452050,
+       0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
+       0x90a000f0, 0x01452050, 0x01452050,
 };
 
-static unsigned int dell_m4_1_pin_configs[13] = {
+static unsigned int dell_m4_1_pin_configs[11] = {
        0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
-       0x23a1902e, 0x23014250, 0x40f000f0, 0x4f0000f0,
-       0x40f000f0, 0x4f0000f0,
+       0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
+       0x40f000f0, 0x4f0000f0, 0x4f0000f0,
 };
 
-static unsigned int dell_m4_2_pin_configs[13] = {
+static unsigned int dell_m4_2_pin_configs[11] = {
        0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
        0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
-       0x40f000f0, 0x044413b0,
+       0x40f000f0, 0x044413b0, 0x044413b0,
+};
+
+static unsigned int dell_m4_3_pin_configs[11] = {
+       0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
+       0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
+       0x40f000f0, 0x044413b0, 0x044413b0,
 };
 
 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
        [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
        [STAC_DELL_M4_1]        = dell_m4_1_pin_configs,
        [STAC_DELL_M4_2]        = dell_m4_2_pin_configs,
+       [STAC_DELL_M4_3]        = dell_m4_3_pin_configs,
+       [STAC_HP_M4]            = NULL,
 };
 
 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
        [STAC_92HD71BXX_REF] = "ref",
        [STAC_DELL_M4_1] = "dell-m4-1",
        [STAC_DELL_M4_2] = "dell-m4-2",
+       [STAC_DELL_M4_3] = "dell-m4-3",
+       [STAC_HP_M4] = "hp-m4",
 };
 
 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
        /* SigmaTel reference board */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
                      "DFI LanParty", STAC_92HD71BXX_REF),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
+                     "HP dv5", STAC_HP_M4),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
+                     "HP dv7", STAC_HP_M4),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
+                               "unknown HP", STAC_HP_M4),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
                                "unknown Dell", STAC_DELL_M4_1),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
@@ -1324,6 +1744,8 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
                                "unknown Dell", STAC_DELL_M4_2),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
                                "unknown Dell", STAC_DELL_M4_2),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
+                               "unknown Dell", STAC_DELL_M4_3),
        {} /* terminator */
 };
 
@@ -1420,6 +1842,11 @@ static unsigned int intel_mac_v5_pin_configs[10] = {
        0x400000fc, 0x400000fb,
 };
 
+static unsigned int ecs202_pin_configs[10] = {
+       0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
+       0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
+       0x9037012e, 0x40e000f2,
+};
 
 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
        [STAC_D945_REF] = ref922x_pin_configs,
@@ -1430,6 +1857,7 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
        [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
        [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
        [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
+       [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
        /* for backward compatibility */
        [STAC_MACMINI] = intel_mac_v3_pin_configs,
        [STAC_MACBOOK] = intel_mac_v5_pin_configs,
@@ -1437,6 +1865,7 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
        [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
        [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
        [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
+       [STAC_ECS_202] = ecs202_pin_configs,
        [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
        [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,       
        [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
@@ -1452,6 +1881,7 @@ static const char *stac922x_models[STAC_922X_MODELS] = {
        [STAC_INTEL_MAC_V3] = "intel-mac-v3",
        [STAC_INTEL_MAC_V4] = "intel-mac-v4",
        [STAC_INTEL_MAC_V5] = "intel-mac-v5",
+       [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
        /* for backward compatibility */
        [STAC_MACMINI]  = "macmini",
        [STAC_MACBOOK]  = "macbook",
@@ -1459,6 +1889,7 @@ static const char *stac922x_models[STAC_922X_MODELS] = {
        [STAC_MACBOOK_PRO_V2]   = "macbook-pro",
        [STAC_IMAC_INTEL] = "imac-intel",
        [STAC_IMAC_INTEL_20] = "imac-intel-20",
+       [STAC_ECS_202] = "ecs202",
        [STAC_922X_DELL_D81] = "dell-d81",
        [STAC_922X_DELL_D82] = "dell-d82",
        [STAC_922X_DELL_M81] = "dell-m81",
@@ -1523,9 +1954,9 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
                      "Intel D945P", STAC_D945GTP5),
        /* other systems  */
-       /* Apple Mac Mini (early 2006) */
+       /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
        SND_PCI_QUIRK(0x8384, 0x7680,
-                     "Mac Mini", STAC_INTEL_MAC_V3),
+                     "Mac", STAC_INTEL_MAC_AUTO),
        /* Dell systems  */
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
                      "unknown Dell", STAC_922X_DELL_D81),
@@ -1545,6 +1976,33 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
                      "unknown Dell", STAC_922X_DELL_D81),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
                      "Dell XPS M1210", STAC_922X_DELL_M82),
+       /* ECS/PC Chips boards */
+       SND_PCI_QUIRK(0x1019, 0x2144,
+                     "ECS/PC chips", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2608,
+                     "ECS/PC chips", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2633,
+                     "ECS/PC chips P17G/1333", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2811,
+                     "ECS/PC chips", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2812,
+                     "ECS/PC chips", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2813,
+                     "ECS/PC chips", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2814,
+                     "ECS/PC chips", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2815,
+                     "ECS/PC chips", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2816,
+                     "ECS/PC chips", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2817,
+                     "ECS/PC chips", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2818,
+                     "ECS/PC chips", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2819,
+                     "ECS/PC chips", STAC_ECS_202),
+       SND_PCI_QUIRK(0x1019, 0x2820,
+                     "ECS/PC chips", STAC_ECS_202),
        {} /* terminator */
 };
 
@@ -1577,6 +2035,7 @@ static unsigned int dell_3st_pin_configs[14] = {
 };
 
 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
+       [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
        [STAC_D965_REF]  = ref927x_pin_configs,
        [STAC_D965_3ST]  = d965_3st_pin_configs,
        [STAC_D965_5ST]  = d965_5st_pin_configs,
@@ -1585,6 +2044,7 @@ static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
 };
 
 static const char *stac927x_models[STAC_927X_MODELS] = {
+       [STAC_D965_REF_NO_JD]   = "ref-no-jd",
        [STAC_D965_REF]         = "ref",
        [STAC_D965_3ST]         = "3stack",
        [STAC_D965_5ST]         = "5stack",
@@ -1624,8 +2084,8 @@ static struct snd_pci_quirk stac927x_cfg_tbl[] = {
        /* Dell 3 stack systems with verb table in BIOS */
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0227, "Dell Vostro 1400  ", STAC_DELL_BIOS),
-       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x022f, "Dell     ", STAC_DELL_BIOS),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x022e, "Dell     ", STAC_DELL_BIOS),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0242, "Dell     ", STAC_DELL_BIOS),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0243, "Dell     ", STAC_DELL_BIOS),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x02ff, "Dell     ", STAC_DELL_BIOS),
@@ -1711,12 +2171,8 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
                      "unknown Dell", STAC_9205_DELL_M42),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
                      "Dell Precision", STAC_9205_DELL_M43),
-       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
-                         "Dell Precision", STAC_9205_DELL_M43),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
                      "Dell Precision", STAC_9205_DELL_M43),
-       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
-                     "Dell Precision", STAC_9205_DELL_M43),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
                      "Dell Precision", STAC_9205_DELL_M43),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
@@ -1727,18 +2183,14 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
                      "Dell Precision", STAC_9205_DELL_M43),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
                      "Dell Precision M4300", STAC_9205_DELL_M43),
-       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
-                     "Dell Precision", STAC_9205_DELL_M43),
-       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
-                     "Dell Inspiron", STAC_9205_DELL_M44),
-       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
-                     "Dell Inspiron", STAC_9205_DELL_M44),
-       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
-                     "Dell Inspiron", STAC_9205_DELL_M44),
-       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
-                     "Dell Inspiron", STAC_9205_DELL_M44),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
                      "unknown Dell", STAC_9205_DELL_M42),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
+                     "Dell Precision", STAC_9205_DELL_M43),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
+                     "Dell Precision", STAC_9205_DELL_M43),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
+                     "Dell Precision", STAC_9205_DELL_M43),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
                      "Dell Inspiron", STAC_9205_DELL_M44),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
@@ -1816,6 +2268,8 @@ static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
                                      struct snd_pcm_substream *substream)
 {
        struct sigmatel_spec *spec = codec->spec;
+       if (spec->stream_delay)
+               msleep(spec->stream_delay);
        return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
                                             hinfo);
 }
@@ -1879,9 +2333,14 @@ static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
                                        struct snd_pcm_substream *substream)
 {
        struct sigmatel_spec *spec = codec->spec;
+       hda_nid_t nid = spec->adc_nids[substream->number];
 
-       snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
-                                   stream_tag, 0, format);
+       if (spec->powerdown_adcs) {
+               msleep(40);
+               snd_hda_codec_write_cache(codec, nid, 0,
+                       AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
+       }
+       snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
        return 0;
 }
 
@@ -1890,8 +2349,12 @@ static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
                                        struct snd_pcm_substream *substream)
 {
        struct sigmatel_spec *spec = codec->spec;
+       hda_nid_t nid = spec->adc_nids[substream->number];
 
-       snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
+       snd_hda_codec_cleanup_stream(codec, nid);
+       if (spec->powerdown_adcs)
+               snd_hda_codec_write_cache(codec, nid, 0,
+                       AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
        return 0;
 }
 
@@ -2010,24 +2473,53 @@ static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int
                                  AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
 }
 
-#define stac92xx_io_switch_info                snd_ctl_boolean_mono_info
+#define stac92xx_hp_switch_info                snd_ctl_boolean_mono_info
 
-static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+static int stac92xx_hp_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;
 
-       ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
+       ucontrol->value.integer.value[0] = !!spec->hp_switch;
        return 0;
 }
 
-static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
+                       struct snd_ctl_elem_value *ucontrol)
 {
-        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       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;
+       int nid = kcontrol->private_value;
+       spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
+
+       /* check to be sure that the ports are upto date with
+        * switch changes
+        */
+       codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
+
+       return 1;
+}
+
+#define stac92xx_io_switch_info                snd_ctl_boolean_mono_info
+
+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;
+
+       ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
+       return 0;
+}
+
+static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+        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];
 
        spec->io_switch[io_idx] = val;
@@ -2081,6 +2573,15 @@ static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
        return 1;
 }
 
+#define STAC_CODEC_HP_SWITCH(xname) \
+       { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+         .name = xname, \
+         .index = 0, \
+         .info = stac92xx_hp_switch_info, \
+         .get = stac92xx_hp_switch_get, \
+         .put = stac92xx_hp_switch_put, \
+       }
+
 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
          .name = xname, \
@@ -2105,6 +2606,9 @@ enum {
        STAC_CTL_WIDGET_VOL,
        STAC_CTL_WIDGET_MUTE,
        STAC_CTL_WIDGET_MONO_MUX,
+       STAC_CTL_WIDGET_AMP_MUX,
+       STAC_CTL_WIDGET_AMP_VOL,
+       STAC_CTL_WIDGET_HP_SWITCH,
        STAC_CTL_WIDGET_IO_SWITCH,
        STAC_CTL_WIDGET_CLFE_SWITCH
 };
@@ -2113,12 +2617,18 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
        HDA_CODEC_VOLUME(NULL, 0, 0, 0),
        HDA_CODEC_MUTE(NULL, 0, 0, 0),
        STAC_MONO_MUX,
+       STAC_AMP_MUX,
+       STAC_AMP_VOL(NULL, 0, 0, 0, 0),
+       STAC_CODEC_HP_SWITCH(NULL),
        STAC_CODEC_IO_SWITCH(NULL, 0),
        STAC_CODEC_CLFE_SWITCH(NULL, 0),
 };
 
 /* add dynamic controls */
-static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
+static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
+                                    struct snd_kcontrol_new *ktemp,
+                                    int idx, const char *name,
+                                    unsigned long val)
 {
        struct snd_kcontrol_new *knew;
 
@@ -2137,15 +2647,33 @@ static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char
        }
 
        knew = &spec->kctl_alloc[spec->num_kctl_used];
-       *knew = stac92xx_control_templates[type];
+       *knew = *ktemp;
+       knew->index = idx;
        knew->name = kstrdup(name, GFP_KERNEL);
-       if (! knew->name)
+       if (!knew->name)
                return -ENOMEM;
        knew->private_value = val;
        spec->num_kctl_used++;
        return 0;
 }
 
+static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
+                                          int type, int idx, const char *name,
+                                          unsigned long val)
+{
+       return stac92xx_add_control_temp(spec,
+                                        &stac92xx_control_templates[type],
+                                        idx, name, val);
+}
+
+
+/* add dynamic controls */
+static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
+                                      const char *name, unsigned long val)
+{
+       return stac92xx_add_control_idx(spec, type, 0, name, val);
+}
+
 /* flag inputs as additional dynamic lineouts */
 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
 {
@@ -2337,14 +2865,14 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
        static const char *chname[4] = {
                "Front", "Surround", NULL /*CLFE*/, "Side"
        };
-       hda_nid_t nid;
+       hda_nid_t nid = 0;
        int i, err;
 
        struct sigmatel_spec *spec = codec->spec;
        unsigned int wid_caps, pincap;
 
 
-       for (i = 0; i < cfg->line_outs; i++) {
+       for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
                if (!spec->multiout.dac_nids[i])
                        continue;
 
@@ -2377,6 +2905,19 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
                }
        }
 
+       if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
+           cfg->hp_outs == 1 && !spec->multiout.hp_nid)
+               spec->multiout.hp_nid = nid;
+
+       if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
+               err = stac92xx_add_control(spec,
+                       STAC_CTL_WIDGET_HP_SWITCH,
+                       "Headphone as Line Out Switch",
+                       cfg->hp_pins[cfg->hp_outs - 1]);
+               if (err < 0)
+                       return err;
+       }
+
        if (spec->line_switch) {
                nid = cfg->input_pins[AUTO_PIN_LINE];
                pincap = snd_hda_param_read(codec, nid,
@@ -2471,12 +3012,8 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
                        return err;
        }
        if (spec->multiout.hp_nid) {
-               const char *pfx;
-               if (old_num_dacs == spec->multiout.num_dacs)
-                       pfx = "Master";
-               else
-                       pfx = "Headphone";
-               err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
+               err = create_controls(spec, "Headphone",
+                                     spec->multiout.hp_nid, 3);
                if (err < 0)
                        return err;
        }
@@ -2485,8 +3022,8 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
 }
 
 /* labels for mono mux outputs */
-static const char *stac92xx_mono_labels[3] = {
-       "DAC0", "DAC1", "Mixer"
+static const char *stac92xx_mono_labels[4] = {
+       "DAC0", "DAC1", "Mixer", "DAC2"
 };
 
 /* create mono mux for mono out on capable codecs */
@@ -2515,6 +3052,153 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
                                "Mono Mux", spec->mono_nid);
 }
 
+/* labels for amp mux outputs */
+static const char *stac92xx_amp_labels[3] = {
+       "Front Microphone", "Microphone", "Line In",
+};
+
+/* create amp out controls mux on capable codecs */
+static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
+{
+       struct sigmatel_spec *spec = codec->spec;
+       struct hda_input_mux *amp_mux = &spec->private_amp_mux;
+       int i, err;
+
+       for (i = 0; i < spec->num_amps; i++) {
+               amp_mux->items[amp_mux->num_items].label =
+                                       stac92xx_amp_labels[i];
+               amp_mux->items[amp_mux->num_items].index = i;
+               amp_mux->num_items++;
+       }
+
+       if (spec->num_amps > 1) {
+               err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
+                       "Amp Selector Capture Switch", 0);
+               if (err < 0)
+                       return err;
+       }
+       return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
+               "Amp Capture Volume",
+               HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
+}
+
+
+/* create PC beep volume controls */
+static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
+                                               hda_nid_t nid)
+{
+       struct sigmatel_spec *spec = codec->spec;
+       u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
+       int err;
+
+       /* check for mute support for the the amp */
+       if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
+               err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
+                       "PC Beep Playback Switch",
+                       HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+       }
+
+       /* check to see if there is volume support for the amp */
+       if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
+               err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
+                       "PC Beep Playback Volume",
+                       HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+       }
+       return 0;
+}
+
+#ifdef CONFIG_SND_HDA_INPUT_BEEP
+#define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
+
+static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       ucontrol->value.integer.value[0] = codec->beep->enabled;
+       return 0;
+}
+
+static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
+                                       struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       int enabled = !!ucontrol->value.integer.value[0];
+       if (codec->beep->enabled != enabled) {
+               codec->beep->enabled = enabled;
+               return 1;
+       }
+       return 0;
+}
+
+static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .info = stac92xx_dig_beep_switch_info,
+       .get = stac92xx_dig_beep_switch_get,
+       .put = stac92xx_dig_beep_switch_put,
+};
+
+static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
+{
+       return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
+                                        0, "PC Beep Playback Switch", 0);
+}
+#endif
+
+static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
+{
+       struct sigmatel_spec *spec = codec->spec;
+       int wcaps, nid, i, err = 0;
+
+       for (i = 0; i < spec->num_muxes; i++) {
+               nid = spec->mux_nids[i];
+               wcaps = get_wcaps(codec, nid);
+
+               if (wcaps & AC_WCAP_OUT_AMP) {
+                       err = stac92xx_add_control_idx(spec,
+                               STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
+                               HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
+                       if (err < 0)
+                               return err;
+               }
+       }
+       return 0;
+};
+
+static const char *stac92xx_spdif_labels[3] = {
+       "Digital Playback", "Analog Mux 1", "Analog Mux 2",
+};
+
+static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
+{
+       struct sigmatel_spec *spec = codec->spec;
+       struct hda_input_mux *spdif_mux = &spec->private_smux;
+       const char **labels = spec->spdif_labels;
+       int i, num_cons;
+       hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
+
+       num_cons = snd_hda_get_connections(codec,
+                               spec->smux_nids[0],
+                               con_lst,
+                               HDA_MAX_NUM_INPUTS);
+       if (!num_cons)
+               return -EINVAL;
+
+       if (!labels)
+               labels = stac92xx_spdif_labels;
+
+       for (i = 0; i < num_cons; i++) {
+               spdif_mux->items[spdif_mux->num_items].label = labels[i];
+               spdif_mux->items[spdif_mux->num_items].index = i;
+               spdif_mux->num_items++;
+       }
+
+       return 0;
+}
+
 /* labels for dmic mux inputs */
 static const char *stac92xx_dmic_labels[5] = {
        "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
@@ -2562,16 +3246,19 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
                        }
                continue;
 found:
-               wcaps = get_wcaps(codec, nid);
+               wcaps = get_wcaps(codec, nid) &
+                       (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
 
-               if (wcaps & AC_WCAP_OUT_AMP) {
+               if (wcaps) {
                        sprintf(name, "%s Capture Volume",
                                stac92xx_dmic_labels[dimux->num_items]);
 
                        err = stac92xx_add_control(spec,
                                STAC_CTL_WIDGET_VOL,
                                name,
-                               HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
+                               HDA_COMPOSE_AMP_VAL(nid, 3, 0,
+                               (wcaps & AC_WCAP_OUT_AMP) ?
+                               HDA_OUTPUT : HDA_INPUT));
                        if (err < 0)
                                return err;
                }
@@ -2695,8 +3382,8 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
                hp_speaker_swap = 1;
        }
        if (spec->autocfg.mono_out_pin) {
-               int dir = (get_wcaps(codec, spec->autocfg.mono_out_pin)
-                               & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
+               int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
+                       (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
                u32 caps = query_amp_caps(codec,
                                spec->autocfg.mono_out_pin, dir);
                hda_nid_t conn_list[1];
@@ -2718,21 +3405,26 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
                                                !(wcaps & AC_WCAP_LR_SWAP))
                                        spec->mono_nid = conn_list[0];
                }
-               /* all mono outs have a least a mute/unmute switch */
-               err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
-                       "Mono Playback Switch",
-                       HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
-                                       1, 0, dir));
-               if (err < 0)
-                       return err;
-               /* check to see if there is volume support for the amp */
-               if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
-                       err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
-                               "Mono Playback Volume",
-                               HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
-                                       1, 0, dir));
+               if (dir) {
+                       hda_nid_t nid = spec->autocfg.mono_out_pin;
+
+                       /* most mono outs have a least a mute/unmute switch */
+                       dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
+                       err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
+                               "Mono Playback Switch",
+                               HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
                        if (err < 0)
                                return err;
+                       /* check for volume support for the amp */
+                       if ((caps & AC_AMPCAP_NUM_STEPS)
+                                       >> AC_AMPCAP_NUM_STEPS_SHIFT) {
+                               err = stac92xx_add_control(spec,
+                                       STAC_CTL_WIDGET_VOL,
+                                       "Mono Playback Volume",
+                               HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
+                               if (err < 0)
+                                       return err;
+                       }
                }
 
                stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
@@ -2750,6 +3442,37 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
        if (err < 0)
                return err;
 
+       /* setup analog beep controls */
+       if (spec->anabeep_nid > 0) {
+               err = stac92xx_auto_create_beep_ctls(codec,
+                       spec->anabeep_nid);
+               if (err < 0)
+                       return err;
+       }
+
+       /* setup digital beep controls and input device */
+#ifdef CONFIG_SND_HDA_INPUT_BEEP
+       if (spec->digbeep_nid > 0) {
+               hda_nid_t nid = spec->digbeep_nid;
+               unsigned int caps;
+
+               err = stac92xx_auto_create_beep_ctls(codec, nid);
+               if (err < 0)
+                       return err;
+               err = snd_hda_attach_beep_device(codec, nid);
+               if (err < 0)
+                       return err;
+               /* if no beep switch is available, make its own one */
+               caps = query_amp_caps(codec, nid, HDA_OUTPUT);
+               if (codec->beep &&
+                   !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
+                       err = stac92xx_beep_switch_ctl(codec);
+                       if (err < 0)
+                               return err;
+               }
+       }
+#endif
+
        if (hp_speaker_swap == 1) {
                /* Restore the hp_outs and line_outs */
                memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
@@ -2778,11 +3501,25 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
                if (err < 0)
                        return err;
        }
-
-       if (spec->num_dmics > 0)
+       if (spec->num_amps > 0) {
+               err = stac92xx_auto_create_amp_output_ctls(codec);
+               if (err < 0)
+                       return err;
+       }
+       if (spec->num_dmics > 0 && !spec->dinput_mux)
                if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
                                                &spec->autocfg)) < 0)
                        return err;
+       if (spec->num_muxes > 0) {
+               err = stac92xx_auto_create_mux_input_ctls(codec);
+               if (err < 0)
+                       return err;
+       }
+       if (spec->num_smuxes > 0) {
+               err = stac92xx_auto_create_spdif_mux_ctls(codec);
+               if (err < 0)
+                       return err;
+       }
 
        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
        if (spec->multiout.max_channels > 2)
@@ -2790,17 +3527,17 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
 
        if (spec->autocfg.dig_out_pin)
                spec->multiout.dig_out_nid = dig_out;
-       if (spec->autocfg.dig_in_pin)
+       if (dig_in && spec->autocfg.dig_in_pin)
                spec->dig_in_nid = dig_in;
 
        if (spec->kctl_alloc)
                spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
 
        spec->input_mux = &spec->private_imux;
-       if (!spec->dinput_mux)
-               spec->dinput_mux = &spec->private_dimux;
+       spec->dinput_mux = &spec->private_dimux;
+       spec->sinput_mux = &spec->private_smux;
        spec->mono_mux = &spec->private_mono_mux;
-
+       spec->amp_mux = &spec->private_amp_mux;
        return 1;
 }
 
@@ -2890,6 +3627,12 @@ static int stac9200_parse_auto_config(struct hda_codec *codec)
        if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
                return err;
 
+       if (spec->num_muxes > 0) {
+               err = stac92xx_auto_create_mux_input_ctls(codec);
+               if (err < 0)
+                       return err;
+       }
+
        if (spec->autocfg.dig_out_pin)
                spec->multiout.dig_out_nid = 0x05;
        if (spec->autocfg.dig_in_pin)
@@ -2972,14 +3715,34 @@ static void stac92xx_power_down(struct hda_codec *codec)
                                        AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
 }
 
+static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
+                                 int enable);
+
 static int stac92xx_init(struct hda_codec *codec)
 {
        struct sigmatel_spec *spec = codec->spec;
        struct auto_pin_cfg *cfg = &spec->autocfg;
+       unsigned int gpio;
        int i;
 
        snd_hda_sequence_write(codec, spec->init);
 
+       /* power down adcs initially */
+       if (spec->powerdown_adcs)
+               for (i = 0; i < spec->num_adcs; i++)
+                       snd_hda_codec_write_cache(codec,
+                               spec->adc_nids[i], 0,
+                               AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
+
+       /* set up GPIO */
+       gpio = spec->gpio_data;
+       /* turn on EAPD statically when spec->eapd_switch isn't set.
+        * otherwise, unsol event will turn it on/off dynamically
+        */
+       if (!spec->eapd_switch)
+               gpio |= spec->eapd_mask;
+       stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
+
        /* set up pins */
        if (spec->hp_detect) {
                /* Enable unsolicited responses on the HP widget */
@@ -3001,41 +3764,61 @@ static int stac92xx_init(struct hda_codec *codec)
        for (i = 0; i < AUTO_PIN_LAST; i++) {
                hda_nid_t nid = cfg->input_pins[i];
                if (nid) {
-                       unsigned int pinctl = AC_PINCTL_IN_EN;
-                       if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
-                               pinctl |= stac92xx_get_vref(codec, nid);
+                       unsigned int pinctl;
+                       if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
+                               /* for mic pins, force to initialize */
+                               pinctl = stac92xx_get_vref(codec, nid);
+                       } else {
+                               pinctl = snd_hda_codec_read(codec, nid, 0,
+                                       AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
+                               /* if PINCTL already set then skip */
+                               if (pinctl & AC_PINCTL_IN_EN)
+                                       continue;
+                       }
+                       pinctl |= AC_PINCTL_IN_EN;
                        stac92xx_auto_set_pinctl(codec, nid, pinctl);
                }
        }
        for (i = 0; i < spec->num_dmics; i++)
                stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
                                        AC_PINCTL_IN_EN);
+       if (cfg->dig_out_pin)
+               stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
+                                        AC_PINCTL_OUT_EN);
+       if (cfg->dig_in_pin)
+               stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
+                                        AC_PINCTL_IN_EN);
        for (i = 0; i < spec->num_pwrs; i++)  {
-               int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
-                                       ? STAC_HP_EVENT : STAC_PWR_EVENT;
-               int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
-                                       0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
+               hda_nid_t nid = spec->pwr_nids[i];
+               int pinctl, def_conf;
+               int event = STAC_PWR_EVENT;
+
+               if (is_nid_hp_pin(cfg, nid) && spec->hp_detect)
+                       continue; /* already has an unsol event */
+
+               pinctl = snd_hda_codec_read(codec, nid, 0,
+                                           AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
                /* outputs are only ports capable of power management
                 * any attempts on powering down a input port cause the
                 * referenced VREF to act quirky.
                 */
                if (pinctl & AC_PINCTL_IN_EN)
                        continue;
+               def_conf = snd_hda_codec_read(codec, nid, 0,
+                                             AC_VERB_GET_CONFIG_DEFAULT, 0);
+               def_conf = get_defcfg_connect(def_conf);
+               /* skip any ports that don't have jacks since presence
+                * detection is useless */
+               if (def_conf != AC_JACK_PORT_COMPLEX) {
+                       if (def_conf != AC_JACK_PORT_NONE)
+                               stac_toggle_power_map(codec, nid, 1);
+                       continue;
+               }
                enable_pin_detect(codec, spec->pwr_nids[i], event | i);
                codec->patch_ops.unsol_event(codec, (event | i) << 26);
        }
        if (spec->dac_list)
                stac92xx_power_down(codec);
-       if (cfg->dig_out_pin)
-               stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
-                                        AC_PINCTL_OUT_EN);
-       if (cfg->dig_in_pin)
-               stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
-                                        AC_PINCTL_IN_EN);
-
-       stac_gpio_set(codec, spec->gpio_mask,
-                                       spec->gpio_dir, spec->gpio_data);
-
        return 0;
 }
 
@@ -3057,6 +3840,7 @@ static void stac92xx_free(struct hda_codec *codec)
                kfree(spec->bios_pin_configs);
 
        kfree(spec);
+       snd_hda_detach_beep_device(codec);
 }
 
 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
@@ -3117,6 +3901,26 @@ static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
        return 0;
 }
 
+/* return non-zero if the hp-pin of the given array index isn't
+ * a jack-detection target
+ */
+static int no_hp_sensing(struct sigmatel_spec *spec, int i)
+{
+       struct auto_pin_cfg *cfg = &spec->autocfg;
+
+       /* ignore sensing of shared line and mic jacks */
+       if (spec->line_switch &&
+           cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
+               return 1;
+       if (spec->mic_switch &&
+           cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
+               return 1;
+       /* ignore if the pin is set as line-out */
+       if (cfg->hp_pins[i] == spec->hp_switch)
+               return 1;
+       return 0;
+}
+
 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
 {
        struct sigmatel_spec *spec = codec->spec;
@@ -3131,59 +3935,109 @@ static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
        for (i = 0; i < cfg->hp_outs; i++) {
                if (presence)
                        break;
+               if (no_hp_sensing(spec, i))
+                       continue;
                presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
        }
 
        if (presence) {
-               /* disable lineouts, enable hp */
+               /* disable lineouts */
+               if (spec->hp_switch)
+                       stac92xx_reset_pinctl(codec, spec->hp_switch,
+                                             AC_PINCTL_OUT_EN);
                for (i = 0; i < cfg->line_outs; i++)
                        stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
                                                AC_PINCTL_OUT_EN);
                for (i = 0; i < cfg->speaker_outs; i++)
                        stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
                                                AC_PINCTL_OUT_EN);
+               if (spec->eapd_mask && spec->eapd_switch)
+                       stac_gpio_set(codec, spec->gpio_mask,
+                               spec->gpio_dir, spec->gpio_data &
+                               ~spec->eapd_mask);
        } else {
-               /* enable lineouts, disable hp */
+               /* enable lineouts */
+               if (spec->hp_switch)
+                       stac92xx_set_pinctl(codec, spec->hp_switch,
+                                           AC_PINCTL_OUT_EN);
                for (i = 0; i < cfg->line_outs; i++)
                        stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
                                                AC_PINCTL_OUT_EN);
                for (i = 0; i < cfg->speaker_outs; i++)
                        stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
                                                AC_PINCTL_OUT_EN);
+               if (spec->eapd_mask && spec->eapd_switch)
+                       stac_gpio_set(codec, spec->gpio_mask,
+                               spec->gpio_dir, spec->gpio_data |
+                               spec->eapd_mask);
+       }
+       /* toggle hp outs */
+       for (i = 0; i < cfg->hp_outs; i++) {
+               unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
+               if (no_hp_sensing(spec, i))
+                       continue;
+               if (presence)
+                       stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
+               else
+                       stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
        }
 } 
 
-static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
+static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
+                                 int enable)
 {
        struct sigmatel_spec *spec = codec->spec;
-       hda_nid_t nid = spec->pwr_nids[idx];
-       int presence, val;
-       val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
-                                                       & 0x000000ff;
-       presence = get_hp_pin_presence(codec, nid);
-       idx = 1 << idx;
-
-       if (presence)
+       unsigned int idx, val;
+
+       for (idx = 0; idx < spec->num_pwrs; idx++) {
+               if (spec->pwr_nids[idx] == nid)
+                       break;
+       }
+       if (idx >= spec->num_pwrs)
+               return;
+
+       /* several codecs have two power down bits */
+       if (spec->pwr_mapping)
+               idx = spec->pwr_mapping[idx];
+       else
+               idx = 1 << idx;
+
+       val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
+       if (enable)
                val &= ~idx;
        else
                val |= idx;
 
        /* power down unused output ports */
        snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
-};
+}
+
+static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
+{
+       stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid));
+}
 
 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
 {
        struct sigmatel_spec *spec = codec->spec;
        int idx = res >> 26 & 0x0f;
 
-       switch ((res >> 26) & 0x30) {
+       switch ((res >> 26) & 0x70) {
        case STAC_HP_EVENT:
                stac92xx_hp_detect(codec, res);
                /* fallthru */
        case STAC_PWR_EVENT:
                if (spec->num_pwrs > 0)
                        stac92xx_pin_sense(codec, idx);
+               break;
+       case STAC_VREF_EVENT: {
+               int data = snd_hda_codec_read(codec, codec->afg, 0,
+                       AC_VERB_GET_GPIO_DATA, 0);
+               /* toggle VREF state based on GPIOx status */
+               snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
+                       !!(data & (1 << idx)));
+               break;
+               }
        }
 }
 
@@ -3264,6 +4118,11 @@ static int patch_stac9200(struct hda_codec *codec)
                spec->init = stac9200_core_init;
        spec->mixer = stac9200_mixer;
 
+       if (spec->board_config == STAC_9200_PANASONIC) {
+               spec->gpio_mask = spec->gpio_dir = 0x09;
+               spec->gpio_data = 0x00;
+       }
+
        err = stac9200_parse_auto_config(codec);
        if (err < 0) {
                stac92xx_free(codec);
@@ -3355,9 +4214,9 @@ static struct hda_input_mux stac92hd73xx_dmux = {
        .num_items = 4,
        .items = {
                { "Analog Inputs", 0x0b },
-               { "CD", 0x08 },
                { "Digital Mic 1", 0x09 },
                { "Digital Mic 2", 0x0a },
+               { "CD", 0x08 },
        }
 };
 
@@ -3372,6 +4231,7 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
                return -ENOMEM;
 
        codec->spec = spec;
+       codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
        spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
        spec->pin_nids = stac92hd73xx_pin_nids;
        spec->board_config = snd_hda_check_board_config(codec,
@@ -3404,6 +4264,7 @@ again:
 
        switch (spec->multiout.num_dacs) {
        case 0x3: /* 6 Channel */
+               spec->multiout.hp_nid = 0x17;
                spec->mixer = stac92hd73xx_6ch_mixer;
                spec->init = stac92hd73xx_6ch_core_init;
                break;
@@ -3422,50 +4283,72 @@ again:
        spec->aloopback_mask = 0x01;
        spec->aloopback_shift = 8;
 
+       spec->digbeep_nid = 0x1c;
        spec->mux_nids = stac92hd73xx_mux_nids;
        spec->adc_nids = stac92hd73xx_adc_nids;
        spec->dmic_nids = stac92hd73xx_dmic_nids;
        spec->dmux_nids = stac92hd73xx_dmux_nids;
+       spec->smux_nids = stac92hd73xx_smux_nids;
+       spec->amp_nids = stac92hd73xx_amp_nids;
+       spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
 
        spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
        spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
        spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
-       spec->dinput_mux = &stac92hd73xx_dmux;
-       /* GPIO0 High = Enable EAPD */
-       spec->gpio_mask = spec->gpio_dir = 0x1;
-       spec->gpio_data = 0x01;
+       memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
+                       sizeof(stac92hd73xx_dmux));
 
        switch (spec->board_config) {
-       case STAC_DELL_M6:
-               switch (codec->subsystem_id) {
-               case 0x1028025e: /* Analog Mics */
-               case 0x1028025f:
+       case STAC_DELL_EQ:
+               spec->init = dell_eq_core_init;
+               /* fallthru */
+       case STAC_DELL_M6_AMIC:
+       case STAC_DELL_M6_DMIC:
+       case STAC_DELL_M6_BOTH:
+               spec->num_smuxes = 0;
+               spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
+               spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
+               spec->eapd_switch = 0;
+               spec->num_amps = 1;
+               spec->multiout.hp_nid = 0; /* dual HPs */
+
+               if (!spec->init)
+                       spec->init = dell_m6_core_init;
+               switch (spec->board_config) {
+               case STAC_DELL_M6_AMIC: /* Analog Mics */
                        stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
                        spec->num_dmics = 0;
+                       spec->private_dimux.num_items = 1;
                        break;
-               case 0x10280254: /* Digital Mics */
-               case 0x10280255:
-               case 0x10280271:
-               case 0x10280272:
+               case STAC_DELL_M6_DMIC: /* Digital Mics */
                        stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
                        spec->num_dmics = 1;
+                       spec->private_dimux.num_items = 2;
                        break;
-               case 0x10280256: /* Both */
-               case 0x10280057:
+               case STAC_DELL_M6_BOTH: /* Both */
                        stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
                        stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
                        spec->num_dmics = 1;
+                       spec->private_dimux.num_items = 2;
                        break;
                }
                break;
        default:
                spec->num_dmics = STAC92HD73XX_NUM_DMICS;
+               spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
+               spec->eapd_switch = 1;
        }
+       if (spec->board_config > STAC_92HD73XX_REF) {
+               /* GPIO0 High = Enable EAPD */
+               spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
+               spec->gpio_data = 0x01;
+       }
+       spec->dinput_mux = &spec->private_dimux;
 
        spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
        spec->pwr_nids = stac92hd73xx_pwr_nids;
 
-       err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
+       err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
 
        if (!err) {
                if (spec->board_config < 0) {
@@ -3482,11 +4365,160 @@ again:
                return err;
        }
 
+       if (spec->board_config == STAC_92HD73XX_NO_JD)
+               spec->hp_detect = 0;
+
+       codec->patch_ops = stac92xx_patch_ops;
+
+       return 0;
+}
+
+static struct hda_input_mux stac92hd83xxx_dmux = {
+       .num_items = 3,
+       .items = {
+               { "Analog Inputs", 0x03 },
+               { "Digital Mic 1", 0x04 },
+               { "Digital Mic 2", 0x05 },
+       }
+};
+
+static int patch_stac92hd83xxx(struct hda_codec *codec)
+{
+       struct sigmatel_spec *spec;
+       int err;
+
+       spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
+       if (spec == NULL)
+               return -ENOMEM;
+
+       codec->spec = spec;
+       codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
+       spec->mono_nid = 0x19;
+       spec->digbeep_nid = 0x21;
+       spec->dmic_nids = stac92hd83xxx_dmic_nids;
+       spec->dmux_nids = stac92hd83xxx_dmux_nids;
+       spec->adc_nids = stac92hd83xxx_adc_nids;
+       spec->pwr_nids = stac92hd83xxx_pwr_nids;
+       spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
+       spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
+       spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
+
+       spec->init = stac92hd83xxx_core_init;
+       switch (codec->vendor_id) {
+       case 0x111d7605:
+               spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
+               break;
+       default:
+               spec->num_pwrs--;
+               spec->init++; /* switch to config #2 */
+               spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
+       }
+
+       spec->mixer = stac92hd83xxx_mixer;
+       spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
+       spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
+       spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
+       spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
+       spec->dinput_mux = &stac92hd83xxx_dmux;
+       spec->pin_nids = stac92hd83xxx_pin_nids;
+       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");
+               err = stac92xx_save_bios_config_regs(codec);
+               if (err < 0) {
+                       stac92xx_free(codec);
+                       return err;
+               }
+               spec->pin_configs = spec->bios_pin_configs;
+       } else {
+               spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
+               stac92xx_set_config_regs(codec);
+       }
+
+       err = stac92xx_parse_auto_config(codec, 0x1d, 0);
+       if (!err) {
+               if (spec->board_config < 0) {
+                       printk(KERN_WARNING "hda_codec: No auto-config is "
+                              "available, default to model=ref\n");
+                       spec->board_config = STAC_92HD83XXX_REF;
+                       goto again;
+               }
+               err = -EINVAL;
+       }
+
+       if (err < 0) {
+               stac92xx_free(codec);
+               return err;
+       }
+
        codec->patch_ops = stac92xx_patch_ops;
 
        return 0;
 }
 
+#ifdef SND_HDA_NEEDS_RESUME
+static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
+{
+       struct sigmatel_spec *spec = codec->spec;
+       int i;
+       snd_hda_codec_write_cache(codec, codec->afg, 0,
+               AC_VERB_SET_POWER_STATE, pwr);
+
+       msleep(1);
+       for (i = 0; i < spec->num_adcs; i++) {
+               snd_hda_codec_write_cache(codec,
+                       spec->adc_nids[i], 0,
+                       AC_VERB_SET_POWER_STATE, pwr);
+       }
+};
+
+static int stac92hd71xx_resume(struct hda_codec *codec)
+{
+       stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
+       return stac92xx_resume(codec);
+}
+
+static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
+{
+       struct sigmatel_spec *spec = codec->spec;
+
+       stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
+       if (spec->eapd_mask)
+               stac_gpio_set(codec, spec->gpio_mask,
+                               spec->gpio_dir, spec->gpio_data &
+                               ~spec->eapd_mask);
+       return 0;
+};
+
+#endif
+
+static struct hda_codec_ops stac92hd71bxx_patch_ops = {
+       .build_controls = stac92xx_build_controls,
+       .build_pcms = stac92xx_build_pcms,
+       .init = stac92xx_init,
+       .free = stac92xx_free,
+       .unsol_event = stac92xx_unsol_event,
+#ifdef SND_HDA_NEEDS_RESUME
+       .resume = stac92hd71xx_resume,
+       .suspend = stac92hd71xx_suspend,
+#endif
+};
+
+static struct hda_input_mux stac92hd71bxx_dmux = {
+       .num_items = 4,
+       .items = {
+               { "Analog Inputs", 0x00 },
+               { "Mixer", 0x01 },
+               { "Digital Mic 1", 0x02 },
+               { "Digital Mic 2", 0x03 },
+       }
+};
+
 static int patch_stac92hd71bxx(struct hda_codec *codec)
 {
        struct sigmatel_spec *spec;
@@ -3497,8 +4529,12 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
                return -ENOMEM;
 
        codec->spec = spec;
+       codec->patch_ops = stac92xx_patch_ops;
        spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
+       spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
        spec->pin_nids = stac92hd71bxx_pin_nids;
+       memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
+                       sizeof(stac92hd71bxx_dmux));
        spec->board_config = snd_hda_check_board_config(codec,
                                                        STAC_92HD71BXX_MODELS,
                                                        stac92hd71bxx_models,
@@ -3518,6 +4554,13 @@ again:
                stac92xx_set_config_regs(codec);
        }
 
+       if (spec->board_config > STAC_92HD71BXX_REF) {
+               /* GPIO0 = EAPD */
+               spec->gpio_mask = 0x01;
+               spec->gpio_dir = 0x01;
+               spec->gpio_data = 0x01;
+       }
+
        switch (codec->vendor_id) {
        case 0x111d76b6: /* 4 Port without Analog Mixer */
        case 0x111d76b7:
@@ -3525,34 +4568,101 @@ again:
        case 0x111d76b5:
                spec->mixer = stac92hd71bxx_mixer;
                spec->init = stac92hd71bxx_core_init;
+               codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
                break;
+       case 0x111d7608: /* 5 Port with Analog Mixer */
+               switch (spec->board_config) {
+               case STAC_HP_M4:
+                       /* Enable VREF power saving on GPIO1 detect */
+                       snd_hda_codec_write_cache(codec, codec->afg, 0,
+                               AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
+                       snd_hda_codec_write_cache(codec, codec->afg, 0,
+                                       AC_VERB_SET_UNSOLICITED_ENABLE,
+                                       (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
+                       spec->gpio_mask |= 0x02;
+                       break;
+               }
+               if ((codec->revision_id & 0xf) == 0 ||
+                               (codec->revision_id & 0xf) == 1) {
+#ifdef SND_HDA_NEEDS_RESUME
+                       codec->patch_ops = stac92hd71bxx_patch_ops;
+#endif
+                       spec->stream_delay = 40; /* 40 milliseconds */
+               }
+
+               /* 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];
+               stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
+               break;
+       case 0x111d7603: /* 6 Port with Analog Mixer */
+               if ((codec->revision_id & 0xf) == 1) {
+#ifdef SND_HDA_NEEDS_RESUME
+                       codec->patch_ops = stac92hd71bxx_patch_ops;
+#endif
+                       spec->stream_delay = 40; /* 40 milliseconds */
+               }
+
+               /* no output amps */
+               spec->num_pwrs = 0;
+               /* fallthru */
        default:
+               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->aloopback_mask = 0x20;
+       spec->aloopback_mask = 0x50;
        spec->aloopback_shift = 0;
 
-       /* GPIO0 High = EAPD */
-       spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0x1;
-
+       spec->powerdown_adcs = 1;
+       spec->digbeep_nid = 0x26;
        spec->mux_nids = stac92hd71bxx_mux_nids;
        spec->adc_nids = stac92hd71bxx_adc_nids;
        spec->dmic_nids = stac92hd71bxx_dmic_nids;
        spec->dmux_nids = stac92hd71bxx_dmux_nids;
+       spec->smux_nids = stac92hd71bxx_smux_nids;
+       spec->pwr_nids = stac92hd71bxx_pwr_nids;
 
        spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
        spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
-       spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
-       spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
 
-       spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
-       spec->pwr_nids = stac92hd71bxx_pwr_nids;
+       switch (spec->board_config) {
+       case STAC_HP_M4:
+               /* enable internal microphone */
+               stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
+               stac92xx_auto_set_pinctl(codec, 0x0e,
+                       AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
+               /* fallthru */
+       case STAC_DELL_M4_2:
+               spec->num_dmics = 0;
+               spec->num_smuxes = 0;
+               spec->num_dmuxes = 0;
+               break;
+       case STAC_DELL_M4_1:
+       case STAC_DELL_M4_3:
+               spec->num_dmics = 1;
+               spec->num_smuxes = 0;
+               spec->num_dmuxes = 0;
+               break;
+       default:
+               spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
+               spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
+               spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
+       };
 
        spec->multiout.num_dacs = 1;
        spec->multiout.hp_nid = 0x11;
        spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
+       if (spec->dinput_mux)
+               spec->private_dimux.num_items +=
+                       spec->num_dmics -
+                               (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
 
        err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
        if (!err) {
@@ -3570,8 +4680,6 @@ again:
                return err;
        }
 
-       codec->patch_ops = stac92xx_patch_ops;
-
        return 0;
 };
 
@@ -3590,7 +4698,7 @@ static int patch_stac922x(struct hda_codec *codec)
        spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
                                                        stac922x_models,
                                                        stac922x_cfg_tbl);
-       if (spec->board_config == STAC_INTEL_MAC_V3) {
+       if (spec->board_config == STAC_INTEL_MAC_AUTO) {
                spec->gpio_mask = spec->gpio_dir = 0x03;
                spec->gpio_data = 0x03;
                /* Intel Macs have all same PCI SSID, so we need to check
@@ -3622,6 +4730,9 @@ static int patch_stac922x(struct hda_codec *codec)
                case 0x106b2200:
                        spec->board_config = STAC_INTEL_MAC_V5;
                        break;
+               default:
+                       spec->board_config = STAC_INTEL_MAC_V3;
+                       break;
                }
        }
 
@@ -3710,10 +4821,14 @@ static int patch_stac927x(struct hda_codec *codec)
                stac92xx_set_config_regs(codec);
        }
 
+       spec->digbeep_nid = 0x23;
        spec->adc_nids = stac927x_adc_nids;
        spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
        spec->mux_nids = stac927x_mux_nids;
        spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
+       spec->smux_nids = stac927x_smux_nids;
+       spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
+       spec->spdif_labels = stac927x_spdif_labels;
        spec->dac_list = stac927x_dac_nids;
        spec->multiout.dac_nids = spec->dac_nids;
 
@@ -3721,7 +4836,7 @@ static int patch_stac927x(struct hda_codec *codec)
        case STAC_D965_3ST:
        case STAC_D965_5ST:
                /* GPIO0 High = Enable EAPD */
-               spec->gpio_mask = spec->gpio_dir = 0x01;
+               spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
                spec->gpio_data = 0x01;
                spec->num_dmics = 0;
 
@@ -3729,6 +4844,13 @@ static int patch_stac927x(struct hda_codec *codec)
                spec->mixer = stac927x_mixer;
                break;
        case STAC_DELL_BIOS:
+               switch (codec->subsystem_id) {
+               case 0x10280209:
+               case 0x1028022e:
+                       /* correct the device field to SPDIF out */
+                       stac92xx_set_config_reg(codec, 0x21, 0x01442070);
+                       break;
+               };
                /* configure the analog microphone on some laptops */
                stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
                /* correct the front output jack as a hp out */
@@ -3738,7 +4860,7 @@ static int patch_stac927x(struct hda_codec *codec)
                /* fallthru */
        case STAC_DELL_3ST:
                /* GPIO2 High = Enable EAPD */
-               spec->gpio_mask = spec->gpio_dir = 0x04;
+               spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
                spec->gpio_data = 0x04;
                spec->dmic_nids = stac927x_dmic_nids;
                spec->num_dmics = STAC927X_NUM_DMICS;
@@ -3749,9 +4871,11 @@ static int patch_stac927x(struct hda_codec *codec)
                spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
                break;
        default:
-               /* GPIO0 High = Enable EAPD */
-               spec->gpio_mask = spec->gpio_dir = 0x1;
-               spec->gpio_data = 0x01;
+               if (spec->board_config > STAC_D965_REF) {
+                       /* GPIO0 High = Enable EAPD */
+                       spec->eapd_mask = spec->gpio_mask = 0x01;
+                       spec->gpio_dir = spec->gpio_data = 0x01;
+               }
                spec->num_dmics = 0;
 
                spec->init = stac927x_core_init;
@@ -3761,6 +4885,7 @@ static int patch_stac927x(struct hda_codec *codec)
        spec->num_pwrs = 0;
        spec->aloopback_mask = 0x40;
        spec->aloopback_shift = 0;
+       spec->eapd_switch = 1;
 
        err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
        if (!err) {
@@ -3791,6 +4916,10 @@ static int patch_stac927x(struct hda_codec *codec)
         */
        codec->bus->needs_damn_long_delay = 1;
 
+       /* no jack detecion for ref-no-jd model */
+       if (spec->board_config == STAC_D965_REF_NO_JD)
+               spec->hp_detect = 0;
+
        return 0;
 }
 
@@ -3823,10 +4952,13 @@ static int patch_stac9205(struct hda_codec *codec)
                stac92xx_set_config_regs(codec);
        }
 
+       spec->digbeep_nid = 0x23;
        spec->adc_nids = stac9205_adc_nids;
        spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
        spec->mux_nids = stac9205_mux_nids;
        spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
+       spec->smux_nids = stac9205_smux_nids;
+       spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
        spec->dmic_nids = stac9205_dmic_nids;
        spec->num_dmics = STAC9205_NUM_DMICS;
        spec->dmux_nids = stac9205_dmux_nids;
@@ -3838,6 +4970,7 @@ static int patch_stac9205(struct hda_codec *codec)
 
        spec->aloopback_mask = 0x40;
        spec->aloopback_shift = 0;
+       spec->eapd_switch = 1;
        spec->multiout.dac_nids = spec->dac_nids;
        
        switch (spec->board_config){
@@ -3847,13 +4980,14 @@ static int patch_stac9205(struct hda_codec *codec)
                stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
 
                /* Enable unsol response for GPIO4/Dock HP connection */
-               snd_hda_codec_write(codec, codec->afg, 0,
+               snd_hda_codec_write_cache(codec, codec->afg, 0,
                        AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
                snd_hda_codec_write_cache(codec, codec->afg, 0,
                                          AC_VERB_SET_UNSOLICITED_ENABLE,
                                          (AC_USRSP_EN | STAC_HP_EVENT));
 
                spec->gpio_dir = 0x0b;
+               spec->eapd_mask = 0x01;
                spec->gpio_mask = 0x1b;
                spec->gpio_mute = 0x10;
                /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
@@ -3861,9 +4995,12 @@ static int patch_stac9205(struct hda_codec *codec)
                 */
                spec->gpio_data = 0x01;
                break;
+       case STAC_9205_REF:
+               /* SPDIF-In enabled */
+               break;
        default:
                /* GPIO0 High = EAPD */
-               spec->gpio_mask = spec->gpio_dir = 0x1;
+               spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
                spec->gpio_data = 0x01;
                break;
        }
@@ -4162,6 +5299,8 @@ struct hda_codec_preset snd_hda_preset_sigmatel[] = {
        { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
        { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
        { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
+       { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
+       { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
        /* The following does not take into account .id=0x83847661 when subsys =
         * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
         * currently not fully supported.
@@ -4177,10 +5316,13 @@ struct hda_codec_preset snd_hda_preset_sigmatel[] = {
        { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
        { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
        { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
+       { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
+       { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
+       { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
+       { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
        { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
        { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
        { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
-       { .id = 0x111d7608, .name = "92HD71BXX", .patch = patch_stac92hd71bxx },
        { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
        { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
        { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },