[PATCH] [UBUNTU:sound] Fix initialization and routing for Realtek ALC* family HDA codecs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] [UBUNTU:sound] Fix initialization and routing for Realtek ALC* family HDA codecs

Daniel T Chen
UpstreamStatus: Added in upstream pci/hda/patch_realtek.c r1.32-r1.59

This gigantenormous patch properly fixes numerous bugs reported in
Malone (#6608, #18964, #21256, #27122, #28443, #28994, #33719) related
to Realtek HDA codecs. Users on ubuntuforums have also reported
difficulties in booting or getting audible output from their ALC* HDA
hardware[0]. This codec family is the most popular among new HDA sound
chipsets.

Significant changes to the initialization and routing for ALC* HDA
codecs, resulting in audible sound on affected hardware, necessitates
the invasiveness of these changes.

The xxx_t typedefs have been retained, as with the other HDA patches,
for compatibility.

[0] http://www.ubuntuforums.org/showthread.php?t=138120 ,
    http://www.ubuntuforums.org/showthread.php?t=138019 ,
    http://www.ubuntuforums.org/showthread.php?t=137994 ,
    http://www.ubuntuforums.org/showthread.php?t=133325 ,
    http://www.ubuntuforums.org/showthread.php?t=132188 ,
    http://www.ubuntuforums.org/showthread.php?t=126686 ,
    http://www.ubuntuforums.org/showthread.php?t=76307 ,
    http://www.ubuntuforums.org/showthread.php?t=76019 , ...

Signed-off-by: Daniel T Chen <[hidden email]>

---

 sound/pci/hda/patch_realtek.c | 3925 +++++++++++++++++++++++++++++++++++------
 1 files changed, 3371 insertions(+), 554 deletions(-)

8db18c04daa88b86833dfc3982be45afa331db6c
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index a0ba2e8..24c9867 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3,8 +3,10 @@
  *
  * HD audio interface patch for ALC 260/880/882 codecs
  *
- * Copyright (c) 2004 PeiSen Hou <[hidden email]>
+ * Copyright (c) 2004 Kailang Yang <[hidden email]>
+ *                    PeiSen Hou <[hidden email]>
  *                    Takashi Iwai <[hidden email]>
+ *                    Jonathan Woithe <[hidden email]>
  *
  *  This driver is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -39,17 +41,21 @@ enum {
  ALC880_5ST_DIG,
  ALC880_W810,
  ALC880_Z71V,
- ALC880_AUTO,
  ALC880_6ST,
  ALC880_6ST_DIG,
  ALC880_F1734,
  ALC880_ASUS,
  ALC880_ASUS_DIG,
  ALC880_ASUS_W1V,
+ ALC880_ASUS_DIG2,
  ALC880_UNIWILL_DIG,
+ ALC880_CLEVO,
+ ALC880_TCL_S700,
+ ALC880_LG,
 #ifdef CONFIG_SND_DEBUG
  ALC880_TEST,
 #endif
+ ALC880_AUTO,
  ALC880_MODEL_LAST /* last tag */
 };
 
@@ -57,30 +63,50 @@ enum {
 enum {
  ALC260_BASIC,
  ALC260_HP,
- ALC260_FUJITSU_S702x,
+ ALC260_HP_3013,
+ ALC260_FUJITSU_S702X,
+ ALC260_ACER,
+#ifdef CONFIG_SND_DEBUG
+ ALC260_TEST,
+#endif
+ ALC260_AUTO,
  ALC260_MODEL_LAST /* last tag */
 };
 
-/* amp values */
-#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
-#define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
-#define AMP_OUT_MUTE 0xb080
-#define AMP_OUT_UNMUTE 0xb000
-#define AMP_OUT_ZERO 0xb000
-/* pinctl values */
-#define PIN_IN 0x20
-#define PIN_VREF80 0x24
-#define PIN_VREF50 0x21
-#define PIN_OUT 0x40
-#define PIN_HP 0xc0
-#define PIN_HP_AMP 0x80
+/* ALC262 models */
+enum {
+ ALC262_BASIC,
+ ALC262_FUJITSU,
+ ALC262_AUTO,
+ ALC262_MODEL_LAST /* last tag */
+};
+
+/* ALC861 models */
+enum {
+ ALC861_3ST,
+ ALC861_3ST_DIG,
+ ALC861_6ST_DIG,
+ ALC861_AUTO,
+ ALC861_MODEL_LAST,
+};
+
+/* ALC882 models */
+enum {
+ ALC882_3ST_DIG,
+ ALC882_6ST_DIG,
+ ALC882_AUTO,
+ ALC882_MODEL_LAST,
+};
+
+/* for GPIO Poll */
+#define GPIO_MASK 0x03
 
 struct alc_spec {
  /* codec parameterization */
- snd_kcontrol_new_t *mixers[3]; /* mixer arrays */
+ snd_kcontrol_new_t *mixers[5]; /* mixer arrays */
  unsigned int num_mixers;
 
- const struct hda_verb *init_verbs[3]; /* initialization verbs
+ const struct hda_verb *init_verbs[5]; /* initialization verbs
  * don't forget NULL termination!
  */
  unsigned int num_init_verbs;
@@ -109,18 +135,46 @@ struct alc_spec {
  unsigned int cur_mux[3];
 
  /* channel model */
- const struct alc_channel_mode *channel_mode;
+ const struct hda_channel_mode *channel_mode;
  int num_channel_mode;
 
  /* PCM information */
- struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
+ struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
 
  /* dynamic controls, init_verbs and input_mux */
  struct auto_pin_cfg autocfg;
  unsigned int num_kctl_alloc, num_kctl_used;
  snd_kcontrol_new_t *kctl_alloc;
  struct hda_input_mux private_imux;
- hda_nid_t private_dac_nids[4];
+ hda_nid_t private_dac_nids[5];
+
+ /* hooks */
+ void (*init_hook)(struct hda_codec *codec);
+ void (*unsol_event)(struct hda_codec *codec, unsigned int res);
+
+ /* for pin sensing */
+ unsigned int sense_updated: 1;
+ unsigned int jack_present: 1;
+};
+
+/*
+ * configuration template - to be copied to the spec instance
+ */
+struct alc_config_preset {
+ snd_kcontrol_new_t *mixers[5]; /* should be identical size with spec */
+ const struct hda_verb *init_verbs[5];
+ unsigned int num_dacs;
+ hda_nid_t *dac_nids;
+ hda_nid_t dig_out_nid; /* optional */
+ hda_nid_t hp_nid; /* optional */
+ unsigned int num_adc_nids;
+ hda_nid_t *adc_nids;
+ hda_nid_t dig_in_nid;
+ unsigned int num_channel_mode;
+ const struct hda_channel_mode *channel_mode;
+ const struct hda_input_mux *input_mux;
+ void (*unsol_event)(struct hda_codec *, unsigned int);
+ void (*init_hook)(struct hda_codec *);
 };
 
 
@@ -157,114 +211,287 @@ static int alc_mux_enum_put(snd_kcontrol
 /*
  * channel mode setting
  */
-struct alc_channel_mode {
- int channels;
- const struct hda_verb *sequence;
-};
+static int alc_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+{
+ struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+ struct alc_spec *spec = codec->spec;
+ return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
+    spec->num_channel_mode);
+}
+
+static int alc_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+ struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+ struct alc_spec *spec = codec->spec;
+ return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
+   spec->num_channel_mode, spec->multiout.max_channels);
+}
 
-static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+static int alc_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
  struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  struct alc_spec *spec = codec->spec;
- int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
+ return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
+   spec->num_channel_mode, &spec->multiout.max_channels);
+}
+
+/*
+ * Control the mode of pin widget settings via the mixer.  "pc" is used
+ * instead of "%" to avoid consequences of accidently treating the % as
+ * being part of a format specifier.  Maximum allowed length of a value is
+ * 63 characters plus NULL terminator.
+ *
+ * Note: some retasking pin complexes seem to ignore requests for input
+ * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
+ * are requested.  Therefore order this list so that this behaviour will not
+ * cause problems when mixer clients move through the enum sequentially.
+ * NIDs 0x0f and 0x10 have been observed to have this behaviour.
+ */
+static char *alc_pin_mode_names[] = {
+ "Mic 50pc bias", "Mic 80pc bias",
+ "Line in", "Line out", "Headphone out",
+};
+static unsigned char alc_pin_mode_values[] = {
+ PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
+};
+/* The control can present all 5 options, or it can limit the options based
+ * in the pin being assumed to be exclusively an input or an output pin.
+ */
+#define ALC_PIN_DIR_IN    0x00
+#define ALC_PIN_DIR_OUT   0x01
+#define ALC_PIN_DIR_INOUT 0x02
+
+/* Info about the pin modes supported by the three different pin directions.
+ * For each direction the minimum and maximum values are given.
+ */
+static signed char alc_pin_mode_dir_info[3][2] = {
+ { 0, 2 },    /* ALC_PIN_DIR_IN */
+ { 3, 4 },    /* ALC_PIN_DIR_OUT */
+ { 0, 4 },    /* ALC_PIN_DIR_INOUT */
+};
+#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
+#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
+#define alc_pin_mode_n_items(_dir) \
+ (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
+
+static int alc_pin_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+{
+ unsigned int item_num = uinfo->value.enumerated.item;
+ unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
 
- snd_assert(spec->channel_mode, return -ENXIO);
  uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  uinfo->count = 1;
- uinfo->value.enumerated.items = items;
- if (uinfo->value.enumerated.item >= items)
- uinfo->value.enumerated.item = items - 1;
- sprintf(uinfo->value.enumerated.name, "%dch",
- spec->channel_mode[uinfo->value.enumerated.item].channels);
+ uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
+
+ if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
+ item_num = alc_pin_mode_min(dir);
+ strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  return 0;
 }
 
-static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+static int alc_pin_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
+ unsigned int i;
  struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
- struct alc_spec *spec = codec->spec;
- int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
- int i;
+ hda_nid_t nid = kcontrol->private_value & 0xffff;
+ unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
+ long *valp = ucontrol->value.integer.value;
+ unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
 
- snd_assert(spec->channel_mode, return -ENXIO);
- for (i = 0; i < items; i++) {
- if (spec->multiout.max_channels == spec->channel_mode[i].channels) {
- ucontrol->value.enumerated.item[0] = i;
- break;
- }
- }
+ /* Find enumerated value for current pinctl setting */
+ i = alc_pin_mode_min(dir);
+ while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir))
+ i++;
+ *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir);
  return 0;
 }
 
