]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Merge branch 'fix/hda' into topic/hda
authorTakashi Iwai <tiwai@suse.de>
Fri, 13 Feb 2009 10:59:26 +0000 (11:59 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 13 Feb 2009 10:59:26 +0000 (11:59 +0100)
1  2 
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_local.h
sound/pci/hda/patch_analog.c
sound/pci/hda/patch_sigmatel.c

index 29eeb748561d5be536848a25d1b73288e6c8b9ae,d03f99298be95eb64856288f71f957e4c63d2e8e..98884bc8f35f83a3dce58cd3139202a1476f8aff
@@@ -1120,7 -1120,6 +1120,7 @@@ int snd_hda_mixer_amp_volume_info(struc
        u16 nid = get_amp_nid(kcontrol);
        u8 chs = get_amp_channels(kcontrol);
        int dir = get_amp_direction(kcontrol);
 +      unsigned int ofs = get_amp_offset(kcontrol);
        u32 caps;
  
        caps = query_amp_caps(codec, nid, dir);
                       kcontrol->id.name);
                return -EINVAL;
        }
 +      if (ofs < caps)
 +              caps -= ofs;
        uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
        uinfo->count = chs == 3 ? 2 : 1;
        uinfo->value.integer.min = 0;
  }
  EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_info);
  
 +
 +static inline unsigned int
 +read_amp_value(struct hda_codec *codec, hda_nid_t nid,
 +             int ch, int dir, int idx, unsigned int ofs)
 +{
 +      unsigned int val;
 +      val = snd_hda_codec_amp_read(codec, nid, ch, dir, idx);
 +      val &= HDA_AMP_VOLMASK;
 +      if (val >= ofs)
 +              val -= ofs;
 +      else
 +              val = 0;
 +      return val;
 +}
 +
 +static inline int
 +update_amp_value(struct hda_codec *codec, hda_nid_t nid,
 +               int ch, int dir, int idx, unsigned int ofs,
 +               unsigned int val)
 +{
 +      if (val > 0)
 +              val += ofs;
 +      return snd_hda_codec_amp_update(codec, nid, ch, dir, idx,
 +                                      HDA_AMP_VOLMASK, val);
 +}
 +
  int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol)
  {
        int chs = get_amp_channels(kcontrol);
        int dir = get_amp_direction(kcontrol);
        int idx = get_amp_index(kcontrol);
 +      unsigned int ofs = get_amp_offset(kcontrol);
        long *valp = ucontrol->value.integer.value;
  
        if (chs & 1)
 -              *valp++ = snd_hda_codec_amp_read(codec, nid, 0, dir, idx)
 -                      & HDA_AMP_VOLMASK;
 +              *valp++ = read_amp_value(codec, nid, 0, dir, idx, ofs);
        if (chs & 2)
 -              *valp = snd_hda_codec_amp_read(codec, nid, 1, dir, idx)
 -                      & HDA_AMP_VOLMASK;
 +              *valp = read_amp_value(codec, nid, 1, dir, idx, ofs);
        return 0;
  }
  EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_get);
@@@ -1195,17 -1167,18 +1195,17 @@@ int snd_hda_mixer_amp_volume_put(struc
        int chs = get_amp_channels(kcontrol);
        int dir = get_amp_direction(kcontrol);
        int idx = get_amp_index(kcontrol);
 +      unsigned int ofs = get_amp_offset(kcontrol);
        long *valp = ucontrol->value.integer.value;
        int change = 0;
  
        snd_hda_power_up(codec);
        if (chs & 1) {
 -              change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx,
 -                                                0x7f, *valp);
 +              change = update_amp_value(codec, nid, 0, dir, idx, ofs, *valp);
                valp++;
        }
        if (chs & 2)
 -              change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx,
 -                                                 0x7f, *valp);
 +              change |= update_amp_value(codec, nid, 1, dir, idx, ofs, *valp);
        snd_hda_power_down(codec);
        return change;
  }
@@@ -1217,7 -1190,6 +1217,7 @@@ int snd_hda_mixer_amp_tlv(struct snd_kc
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        hda_nid_t nid = get_amp_nid(kcontrol);
        int dir = get_amp_direction(kcontrol);
 +      unsigned int ofs = get_amp_offset(kcontrol);
        u32 caps, val1, val2;
  
        if (size < 4 * sizeof(unsigned int))
        val2 = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT;
        val2 = (val2 + 1) * 25;
        val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT);
 +      val1 += ofs;
        val1 = ((int)val1) * ((int)val2);
        if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv))
                return -EFAULT;
@@@ -1984,8 -1955,6 +1984,8 @@@ int snd_hda_create_spdif_in_ctls(struc
        }
        for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
                kctl = snd_ctl_new1(dig_mix, codec);
 +              if (!kctl)
 +                      return -ENOMEM;
                kctl->private_value = nid;
                err = snd_hda_ctl_add(codec, kctl);
                if (err < 0)
@@@ -2645,7 -2614,7 +2645,7 @@@ int snd_hda_codec_build_pcms(struct hda
                int dev;
  
                if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
 -                      return 0; /* no substreams assigned */
 +                      continue; /* no substreams assigned */
  
                if (!cpcm->pcm) {
                        dev = get_empty_pcm_device(codec->bus, cpcm->pcm_type);
@@@ -3119,6 -3088,16 +3119,16 @@@ int snd_hda_multi_out_dig_prepare(struc
  }
  EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_prepare);
  
+ int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec,
+                                 struct hda_multi_out *mout)
+ {
+       mutex_lock(&codec->spdif_mutex);
+       cleanup_dig_out_stream(codec, mout->dig_out_nid);
+       mutex_unlock(&codec->spdif_mutex);
+       return 0;
+ }
+ EXPORT_SYMBOL_HDA(snd_hda_multi_out_dig_cleanup);
  /*
   * release the digital out
   */
@@@ -3422,22 -3401,10 +3432,22 @@@ int snd_hda_parse_pin_def_config(struc
                        cfg->input_pins[AUTO_PIN_AUX] = nid;
                        break;
                case AC_JACK_SPDIF_OUT:
 -                      cfg->dig_out_pin = nid;
 +              case AC_JACK_DIG_OTHER_OUT:
 +                      if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins))
 +                              continue;
 +                      cfg->dig_out_pins[cfg->dig_outs] = nid;
 +                      cfg->dig_out_type[cfg->dig_outs] =
 +                              (loc == AC_JACK_LOC_HDMI) ?
 +                              HDA_PCM_TYPE_HDMI : HDA_PCM_TYPE_SPDIF;
 +                      cfg->dig_outs++;
                        break;
                case AC_JACK_SPDIF_IN:
 +              case AC_JACK_DIG_OTHER_IN:
                        cfg->dig_in_pin = nid;
 +                      if (loc == AC_JACK_LOC_HDMI)
 +                              cfg->dig_in_type = HDA_PCM_TYPE_HDMI;
 +                      else
 +                              cfg->dig_in_type = HDA_PCM_TYPE_SPDIF;
                        break;
                }
        }
                   cfg->hp_pins[1], cfg->hp_pins[2],
                   cfg->hp_pins[3], cfg->hp_pins[4]);
        snd_printd("   mono: mono_out=0x%x\n", cfg->mono_out_pin);
 +      if (cfg->dig_outs)
 +              snd_printd("   dig-out=0x%x/0x%x\n",
 +                         cfg->dig_out_pins[0], cfg->dig_out_pins[1]);
        snd_printd("   inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x,"
                   " cd=0x%x, aux=0x%x\n",
                   cfg->input_pins[AUTO_PIN_MIC],
                   cfg->input_pins[AUTO_PIN_FRONT_LINE],
                   cfg->input_pins[AUTO_PIN_CD],
                   cfg->input_pins[AUTO_PIN_AUX]);
 +      if (cfg->dig_in_pin)
 +              snd_printd("   dig-in=0x%x\n", cfg->dig_in_pin);
  
        return 0;
  }
