]> err.no Git - linux-2.6/blobdiff - sound/pci/hda/patch_realtek.c
[ALSA] hda-codec - Add support for Sony Vaio VGN-A790 laptop
[linux-2.6] / sound / pci / hda / patch_realtek.c
index 219ddf0b8d437c76e243b3febc69d8d562a802e4..cf6c100940dcebc2c5b8db6df1b898769ff238ef 100644 (file)
@@ -51,6 +51,8 @@ enum {
        ALC880_UNIWILL_DIG,
        ALC880_CLEVO,
        ALC880_TCL_S700,
+       ALC880_LG,
+       ALC880_LG_LW,
 #ifdef CONFIG_SND_DEBUG
        ALC880_TEST,
 #endif
@@ -75,6 +77,7 @@ enum {
 /* ALC262 models */
 enum {
        ALC262_BASIC,
+       ALC262_FUJITSU,
        ALC262_AUTO,
        ALC262_MODEL_LAST /* last tag */
 };
@@ -129,6 +132,7 @@ struct alc_spec {
        hda_nid_t dig_in_nid;           /* digital-in NID; optional */
 
        /* capture source */
+       unsigned int num_mux_defs;
        const struct hda_input_mux *input_mux;
        unsigned int cur_mux[3];
 
@@ -145,6 +149,14 @@ struct alc_spec {
        struct snd_kcontrol_new *kctl_alloc;
        struct hda_input_mux private_imux;
        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;
 };
 
 /*
@@ -162,7 +174,10 @@ struct alc_config_preset {
        hda_nid_t dig_in_nid;
        unsigned int num_channel_mode;
        const struct hda_channel_mode *channel_mode;
+       unsigned int num_mux_defs;
        const struct hda_input_mux *input_mux;
+       void (*unsol_event)(struct hda_codec *, unsigned int);
+       void (*init_hook)(struct hda_codec *);
 };
 
 
@@ -173,7 +188,10 @@ static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct alc_spec *spec = codec->spec;
-       return snd_hda_input_mux_info(spec->input_mux, uinfo);
+       unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
+       if (mux_idx >= spec->num_mux_defs)
+               mux_idx = 0;
+       return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
 }
 
 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
@@ -191,7 +209,8 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        struct alc_spec *spec = codec->spec;
        unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
-       return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
+       unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
+       return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
                                     spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
 }
 
@@ -233,7 +252,8 @@ static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_va
  * 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.
+ * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
+ * March 2006.
  */
 static char *alc_pin_mode_names[] = {
        "Mic 50pc bias", "Mic 80pc bias",
@@ -243,19 +263,27 @@ 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.
+ * in the pin being assumed to be exclusively an input or an output pin.  In
+ * addition, "input" pins may or may not process the mic bias option
+ * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
+ * accept requests for bias as of chip versions up to March 2006) and/or
+ * wiring in the computer.
  */
-#define ALC_PIN_DIR_IN    0x00
-#define ALC_PIN_DIR_OUT   0x01
-#define ALC_PIN_DIR_INOUT 0x02
+#define ALC_PIN_DIR_IN              0x00
+#define ALC_PIN_DIR_OUT             0x01
+#define ALC_PIN_DIR_INOUT           0x02
+#define ALC_PIN_DIR_IN_NOMICBIAS    0x03
+#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
 
-/* Info about the pin modes supported by the three different pin directions. 
+/* Info about the pin modes supported by the different pin direction modes. 
  * For each direction the minimum and maximum values are given.
  */
-static signed char alc_pin_mode_dir_info[3][2] = {
+static signed char alc_pin_mode_dir_info[5][2] = {
        { 0, 2 },    /* ALC_PIN_DIR_IN */
        { 3, 4 },    /* ALC_PIN_DIR_OUT */
        { 0, 4 },    /* ALC_PIN_DIR_INOUT */
+       { 2, 2 },    /* ALC_PIN_DIR_IN_NOMICBIAS */
+       { 2, 4 },    /* ALC_PIN_DIR_INOUT_NOMICBIAS */
 };
 #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])
@@ -317,9 +345,10 @@ static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
                 * 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.
+                * reduces noise slightly (particularly on input) so we'll
+                * do it.  However, having both input and output buffers
+                * enabled simultaneously doesn't seem to be problematic if
+                * this turns out to be necessary in the future.
                 */
                if (val <= 2) {
                        snd_hda_codec_write(codec,nid,0,AC_VERB_SET_AMP_GAIN_MUTE,
@@ -471,11 +500,17 @@ static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *
        spec->multiout.dig_out_nid = preset->dig_out_nid;
        spec->multiout.hp_nid = preset->hp_nid;
        
+       spec->num_mux_defs = preset->num_mux_defs;
+       if (! spec->num_mux_defs)
+               spec->num_mux_defs = 1;
        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;
 }
 
 /*
@@ -1278,6 +1313,217 @@ static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
 };
 
 /*
+ * 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 struct snd_kcontrol_new 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);
+}
+
+/*
+ * LG LW20
+ *
+ * Pin assignment:
+ *   Speaker-out: 0x14
+ *   Mic-In: 0x18
+ *   Built-in Mic-In: 0x19 (?)
+ *   HP-Out: 0x1b
+ *   SPDIF-Out: 0x1e
+ */
+
+/* seems analog CD is not working */
+static struct hda_input_mux alc880_lg_lw_capture_source = {
+       .num_items = 2,
+       .items = {
+               { "Mic", 0x0 },
+               { "Internal Mic", 0x1 },
+       },
+};
+
+static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
+       HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, 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("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
+       HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
+       { } /* end */
+};
+
+static struct hda_verb alc880_lg_lw_init_verbs[] = {
+       /* set capture source to mic-in */
+       {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
+       {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
+       /* speaker-out */
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       /* HP-out */
+       {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       /* mic-in to input */
+       {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       /* built-in mic */
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
+       {0x19, 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_lw_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, 0x14, 0, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+       snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
+                                0x80, present ? 0x80 : 0);
+}
+
+static void alc880_lg_lw_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_lw_automute(codec);
+}
+
+/*
+ * Common callbacks
  */
 
 static int alc_init(struct hda_codec *codec)
@@ -1287,9 +1533,21 @@ static int alc_init(struct hda_codec *codec)
 
        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
@@ -1526,6 +1784,7 @@ static struct hda_codec_ops alc_patch_ops = {
        .build_pcms = alc_build_pcms,
        .init = alc_init,
        .free = alc_free,
+       .unsol_event = alc_unsol_event,
 #ifdef CONFIG_PM
        .resume = alc_resume,
 #endif
@@ -1544,13 +1803,15 @@ 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 },
        },
 };
 
@@ -1857,6 +2118,8 @@ static struct hda_board_config alc880_cfg_tbl[] = {
        { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
        { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
        { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
+       { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
+         .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
        /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
        { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
        /* note subvendor = 0 below */
@@ -1884,6 +2147,8 @@ static struct hda_board_config alc880_cfg_tbl[] = {
        { .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 */
+       { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
+       { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
 
        { .modelname = "asus", .config = ALC880_ASUS },
        { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
@@ -1897,6 +2162,7 @@ static struct hda_board_config alc880_cfg_tbl[] = {
        { .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 = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
        { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
 
        { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
@@ -1906,6 +2172,12 @@ static struct hda_board_config alc880_cfg_tbl[] = {
        { .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 },
+
+       { .modelname = "lg-lw", .config = ALC880_LG_LW },
+       { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
+
 #ifdef CONFIG_SND_DEBUG
        { .modelname = "test", .config = ALC880_TEST },
 #endif
@@ -2083,6 +2355,32 @@ static struct alc_config_preset alc880_presets[] = {
                .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,
+       },
+       [ALC880_LG_LW] = {
+               .mixers = { alc880_lg_lw_mixer },
+               .init_verbs = { alc880_volume_init_verbs,
+                               alc880_lg_lw_init_verbs },
+               .num_dacs = 1, 
+               .dac_nids = alc880_dac_nids,
+               .dig_out_nid = ALC880_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
+               .channel_mode = alc880_2_jack_modes,
+               .input_mux = &alc880_lg_lw_capture_source,
+               .unsol_event = alc880_lg_lw_unsol_event,
+               .init_hook = alc880_lg_lw_automute,
+       },
 #ifdef CONFIG_SND_DEBUG
        [ALC880_TEST] = {
                .mixers = { alc880_test_mixer },
@@ -2247,14 +2545,11 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
 
        if (alc880_is_fixed_pin(pin)) {
                nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
-               if (! spec->multiout.dac_nids[0]) {
-                       /* use this as the primary output */
-                       spec->multiout.dac_nids[0] = nid;
-                       if (! spec->multiout.num_dacs)
-                               spec->multiout.num_dacs = 1;
-               } else 
-                       /* specify the DAC as the extra output */
+               /* specify the DAC as the extra output */
+               if (! spec->multiout.hp_nid)
                        spec->multiout.hp_nid = nid;
+               else
+                       spec->multiout.extra_out_nid[0] = nid;
                /* control HP volume/switch on the output mixer amp */
                nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
                sprintf(name, "%s Playback Volume", pfx);
@@ -2267,12 +2562,6 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
                        return err;
        } else if (alc880_is_multi_pin(pin)) {
                /* set manual connection */
-               if (! spec->multiout.dac_nids[0]) {
-                       /* use this as the primary output */
-                       spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
-                       if (! spec->multiout.num_dacs)
-                               spec->multiout.num_dacs = 1;
-               }
                /* we have only a switch on HP-out PIN */
                sprintf(name, "%s Playback Switch", pfx);
                if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
@@ -2356,7 +2645,7 @@ 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;
+       pin = spec->autocfg.speaker_pins[0];
        if (pin) /* connect to front */
                alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
        pin = spec->autocfg.hp_pin;
@@ -2392,15 +2681,15 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
        if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
                                                alc880_ignore)) < 0)
                return err;
-       if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
-           ! spec->autocfg.hp_pin)
+       if (! spec->autocfg.line_outs)
                return 0; /* can't find valid BIOS pin config */
 
        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,
+           (err = alc880_auto_create_extra_out(spec,
+                                               spec->autocfg.speaker_pins[0],
                                                "Speaker")) < 0 ||
-           (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
+           (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
                                                "Headphone")) < 0 ||
            (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
                return err;
@@ -2417,19 +2706,18 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
 
        spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
 
+       spec->num_mux_defs = 1;
        spec->input_mux = &spec->private_imux;
 
        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_extra_out(codec);
        alc880_auto_init_analog_input(codec);
-       return 0;
 }
 
 /*
@@ -2496,7 +2784,7 @@ static int patch_alc880(struct hda_codec *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;
 }
@@ -2548,30 +2836,56 @@ static struct hda_input_mux alc260_capture_source = {
 };
 
 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
- * headphone jack and the internal CD lines.
+ * headphone jack and the internal CD lines since these are the only pins at
+ * which audio can appear.  For flexibility, also allow the option of
+ * recording the mixer output on the second ADC (ADC0 doesn't have a
+ * connection to the mixer output).
  */
-static struct hda_input_mux alc260_fujitsu_capture_source = {
-       .num_items = 3,
-       .items = {
-               { "Mic/Line", 0x0 },
-               { "CD", 0x4 },
-               { "Headphone", 0x2 },
+static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
+       {
+               .num_items = 3,
+               .items = {
+                       { "Mic/Line", 0x0 },
+                       { "CD", 0x4 },
+                       { "Headphone", 0x2 },
+               },
+       },
+       {
+               .num_items = 4,
+               .items = {
+                       { "Mic/Line", 0x0 },
+                       { "CD", 0x4 },
+                       { "Headphone", 0x2 },
+                       { "Mixer", 0x5 },
+               },
        },
+
 };
 
-/* 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.
+/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
+ * the Fujitsu S702x, but jacks are marked differently.
  */
-static struct hda_input_mux alc260_acer_capture_source = {
-       .num_items = 3,
-       .items = {
-               { "Mic", 0x0 },
-               { "Line", 0x2 },
-               { "CD", 0x4 },
+static struct hda_input_mux alc260_acer_capture_sources[2] = {
+       {
+               .num_items = 4,
+               .items = {
+                       { "Mic", 0x0 },
+                       { "Line", 0x2 },
+                       { "CD", 0x4 },
+                       { "Headphone", 0x5 },
+               },
+       },
+       {
+               .num_items = 5,
+               .items = {
+                       { "Mic", 0x0 },
+                       { "Line", 0x2 },
+                       { "CD", 0x4 },
+                       { "Headphone", 0x6 },
+                       { "Mixer", 0x5 },
+               },
        },
 };
-
 /*
  * This is just place-holder, so there's something for alc_build_pcms to look
  * at when it calculates the maximum number of channels. ALC260 has no mixer
@@ -2632,6 +2946,9 @@ static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
        { } /* end */
 };
 
+/* Fujitsu S702x series laptops.  ALC260 pin usage: Mic/Line jack = 0x12, 
+ * HP jack = 0x14, CD audio =  0x16, internal speaker = 0x10.
+ */
 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
        HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
        HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
@@ -2648,9 +2965,28 @@ static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
        { } /* end */
 };
 
+/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks.  Note that current
+ * versions of the ALC260 don't act on requests to enable mic bias from NID
+ * 0x0f (used to drive the headphone jack in these laptops).  The ALC260
+ * datasheet doesn't mention this restriction.  At this stage it's not clear
+ * whether this behaviour is intentional or is a hardware bug in chip
+ * revisions available in early 2006.  Therefore for now allow the
+ * "Headphone Jack Mode" control to span all choices, but if it turns out
+ * that the lack of mic bias for this NID is intentional we could change the
+ * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
+ *
+ * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
+ * don't appear to make the mic bias available from the "line" jack, even
+ * though the NID used for this jack (0x14) can supply it.  The theory is
+ * that perhaps Acer have included blocking capacitors between the ALC260
+ * and the output jack.  If this turns out to be the case for all such
+ * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
+ * to ALC_PIN_DIR_INOUT_NOMICBIAS.
+ */
 static struct snd_kcontrol_new alc260_acer_mixer[] = {
        HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
        HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
+       ALC_PIN_MODE("Headphone Jack Mode", 0x0f, 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 Playback Volume", 0x07, 0x0, HDA_INPUT),
@@ -2864,7 +3200,8 @@ static struct hda_verb alc260_hp_3013_init_verbs[] = {
 };
 
 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
- * laptops.
+ * laptops.  ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
+ * audio = 0x16, internal speaker = 0x10.
  */
 static struct hda_verb alc260_fujitsu_init_verbs[] = {
        /* Disable all GPIOs */
@@ -3011,10 +3348,10 @@ static struct hda_verb alc260_acer_init_verbs[] = {
        {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
 
        /* Do similar with the second ADC: mute capture input amp and
-        * set ADC connection to line (on line1 pin)
+        * set ADC connection to mic to match ALSA's default state.
         */
        {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
-       {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
+       {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
 
        /* Mute all inputs to mixer widget (even unconnected ones) */
        {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
@@ -3039,26 +3376,35 @@ static hda_nid_t alc260_test_dac_nids[1] = {
 static hda_nid_t alc260_test_adc_nids[2] = {
        0x04, 0x05,
 };
-/* This is a bit messy since the two input muxes in the ALC260 have slight
- * variations in their signal assignments.  The ideal way to deal with this
- * is to extend alc_spec.input_mux to allow a different input MUX for each
- * ADC.  For the purposes of the test model it's sufficient to just list
- * both options for affected signal indices.  The separate input mux
- * functionality only needs to be considered if a model comes along which
- * actually uses signals 0x5, 0x6 and 0x7 for something which makes sense to
- * record.
+/* For testing the ALC260, each input MUX needs its own definition since
+ * the signal assignments are different.  This assumes that the first ADC 
+ * is NID 0x04.
  */
-static struct hda_input_mux alc260_test_capture_source = {
-       .num_items = 8,
-       .items = {
-               { "MIC1 pin", 0x0 },
-               { "MIC2 pin", 0x1 },
-               { "LINE1 pin", 0x2 },
-               { "LINE2 pin", 0x3 },
-               { "CD pin", 0x4 },
-               { "LINE-OUT pin (cap1), Mixer (cap2)", 0x5 },
-               { "HP-OUT pin (cap1), LINE-OUT pin (cap2)", 0x6 },
-               { "HP-OUT pin (cap2 only)", 0x7 },
+static struct hda_input_mux alc260_test_capture_sources[2] = {
+       {
+               .num_items = 7,
+               .items = {
+                       { "MIC1 pin", 0x0 },
+                       { "MIC2 pin", 0x1 },
+                       { "LINE1 pin", 0x2 },
+                       { "LINE2 pin", 0x3 },
+                       { "CD pin", 0x4 },
+                       { "LINE-OUT pin", 0x5 },
+                       { "HP-OUT pin", 0x6 },
+               },
+        },
+       {
+               .num_items = 8,
+               .items = {
+                       { "MIC1 pin", 0x0 },
+                       { "MIC2 pin", 0x1 },
+                       { "LINE1 pin", 0x2 },
+                       { "LINE2 pin", 0x3 },
+                       { "CD pin", 0x4 },
+                       { "Mixer", 0x5 },
+                       { "LINE-OUT pin", 0x6 },
+                       { "HP-OUT pin", 0x7 },
+               },
         },
 };
 static struct snd_kcontrol_new alc260_test_mixer[] = {
@@ -3070,7 +3416,17 @@ static struct snd_kcontrol_new alc260_test_mixer[] = {
        HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
        HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
 
-       /* Modes for retasking pin widgets */
+       /* Modes for retasking pin widgets
+        * Note: the ALC260 doesn't seem to act on requests to enable mic
+         * bias from NIDs 0x0f and 0x10.  The ALC260 datasheet doesn't
+         * mention this restriction.  At this stage it's not clear whether
+         * this behaviour is intentional or is a hardware bug in chip
+         * revisions available at least up until early 2006.  Therefore for
+         * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
+         * choices, but if it turns out that the lack of mic bias for these
+         * NIDs is intentional we could change their modes from
+         * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
+        */
        ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
        ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
        ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
@@ -3263,7 +3619,7 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
                        return err;
        }
 
-       nid = cfg->speaker_pin;
+       nid = cfg->speaker_pins[0];
        if (nid) {
                err = alc260_add_playback_controls(spec, nid, "Speaker");
                if (err < 0)
@@ -3336,7 +3692,7 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec)
        if (nid)
                alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
        
-       nid = spec->autocfg.speaker_pin;
+       nid = spec->autocfg.speaker_pins[0];
        if (nid)
                alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
 
@@ -3432,6 +3788,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
 
        spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
 
+       spec->num_mux_defs = 1;
        spec->input_mux = &spec->private_imux;
 
        /* check whether NID 0x04 is valid */
@@ -3451,13 +3808,11 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
        return 1;
 }
 
-/* init callback for auto-configuration model -- overriding the default init */
-static int alc260_auto_init(struct hda_codec *codec)
+/* additional initialization for auto-configuration model */
+static void alc260_auto_init(struct hda_codec *codec)
 {
-       alc_init(codec);
        alc260_auto_init_multi_out(codec);
        alc260_auto_init_analog_input(codec);
-       return 0;
 }
 
 /*
@@ -3467,6 +3822,10 @@ static struct hda_board_config alc260_cfg_tbl[] = {
        { .modelname = "basic", .config = ALC260_BASIC },
        { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
          .config = ALC260_BASIC }, /* Sony VAIO */
+       { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
+         .config = ALC260_BASIC }, /* Sony VAIO */
+       { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
+         .config = ALC260_BASIC }, /* CTL Travel Master U553W */
        { .modelname = "hp", .config = ALC260_HP },
        { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
        { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
@@ -3537,7 +3896,8 @@ static struct alc_config_preset alc260_presets[] = {
                .adc_nids = alc260_dual_adc_nids,
                .num_channel_mode = ARRAY_SIZE(alc260_modes),
                .channel_mode = alc260_modes,
-               .input_mux = &alc260_fujitsu_capture_source,
+               .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
+               .input_mux = alc260_fujitsu_capture_sources,
        },
        [ALC260_ACER] = {
                .mixers = { alc260_acer_mixer,
@@ -3549,7 +3909,8 @@ static struct alc_config_preset alc260_presets[] = {
                .adc_nids = alc260_dual_adc_nids,
                .num_channel_mode = ARRAY_SIZE(alc260_modes),
                .channel_mode = alc260_modes,
-               .input_mux = &alc260_acer_capture_source,
+               .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
+               .input_mux = alc260_acer_capture_sources,
        },
 #ifdef CONFIG_SND_DEBUG
        [ALC260_TEST] = {
@@ -3562,7 +3923,8 @@ static struct alc_config_preset alc260_presets[] = {
                .adc_nids = alc260_test_adc_nids,
                .num_channel_mode = ARRAY_SIZE(alc260_modes),
                .channel_mode = alc260_modes,
-               .input_mux = &alc260_test_capture_source,
+               .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
+               .input_mux = alc260_test_capture_sources,
        },
 #endif
 };
@@ -3609,7 +3971,7 @@ static int patch_alc260(struct hda_codec *codec)
 
        codec->patch_ops = alc_patch_ops;
        if (board_config == ALC260_AUTO)
-               codec->patch_ops.init = alc260_auto_init;
+               spec->init_hook = alc260_auto_init;
 
        return 0;
 }
@@ -3654,7 +4016,6 @@ static struct hda_input_mux alc882_capture_source = {
                { "CD", 0x4 },
        },
 };
-
 #define alc882_mux_enum_info alc_mux_enum_info
 #define alc882_mux_enum_get alc_mux_enum_get
 
@@ -4084,14 +4445,12 @@ static int alc882_parse_auto_config(struct hda_codec *codec)
        return err;
 }
 
-/* init callback for auto-configuration model -- overriding the default init */
-static int alc882_auto_init(struct hda_codec *codec)
+/* additional initialization for auto-configuration model */
+static void alc882_auto_init(struct hda_codec *codec)
 {
-       alc_init(codec);
        alc882_auto_init_multi_out(codec);
        alc882_auto_init_hp_out(codec);
        alc882_auto_init_analog_input(codec);
-       return 0;
 }
 
 /*
@@ -4158,7 +4517,7 @@ static int patch_alc882(struct hda_codec *codec)
 
        codec->patch_ops = alc_patch_ops;
        if (board_config == ALC882_AUTO)
-               codec->patch_ops.init = alc882_auto_init;
+               spec->init_hook = alc882_auto_init;
 
        return 0;
 }
@@ -4194,19 +4553,9 @@ static struct snd_kcontrol_new alc262_base_mixer[] = {
        HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
        HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
        HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
-       HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
-       HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
-       {
-               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "Capture Source",
-               .count = 1,
-               .info = alc882_mux_enum_info,
-               .get = alc882_mux_enum_get,
-               .put = alc882_mux_enum_put,
-       },
        { } /* end */
-};                     
-       
+};
+
 #define alc262_capture_mixer           alc882_capture_mixer
 #define alc262_capture_alt_mixer       alc882_capture_alt_mixer
 
@@ -4289,6 +4638,129 @@ static struct hda_verb alc262_init_verbs[] = {
        { }
 };
 
+/*
+ * fujitsu model
+ *  0x14 = headphone/spdif-out, 0x15 = internal speaker
+ */
+
+#define ALC_HP_EVENT   0x37
+
+static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
+       {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
+       {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {}
+};
+
+static struct hda_input_mux alc262_fujitsu_capture_source = {
+       .num_items = 2,
+       .items = {
+               { "Mic", 0x0 },
+               { "CD", 0x4 },
+       },
+};
+
+/* mute/unmute internal speaker according to the hp jack and mute state */
+static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
+{
+       struct alc_spec *spec = codec->spec;
+       unsigned int mute;
+
+       if (force || ! spec->sense_updated) {
+               unsigned int present;
+               /* need to execute and sync at first */
+               snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
+               present = snd_hda_codec_read(codec, 0x14, 0,
+                                        AC_VERB_GET_PIN_SENSE, 0);
+               spec->jack_present = (present & 0x80000000) != 0;
+               spec->sense_updated = 1;
+       }
+       if (spec->jack_present) {
+               /* mute internal speaker */
+               snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
+                                        0x80, 0x80);
+               snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
+                                        0x80, 0x80);
+       } else {
+               /* unmute internal speaker if necessary */
+               mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
+                                        0x80, mute & 0x80);
+               mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
+               snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
+                                        0x80, mute & 0x80);
+       }
+}
+
+/* unsolicited event for HP jack sensing */
+static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
+                                      unsigned int res)
+{
+       if ((res >> 26) != ALC_HP_EVENT)
+               return;
+       alc262_fujitsu_automute(codec, 1);
+}
+
+/* bind volumes of both NID 0x0c and 0x0d */
+static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
+                                        struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       long *valp = ucontrol->value.integer.value;
+       int change;
+
+       change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
+                                         0x7f, valp[0] & 0x7f);
+       change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
+                                          0x7f, valp[1] & 0x7f);
+       snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
+                                0x7f, valp[0] & 0x7f);
+       snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
+                                0x7f, valp[1] & 0x7f);
+       return change;
+}
+
+/* bind hp and internal speaker mute (with plug check) */
+static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
+                                        struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       long *valp = ucontrol->value.integer.value;
+       int change;
+
+       change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
+                                         0x80, valp[0] ? 0 : 0x80);
+       change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
+                                          0x80, valp[1] ? 0 : 0x80);
+       if (change || codec->in_resume)
+               alc262_fujitsu_automute(codec, codec->in_resume);
+       return change;
+}
+
+static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Master Playback Volume",
+               .info = snd_hda_mixer_amp_volume_info,
+               .get = snd_hda_mixer_amp_volume_get,
+               .put = alc262_fujitsu_master_vol_put,
+               .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
+       },
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Master Playback Switch",
+               .info = snd_hda_mixer_amp_switch_info,
+               .get = snd_hda_mixer_amp_switch_get,
+               .put = alc262_fujitsu_master_sw_put,
+               .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, 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 Boost", 0x18, 0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       { } /* end */
+};
+
 /* add playback controls from the parsed DAC table */
 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
 {
@@ -4309,7 +4781,7 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
                        return err;
        }
 
-       nid = cfg->speaker_pin;
+       nid = cfg->speaker_pins[0];
        if (nid) {
                if (nid == 0x16) {
                        if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
@@ -4319,10 +4791,6 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
                                               HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
                                return err;
                } else {
-                       if (! cfg->line_out_pins[0])
-                               if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
-                                              HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
-                                       return err;
                        if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
                                               HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
                                return err;
@@ -4339,10 +4807,6 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct
                                               HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
                                return err;
                } else {
-                       if (! cfg->line_out_pins[0])
-                               if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
-                                              HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
-                                       return err;
                        if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
                                               HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
                                return err;
@@ -4436,8 +4900,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
        if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
                                                alc262_ignore)) < 0)
                return err;
-       if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
-           ! spec->autocfg.hp_pin)
+       if (! spec->autocfg.line_outs)
                return 0; /* can't find valid BIOS pin config */
        if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
            (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
@@ -4454,6 +4917,7 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
                spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
 
        spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
+       spec->num_mux_defs = 1;
        spec->input_mux = &spec->private_imux;
 
        return 1;
@@ -4465,13 +4929,11 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
 
 
 /* init callback for auto-configuration model -- overriding the default init */
-static int alc262_auto_init(struct hda_codec *codec)
+static void alc262_auto_init(struct hda_codec *codec)
 {
-       alc_init(codec);
        alc262_auto_init_multi_out(codec);
        alc262_auto_init_hp_out(codec);
        alc262_auto_init_analog_input(codec);
-       return 0;
 }
 
 /*
@@ -4479,6 +4941,8 @@ static int alc262_auto_init(struct hda_codec *codec)
  */
 static struct hda_board_config alc262_cfg_tbl[] = {
        { .modelname = "basic", .config = ALC262_BASIC },
+       { .modelname = "fujitsu", .config = ALC262_FUJITSU },
+       { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU },
        { .modelname = "auto", .config = ALC262_AUTO },
        {}
 };
@@ -4494,6 +4958,18 @@ static struct alc_config_preset alc262_presets[] = {
                .channel_mode = alc262_modes,
                .input_mux = &alc262_capture_source,
        },
+       [ALC262_FUJITSU] = {
+               .mixers = { alc262_fujitsu_mixer },
+               .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
+               .num_dacs = ARRAY_SIZE(alc262_dac_nids),
+               .dac_nids = alc262_dac_nids,
+               .hp_nid = 0x03,
+               .dig_out_nid = ALC262_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc262_modes),
+               .channel_mode = alc262_modes,
+               .input_mux = &alc262_fujitsu_capture_source,
+               .unsol_event = alc262_fujitsu_unsol_event,
+       },
 };
 
 static int patch_alc262(struct hda_codec *codec)
@@ -4567,8 +5043,8 @@ static int patch_alc262(struct hda_codec *codec)
 
        codec->patch_ops = alc_patch_ops;
        if (board_config == ALC262_AUTO)
-               codec->patch_ops.init = alc262_auto_init;
-       
+               spec->init_hook = alc262_auto_init;
+               
        return 0;
 }
 
@@ -5099,8 +5575,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
        if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
                                                alc861_ignore)) < 0)
                return err;
-       if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
-           ! spec->autocfg.hp_pin)
+       if (! spec->autocfg.line_outs)
                return 0; /* can't find valid BIOS pin config */
 
        if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
@@ -5119,6 +5594,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
 
        spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
 
+       spec->num_mux_defs = 1;
        spec->input_mux = &spec->private_imux;
 
        spec->adc_nids = alc861_adc_nids;
@@ -5129,15 +5605,12 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
        return 1;
 }
 
-/* init callback for auto-configuration model -- overriding the default init */
-static int alc861_auto_init(struct hda_codec *codec)
+/* additional initialization for auto-configuration model */
+static void alc861_auto_init(struct hda_codec *codec)
 {
-       alc_init(codec);
        alc861_auto_init_multi_out(codec);
        alc861_auto_init_hp_out(codec);
        alc861_auto_init_analog_input(codec);
-
-       return 0;
 }
 
 
@@ -5235,7 +5708,7 @@ static int patch_alc861(struct hda_codec *codec)
 
        codec->patch_ops = alc_patch_ops;
        if (board_config == ALC861_AUTO)
-               codec->patch_ops.init = alc861_auto_init;
+               spec->init_hook = alc861_auto_init;
                
        return 0;
 }