-static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+static int alc_pin_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
+ signed int change;
  struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
- struct alc_spec *spec = codec->spec;
- int mode;
+ hda_nid_t nid = kcontrol->private_value & 0xffff;
+ unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
+ long val = *ucontrol->value.integer.value;
+ unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
 
- snd_assert(spec->channel_mode, return -ENXIO);
- mode = ucontrol->value.enumerated.item[0] ? 1 : 0;
- if (spec->multiout.max_channels == spec->channel_mode[mode].channels &&
-    ! codec->in_resume)
- return 0;
+ if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir))
+ val = alc_pin_mode_min(dir);
 
- /* change the current channel setting */
- spec->multiout.max_channels = spec->channel_mode[mode].channels;
- if (spec->channel_mode[mode].sequence)
- snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence);
+ change = pinctl != alc_pin_mode_values[val];
+ if (change) {
+ /* Set pin mode to that requested */
+ snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
+ alc_pin_mode_values[val]);
 
- return 1;
+ /* Also enable the retasking pin's input/output as required
+ * for the requested pin mode.  Enum values of 2 or less are
+ * input modes.
+ *
+ * Dynamically switching the input/output buffers probably
+ * reduces noise slightly, particularly on input.  However,
+ * havingboth input and output buffers enabled
+ * simultaneously doesn't seem to be problematic.
+ */
+ if (val <= 2) {
+ snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
+ AMP_OUT_MUTE);
+ snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
+ AMP_IN_UNMUTE(0));
+ } else {
+ snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
+ AMP_IN_MUTE(0));
+ snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
+ AMP_OUT_UNMUTE);
+ }
+ }
+ return change;
 }
 