index 2ae6b53a46283a23fb1ba764e95008033f9628e3,44f189cb97aee1f8d40f166a5a998ae0ddca61b1..84e2cf644fd77bbfb3f62c9e1b6ec0ea1b5133ab
  /*
   * for mixer controls
   */
 +#define HDA_COMPOSE_AMP_VAL_OFS(nid,chs,idx,dir,ofs)          \
 +      ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19) | ((ofs)<<23))
  #define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \
 -      ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19))
 +      HDA_COMPOSE_AMP_VAL_OFS(nid, chs, idx, dir, 0)
  /* mono volume with index (index=0,1,...) (channel=1,2) */
  #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx,  \
@@@ -229,7 -227,6 +229,7 @@@ struct hda_multi_out 
        hda_nid_t hp_nid;       /* optional DAC for HP, 0 when not exists */
        hda_nid_t extra_out_nid[3];     /* optional DACs, 0 when not exists */
        hda_nid_t dig_out_nid;  /* digital out audio widget */
 +      hda_nid_t *slave_dig_outs;
        int max_channels;       /* currently supported analog channels */
        int dig_out_used;       /* current usage of digital out (HDA_DIG_XXX) */
        int no_share_stream;    /* don't share a stream with multiple pins */
@@@ -254,6 -251,8 +254,8 @@@ int snd_hda_multi_out_dig_prepare(struc
                                  unsigned int stream_tag,
                                  unsigned int format,
                                  struct snd_pcm_substream *substream);
+ int snd_hda_multi_out_dig_cleanup(struct hda_codec *codec,
+                                 struct hda_multi_out *mout);
  int snd_hda_multi_out_analog_open(struct hda_codec *codec,
                                  struct hda_multi_out *mout,
                                  struct snd_pcm_substream *substream,
@@@ -355,12 -354,9 +357,12 @@@ struct auto_pin_cfg 
        int line_out_type;      /* AUTO_PIN_XXX_OUT */
        hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS];
        hda_nid_t input_pins[AUTO_PIN_LAST];
 -      hda_nid_t dig_out_pin;
 +      int dig_outs;
 +      hda_nid_t dig_out_pins[2];
        hda_nid_t dig_in_pin;
        hda_nid_t mono_out_pin;
 +      int dig_out_type[2]; /* HDA_PCM_TYPE_XXX */
 +      int dig_in_type; /* HDA_PCM_TYPE_XXX */
  };
  
  #define get_defcfg_connect(cfg) \
@@@ -462,7 -458,6 +464,7 @@@ int snd_hda_check_amp_list_power(struc
  #define get_amp_channels(kc)  (((kc)->private_value >> 16) & 0x3)
  #define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1)
  #define get_amp_index(kc)     (((kc)->private_value >> 19) & 0xf)
 +#define get_amp_offset(kc)    (((kc)->private_value >> 23) & 0x3f)
  
  /*
   * CEA Short Audio Descriptor data
index d58c32b5b433a248c22be70f6fc035286c584ca0,e48612323aa0f11facf58c1d9df107bca5fa3692..af6b0035e2e84b41ec237703586f12b65de33ce4
  #include <sound/core.h>
  #include "hda_codec.h"
  #include "hda_local.h"
 +#include "hda_beep.h"
  
  struct ad198x_spec {
        struct snd_kcontrol_new *mixers[5];
        int num_mixers;
 -
 +      unsigned int beep_amp;  /* beep amp value, set via set_beep_amp() */
        const struct hda_verb *init_verbs[5];   /* initialization verbs
                                                 * don't forget NULL termination!
                                                 */
@@@ -155,16 -154,6 +155,16 @@@ static const char *ad_slave_sws[] = 
  
  static void ad198x_free_kctls(struct hda_codec *codec);
  
 +/* additional beep mixers; the actual parameters are overwritten at build */
 +static struct snd_kcontrol_new ad_beep_mixer[] = {
 +      HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT),
 +      HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_OUTPUT),
 +      { } /* end */
 +};
 +
 +#define set_beep_amp(spec, nid, idx, dir) \
 +      ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
 +
  static int ad198x_build_controls(struct hda_codec *codec)
  {
        struct ad198x_spec *spec = codec->spec;
                        return err;
        }
  
 +      /* create beep controls if needed */
 +      if (spec->beep_amp) {
 +              struct snd_kcontrol_new *knew;
 +              for (knew = ad_beep_mixer; knew->name; knew++) {
 +                      struct snd_kcontrol *kctl;
 +                      kctl = snd_ctl_new1(knew, codec);
 +                      if (!kctl)
 +                              return -ENOMEM;
 +                      kctl->private_value = spec->beep_amp;
 +                      err = snd_hda_ctl_add(codec, kctl);
 +                      if (err < 0)
 +                              return err;
 +              }
 +      }
 +
        /* if we have no master control, let's create it */
        if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
                unsigned int vmaster_tlv[4];
@@@ -301,6 -275,14 +301,14 @@@ static int ad198x_dig_playback_pcm_prep
                                             format, substream);
  }
  
+ static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
+                                          struct hda_codec *codec,
+                                          struct snd_pcm_substream *substream)
+ {
+       struct ad198x_spec *spec = codec->spec;
+       return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
+ }
  /*
   * Analog capture
   */
@@@ -359,7 -341,8 +367,8 @@@ static struct hda_pcm_stream ad198x_pcm
        .ops = {
                .open = ad198x_dig_playback_pcm_open,
                .close = ad198x_dig_playback_pcm_close,
-               .prepare = ad198x_dig_playback_pcm_prepare
+               .prepare = ad198x_dig_playback_pcm_prepare,
+               .cleanup = ad198x_dig_playback_pcm_cleanup
        },
  };
  
@@@ -423,8 -406,7 +432,8 @@@ static void ad198x_free(struct hda_code
                return;
  
        ad198x_free_kctls(codec);
 -      kfree(codec->spec);
 +      kfree(spec);
 +      snd_hda_detach_beep_device(codec);
  }
  
  static struct hda_codec_ops ad198x_patch_ops = {
@@@ -563,6 -545,8 +572,6 @@@ static struct snd_kcontrol_new ad1986a_
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
@@@ -626,7 -610,8 +635,7 @@@ static struct snd_kcontrol_new ad1986a_
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
 -      /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
 -         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
 +      /* 
           HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
           HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
        HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
@@@ -824,6 -809,8 +833,6 @@@ static struct snd_kcontrol_new ad1986a_
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_VOLUME("Beep Playback Volume", 0x18, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0x18, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
        {
@@@ -1015,8 -1002,10 +1024,8 @@@ static struct snd_pci_quirk ad1986a_cfg
        SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD),
        SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
        SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
 -      SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_SAMSUNG),
 -      SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_SAMSUNG),
 -      SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_SAMSUNG),
        SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
 +      SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG),
        SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
        SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
        SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
@@@ -1046,7 -1035,7 +1055,7 @@@ static int is_jack_available(struct hda
  static int patch_ad1986a(struct hda_codec *codec)
  {
        struct ad198x_spec *spec;
 -      int board_config;
 +      int err, board_config;
  
        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
  
        codec->spec = spec;
  
 +      err = snd_hda_attach_beep_device(codec, 0x19);
 +      if (err < 0) {
 +              ad198x_free(codec);
 +              return err;
 +      }
 +      set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
 +
        spec->multiout.max_channels = 6;
        spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
        spec->multiout.dac_nids = ad1986a_dac_nids;
@@@ -1240,6 -1222,8 +1249,6 @@@ static struct snd_kcontrol_new ad1983_m
        HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
@@@ -1310,7 -1294,6 +1319,7 @@@ static struct hda_amp_list ad1983_loopb
  static int patch_ad1983(struct hda_codec *codec)
  {
        struct ad198x_spec *spec;
 +      int err;
  
        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
  
        codec->spec = spec;
  
 +      err = snd_hda_attach_beep_device(codec, 0x10);
 +      if (err < 0) {
 +              ad198x_free(codec);
 +              return err;
 +      }
 +      set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
 +
        spec->multiout.max_channels = 2;
        spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
        spec->multiout.dac_nids = ad1983_dac_nids;
@@@ -1394,6 -1370,8 +1403,6 @@@ static struct snd_kcontrol_new ad1981_m
        HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
@@@ -1438,8 -1416,8 +1447,8 @@@ static struct hda_verb ad1981_init_verb
        {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
        {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
        /* Mic boost: 0dB */
 -      {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
 -      {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
 +      {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
 +      {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        /* Record selector: Front mic */
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
@@@ -1704,10 -1682,10 +1713,10 @@@ static struct snd_pci_quirk ad1981_cfg_
        SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
        SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD),
        /* All HP models */
 -      SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP),
 +      SND_PCI_QUIRK_VENDOR(0x103c, "HP nx", AD1981_HP),
        SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
        /* Lenovo Thinkpad T60/X60/Z6xx */
 -      SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD),
 +      SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1981_THINKPAD),
        /* HP nx6320 (reversed SSID, H/W bug) */
        SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
        {}
  static int patch_ad1981(struct hda_codec *codec)
  {
        struct ad198x_spec *spec;
 -      int board_config;
 +      int err, board_config;
  
        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
  
        codec->spec = spec;
  
 +      err = snd_hda_attach_beep_device(codec, 0x10);
 +      if (err < 0) {
 +              ad198x_free(codec);
 +              return err;
 +      }
 +      set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT);
 +
        spec->multiout.max_channels = 2;
        spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
        spec->multiout.dac_nids = ad1981_dac_nids;
@@@ -1923,8 -1894,8 +1932,8 @@@ static hda_nid_t ad1988_capsrc_nids[3] 
  #define AD1988_SPDIF_OUT_HDMI 0x0b
  #define AD1988_SPDIF_IN               0x07
  
- static hda_nid_t ad1989b_slave_dig_outs[2] = {
-       AD1988_SPDIF_OUT, AD1988_SPDIF_OUT_HDMI
+ static hda_nid_t ad1989b_slave_dig_outs[] = {
+       AD1988_SPDIF_OUT, AD1988_SPDIF_OUT_HDMI, 0
  };
  
  static struct hda_input_mux ad1988_6stack_capture_source = {
@@@ -2017,6 -1988,9 +2026,6 @@@ static struct snd_kcontrol_new ad1988_6
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
        HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
  
 -      HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
 -
        HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
  
@@@ -2060,6 -2034,9 +2069,6 @@@ static struct snd_kcontrol_new ad1988_3
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
        HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
  
 -      HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
 -
        HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
  
@@@ -2089,6 -2066,9 +2098,6 @@@ static struct snd_kcontrol_new ad1988_l
        HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
        HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
  
 -      HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
 -
        HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
  
@@@ -2317,6 -2297,10 +2326,6 @@@ static struct hda_verb ad1988_capture_i
        {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
        {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
        {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
 -      /* ADCs; muted */
 -      {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
 -      {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
 -      {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  
        { }
  };
@@@ -2424,6 -2408,10 +2433,6 @@@ static struct hda_verb ad1988_3stack_in
        {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
        {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
        {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
 -      /* ADCs; muted */
 -      {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
 -      {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
 -      {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
        /* Analog Mix output amp */
        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
        { }
@@@ -2495,6 -2483,10 +2504,6 @@@ static struct hda_verb ad1988_laptop_in
        {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
        {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
        {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
 -      /* ADCs; muted */
 -      {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
 -      {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
 -      {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
        /* Analog Mix output amp */
        {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
        { }
@@@ -2898,7 -2890,7 +2907,7 @@@ static int ad1988_parse_auto_config(str
  
        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  
 -      if (spec->autocfg.dig_out_pin)
 +      if (spec->autocfg.dig_outs)
                spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
        if (spec->autocfg.dig_in_pin)
                spec->dig_in_nid = AD1988_SPDIF_IN;
@@@ -2948,7 -2940,7 +2957,7 @@@ static struct snd_pci_quirk ad1988_cfg_
  static int patch_ad1988(struct hda_codec *codec)
  {
        struct ad198x_spec *spec;
 -      int board_config;
 +      int err, board_config;
  
        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
  
        if (board_config == AD1988_AUTO) {
                /* automatic parse from the BIOS config */
 -              int err = ad1988_parse_auto_config(codec);
 +              err = ad1988_parse_auto_config(codec);
                if (err < 0) {
                        ad198x_free(codec);
                        return err;
                }
        }
  
 +      err = snd_hda_attach_beep_device(codec, 0x10);
 +      if (err < 0) {
 +              ad198x_free(codec);
 +              return err;
 +      }
 +      set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
 +
        switch (board_config) {
        case AD1988_6STACK:
        case AD1988_6STACK_DIG:
@@@ -3141,6 -3126,12 +3150,6 @@@ static struct snd_kcontrol_new ad1884_b
        HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
        HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
        HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
 -      /*
 -      HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
 -      HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
 -      HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
 -      */
        HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@@ -3213,10 -3204,10 +3222,10 @@@ static struct hda_verb ad1884_init_verb
        {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
        /* Port-B (front mic) pin */
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
 -      {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
 +      {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        /* Port-C (rear mic) pin */
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
 -      {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
 +      {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        /* Analog mixer; mute as default */
        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
@@@ -3249,7 -3240,7 +3258,7 @@@ static const char *ad1884_slave_vols[] 
        "CD Playback Volume",
        "Internal Mic Playback Volume",
        "Docking Mic Playback Volume"
 -      "Beep Playback Volume",
 +      /* "Beep Playback Volume", */
        "IEC958 Playback Volume",
        NULL
  };
  static int patch_ad1884(struct hda_codec *codec)
  {
        struct ad198x_spec *spec;
 +      int err;
  
        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
  
        codec->spec = spec;
  
 +      err = snd_hda_attach_beep_device(codec, 0x10);
 +      if (err < 0) {
 +              ad198x_free(codec);
 +              return err;
 +      }
 +      set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
 +
        spec->multiout.max_channels = 2;
        spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
        spec->multiout.dac_nids = ad1884_dac_nids;
@@@ -3338,6 -3321,8 +3347,6 @@@ static struct snd_kcontrol_new ad1984_t
        HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT),
 -      HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
        HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
@@@ -3373,7 -3358,7 +3382,7 @@@ static struct hda_verb ad1984_thinkpad_
        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
        {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
        /* docking mic boost */
 -      {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
 +      {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
        /* Analog mixer - docking mic; mute as default */
        {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
        /* enable EAPD bit */
@@@ -3394,6 -3379,10 +3403,6 @@@ static struct snd_kcontrol_new ad1984_d
        HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
        HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT),
        HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT),
 -      /*
 -      HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
 -      HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
 -      */
        HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@@ -3479,7 -3468,7 +3488,7 @@@ static const char *ad1984_models[AD1984
  
  static struct snd_pci_quirk ad1984_cfg_tbl[] = {
        /* Lenovo Thinkpad T61/X61 */
 -      SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD),
 +      SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1984_THINKPAD),
        SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP),
        {}
  };
@@@ -3572,6 -3561,8 +3581,6 @@@ static struct snd_kcontrol_new ad1884a_
        HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
        HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
        HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
 -      HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
        HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT),
@@@ -3631,10 -3622,10 +3640,10 @@@ static struct hda_verb ad1884a_init_ver
        {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
        /* Port-B (front mic) pin */
        {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
 -      {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
 +      {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        /* Port-C (rear line-in) pin */
        {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
 -      {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
 +      {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        /* Port-E (rear mic) pin */
        {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
        {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
@@@ -3704,6 -3695,8 +3713,6 @@@ static struct snd_kcontrol_new ad1884a_
        HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
        HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
        HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
 -      HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT),
@@@ -3731,6 -3724,8 +3740,6 @@@ static struct snd_kcontrol_new ad1884a_
        HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
        HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
 -      HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@@ -3841,6 -3836,8 +3850,6 @@@ static struct snd_kcontrol_new ad1984a_
        HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
        HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
 -      HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
        HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT),
        HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@@ -3914,8 -3911,6 +3923,8 @@@ static struct snd_pci_quirk ad1884a_cfg
        SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
        SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP),
        SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE),
 +      SND_PCI_QUIRK(0x103c, 0x3072, "HP", AD1884A_LAPTOP),
 +      SND_PCI_QUIRK(0x103c, 0x3077, "HP", AD1884A_LAPTOP),
        SND_PCI_QUIRK(0x103c, 0x30e6, "HP 6730b", AD1884A_LAPTOP),
        SND_PCI_QUIRK(0x103c, 0x30e7, "HP EliteBook 8530p", AD1884A_LAPTOP),
        SND_PCI_QUIRK(0x103c, 0x3614, "HP 6730s", AD1884A_LAPTOP),
  static int patch_ad1884a(struct hda_codec *codec)
  {
        struct ad198x_spec *spec;
 -      int board_config;
 +      int err, board_config;
  
        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
  
        codec->spec = spec;
  
 +      err = snd_hda_attach_beep_device(codec, 0x10);
 +      if (err < 0) {
 +              ad198x_free(codec);
 +              return err;
 +      }
 +      set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
 +
        spec->multiout.max_channels = 2;
        spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids);
        spec->multiout.dac_nids = ad1884a_dac_nids;
@@@ -4095,6 -4083,8 +4104,6 @@@ static struct snd_kcontrol_new ad1882_l
        HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT),
        HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
        HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
 -      HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
        { } /* end */
  };
  
@@@ -4107,6 -4097,8 +4116,6 @@@ static struct snd_kcontrol_new ad1882a_
        HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
        HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
        HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
 -      HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
 -      HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
        HDA_CODEC_VOLUME("Digital Mic Boost", 0x1f, 0x0, HDA_INPUT),
        { } /* end */
  };
@@@ -4265,7 -4257,7 +4274,7 @@@ static const char *ad1882_models[AD1986
  static int patch_ad1882(struct hda_codec *codec)
  {
        struct ad198x_spec *spec;
 -      int board_config;
 +      int err, board_config;
  
        spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
  
        codec->spec = spec;
  
 +      err = snd_hda_attach_beep_device(codec, 0x10);
 +      if (err < 0) {
 +              ad198x_free(codec);
 +              return err;
 +      }
 +      set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
 +
        spec->multiout.max_channels = 6;
        spec->multiout.num_dacs = 3;
        spec->multiout.dac_nids = ad1882_dac_nids;
index c8573e265e00efcad7be2099ea6d362581792abd,8027edf3c8f2ab2d13848b45ab3a66495ceb2e81..aeb5d2126daeb0400d5f1f8050e10859d096d5c7
@@@ -66,7 -66,6 +66,7 @@@ enum 
        STAC_9205_DELL_M42,
        STAC_9205_DELL_M43,
        STAC_9205_DELL_M44,
 +      STAC_9205_EAPD,
        STAC_9205_MODELS
  };
  
@@@ -83,7 -82,6 +83,7 @@@ enum 
  enum {
        STAC_92HD83XXX_REF,
        STAC_92HD83XXX_PWR_REF,
 +      STAC_DELL_S14,
        STAC_92HD83XXX_MODELS
  };
  
@@@ -169,7 -167,6 +169,7 @@@ struct sigmatel_spec 
        unsigned int alt_switch: 1;
        unsigned int hp_detect: 1;
        unsigned int spdif_mute: 1;
 +      unsigned int check_volume_offset:1;
  
        /* gpio lines */
        unsigned int eapd_mask;
        hda_nid_t hp_dacs[5];
        hda_nid_t speaker_dacs[5];
  
 +      int volume_offset;
 +
        /* capture */
        hda_nid_t *adc_nids;
        unsigned int num_adcs;
@@@ -405,10 -400,6 +405,10 @@@ static hda_nid_t stac922x_mux_nids[2] 
          0x12, 0x13,
  };
  
 +static hda_nid_t stac927x_slave_dig_outs[2] = {
 +      0x1f, 0,
 +};
 +
  static hda_nid_t stac927x_adc_nids[3] = {
          0x07, 0x08, 0x09
  };
@@@ -481,21 -472,15 +481,21 @@@ static hda_nid_t stac92hd73xx_pin_nids[
        0x14, 0x22, 0x23
  };
  
 -static hda_nid_t stac92hd83xxx_pin_nids[14] = {
 +static hda_nid_t stac92hd83xxx_pin_nids[10] = {
        0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
 -      0x0f, 0x10, 0x11, 0x12, 0x13,
 -      0x1d, 0x1e, 0x1f, 0x20
 +      0x0f, 0x10, 0x11, 0x1f, 0x20,
  };
 -static hda_nid_t stac92hd71bxx_pin_nids[11] = {
 +
 +#define STAC92HD71BXX_NUM_PINS 13
 +static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
 +      0x0a, 0x0b, 0x0c, 0x0d, 0x00,
 +      0x00, 0x14, 0x18, 0x19, 0x1e,
 +      0x1f, 0x20, 0x27
 +};
 +static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
        0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
        0x0f, 0x14, 0x18, 0x19, 0x1e,
 -      0x1f,
 +      0x1f, 0x20, 0x27
  };
  
  static hda_nid_t stac927x_pin_nids[14] = {
@@@ -857,9 -842,9 +857,9 @@@ static struct hda_verb stac92hd73xx_10c
  };
  
  static struct hda_verb stac92hd83xxx_core_init[] = {
 -      { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
 -      { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
 -      { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
 +      { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
 +      { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
 +      { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
  
        /* 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},
 -      /* 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
 +#define HD_DISABLE_PORTF 1
  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},
 -      /* unmute right and left channels for nodes 0x0a, 0xd */
 +      {}
 +};
 +
 +static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
 +      /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
 +      { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
        {}
@@@ -968,6 -954,16 +968,6 @@@ static struct hda_verb stac9205_core_in
                .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
        }
  
 -#define STAC_INPUT_SOURCE(cnt) \
 -      { \
 -              .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
 -              .name = "Input Source", \
 -              .count = cnt, \
 -              .info = stac92xx_mux_enum_info, \
 -              .get = stac92xx_mux_enum_get, \
 -              .put = stac92xx_mux_enum_put, \
 -      }
 -
  #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
        { \
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  static struct snd_kcontrol_new stac9200_mixer[] = {
        HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
 -      STAC_INPUT_SOURCE(1),
        HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
        { } /* end */
@@@ -1097,6 -1094,7 +1097,6 @@@ static struct snd_kcontrol_new stac92hd
  };
  
  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),
  };
  
  static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
 -      STAC_INPUT_SOURCE(2),
        STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
  
        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
  static struct snd_kcontrol_new stac925x_mixer[] = {
        HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
 -      STAC_INPUT_SOURCE(1),
        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
        HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
        { } /* end */
  };
  
  static struct snd_kcontrol_new stac9205_mixer[] = {
 -      STAC_INPUT_SOURCE(2),
        STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
  
        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
  
  /* This needs to be generated dynamically based on sequence */
  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),
  
  
  
  static struct snd_kcontrol_new stac927x_mixer[] = {
 -      STAC_INPUT_SOURCE(3),
        STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
  
        HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
@@@ -1291,8 -1294,6 +1291,8 @@@ static int stac92xx_build_controls(stru
                unsigned int vmaster_tlv[4];
                snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
                                        HDA_OUTPUT, vmaster_tlv);
 +              /* correct volume offset */
 +              vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
                err = snd_hda_add_vmaster(codec, "Master Playback Volume",
                                          vmaster_tlv, slave_vols);
                if (err < 0)
@@@ -1510,8 -1511,6 +1510,8 @@@ static struct snd_pci_quirk stac9200_cf
        /* SigmaTel reference board */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
                      "DFI LanParty", STAC_REF),
 +      SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
 +                    "DFI LanParty", STAC_REF),
        /* Dell laptops have BIOS problem */
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
                      "unknown Dell", STAC_9200_DELL_D21),
@@@ -1661,7 -1660,6 +1661,7 @@@ static struct snd_pci_quirk stac925x_co
  static struct snd_pci_quirk stac925x_cfg_tbl[] = {
        /* SigmaTel reference board */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
 +      SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
        SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
  
        /* Default table for unknown ID */
@@@ -1705,8 -1703,6 +1705,8 @@@ static struct snd_pci_quirk stac92hd73x
        /* SigmaTel reference board */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
                                "DFI LanParty", STAC_92HD73XX_REF),
 +      SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
 +                              "DFI LanParty", STAC_92HD73XX_REF),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
                                "Dell Studio 1535", STAC_DELL_M6_DMIC),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
        {} /* terminator */
  };
  
 -static unsigned int ref92hd83xxx_pin_configs[14] = {
 +static unsigned int ref92hd83xxx_pin_configs[10] = {
        0x02214030, 0x02211010, 0x02a19020, 0x02170130,
        0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
 -      0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
        0x01451160, 0x98560170,
  };
  
 +static unsigned int dell_s14_pin_configs[10] = {
 +      0x02214030, 0x02211010, 0x02a19020, 0x01014050,
 +      0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
 +      0x40f000f0, 0x40f000f0,
 +};
 +
  static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
        [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
        [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
 +      [STAC_DELL_S14] = dell_s14_pin_configs,
  };
  
  static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
        [STAC_92HD83XXX_REF] = "ref",
        [STAC_92HD83XXX_PWR_REF] = "mic-ref",
 +      [STAC_DELL_S14] = "dell-s14",
  };
  
  static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
        /* SigmaTel reference board */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
                      "DFI LanParty", STAC_92HD83XXX_REF),
 +      SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
 +                    "DFI LanParty", STAC_92HD83XXX_REF),
 +      SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
 +                    "unknown Dell", STAC_DELL_S14),
        {} /* terminator */
  };
  
 -static unsigned int ref92hd71bxx_pin_configs[11] = {
 +static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
        0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
        0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
 -      0x90a000f0, 0x01452050, 0x01452050,
 +      0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
 +      0x00000000
  };
  
 -static unsigned int dell_m4_1_pin_configs[11] = {
 +static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
        0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
        0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
 -      0x40f000f0, 0x4f0000f0, 0x4f0000f0,
 +      0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
 +      0x00000000
  };
  
 -static unsigned int dell_m4_2_pin_configs[11] = {
 +static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
        0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
        0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
 -      0x40f000f0, 0x044413b0, 0x044413b0,
 +      0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
 +      0x00000000
  };
  
 -static unsigned int dell_m4_3_pin_configs[11] = {
 +static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
        0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
        0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
 -      0x40f000f0, 0x044413b0, 0x044413b0,
 +      0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
 +      0x00000000
  };
  
  static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
@@@ -1815,8 -1796,6 +1815,8 @@@ static struct snd_pci_quirk stac92hd71b
        /* SigmaTel reference board */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
                      "DFI LanParty", STAC_92HD71BXX_REF),
 +      SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
 +                    "DFI LanParty", STAC_92HD71BXX_REF),
        SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2,
                      "HP dv5", STAC_HP_M4),
        SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4,
@@@ -2009,8 -1988,6 +2009,8 @@@ static struct snd_pci_quirk stac922x_cf
        /* SigmaTel reference board */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
                      "DFI LanParty", STAC_D945_REF),
 +      SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
 +                    "DFI LanParty", STAC_D945_REF),
        /* Intel 945G based systems */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
                      "Intel D945G", STAC_D945GTP3),
                      "Intel D945P", STAC_D945GTP3),
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
                      "Intel D945P", STAC_D945GTP5),
 +      /* other intel */
 +      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
 +                    "Intel D945", STAC_D945_REF),
        /* other systems  */
        /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
        SND_PCI_QUIRK(0x8384, 0x7680,
        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,
 +      SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
                      "ECS/PC chips", STAC_ECS_202),
        {} /* terminator */
  };
@@@ -2146,16 -2144,26 +2146,16 @@@ static struct snd_pci_quirk stac927x_cf
        /* SigmaTel reference board */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
                      "DFI LanParty", STAC_D965_REF),
 +      SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
 +                    "DFI LanParty", STAC_D965_REF),
         /* Intel 946 based systems */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
        /* 965 based 3 stack systems */
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
 +      SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
 +                         "Intel D965", STAC_D965_3ST),
 +      SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
 +                         "Intel D965", STAC_D965_3ST),
        /* Dell 3 stack systems */
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x02ff, "Dell     ", STAC_DELL_BIOS),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL,  0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
        /* 965 based 5 stack systems */
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
 -      SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
 +      SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
 +                         "Intel D965", STAC_D965_5ST),
 +      SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
 +                         "Intel D965", STAC_D965_5ST),
        {} /* terminator */
  };
  
@@@ -2227,7 -2240,6 +2227,7 @@@ static unsigned int *stac9205_brd_tbl[S
        [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
        [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
        [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
 +      [STAC_9205_EAPD] = NULL,
  };
  
  static const char *stac9205_models[STAC_9205_MODELS] = {
        [STAC_9205_DELL_M42] = "dell-m42",
        [STAC_9205_DELL_M43] = "dell-m43",
        [STAC_9205_DELL_M44] = "dell-m44",
 +      [STAC_9205_EAPD] = "eapd",
  };
  
  static struct snd_pci_quirk stac9205_cfg_tbl[] = {
        /* SigmaTel reference board */
        SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
                      "DFI LanParty", STAC_9205_REF),
 +      SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
 +                    "DFI LanParty", STAC_9205_REF),
 +      /* Dell */
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
                      "unknown Dell", STAC_9205_DELL_M42),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
                      "Dell Inspiron", STAC_9205_DELL_M44),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
                      "Dell Vostro 1500", STAC_9205_DELL_M42),
 +      /* Gateway */
 +      SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
        {} /* terminator */
  };
  
@@@ -2294,9 -2300,7 +2294,9 @@@ static int stac92xx_save_bios_config_re
        for (i = 0; i < spec->num_pins; i++) {
                hda_nid_t nid = spec->pin_nids[i];
                unsigned int pin_cfg;
 -              
 +
 +              if (!nid)
 +                      continue;
                pin_cfg = snd_hda_codec_read(codec, nid, 0, 
                        AC_VERB_GET_CONFIG_DEFAULT, 0x00);      
                snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
@@@ -2339,9 -2343,8 +2339,9 @@@ static void stac92xx_set_config_regs(st
                return;
  
        for (i = 0; i < spec->num_pins; i++)
 -              stac92xx_set_config_reg(codec, spec->pin_nids[i],
 -                                      spec->pin_configs[i]);
 +              if (spec->pin_nids[i] && spec->pin_configs[i])
 +                      stac92xx_set_config_reg(codec, spec->pin_nids[i],
 +                                              spec->pin_configs[i]);
  }
  
  static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
@@@ -2439,6 -2442,14 +2439,14 @@@ static int stac92xx_dig_playback_pcm_pr
                                             stream_tag, format, substream);
  }
  
+ static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
+                                       struct hda_codec *codec,
+                                       struct snd_pcm_substream *substream)
+ {
+       struct sigmatel_spec *spec = codec->spec;
+       return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
+ }
  
  /*
   * Analog capture callbacks
@@@ -2483,7 -2494,8 +2491,8 @@@ static struct hda_pcm_stream stac92xx_p
        .ops = {
                .open = stac92xx_dig_playback_pcm_open,
                .close = stac92xx_dig_playback_pcm_close,
-               .prepare = stac92xx_dig_playback_pcm_prepare
+               .prepare = stac92xx_dig_playback_pcm_prepare,
+               .cleanup = stac92xx_dig_playback_pcm_cleanup
        },
  };
  
@@@ -2555,7 -2567,7 +2564,7 @@@ static int stac92xx_build_pcms(struct h
                codec->num_pcms++;
                info++;
                info->name = "STAC92xx Digital";
 -              info->pcm_type = HDA_PCM_TYPE_SPDIF;
 +              info->pcm_type = spec->autocfg.dig_out_type[0];
                if (spec->multiout.dig_out_nid) {
                        info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
                        info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
@@@ -2747,37 -2759,22 +2756,37 @@@ static struct snd_kcontrol_new stac92xx
  };
  
  /* add dynamic controls */
 -static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
 -                                   struct snd_kcontrol_new *ktemp,
 -                                   int idx, const char *name,
 -                                   unsigned long val)
 +static struct snd_kcontrol_new *
 +stac_control_new(struct sigmatel_spec *spec,
 +               struct snd_kcontrol_new *ktemp,
 +               const char *name)
  {
        struct snd_kcontrol_new *knew;
  
        snd_array_init(&spec->kctls, sizeof(*knew), 32);
        knew = snd_array_new(&spec->kctls);
        if (!knew)
 -              return -ENOMEM;
 +              return NULL;
        *knew = *ktemp;
 -      knew->index = idx;
        knew->name = kstrdup(name, GFP_KERNEL);
 -      if (!knew->name)
 +      if (!knew->name) {
 +              /* roolback */
 +              memset(knew, 0, sizeof(*knew));
 +              spec->kctls.alloced--;
 +              return NULL;
 +      }
 +      return knew;
 +}
 +
 +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 = stac_control_new(spec, ktemp, name);
 +      if (!knew)
                return -ENOMEM;
 +      knew->index = idx;
        knew->private_value = val;
        return 0;
  }
@@@ -2799,29 -2796,6 +2808,29 @@@ static inline int stac92xx_add_control(
        return stac92xx_add_control_idx(spec, type, 0, name, val);
  }
  
 +static struct snd_kcontrol_new stac_input_src_temp = {
 +      .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 +      .name = "Input Source",
 +      .info = stac92xx_mux_enum_info,
 +      .get = stac92xx_mux_enum_get,
 +      .put = stac92xx_mux_enum_put,
 +};
 +
 +static int stac92xx_add_input_source(struct sigmatel_spec *spec)
 +{
 +      struct snd_kcontrol_new *knew;
 +      struct hda_input_mux *imux = &spec->private_imux;
 +
 +      if (!spec->num_adcs || imux->num_items <= 1)
 +              return 0; /* no need for input source control */
 +      knew = stac_control_new(spec, &stac_input_src_temp,
 +                              stac_input_src_temp.name);
 +      if (!knew)
 +              return -ENOMEM;
 +      knew->count = spec->num_adcs;
 +      return 0;
 +}
 +
  /* check whether the line-input can be used as line-out */
  static hda_nid_t check_line_out_switch(struct hda_codec *codec)
  {
@@@ -3020,34 -2994,14 +3029,34 @@@ static int stac92xx_auto_fill_dac_nids(
  }
  
  /* create volume control/switch for the given prefx type */
 -static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
 +static int create_controls(struct hda_codec *codec, const char *pfx,
 +                         hda_nid_t nid, int chs)
  {
 +      struct sigmatel_spec *spec = codec->spec;
        char name[32];
        int err;
  
 +      if (!spec->check_volume_offset) {
 +              unsigned int caps, step, nums, db_scale;
 +              caps = query_amp_caps(codec, nid, HDA_OUTPUT);
 +              step = (caps & AC_AMPCAP_STEP_SIZE) >>
 +                      AC_AMPCAP_STEP_SIZE_SHIFT;
 +              step = (step + 1) * 25; /* in .01dB unit */
 +              nums = (caps & AC_AMPCAP_NUM_STEPS) >>
 +                      AC_AMPCAP_NUM_STEPS_SHIFT;
 +              db_scale = nums * step;
 +              /* if dB scale is over -64dB, and finer enough,
 +               * let's reduce it to half
 +               */
 +              if (db_scale > 6400 && nums >= 0x1f)
 +                      spec->volume_offset = nums / 2;
 +              spec->check_volume_offset = 1;
 +      }
 +
        sprintf(name, "%s Playback Volume", pfx);
        err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
 -                                 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
 +              HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
 +                                      spec->volume_offset));
        if (err < 0)
                return err;
        sprintf(name, "%s Playback Switch", pfx);
@@@ -3113,10 -3067,10 +3122,10 @@@ static int stac92xx_auto_create_multi_o
                nid = spec->multiout.dac_nids[i];
                if (i == 2) {
                        /* Center/LFE */
 -                      err = create_controls(spec, "Center", nid, 1);
 +                      err = create_controls(codec, "Center", nid, 1);
                        if (err < 0)
                                return err;
 -                      err = create_controls(spec, "LFE", nid, 2);
 +                      err = create_controls(codec, "LFE", nid, 2);
                        if (err < 0)
                                return err;
  
                                        break;
                                }
                        }
 -                      err = create_controls(spec, name, nid, 3);
 +                      err = create_controls(codec, name, nid, 3);
                        if (err < 0)
                                return err;
                }