-
-/*
- * Control of pin widget settings via the mixer.  Only boolean settings are
- * supported, so VrefEn can't be controlled using these functions as they
- * stand.
+#define ALC_PIN_MODE(xname, nid, dir) \
+ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
+  .info = alc_pin_mode_info, \
+  .get = alc_pin_mode_get, \
+  .put = alc_pin_mode_put, \
+  .private_value = nid | (dir<<16) }
+
+/* A switch control for ALC260 GPIO pins.  Multiple GPIOs can be ganged
+ * together using a mask with more than one bit set.  This control is
+ * currently used only by the ALC260 test model.  At this stage they are not
+ * needed for any "production" models.
  */
-static int alc_pinctl_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+#ifdef CONFIG_SND_DEBUG
+static int alc_gpio_data_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
 {
  uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  uinfo->count = 1;
  uinfo->value.integer.min = 0;
  uinfo->value.integer.max = 1;
  return 0;
-}
-
-static int alc_pinctl_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+}                                
+static int alc_gpio_data_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
  struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  hda_nid_t nid = kcontrol->private_value & 0xffff;
- long mask = (kcontrol->private_value >> 16) & 0xff;
+ unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  long *valp = ucontrol->value.integer.value;
+ unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
 
- *valp = 0;
- if (snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00) & mask)
- *valp = 1;
+ *valp = (val & mask) != 0;
  return 0;
 }
+static int alc_gpio_data_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+ signed int change;
+ struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+ hda_nid_t nid = kcontrol->private_value & 0xffff;
+ unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
+ long val = *ucontrol->value.integer.value;
+ unsigned int gpio_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_GPIO_DATA,0x00);
+
+ /* Set/unset the masked GPIO bit(s) as needed */
+ change = (val==0?0:mask) != (gpio_data & mask);
+ if (val==0)
+ gpio_data &= ~mask;
+ else
+ gpio_data |= mask;
+ snd_hda_codec_write(codec,nid,0,AC_VERB_SET_GPIO_DATA,gpio_data);
 
-static int alc_pinctl_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+ return change;
+}
+#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
+ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
+  .info = alc_gpio_data_info, \
+  .get = alc_gpio_data_get, \
+  .put = alc_gpio_data_put, \
+  .private_value = nid | (mask<<16) }
+#endif   /* CONFIG_SND_DEBUG */
+
+/* A switch control to allow the enabling of the digital IO pins on the
+ * ALC260.  This is incredibly simplistic; the intention of this control is
+ * to provide something in the test model allowing digital outputs to be
+ * identified if present.  If models are found which can utilise these
+ * outputs a more complete mixer control can be devised for those models if
+ * necessary.
+ */
+#ifdef CONFIG_SND_DEBUG
+static int alc_spdif_ctrl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+{
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+ uinfo->count = 1;
+ uinfo->value.integer.min = 0;
+ uinfo->value.integer.max = 1;
+ return 0;
+}                                
+static int alc_spdif_ctrl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
  struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  hda_nid_t nid = kcontrol->private_value & 0xffff;
- long mask = (kcontrol->private_value >> 16) & 0xff;
+ unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  long *valp = ucontrol->value.integer.value;
- unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
- int change = ((pinctl & mask)!=0) != *valp;
+ unsigned int val = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
 
- if (change)
- snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
- *valp?(pinctl|mask):(pinctl&~mask));
- return change;
+ *valp = (val & mask) != 0;
+ return 0;
 }
+static int alc_spdif_ctrl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
+{
+ signed int change;
+ struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+ hda_nid_t nid = kcontrol->private_value & 0xffff;
+ unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
+ long val = *ucontrol->value.integer.value;
+ unsigned int ctrl_data = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_DIGI_CONVERT,0x00);
+
+ /* Set/unset the masked control bit(s) as needed */
+ change = (val==0?0:mask) != (ctrl_data & mask);
+ if (val==0)
+ ctrl_data &= ~mask;
+ else
+ ctrl_data |= mask;
+ snd_hda_codec_write(codec,nid,0,AC_VERB_SET_DIGI_CONVERT_1,ctrl_data);
 
-#define ALC_PINCTL_SWITCH(xname, nid, mask) \
+ return change;
+}
+#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
-  .info = alc_pinctl_switch_info, \
-  .get = alc_pinctl_switch_get, \
-  .put = alc_pinctl_switch_put, \
-  .private_value = (nid) | (mask<<16) }
+  .info = alc_spdif_ctrl_info, \
+  .get = alc_spdif_ctrl_get, \
+  .put = alc_spdif_ctrl_put, \
+  .private_value = nid | (mask<<16) }
+#endif   /* CONFIG_SND_DEBUG */
+
+/*
+ * set up from the preset table
+ */
+static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
+ spec->mixers[spec->num_mixers++] = preset->mixers[i];
+ for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
+ spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
+
+ spec->channel_mode = preset->channel_mode;
+ spec->num_channel_mode = preset->num_channel_mode;
+
+ spec->multiout.max_channels = spec->channel_mode[0].channels;
+
+ spec->multiout.num_dacs = preset->num_dacs;
+ spec->multiout.dac_nids = preset->dac_nids;
+ spec->multiout.dig_out_nid = preset->dig_out_nid;
+ spec->multiout.hp_nid = preset->hp_nid;
+
+ spec->input_mux = preset->input_mux;
+
+ spec->num_adc_nids = preset->num_adc_nids;
+ spec->adc_nids = preset->adc_nids;
+ spec->dig_in_nid = preset->dig_in_nid;
+
+ spec->unsol_event = preset->unsol_event;
+ spec->init_hook = preset->init_hook;
+}
 
 /*
  * ALC880 3-stack model
@@ -286,6 +513,7 @@ static hda_nid_t alc880_adc_nids[3] = {
 
 /* The datasheet says the node 0x07 is connected from inputs,
  * but it shows zero connection in the real implementation on some devices.
+ * Note: this is a 915GAV bug, fixed on 915GLV
  */
 static hda_nid_t alc880_adc_nids_alt[2] = {
  /* ADC1-2 */
@@ -328,7 +556,7 @@ static struct hda_verb alc880_threestack
  { } /* end */
 };
 