@@@ -3199,7 -3153,7 +3208,7 @@@ static int stac92xx_auto_create_hp_ctls
                nid = spec->hp_dacs[i];
                if (!nid)
                        continue;
 -              err = create_controls(spec, pfxs[nums++], nid, 3);
 +              err = create_controls(codec, pfxs[nums++], nid, 3);
                if (err < 0)
                        return err;
        }
                nid = spec->speaker_dacs[i];
                if (!nid)
                        continue;
 -              err = create_controls(spec, pfxs[nums++], nid, 3);
 +              err = create_controls(codec, pfxs[nums++], nid, 3);
                if (err < 0)
                        return err;
        }
@@@ -3707,15 -3661,11 +3716,15 @@@ static int stac92xx_parse_auto_config(s
                        return err;
        }
  
 +      err = stac92xx_add_input_source(spec);
 +      if (err < 0)
 +              return err;
 +
        spec->multiout.max_channels = spec->multiout.num_dacs * 2;
        if (spec->multiout.max_channels > 2)
                spec->surr_switch = 1;
  
 -      if (spec->autocfg.dig_out_pin)
 +      if (spec->autocfg.dig_outs)
                spec->multiout.dig_out_nid = dig_out;
        if (dig_in && spec->autocfg.dig_in_pin)
                spec->dig_in_nid = dig_in;