-static struct alc_channel_mode alc880_threestack_modes[2] = {
+static struct hda_channel_mode alc880_threestack_modes[2] = {
  { 2, alc880_threestack_ch2_init },
  { 6, alc880_threestack_ch6_init },
 };
@@ -356,9 +584,9 @@ static snd_kcontrol_new_t alc880_three_s
  {
  .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  .name = "Channel Mode",
- .info = alc880_ch_mode_info,
- .get = alc880_ch_mode_get,
- .put = alc880_ch_mode_put,
+ .info = alc_ch_mode_info,
+ .get = alc_ch_mode_get,
+ .put = alc_ch_mode_put,
  },
  { } /* end */
 };
@@ -443,7 +671,7 @@ static struct hda_verb alc880_fivestack_
  { } /* end */
 };
 
-static struct alc_channel_mode alc880_fivestack_modes[2] = {
+static struct hda_channel_mode alc880_fivestack_modes[2] = {
  { 6, alc880_fivestack_ch6_init },
  { 8, alc880_fivestack_ch8_init },
 };
@@ -473,7 +701,7 @@ static struct hda_input_mux alc880_6stac
 };
 
 /* fixed 8-channels */
-static struct alc_channel_mode alc880_sixstack_modes[1] = {
+static struct hda_channel_mode alc880_sixstack_modes[1] = {
  { 8, NULL },
 };
 
@@ -501,9 +729,9 @@ static snd_kcontrol_new_t alc880_six_sta
  {
  .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  .name = "Channel Mode",
- .info = alc880_ch_mode_info,
- .get = alc880_ch_mode_get,
- .put = alc880_ch_mode_put,
+ .info = alc_ch_mode_info,
+ .get = alc_ch_mode_get,
+ .put = alc_ch_mode_put,
  },
  { } /* end */
 };
@@ -540,7 +768,7 @@ static hda_nid_t alc880_w810_dac_nids[3]
 };
 
 /* fixed 6 channels */
-static struct alc_channel_mode alc880_w810_modes[1] = {
+static struct hda_channel_mode alc880_w810_modes[1] = {
  { 6, NULL }
 };
 
@@ -572,7 +800,7 @@ static hda_nid_t alc880_z71v_dac_nids[1]
 #define ALC880_Z71V_HP_DAC 0x03
 
 /* fixed 2 channels */
-static struct alc_channel_mode alc880_2_jack_modes[1] = {
+static struct hda_channel_mode alc880_2_jack_modes[1] = {
  { 2, NULL }
 };
 
@@ -645,9 +873,9 @@ static snd_kcontrol_new_t alc880_asus_mi
  {
  .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  .name = "Channel Mode",
- .info = alc880_ch_mode_info,
- .get = alc880_ch_mode_get,
- .put = alc880_ch_mode_put,
+ .info = alc_ch_mode_info,
+ .get = alc_ch_mode_get,
+ .put = alc_ch_mode_put,
  },
  { } /* end */
 };
@@ -675,6 +903,33 @@ static snd_kcontrol_new_t alc880_pcbeep_
  { } /* end */
 };
 
+/* TCL S700 */
+static snd_kcontrol_new_t alc880_tcl_s700_mixer[] = {
+ HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+ HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+ HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
+ HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
+ HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
+ HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
+ HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
+ HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
+ HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
+ {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ /* The multiple "Capture Source" controls confuse alsamixer
+ * So call somewhat different..
+ * FIXME: the controls appear in the "playback" view!
+ */
+ /* .name = "Capture Source", */
+ .name = "Input Source",
+ .count = 1,
+ .info = alc_mux_enum_info,
+ .get = alc_mux_enum_get,
+ .put = alc_mux_enum_put,
+ },
+ { } /* end */
+};
+
 /*
  * build control elements
  */
@@ -974,6 +1229,8 @@ static struct hda_verb alc880_gpio1_init
  {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
+
+ { }
 };
 
 /* Enable GPIO mask and set output */