@@@ -3793,7 -3743,7 +3802,7 @@@ static int stac9200_auto_create_lfe_ctl
        }
  
        if (lfe_pin) {
 -              err = create_controls(spec, "LFE", lfe_pin, 1);
 +              err = create_controls(codec, "LFE", lfe_pin, 1);
                if (err < 0)
                        return err;
        }
@@@ -3824,11 -3774,7 +3833,11 @@@ static int stac9200_parse_auto_config(s
                        return err;
        }
  
 -      if (spec->autocfg.dig_out_pin)
 +      err = stac92xx_add_input_source(spec);
 +      if (err < 0)
 +              return err;
 +
 +      if (spec->autocfg.dig_outs)
                spec->multiout.dig_out_nid = 0x05;
        if (spec->autocfg.dig_in_pin)
                spec->dig_in_nid = 0x04;
@@@ -4078,8 -4024,8 +4087,8 @@@ static int stac92xx_init(struct hda_cod
        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,
 +      if (cfg->dig_out_pins[0])
 +              stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
                                         AC_PINCTL_OUT_EN);
        if (cfg->dig_in_pin)
                stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
@@@ -4173,9 -4119,7 +4182,9 @@@ static void stac92xx_free(struct hda_co
  static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
                                unsigned int flag)
  {
 -      unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
 +      unsigned int old_ctl, pin_ctl;
 +
 +      pin_ctl = snd_hda_codec_read(codec, nid,
                        0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  
        if (pin_ctl & AC_PINCTL_IN_EN) {
                        return;
        }
  
 +      old_ctl = pin_ctl;
        /* if setting pin direction bits, clear the current
           direction bits first */
        if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
                pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
        
 -      snd_hda_codec_write_cache(codec, nid, 0,
 -                      AC_VERB_SET_PIN_WIDGET_CONTROL,
 -                      pin_ctl | flag);
 +      pin_ctl |= flag;
 +      if (old_ctl != pin_ctl)
 +              snd_hda_codec_write_cache(codec, nid, 0,
 +                                        AC_VERB_SET_PIN_WIDGET_CONTROL,
 +                                        pin_ctl);
  }
  
  static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
  {
        unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
                        0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
 -      snd_hda_codec_write_cache(codec, nid, 0,
 -                      AC_VERB_SET_PIN_WIDGET_CONTROL,
 -                      pin_ctl & ~flag);
 +      if (pin_ctl & flag)
 +              snd_hda_codec_write_cache(codec, nid, 0,
 +                                        AC_VERB_SET_PIN_WIDGET_CONTROL,
 +                                        pin_ctl & ~flag);
  }
  
  static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
@@@ -4831,7 -4771,6 +4840,7 @@@ static int patch_stac92hd83xxx(struct h
        hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
        int err;
        int num_dacs;
 +      hda_nid_t nid;
  
        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
        spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
        spec->multiout.dac_nids = spec->dac_nids;
  
 -
 -      /* set port 0xe to select the last DAC
 -       */
 -      num_dacs = snd_hda_get_connections(codec, 0x0e,
 -              conn, STAC92HD83_DAC_COUNT + 1) - 1;
 -
 -      snd_hda_codec_write_cache(codec, 0xe, 0,
 -              AC_VERB_SET_CONNECT_SEL, num_dacs);
 -
        spec->init = stac92hd83xxx_core_init;
        spec->mixer = stac92hd83xxx_mixer;
        spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
@@@ -4901,23 -4849,6 +4910,23 @@@ again
                return err;
        }
  
 +      switch (spec->board_config) {
 +      case STAC_DELL_S14:
 +              nid = 0xf;
 +              break;
 +      default:
 +              nid = 0xe;
 +              break;
 +      }
 +
 +      num_dacs = snd_hda_get_connections(codec, nid,
 +                              conn, STAC92HD83_DAC_COUNT + 1) - 1;
 +
 +      /* set port X to select the last DAC
 +       */
 +      snd_hda_codec_write_cache(codec, nid, 0,
 +                      AC_VERB_SET_CONNECT_SEL, num_dacs);
 +
        codec->patch_ops = stac92xx_patch_ops;
  
        codec->proc_widget_hook = stac92hd_proc_hook;
        return 0;
  }
  
 -static struct hda_input_mux stac92hd71bxx_dmux = {
 +static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
 +      .num_items = 3,
 +      .items = {
 +              { "Analog Inputs", 0x00 },
 +              { "Digital Mic 1", 0x02 },
 +              { "Digital Mic 2", 0x03 },
 +      }
 +};
 +
 +static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
        .num_items = 4,
        .items = {
                { "Analog Inputs", 0x00 },
        }
  };
  
 +static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
 +                                       hda_nid_t *nids, int num_nids)
 +{
 +      struct sigmatel_spec *spec = codec->spec;
 +      int idx, num;
 +      unsigned int def_conf;
 +
 +      for (num = 0; num < num_nids; num++) {
 +              for (idx = 0; idx < spec->num_pins; idx++)
 +                      if (spec->pin_nids[idx] == nids[num])
 +                              break;
 +              if (idx >= spec->num_pins)
 +                      break;
 +              def_conf = get_defcfg_connect(spec->pin_configs[idx]);
 +              if (def_conf == AC_JACK_PORT_NONE)
 +                      break;
 +      }
 +      return num;
 +}
 +
 +static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
 +                                        hda_nid_t dig0pin)
 +{
 +      struct sigmatel_spec *spec = codec->spec;
 +      int idx;
 +
 +      for (idx = 0; idx < spec->num_pins; idx++)
 +              if (spec->pin_nids[idx] == dig0pin)
 +                      break;
 +      if ((idx + 2) >= spec->num_pins)
 +              return 0;
 +
 +      /* dig1pin case */
 +      if (get_defcfg_connect(spec->pin_configs[idx+1]) != AC_JACK_PORT_NONE)
 +              return 2;
 +
 +      /* dig0pin + dig2pin case */
 +      if (get_defcfg_connect(spec->pin_configs[idx+2]) != AC_JACK_PORT_NONE)
 +              return 2;
 +      if (get_defcfg_connect(spec->pin_configs[idx]) != AC_JACK_PORT_NONE)
 +              return 1;
 +      else
 +              return 0;
 +}
 +
  static int patch_stac92hd71bxx(struct hda_codec *codec)
  {
        struct sigmatel_spec *spec;
 +      struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
        int err = 0;
 +      unsigned int ndmic_nids = 0;
  
        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
  
        codec->spec = spec;
        codec->patch_ops = stac92xx_patch_ops;
 -      spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
 +      spec->num_pins = STAC92HD71BXX_NUM_PINS;
 +      switch (codec->vendor_id) {
 +      case 0x111d76b6:
 +      case 0x111d76b7:
 +              spec->pin_nids = stac92hd71bxx_pin_nids_4port;
 +              break;
 +      case 0x111d7603:
 +      case 0x111d7608:
 +              /* On 92HD75Bx 0x27 isn't a pin nid */
 +              spec->num_pins--;
 +              /* fallthrough */
 +      default:
 +              spec->pin_nids = stac92hd71bxx_pin_nids_6port;
 +      }
        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,
@@@ -5041,34 -4906,16 +5050,34 @@@ again
                spec->gpio_data = 0x01;
        }
  
 +      spec->dmic_nids = stac92hd71bxx_dmic_nids;
 +      spec->dmux_nids = stac92hd71bxx_dmux_nids;
 +
        switch (codec->vendor_id) {
        case 0x111d76b6: /* 4 Port without Analog Mixer */
        case 0x111d76b7:
 +              unmute_init++;
 +              /* fallthru */
        case 0x111d76b4: /* 6 Port without Analog Mixer */
        case 0x111d76b5:
 +              memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
 +                     sizeof(stac92hd71bxx_dmux_nomixer));
                spec->mixer = stac92hd71bxx_mixer;
                spec->init = stac92hd71bxx_core_init;
                codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
 +              spec->num_dmics = stac92hd71bxx_connected_ports(codec,
 +                                      stac92hd71bxx_dmic_nids,
 +                                      STAC92HD71BXX_NUM_DMICS);
 +              if (spec->num_dmics) {
 +                      spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
 +                      spec->dinput_mux = &spec->private_dimux;
 +                      ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
 +              }
                break;
        case 0x111d7608: /* 5 Port with Analog Mixer */
 +              memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
 +                     sizeof(stac92hd71bxx_dmux_amixer));
 +              spec->private_dimux.num_items--;
                switch (spec->board_config) {
                case STAC_HP_M4:
                        /* Enable VREF power saving on GPIO1 detect */
  
                /* disable VSW */
                spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
 -              stac_change_pin_config(codec, 0xf, 0x40f000f0);
 +              unmute_init++;
 +              stac_change_pin_config(codec, 0x0f, 0x40f000f0);
 +              stac_change_pin_config(codec, 0x19, 0x40f000f3);
 +              stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
 +              spec->num_dmics = stac92hd71bxx_connected_ports(codec,
 +                                      stac92hd71bxx_dmic_nids,
 +                                      STAC92HD71BXX_NUM_DMICS - 1);
 +              spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
 +              ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
                break;
        case 0x111d7603: /* 6 Port with Analog Mixer */
                if ((codec->revision_id & 0xf) == 1)
                spec->num_pwrs = 0;
                /* fallthru */
        default:
 +              memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
 +                     sizeof(stac92hd71bxx_dmux_amixer));
                spec->dinput_mux = &spec->private_dimux;
                spec->mixer = stac92hd71bxx_analog_mixer;
                spec->init = stac92hd71bxx_analog_core_init;
                codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
 +              spec->num_dmics = stac92hd71bxx_connected_ports(codec,
 +                                      stac92hd71bxx_dmic_nids,
 +                                      STAC92HD71BXX_NUM_DMICS);
 +              spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
 +              ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
        }
  
 +      if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
 +              snd_hda_sequence_write_cache(codec, unmute_init);
 +
        spec->aloopback_mask = 0x50;
        spec->aloopback_shift = 0;
  
        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_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
  
        switch (spec->board_config) {
        case STAC_HP_M4:
                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.dac_nids = spec->dac_nids;
        if (spec->dinput_mux)
 -              spec->private_dimux.num_items +=
 -                      spec->num_dmics -
 -                              (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
 +              spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
  
 -      err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
 +      err = stac92xx_parse_auto_config(codec, 0x21, 0);
        if (!err) {
                if (spec->board_config < 0) {
                        printk(KERN_WARNING "hda_codec: No auto-config is "
@@@ -5303,16 -5139,16 +5312,16 @@@ static int patch_stac927x(struct hda_co
                return -ENOMEM;
  
        codec->spec = spec;
 +      codec->slave_dig_outs = stac927x_slave_dig_outs;
        spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
        spec->pin_nids = stac927x_pin_nids;
        spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
                                                        stac927x_models,
                                                        stac927x_cfg_tbl);
   again:
 -      if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
 -              if (spec->board_config < 0)
 -                      snd_printdd(KERN_INFO "hda_codec: Unknown model for"
 -                                  "STAC927x, using BIOS defaults\n");
 +      if (spec->board_config < 0) {
 +              snd_printdd(KERN_INFO "hda_codec: Unknown model for"
 +                          "STAC927x, using BIOS defaults\n");
                err = stac92xx_save_bios_config_regs(codec);
        } else
                err = stac_save_pin_cfgs(codec,
@@@ -5471,9 -5307,7 +5480,9 @@@ static int patch_stac9205(struct hda_co
  
        spec->aloopback_mask = 0x40;
        spec->aloopback_shift = 0;
 -      spec->eapd_switch = 1;
 +      /* Turn on/off EAPD per HP plugging */
 +      if (spec->board_config != STAC_9205_EAPD)
 +              spec->eapd_switch = 1;
        spec->multiout.dac_nids = spec->dac_nids;
        
        switch (spec->board_config){
   * STAC9872 hack
   */
  
 -/* static config for Sony VAIO FE550G and Sony VAIO AR */
 -static hda_nid_t vaio_dacs[] = { 0x2 };
 -#define VAIO_HP_DAC   0x5
 -static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
 -static hda_nid_t vaio_mux_nids[] = { 0x15 };
 -
 -static struct hda_input_mux vaio_mux = {
 -      .num_items = 3,
 -      .items = {
 -              /* { "HP", 0x0 }, */
 -              { "Mic Jack", 0x1 },
 -              { "Internal Mic", 0x2 },
 -              { "PCM", 0x3 },
 -      }
 -};
 -
 -static struct hda_verb vaio_init[] = {
 -      {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
 -      {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
 -      {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
 -      {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
 -      {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
 -      {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
 +static struct hda_verb stac9872_core_init[] = {
        {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
 -      {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
 -      {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
 -      {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
 -      {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
        {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
        {}
  };
  
 -static struct hda_verb vaio_ar_init[] = {
 -      {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
 -      {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
 -      {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
 -      {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
 -/*    {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
 -      {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
 -      {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
 -      {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
 -      {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
 -/*    {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
 -      {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
 -      {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
 -      {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
 -      {}
 -};
 -
 -static struct snd_kcontrol_new vaio_mixer[] = {
 -      HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
 -      HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
 -      /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
 -      HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
 -      HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
 -      {
 -              .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 -              .name = "Capture Source",
 -              .count = 1,
 -              .info = stac92xx_mux_enum_info,
 -              .get = stac92xx_mux_enum_get,
 -              .put = stac92xx_mux_enum_put,
 -      },
 -      {}
 -};
 -
 -static struct snd_kcontrol_new vaio_ar_mixer[] = {
 -      HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
 -      HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
 -      HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
 -      /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
 +static struct snd_kcontrol_new stac9872_mixer[] = {
        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
        HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
 -      /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
 -      HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
 -      {
 -              .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
 -              .name = "Capture Source",
 -              .count = 1,
 -              .info = stac92xx_mux_enum_info,
 -              .get = stac92xx_mux_enum_get,
 -              .put = stac92xx_mux_enum_put,
 -      },
 -      {}
 -};
 -
 -static struct hda_codec_ops stac9872_patch_ops = {
 -      .build_controls = stac92xx_build_controls,
 -      .build_pcms = stac92xx_build_pcms,
 -      .init = stac92xx_init,
 -      .free = stac92xx_free,
 -#ifdef SND_HDA_NEEDS_RESUME
 -      .resume = stac92xx_resume,
 -#endif
 -};
 -
 -static int stac9872_vaio_init(struct hda_codec *codec)
 -{
 -      int err;
 -
 -      err = stac92xx_init(codec);
 -      if (err < 0)
 -              return err;
 -      if (codec->patch_ops.unsol_event)
 -              codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
 -      return 0;
 -}
 -
 -static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
 -{
 -      if (get_pin_presence(codec, 0x0a)) {
 -              stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
 -              stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
 -      } else {
 -              stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
 -              stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
 -      }
 -} 
 -
 -static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
 -{
 -      switch (res >> 26) {
 -      case STAC_HP_EVENT:
 -              stac9872_vaio_hp_detect(codec, res);
 -              break;
 -      }
 -}
 -
 -static struct hda_codec_ops stac9872_vaio_patch_ops = {
 -      .build_controls = stac92xx_build_controls,
 -      .build_pcms = stac92xx_build_pcms,
 -      .init = stac9872_vaio_init,
 -      .free = stac92xx_free,
 -      .unsol_event = stac9872_vaio_unsol_event,
 -#ifdef CONFIG_PM
 -      .resume = stac92xx_resume,
 -#endif
 +      { } /* end */
  };
  
 -enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
 -       CXD9872RD_VAIO,
 -       /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
 -       STAC9872AK_VAIO, 
 -       /* Unknown. id=0x83847661 and subsys=0x104D1200. */
 -       STAC9872K_VAIO,
 -       /* AR Series. id=0x83847664 and subsys=104D1300 */
 -       CXD9872AKD_VAIO,
 -       STAC_9872_MODELS,
 +static hda_nid_t stac9872_pin_nids[] = {
 +      0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
 +      0x11, 0x13, 0x14,
  };
  
 -static const char *stac9872_models[STAC_9872_MODELS] = {
 -      [CXD9872RD_VAIO]        = "vaio",
 -      [CXD9872AKD_VAIO]       = "vaio-ar",
 +static hda_nid_t stac9872_adc_nids[] = {
 +      0x8 /*,0x6*/
  };
  
 -static struct snd_pci_quirk stac9872_cfg_tbl[] = {
 -      SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
 -      SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
 -      SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
 -      SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
 -      {}
 +static hda_nid_t stac9872_mux_nids[] = {
 +      0x15
  };
  
  static int patch_stac9872(struct hda_codec *codec)
  {
        struct sigmatel_spec *spec;
 -      int board_config;
 +      int err;
  
 -      board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
 -                                                stac9872_models,
 -                                                stac9872_cfg_tbl);
 -      if (board_config < 0)
 -              /* unknown config, let generic-parser do its job... */
 -              return snd_hda_parse_generic_codec(codec);
 -      
        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
                return -ENOMEM;
 -
        codec->spec = spec;
 -      switch (board_config) {
 -      case CXD9872RD_VAIO:
 -      case STAC9872AK_VAIO:
 -      case STAC9872K_VAIO:
 -              spec->mixer = vaio_mixer;
 -              spec->init = vaio_init;
 -              spec->multiout.max_channels = 2;
 -              spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
 -              spec->multiout.dac_nids = vaio_dacs;
 -              spec->multiout.hp_nid = VAIO_HP_DAC;
 -              spec->num_adcs = ARRAY_SIZE(vaio_adcs);
 -              spec->adc_nids = vaio_adcs;
 -              spec->num_pwrs = 0;
 -              spec->input_mux = &vaio_mux;
 -              spec->mux_nids = vaio_mux_nids;
 -              codec->patch_ops = stac9872_vaio_patch_ops;
 -              break;
 -      
 -      case CXD9872AKD_VAIO:
 -              spec->mixer = vaio_ar_mixer;
 -              spec->init = vaio_ar_init;
 -              spec->multiout.max_channels = 2;
 -              spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
 -              spec->multiout.dac_nids = vaio_dacs;
 -              spec->multiout.hp_nid = VAIO_HP_DAC;
 -              spec->num_adcs = ARRAY_SIZE(vaio_adcs);
 -              spec->num_pwrs = 0;
 -              spec->adc_nids = vaio_adcs;
 -              spec->input_mux = &vaio_mux;
 -              spec->mux_nids = vaio_mux_nids;
 -              codec->patch_ops = stac9872_patch_ops;
 -              break;
 -      }
  
 +#if 0 /* no model right now */
 +      spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
 +                                                      stac9872_models,
 +                                                      stac9872_cfg_tbl);
 +#endif
 +
 +      spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
 +      spec->pin_nids = stac9872_pin_nids;
 +      spec->multiout.dac_nids = spec->dac_nids;
 +      spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
 +      spec->adc_nids = stac9872_adc_nids;
 +      spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
 +      spec->mux_nids = stac9872_mux_nids;
 +      spec->mixer = stac9872_mixer;
 +      spec->init = stac9872_core_init;
 +
 +      err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
 +      if (err < 0) {
 +              stac92xx_free(codec);
 +              return -EINVAL;
 +      }
 +      spec->input_mux = &spec->private_imux;
 +      codec->patch_ops = stac92xx_patch_ops;
        return 0;
  }