@@ -981,10 +1238,196 @@ static struct hda_verb alc880_gpio2_init
  {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
+
+ { }
+};
+
+/* Clevo m520g init */
+static struct hda_verb alc880_pin_clevo_init_verbs[] = {
+ /* headphone output */
+ {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
+ /* line-out */
+ {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+ {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+ /* Line-in */
+ {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+ {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+ /* CD */
+ {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+ {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+ /* Mic1 (rear panel) */
+ {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+ {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+ /* Mic2 (front panel) */
+ {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+ {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+ /* headphone */
+ {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+ {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+        /* change to EAPD mode */
+ {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
+ {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
+
+ { }
+};
+
+static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
+ /* Headphone output */
+ {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+ /* Front output*/
+ {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+ {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
+
+ /* Line In pin widget for input */
+ {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+ /* CD pin widget for input */
+ {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+ /* Mic1 (rear panel) pin widget for input and vref at 80% */
+ {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+
+ /* change to EAPD mode */
+ {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
+ {0x20, AC_VERB_SET_PROC_COEF,  0x3070},
+
+ { }
+};
+
+/*
+ * LG m1 express dual
+ *
+ * Pin assignment:
+ *   Rear Line-In/Out (blue): 0x14
+ *   Build-in Mic-In: 0x15
+ *   Speaker-out: 0x17
+ *   HP-Out (green): 0x1b
+ *   Mic-In/Out (red): 0x19
+ *   SPDIF-Out: 0x1e
+ */
+
+/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
+static hda_nid_t alc880_lg_dac_nids[3] = {
+ 0x05, 0x02, 0x03
+};
+
+/* seems analog CD is not working */
+static struct hda_input_mux alc880_lg_capture_source = {
+ .num_items = 3,
+ .items = {
+ { "Mic", 0x1 },
+ { "Line", 0x5 },
+ { "Internal Mic", 0x6 },
+ },
+};
+
+/* 2,4,6 channel modes */
+static struct hda_verb alc880_lg_ch2_init[] = {
+ /* set line-in and mic-in to input */
+ { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
+ { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
+ { }
+};
+
+static struct hda_verb alc880_lg_ch4_init[] = {
+ /* set line-in to out and mic-in to input */
+ { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
+ { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
+ { }
+};
+
+static struct hda_verb alc880_lg_ch6_init[] = {
+ /* set line-in and mic-in to output */
+ { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
+ { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
+ { }
+};
+
+static struct hda_channel_mode alc880_lg_ch_modes[3] = {
+ { 2, alc880_lg_ch2_init },
+ { 4, alc880_lg_ch4_init },
+ { 6, alc880_lg_ch6_init },
+};
+
+static snd_kcontrol_new_t alc880_lg_mixer[] = {
+ /* FIXME: it's not really "master" but front channels */
+ HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
+ HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
+ HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+ HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
+ HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
+ HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
+ HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
+ HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
+ HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+ HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
+ HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
+ HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
+ HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
+ HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
+ {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "Channel Mode",
+ .info = alc_ch_mode_info,
+ .get = alc_ch_mode_get,
+ .put = alc_ch_mode_put,
+ },
+ { } /* end */
+};
+
+static struct hda_verb alc880_lg_init_verbs[] = {
+ /* set capture source to mic-in */
+ {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+ {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+ {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
+ /* mute all amp mixer inputs */
+ {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
+ {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
+ {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
+ /* line-in to input */
+ {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+ {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+ /* built-in mic */
+ {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+ {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+ /* speaker-out */
+ {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+ {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+ /* mic-in to input */
+ {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
+ {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+ {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+ /* HP-out */
+ {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
+ {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+ {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+ /* jack sense */
+ {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
+ { }
 };
 
+/* toggle speaker-output according to the hp-jack state */
+static void alc880_lg_automute(struct hda_codec *codec)
+{
+ unsigned int present;
+
+ present = snd_hda_codec_read(codec, 0x1b, 0,
+     AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
+ snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
+ 0x80, present ? 0x80 : 0);
+ snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
+ 0x80, present ? 0x80 : 0);
+}
+
+static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
+{
+ /* Looks like the unsol event is incompatible with the standard
+ * definition.  4bit tag is placed at 28 bit!
+ */
+ if ((res >> 28) == 0x01)
+ alc880_lg_automute(codec);
+}
 
 /*
+ * Common callbacks
  */
 
 static int alc_init(struct hda_codec *codec)
@@ -994,9 +1437,21 @@ static int alc_init(struct hda_codec *co
 
  for (i = 0; i < spec->num_init_verbs; i++)
  snd_hda_sequence_write(codec, spec->init_verbs[i]);
+
+ if (spec->init_hook)
+ spec->init_hook(codec);
+
  return 0;
 }
 
+static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
+{
+ struct alc_spec *spec = codec->spec;
+
+ if (spec->unsol_event)
+ spec->unsol_event(codec, res);
+}
+
 #ifdef CONFIG_PM
 /*
  * resume
@@ -1137,6 +1592,13 @@ static struct hda_pcm_stream alc880_pcm_
  /* NID is set in alc_build_pcms */
 };
 
+/* Used by alc_build_pcms to flag that a PCM has no playback stream */
+static struct hda_pcm_stream alc_pcm_null_playback = {
+ .substreams = 0,
+ .channels_min = 0,
+ .channels_max = 0,
+};
+
 static int alc_build_pcms(struct hda_codec *codec)
 {
  struct alc_spec *spec = codec->spec;
@@ -1147,15 +1609,40 @@ static int alc_build_pcms(struct hda_cod
  codec->pcm_info = info;
 
  info->name = spec->stream_name_analog;
- info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
- info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
- info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
- info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
-
- info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
- for (i = 0; i < spec->num_channel_mode; i++) {
- if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
-    info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
+ if (spec->stream_analog_playback) {
+ snd_assert(spec->multiout.dac_nids, return -EINVAL);
+ info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
+ info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
+ }
+ if (spec->stream_analog_capture) {
+ snd_assert(spec->adc_nids, return -EINVAL);
+ info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
+ info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
+ }
+
+ if (spec->channel_mode) {
+ info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
+ for (i = 0; i < spec->num_channel_mode; i++) {
+ if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
+ info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
+ }
+ }
+ }
+
+ /* If the use of more than one ADC is requested for the current
+ * model, configure a second analog capture-only PCM.
+ */
+ if (spec->num_adc_nids > 1) {
+ codec->num_pcms++;
+ info++;
+ info->name = spec->stream_name_analog;
+ /* No playback stream for second PCM */
+ info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
+ info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
+ if (spec->stream_analog_capture) {
+ snd_assert(spec->adc_nids, return -EINVAL);
+ info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
+ info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  }
  }
 
@@ -1163,11 +1650,13 @@ static int alc_build_pcms(struct hda_cod
  codec->num_pcms++;
  info++;
  info->name = spec->stream_name_digital;
- if (spec->multiout.dig_out_nid) {
+ if (spec->multiout.dig_out_nid &&
+    spec->stream_digital_playback) {
  info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  }
- if (spec->dig_in_nid) {
+ if (spec->dig_in_nid &&
+    spec->stream_digital_capture) {
  info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  }
@@ -1199,6 +1688,7 @@ static struct hda_codec_ops alc_patch_op
  .build_pcms = alc_build_pcms,
  .init = alc_init,
  .free = alc_free,
+ .unsol_event = alc_unsol_event,
 #ifdef CONFIG_PM
  .resume = alc_resume,
 #endif
@@ -1217,17 +1707,19 @@ static hda_nid_t alc880_test_dac_nids[4]
 };
 
 static struct hda_input_mux alc880_test_capture_source = {
- .num_items = 5,
+ .num_items = 7,
  .items = {
  { "In-1", 0x0 },
  { "In-2", 0x1 },
  { "In-3", 0x2 },
  { "In-4", 0x3 },
  { "CD", 0x4 },
+ { "Front", 0x5 },
+ { "Surround", 0x6 },
  },
 };
 
-static struct alc_channel_mode alc880_test_modes[4] = {
+static struct hda_channel_mode alc880_test_modes[4] = {
  { 2, NULL },
  { 4, NULL },
  { 6, NULL },
@@ -1393,9 +1885,9 @@ static snd_kcontrol_new_t alc880_test_mi
  {
  .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  .name = "Channel Mode",
- .info = alc880_ch_mode_info,
- .get = alc880_ch_mode_get,
- .put = alc880_ch_mode_put,
+ .info = alc_ch_mode_info,
+ .get = alc_ch_mode_get,
+ .put = alc_ch_mode_put,
  },
  { } /* end */
 };
@@ -1491,6 +1983,8 @@ static struct hda_board_config alc880_cf
  { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
+ /* TCL S700 */
+ { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
 
  /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
@@ -1501,6 +1995,8 @@ static struct hda_board_config alc880_cf
  { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
+ /* Clevo m520G NB */
+ { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
 
  /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
@@ -1538,13 +2034,21 @@ static struct hda_board_config alc880_cf
  { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
 
  { .modelname = "6stack", .config = ALC880_6ST },
+ { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
+ { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
  { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
+ { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
 
  { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
  { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
  { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
  { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
  { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
+ { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
+ { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
+ { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
+ { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
+ { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
 
  { .modelname = "asus", .config = ALC880_ASUS },
  { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
@@ -1558,37 +2062,29 @@ static struct hda_board_config alc880_cf
  { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
  { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
  { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
+ { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
 
  { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
 
  { .modelname = "F1734", .config = ALC880_F1734 },
  { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
+ { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
+
+ { .modelname = "lg", .config = ALC880_LG },
+ { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
 
 #ifdef CONFIG_SND_DEBUG
  { .modelname = "test", .config = ALC880_TEST },
 #endif
+ { .modelname = "auto", .config = ALC880_AUTO },
 
  {}
 };
 
 /*
- * configuration template - to be copied to the spec instance
+ * ALC880 codec presets
  */
-struct alc_config_preset {
- snd_kcontrol_new_t *mixers[4];
- const struct hda_verb *init_verbs[4];
- unsigned int num_dacs;
- hda_nid_t *dac_nids;
- hda_nid_t dig_out_nid; /* optional */
- hda_nid_t hp_nid; /* optional */
- unsigned int num_adc_nids;
- hda_nid_t *adc_nids;
- unsigned int num_channel_mode;
- const struct alc_channel_mode *channel_mode;
- const struct hda_input_mux *input_mux;
-};
-
 static struct alc_config_preset alc880_presets[] = {
  [ALC880_3ST] = {
  .mixers = { alc880_three_stack_mixer },
@@ -1609,6 +2105,18 @@ static struct alc_config_preset alc880_p
  .channel_mode = alc880_threestack_modes,
  .input_mux = &alc880_capture_source,
  },
+ [ALC880_TCL_S700] = {
+ .mixers = { alc880_tcl_s700_mixer },
+ .init_verbs = { alc880_volume_init_verbs,
+ alc880_pin_tcl_S700_init_verbs,
+ alc880_gpio2_init_verbs },
+ .num_dacs = ARRAY_SIZE(alc880_dac_nids),
+ .dac_nids = alc880_dac_nids,
+ .hp_nid = 0x03,
+ .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
+ .channel_mode = alc880_2_jack_modes,
+ .input_mux = &alc880_capture_source,
+ },
  [ALC880_5ST] = {
  .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
@@ -1700,6 +2208,17 @@ static struct alc_config_preset alc880_p
  .channel_mode = alc880_asus_modes,
  .input_mux = &alc880_capture_source,
  },
+ [ALC880_ASUS_DIG2] = {
+ .mixers = { alc880_asus_mixer },
+ .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
+ alc880_gpio2_init_verbs }, /* use GPIO2 */
+ .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
+ .dac_nids = alc880_asus_dac_nids,
+ .dig_out_nid = ALC880_DIGOUT_NID,
+ .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
+ .channel_mode = alc880_asus_modes,
+ .input_mux = &alc880_capture_source,
+ },
  [ALC880_ASUS_W1V] = {
  .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
@@ -1721,13 +2240,37 @@ static struct alc_config_preset alc880_p
  .channel_mode = alc880_asus_modes,
  .input_mux = &alc880_capture_source,
  },
-#ifdef CONFIG_SND_DEBUG
- [ALC880_TEST] = {
- .mixers = { alc880_test_mixer },
- .init_verbs = { alc880_test_init_verbs },
- .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
- .dac_nids = alc880_test_dac_nids,
- .dig_out_nid = ALC880_DIGOUT_NID,
+ [ALC880_CLEVO] = {
+ .mixers = { alc880_three_stack_mixer },
+ .init_verbs = { alc880_volume_init_verbs,
+ alc880_pin_clevo_init_verbs },
+ .num_dacs = ARRAY_SIZE(alc880_dac_nids),
+ .dac_nids = alc880_dac_nids,
+ .hp_nid = 0x03,
+ .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
+ .channel_mode = alc880_threestack_modes,
+ .input_mux = &alc880_capture_source,
+ },
+ [ALC880_LG] = {
+ .mixers = { alc880_lg_mixer },
+ .init_verbs = { alc880_volume_init_verbs,
+ alc880_lg_init_verbs },
+ .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
+ .dac_nids = alc880_lg_dac_nids,
+ .dig_out_nid = ALC880_DIGOUT_NID,
+ .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
+ .channel_mode = alc880_lg_ch_modes,
+ .input_mux = &alc880_lg_capture_source,
+ .unsol_event = alc880_lg_unsol_event,
+ .init_hook = alc880_lg_automute,
+ },
+#ifdef CONFIG_SND_DEBUG
+ [ALC880_TEST] = {
+ .mixers = { alc880_test_mixer },
+ .init_verbs = { alc880_test_init_verbs },
+ .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
+ .dac_nids = alc880_test_dac_nids,
+ .dig_out_nid = ALC880_DIGOUT_NID,
  .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  .channel_mode = alc880_test_modes,
  .input_mux = &alc880_test_capture_source,
@@ -1832,7 +2375,8 @@ static int alc880_auto_fill_dac_nids(str
 }
 
 /* add playback controls from the parsed DAC table */
-static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
+static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
+     const struct auto_pin_cfg *cfg)
 {
  char name[32];
  static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
@@ -1868,15 +2412,16 @@ static int alc880_auto_create_multi_out_
  return err;
  }
  }
-
  return 0;
 }
 
-/* add playback controls for HP output */
-static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
+/* add playback controls for speaker and HP outputs */
+static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
+ const char *pfx)
 {
  hda_nid_t nid;
  int err;
+ char name[32];
 
  if (! pin)
  return 0;
@@ -1889,14 +2434,16 @@ static int alc880_auto_create_hp_ctls(st
  if (! spec->multiout.num_dacs)
  spec->multiout.num_dacs = 1;
  } else
- /* specify the DAC as the extra HP output */
+ /* specify the DAC as the extra output */
  spec->multiout.hp_nid = nid;
  /* control HP volume/switch on the output mixer amp */
  nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
- if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
+ sprintf(name, "%s Playback Volume", pfx);
+ if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
        HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  return err;
- if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Headphone Playback Switch",
+ sprintf(name, "%s Playback Switch", pfx);
+ if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
        HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  return err;
  } else if (alc880_is_multi_pin(pin)) {
@@ -1908,7 +2455,8 @@ static int alc880_auto_create_hp_ctls(st
  spec->multiout.num_dacs = 1;
  }
  /* we have only a switch on HP-out PIN */
- if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
+ sprintf(name, "%s Playback Switch", pfx);
+ if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
        HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  return err;
  }
@@ -1916,38 +2464,39 @@ static int alc880_auto_create_hp_ctls(st
 }
 
 /* create input playback/capture controls for the given pin */
-static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname)
+static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
+    int idx, hda_nid_t mix_nid)
 {
  char name[32];
- int err, idx;
+ int err;
 
  sprintf(name, "%s Playback Volume", ctlname);
- idx = alc880_input_pin_idx(pin);
  if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
-       HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
+       HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  return err;
  sprintf(name, "%s Playback Switch", ctlname);
  if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
-       HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
+       HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  return err;
  return 0;
 }
 
 /* create playback/capture controls for input pins */
-static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
+static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
+ const struct auto_pin_cfg *cfg)
 {
- static char *labels[AUTO_PIN_LAST] = {
- "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
- };
  struct hda_input_mux *imux = &spec->private_imux;
- int i, err;
+ int i, err, idx;
 
  for (i = 0; i < AUTO_PIN_LAST; i++) {
  if (alc880_is_input_pin(cfg->input_pins[i])) {
- err = new_analog_input(spec, cfg->input_pins[i], labels[i]);
+ idx = alc880_input_pin_idx(cfg->input_pins[i]);
+ err = new_analog_input(spec, cfg->input_pins[i],
+       auto_pin_cfg_labels[i],
+       idx, 0x0b);
  if (err < 0)
  return err;
- imux->items[imux->num_items].label = labels[i];
+ imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  imux->num_items++;
  }
@@ -1955,7 +2504,8 @@ static int alc880_auto_create_analog_inp
  return 0;
 }
 
-static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, int pin_type,
+static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
+      hda_nid_t nid, int pin_type,
       int dac_idx)
 {
  /* set as output */
@@ -1982,11 +2532,14 @@ static void alc880_auto_init_multi_out(s
  }
 }
 
-static void alc880_auto_init_hp_out(struct hda_codec *codec)
+static void alc880_auto_init_extra_out(struct hda_codec *codec)
 {
  struct alc_spec *spec = codec->spec;
  hda_nid_t pin;
 
+ pin = spec->autocfg.speaker_pin;
+ if (pin) /* connect to front */
+ alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  pin = spec->autocfg.hp_pin;
  if (pin) /* connect to front */
  alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
@@ -2015,15 +2568,21 @@ static int alc880_parse_auto_config(stru
 {
  struct alc_spec *spec = codec->spec;
  int err;
+ static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
 
- if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0)
+ if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
+ alc880_ignore)) < 0)
  return err;
- if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0)
- return err;
- if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
+ if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
+    ! spec->autocfg.hp_pin)
  return 0; /* can't find valid BIOS pin config */
- if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
-    (err = alc880_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
+
+ if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
+    (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
+    (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
+ "Speaker")) < 0 ||
+    (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
+ "Headphone")) < 0 ||
     (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  return err;
 
@@ -2044,14 +2603,12 @@ static int alc880_parse_auto_config(stru
  return 1;
 }
 
-/* init callback for auto-configuration model -- overriding the default init */
-static int alc880_auto_init(struct hda_codec *codec)
+/* additional initialization for auto-configuration model */
+static void alc880_auto_init(struct hda_codec *codec)
 {
- alc_init(codec);
  alc880_auto_init_multi_out(codec);
- alc880_auto_init_hp_out(codec);
+ alc880_auto_init_extra_out(codec);
  alc880_auto_init_analog_input(codec);
- return 0;
 }
 
 /*
@@ -2062,7 +2619,7 @@ static int patch_alc880(struct hda_codec
 {
  struct alc_spec *spec;
  int board_config;
- int i, err;
+ int err;
 
  spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  if (spec == NULL)
@@ -2088,36 +2645,8 @@ static int patch_alc880(struct hda_codec
  }
  }
 
- if (board_config != ALC880_AUTO) {
- /* set up from the preset table */
- const struct alc_config_preset *preset;
-
- preset = &alc880_presets[board_config];
-
- for (i = 0; preset->mixers[i]; i++) {
- snd_assert(spec->num_mixers < ARRAY_SIZE(spec->mixers), break);
- spec->mixers[spec->num_mixers++] = preset->mixers[i];
- }
- for (i = 0; preset->init_verbs[i]; i++) {
- snd_assert(spec->num_init_verbs < ARRAY_SIZE(spec->init_verbs), break);
- spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
- }
-
- spec->channel_mode = preset->channel_mode;
- spec->num_channel_mode = preset->num_channel_mode;
-
- spec->multiout.max_channels = spec->channel_mode[0].channels;
-
- spec->multiout.num_dacs = preset->num_dacs;
- spec->multiout.dac_nids = preset->dac_nids;
- spec->multiout.dig_out_nid = preset->dig_out_nid;
- spec->multiout.hp_nid = preset->hp_nid;
-
- spec->input_mux = preset->input_mux;
-
- spec->num_adc_nids = preset->num_adc_nids;
- spec->adc_nids = preset->adc_nids;
- }
+ if (board_config != ALC880_AUTO)
+ setup_preset(spec, &alc880_presets[board_config]);
 
  spec->stream_name_analog = "ALC880 Analog";
  spec->stream_analog_playback = &alc880_pcm_analog_playback;
@@ -2129,8 +2658,7 @@ static int patch_alc880(struct hda_codec
 
  if (! spec->adc_nids && spec->input_mux) {
  /* check whether NID 0x07 is valid */
- unsigned int wcap = snd_hda_param_read(codec, alc880_adc_nids[0],
-       AC_PAR_AUDIO_WIDGET_CAP);
+ unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  if (wcap != AC_WID_AUD_IN) {
  spec->adc_nids = alc880_adc_nids_alt;
@@ -2147,7 +2675,7 @@ static int patch_alc880(struct hda_codec
 
  codec->patch_ops = alc_patch_ops;
  if (board_config == ALC880_AUTO)
- codec->patch_ops.init = alc880_auto_init;
+ spec->init_hook = alc880_auto_init;
 
  return 0;
 }
@@ -2167,11 +2695,24 @@ static hda_nid_t alc260_adc_nids[1] = {
  0x04,
 };
 
-static hda_nid_t alc260_hp_adc_nids[1] = {
+static hda_nid_t alc260_adc_nids_alt[1] = {
  /* ADC1 */
  0x05,
 };
 
+static hda_nid_t alc260_hp_adc_nids[2] = {
+ /* ADC1, 0 */
+ 0x05, 0x04
+};
+
+/* NIDs used when simultaneous access to both ADCs makes sense.  Note that
+ * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
+ */
+static hda_nid_t alc260_dual_adc_nids[2] = {
+ /* ADC0, ADC1 */
+ 0x04, 0x05
+};
+
 #define ALC260_DIGOUT_NID 0x03
 #define ALC260_DIGIN_NID 0x06
 
@@ -2185,14 +2726,28 @@ static struct hda_input_mux alc260_captu
  },
 };
 
-/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack
- * and the internal CD lines.
+/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
+ * headphone jack and the internal CD lines.
  */
 static struct hda_input_mux alc260_fujitsu_capture_source = {
- .num_items = 2,
+ .num_items = 3,
  .items = {
  { "Mic/Line", 0x0 },
  { "CD", 0x4 },
+ { "Headphone", 0x2 },
+ },
+};
+
+/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configutation to
+ * the Fujitsu S702x, but jacks are marked differently. We won't allow
+ * retasking the Headphone jack, so it won't be available here.
+ */
+static struct hda_input_mux alc260_acer_capture_source = {
+ .num_items = 3,
+ .items = {
+ { "Mic", 0x0 },
+ { "Line", 0x2 },
+ { "CD", 0x4 },
  },
 };
 
@@ -2202,42 +2757,31 @@ static struct hda_input_mux alc260_fujit
  * element which allows changing the channel mode, so the verb list is
  * never used.
  */
-static struct alc_channel_mode alc260_modes[1] = {
+static struct hda_channel_mode alc260_modes[1] = {
  { 2, NULL },
 };
 
-static snd_kcontrol_new_t alc260_base_mixer[] = {
+
+/* Mixer combinations
+ *
+ * basic: base_output + input + pc_beep + capture
+ * HP: base_output + input + capture_alt
+ * HP_3013: hp_3013 + input + capture
+ * fujitsu: fujitsu + capture
+ * acer: acer + capture
+ */
+
+static snd_kcontrol_new_t alc260_base_output_mixer[] = {
  HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
- HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
- HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
- HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
- HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
- HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
- HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
- HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
- HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
- HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
- HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
- HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
- HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
- {
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "Capture Source",
- .info = alc_mux_enum_info,
- .get = alc_mux_enum_get,
- .put = alc_mux_enum_put,
- },
  { } /* end */
-};
+};
 
-static snd_kcontrol_new_t alc260_hp_mixer[] = {
- HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
- HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
+static snd_kcontrol_new_t alc260_input_mixer[] = {
  HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
@@ -2246,39 +2790,93 @@ static snd_kcontrol_new_t alc260_hp_mixe
  HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
- HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
- HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
- HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
- HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
- HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
- HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
- {
- .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "Capture Source",
- .info = alc_mux_enum_info,
- .get = alc_mux_enum_get,
- .put = alc_mux_enum_put,
- },
+ { } /* end */
+};
+
+static snd_kcontrol_new_t alc260_pc_beep_mixer[] = {
+ HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
+ HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
+ { } /* end */
+};
+
+static snd_kcontrol_new_t alc260_hp_3013_mixer[] = {
+ HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
+ HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
+ HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
+ HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
+ HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
+ HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
+ HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
+ HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  { } /* end */
 };
 
 static snd_kcontrol_new_t alc260_fujitsu_mixer[] = {
  HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
- ALC_PINCTL_SWITCH("Headphone Amp Switch", 0x14, PIN_HP_AMP),
+ ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
+ ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
+ { } /* end */
+};
+
+static snd_kcontrol_new_t alc260_acer_mixer[] = {
+ HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
+ HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
+ HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
+ HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
+ HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
+ HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
+ ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
+ HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
+ HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
+ ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
+ HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
+ HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
+ { } /* end */
+};
+
+/* capture mixer elements */
+static snd_kcontrol_new_t alc260_capture_mixer[] = {
  HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
+ HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
+ HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  {
  .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
- .name = "Capture Source",
+ /* The multiple "Capture Source" controls confuse alsamixer
+ * So call somewhat different..
+ * FIXME: the controls appear in the "playback" view!
+ */
+ /* .name = "Capture Source", */
+ .name = "Input Source",
+ .count = 2,
+ .info = alc_mux_enum_info,
+ .get = alc_mux_enum_get,
+ .put = alc_mux_enum_put,
+ },
+ { } /* end */
+};
+
+static snd_kcontrol_new_t alc260_capture_alt_mixer[] = {
+ HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
+ HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
+ {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ /* The multiple "Capture Source" controls confuse alsamixer
+ * So call somewhat different..
+ * FIXME: the controls appear in the "playback" view!
+ */
+ /* .name = "Capture Source", */
+ .name = "Input Source",
+ .count = 1,
  .info = alc_mux_enum_info,
  .get = alc_mux_enum_get,
  .put = alc_mux_enum_put,
@@ -2286,6 +2884,9 @@ static snd_kcontrol_new_t alc260_fujitsu
  { } /* end */
 };
 
+/*
+ * initialization verbs
+ */
 static struct hda_verb alc260_init_verbs[] = {
  /* Line In pin widget for input */
  {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
@@ -2298,7 +2899,7 @@ static struct hda_verb alc260_init_verbs
  /* LINE-2 is used for line-out in rear */
  {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  /* select line-out */
- {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
+ {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  /* LINE-OUT pin */
  {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  /* enable HP */
@@ -2347,6 +2948,100 @@ static struct hd