ASoC: Set correct name for WM8753 rec mixer output
[linux-2.6.git] / sound / pci / hda / patch_realtek.c
1 /*
2  * Universal Interface for Intel High Definition Audio Codec
3  *
4  * HD audio interface patch for ALC 260/880/882 codecs
5  *
6  * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7  *                    PeiSen Hou <pshou@realtek.com.tw>
8  *                    Takashi Iwai <tiwai@suse.de>
9  *                    Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
10  *
11  *  This driver is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This driver is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
24  */
25
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <sound/core.h>
31 #include "hda_codec.h"
32 #include "hda_local.h"
33 #include "hda_patch.h"
34
35 #define ALC880_FRONT_EVENT              0x01
36 #define ALC880_DCVOL_EVENT              0x02
37 #define ALC880_HP_EVENT                 0x04
38 #define ALC880_MIC_EVENT                0x08
39
40 /* ALC880 board config type */
41 enum {
42         ALC880_3ST,
43         ALC880_3ST_DIG,
44         ALC880_5ST,
45         ALC880_5ST_DIG,
46         ALC880_W810,
47         ALC880_Z71V,
48         ALC880_6ST,
49         ALC880_6ST_DIG,
50         ALC880_F1734,
51         ALC880_ASUS,
52         ALC880_ASUS_DIG,
53         ALC880_ASUS_W1V,
54         ALC880_ASUS_DIG2,
55         ALC880_FUJITSU,
56         ALC880_UNIWILL_DIG,
57         ALC880_UNIWILL,
58         ALC880_UNIWILL_P53,
59         ALC880_CLEVO,
60         ALC880_TCL_S700,
61         ALC880_LG,
62         ALC880_LG_LW,
63         ALC880_MEDION_RIM,
64 #ifdef CONFIG_SND_DEBUG
65         ALC880_TEST,
66 #endif
67         ALC880_AUTO,
68         ALC880_MODEL_LAST /* last tag */
69 };
70
71 /* ALC260 models */
72 enum {
73         ALC260_BASIC,
74         ALC260_HP,
75         ALC260_HP_3013,
76         ALC260_FUJITSU_S702X,
77         ALC260_ACER,
78         ALC260_WILL,
79         ALC260_REPLACER_672V,
80 #ifdef CONFIG_SND_DEBUG
81         ALC260_TEST,
82 #endif
83         ALC260_AUTO,
84         ALC260_MODEL_LAST /* last tag */
85 };
86
87 /* ALC262 models */
88 enum {
89         ALC262_BASIC,
90         ALC262_HIPPO,
91         ALC262_HIPPO_1,
92         ALC262_FUJITSU,
93         ALC262_HP_BPC,
94         ALC262_HP_BPC_D7000_WL,
95         ALC262_HP_BPC_D7000_WF,
96         ALC262_HP_TC_T5735,
97         ALC262_HP_RP5700,
98         ALC262_BENQ_ED8,
99         ALC262_SONY_ASSAMD,
100         ALC262_BENQ_T31,
101         ALC262_ULTRA,
102         ALC262_LENOVO_3000,
103         ALC262_AUTO,
104         ALC262_MODEL_LAST /* last tag */
105 };
106
107 /* ALC268 models */
108 enum {
109         ALC267_QUANTA_IL1,
110         ALC268_3ST,
111         ALC268_TOSHIBA,
112         ALC268_ACER,
113         ALC268_DELL,
114         ALC268_ZEPTO,
115 #ifdef CONFIG_SND_DEBUG
116         ALC268_TEST,
117 #endif
118         ALC268_AUTO,
119         ALC268_MODEL_LAST /* last tag */
120 };
121
122 /* ALC269 models */
123 enum {
124         ALC269_BASIC,
125         ALC269_ASUS_EEEPC_P703,
126         ALC269_ASUS_EEEPC_P901,
127         ALC269_AUTO,
128         ALC269_MODEL_LAST /* last tag */
129 };
130
131 /* ALC861 models */
132 enum {
133         ALC861_3ST,
134         ALC660_3ST,
135         ALC861_3ST_DIG,
136         ALC861_6ST_DIG,
137         ALC861_UNIWILL_M31,
138         ALC861_TOSHIBA,
139         ALC861_ASUS,
140         ALC861_ASUS_LAPTOP,
141         ALC861_AUTO,
142         ALC861_MODEL_LAST,
143 };
144
145 /* ALC861-VD models */
146 enum {
147         ALC660VD_3ST,
148         ALC660VD_3ST_DIG,
149         ALC861VD_3ST,
150         ALC861VD_3ST_DIG,
151         ALC861VD_6ST_DIG,
152         ALC861VD_LENOVO,
153         ALC861VD_DALLAS,
154         ALC861VD_HP,
155         ALC861VD_AUTO,
156         ALC861VD_MODEL_LAST,
157 };
158
159 /* ALC662 models */
160 enum {
161         ALC662_3ST_2ch_DIG,
162         ALC662_3ST_6ch_DIG,
163         ALC662_3ST_6ch,
164         ALC662_5ST_DIG,
165         ALC662_LENOVO_101E,
166         ALC662_ASUS_EEEPC_P701,
167         ALC662_ASUS_EEEPC_EP20,
168         ALC663_ASUS_M51VA,
169         ALC663_ASUS_G71V,
170         ALC663_ASUS_H13,
171         ALC663_ASUS_G50V,
172         ALC662_AUTO,
173         ALC662_MODEL_LAST,
174 };
175
176 /* ALC882 models */
177 enum {
178         ALC882_3ST_DIG,
179         ALC882_6ST_DIG,
180         ALC882_ARIMA,
181         ALC882_W2JC,
182         ALC882_TARGA,
183         ALC882_ASUS_A7J,
184         ALC882_ASUS_A7M,
185         ALC885_MACPRO,
186         ALC885_MBP3,
187         ALC885_IMAC24,
188         ALC882_AUTO,
189         ALC882_MODEL_LAST,
190 };
191
192 /* ALC883 models */
193 enum {
194         ALC883_3ST_2ch_DIG,
195         ALC883_3ST_6ch_DIG,
196         ALC883_3ST_6ch,
197         ALC883_6ST_DIG,
198         ALC883_TARGA_DIG,
199         ALC883_TARGA_2ch_DIG,
200         ALC883_ACER,
201         ALC883_ACER_ASPIRE,
202         ALC883_MEDION,
203         ALC883_MEDION_MD2,      
204         ALC883_LAPTOP_EAPD,
205         ALC883_LENOVO_101E_2ch,
206         ALC883_LENOVO_NB0763,
207         ALC888_LENOVO_MS7195_DIG,
208         ALC883_HAIER_W66,               
209         ALC888_3ST_HP,
210         ALC888_6ST_DELL,
211         ALC883_MITAC,
212         ALC883_CLEVO_M720,
213         ALC883_FUJITSU_PI2515,
214         ALC883_3ST_6ch_INTEL,
215         ALC883_AUTO,
216         ALC883_MODEL_LAST,
217 };
218
219 /* for GPIO Poll */
220 #define GPIO_MASK       0x03
221
222 struct alc_spec {
223         /* codec parameterization */
224         struct snd_kcontrol_new *mixers[5];     /* mixer arrays */
225         unsigned int num_mixers;
226
227         const struct hda_verb *init_verbs[5];   /* initialization verbs
228                                                  * don't forget NULL
229                                                  * termination!
230                                                  */
231         unsigned int num_init_verbs;
232
233         char *stream_name_analog;       /* analog PCM stream */
234         struct hda_pcm_stream *stream_analog_playback;
235         struct hda_pcm_stream *stream_analog_capture;
236         struct hda_pcm_stream *stream_analog_alt_playback;
237         struct hda_pcm_stream *stream_analog_alt_capture;
238
239         char *stream_name_digital;      /* digital PCM stream */
240         struct hda_pcm_stream *stream_digital_playback;
241         struct hda_pcm_stream *stream_digital_capture;
242
243         /* playback */
244         struct hda_multi_out multiout;  /* playback set-up
245                                          * max_channels, dacs must be set
246                                          * dig_out_nid and hp_nid are optional
247                                          */
248         hda_nid_t alt_dac_nid;
249
250         /* capture */
251         unsigned int num_adc_nids;
252         hda_nid_t *adc_nids;
253         hda_nid_t *capsrc_nids;
254         hda_nid_t dig_in_nid;           /* digital-in NID; optional */
255
256         /* capture source */
257         unsigned int num_mux_defs;
258         const struct hda_input_mux *input_mux;
259         unsigned int cur_mux[3];
260
261         /* channel model */
262         const struct hda_channel_mode *channel_mode;
263         int num_channel_mode;
264         int need_dac_fix;
265
266         /* PCM information */
267         struct hda_pcm pcm_rec[3];      /* used in alc_build_pcms() */
268
269         /* dynamic controls, init_verbs and input_mux */
270         struct auto_pin_cfg autocfg;
271         unsigned int num_kctl_alloc, num_kctl_used;
272         struct snd_kcontrol_new *kctl_alloc;
273         struct hda_input_mux private_imux;
274         hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
275
276         /* hooks */
277         void (*init_hook)(struct hda_codec *codec);
278         void (*unsol_event)(struct hda_codec *codec, unsigned int res);
279
280         /* for pin sensing */
281         unsigned int sense_updated: 1;
282         unsigned int jack_present: 1;
283         unsigned int master_sw: 1;
284
285         /* for virtual master */
286         hda_nid_t vmaster_nid;
287 #ifdef CONFIG_SND_HDA_POWER_SAVE
288         struct hda_loopback_check loopback;
289 #endif
290
291         /* for PLL fix */
292         hda_nid_t pll_nid;
293         unsigned int pll_coef_idx, pll_coef_bit;
294 };
295
296 /*
297  * configuration template - to be copied to the spec instance
298  */
299 struct alc_config_preset {
300         struct snd_kcontrol_new *mixers[5]; /* should be identical size
301                                              * with spec
302                                              */
303         const struct hda_verb *init_verbs[5];
304         unsigned int num_dacs;
305         hda_nid_t *dac_nids;
306         hda_nid_t dig_out_nid;          /* optional */
307         hda_nid_t hp_nid;               /* optional */
308         unsigned int num_adc_nids;
309         hda_nid_t *adc_nids;
310         hda_nid_t *capsrc_nids;
311         hda_nid_t dig_in_nid;
312         unsigned int num_channel_mode;
313         const struct hda_channel_mode *channel_mode;
314         int need_dac_fix;
315         unsigned int num_mux_defs;
316         const struct hda_input_mux *input_mux;
317         void (*unsol_event)(struct hda_codec *, unsigned int);
318         void (*init_hook)(struct hda_codec *);
319 #ifdef CONFIG_SND_HDA_POWER_SAVE
320         struct hda_amp_list *loopbacks;
321 #endif
322 };
323
324
325 /*
326  * input MUX handling
327  */
328 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
329                              struct snd_ctl_elem_info *uinfo)
330 {
331         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
332         struct alc_spec *spec = codec->spec;
333         unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
334         if (mux_idx >= spec->num_mux_defs)
335                 mux_idx = 0;
336         return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
337 }
338
339 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
340                             struct snd_ctl_elem_value *ucontrol)
341 {
342         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
343         struct alc_spec *spec = codec->spec;
344         unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
345
346         ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
347         return 0;
348 }
349
350 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
351                             struct snd_ctl_elem_value *ucontrol)
352 {
353         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
354         struct alc_spec *spec = codec->spec;
355         unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
356         unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
357         hda_nid_t nid = spec->capsrc_nids ?
358                 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
359         return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
360                                      nid, &spec->cur_mux[adc_idx]);
361 }
362
363
364 /*
365  * channel mode setting
366  */
367 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
368                             struct snd_ctl_elem_info *uinfo)
369 {
370         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
371         struct alc_spec *spec = codec->spec;
372         return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
373                                     spec->num_channel_mode);
374 }
375
376 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
377                            struct snd_ctl_elem_value *ucontrol)
378 {
379         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
380         struct alc_spec *spec = codec->spec;
381         return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
382                                    spec->num_channel_mode,
383                                    spec->multiout.max_channels);
384 }
385
386 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
387                            struct snd_ctl_elem_value *ucontrol)
388 {
389         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
390         struct alc_spec *spec = codec->spec;
391         int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
392                                       spec->num_channel_mode,
393                                       &spec->multiout.max_channels);
394         if (err >= 0 && spec->need_dac_fix)
395                 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
396         return err;
397 }
398
399 /*
400  * Control the mode of pin widget settings via the mixer.  "pc" is used
401  * instead of "%" to avoid consequences of accidently treating the % as 
402  * being part of a format specifier.  Maximum allowed length of a value is
403  * 63 characters plus NULL terminator.
404  *
405  * Note: some retasking pin complexes seem to ignore requests for input
406  * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
407  * are requested.  Therefore order this list so that this behaviour will not
408  * cause problems when mixer clients move through the enum sequentially.
409  * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
410  * March 2006.
411  */
412 static char *alc_pin_mode_names[] = {
413         "Mic 50pc bias", "Mic 80pc bias",
414         "Line in", "Line out", "Headphone out",
415 };
416 static unsigned char alc_pin_mode_values[] = {
417         PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
418 };
419 /* The control can present all 5 options, or it can limit the options based
420  * in the pin being assumed to be exclusively an input or an output pin.  In
421  * addition, "input" pins may or may not process the mic bias option
422  * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
423  * accept requests for bias as of chip versions up to March 2006) and/or
424  * wiring in the computer.
425  */
426 #define ALC_PIN_DIR_IN              0x00
427 #define ALC_PIN_DIR_OUT             0x01
428 #define ALC_PIN_DIR_INOUT           0x02
429 #define ALC_PIN_DIR_IN_NOMICBIAS    0x03
430 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
431
432 /* Info about the pin modes supported by the different pin direction modes. 
433  * For each direction the minimum and maximum values are given.
434  */
435 static signed char alc_pin_mode_dir_info[5][2] = {
436         { 0, 2 },    /* ALC_PIN_DIR_IN */
437         { 3, 4 },    /* ALC_PIN_DIR_OUT */
438         { 0, 4 },    /* ALC_PIN_DIR_INOUT */
439         { 2, 2 },    /* ALC_PIN_DIR_IN_NOMICBIAS */
440         { 2, 4 },    /* ALC_PIN_DIR_INOUT_NOMICBIAS */
441 };
442 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
443 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
444 #define alc_pin_mode_n_items(_dir) \
445         (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
446
447 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
448                              struct snd_ctl_elem_info *uinfo)
449 {
450         unsigned int item_num = uinfo->value.enumerated.item;
451         unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
452
453         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
454         uinfo->count = 1;
455         uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
456
457         if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
458                 item_num = alc_pin_mode_min(dir);
459         strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
460         return 0;
461 }
462
463 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
464                             struct snd_ctl_elem_value *ucontrol)
465 {
466         unsigned int i;
467         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468         hda_nid_t nid = kcontrol->private_value & 0xffff;
469         unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
470         long *valp = ucontrol->value.integer.value;
471         unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
472                                                  AC_VERB_GET_PIN_WIDGET_CONTROL,
473                                                  0x00);
474
475         /* Find enumerated value for current pinctl setting */
476         i = alc_pin_mode_min(dir);
477         while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
478                 i++;
479         *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
480         return 0;
481 }
482
483 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
484                             struct snd_ctl_elem_value *ucontrol)
485 {
486         signed int change;
487         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
488         hda_nid_t nid = kcontrol->private_value & 0xffff;
489         unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
490         long val = *ucontrol->value.integer.value;
491         unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
492                                                  AC_VERB_GET_PIN_WIDGET_CONTROL,
493                                                  0x00);
494
495         if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
496                 val = alc_pin_mode_min(dir);
497
498         change = pinctl != alc_pin_mode_values[val];
499         if (change) {
500                 /* Set pin mode to that requested */
501                 snd_hda_codec_write_cache(codec, nid, 0,
502                                           AC_VERB_SET_PIN_WIDGET_CONTROL,
503                                           alc_pin_mode_values[val]);
504
505                 /* Also enable the retasking pin's input/output as required 
506                  * for the requested pin mode.  Enum values of 2 or less are
507                  * input modes.
508                  *
509                  * Dynamically switching the input/output buffers probably
510                  * reduces noise slightly (particularly on input) so we'll
511                  * do it.  However, having both input and output buffers
512                  * enabled simultaneously doesn't seem to be problematic if
513                  * this turns out to be necessary in the future.
514                  */
515                 if (val <= 2) {
516                         snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
517                                                  HDA_AMP_MUTE, HDA_AMP_MUTE);
518                         snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
519                                                  HDA_AMP_MUTE, 0);
520                 } else {
521                         snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
522                                                  HDA_AMP_MUTE, HDA_AMP_MUTE);
523                         snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
524                                                  HDA_AMP_MUTE, 0);
525                 }
526         }
527         return change;
528 }
529
530 #define ALC_PIN_MODE(xname, nid, dir) \
531         { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
532           .info = alc_pin_mode_info, \
533           .get = alc_pin_mode_get, \
534           .put = alc_pin_mode_put, \
535           .private_value = nid | (dir<<16) }
536
537 /* A switch control for ALC260 GPIO pins.  Multiple GPIOs can be ganged
538  * together using a mask with more than one bit set.  This control is
539  * currently used only by the ALC260 test model.  At this stage they are not
540  * needed for any "production" models.
541  */
542 #ifdef CONFIG_SND_DEBUG
543 #define alc_gpio_data_info      snd_ctl_boolean_mono_info
544
545 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
546                              struct snd_ctl_elem_value *ucontrol)
547 {
548         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
549         hda_nid_t nid = kcontrol->private_value & 0xffff;
550         unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
551         long *valp = ucontrol->value.integer.value;
552         unsigned int val = snd_hda_codec_read(codec, nid, 0,
553                                               AC_VERB_GET_GPIO_DATA, 0x00);
554
555         *valp = (val & mask) != 0;
556         return 0;
557 }
558 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
559                              struct snd_ctl_elem_value *ucontrol)
560 {
561         signed int change;
562         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
563         hda_nid_t nid = kcontrol->private_value & 0xffff;
564         unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
565         long val = *ucontrol->value.integer.value;
566         unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
567                                                     AC_VERB_GET_GPIO_DATA,
568                                                     0x00);
569
570         /* Set/unset the masked GPIO bit(s) as needed */
571         change = (val == 0 ? 0 : mask) != (gpio_data & mask);
572         if (val == 0)
573                 gpio_data &= ~mask;
574         else
575                 gpio_data |= mask;
576         snd_hda_codec_write_cache(codec, nid, 0,
577                                   AC_VERB_SET_GPIO_DATA, gpio_data);
578
579         return change;
580 }
581 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
582         { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
583           .info = alc_gpio_data_info, \
584           .get = alc_gpio_data_get, \
585           .put = alc_gpio_data_put, \
586           .private_value = nid | (mask<<16) }
587 #endif   /* CONFIG_SND_DEBUG */
588
589 /* A switch control to allow the enabling of the digital IO pins on the
590  * ALC260.  This is incredibly simplistic; the intention of this control is
591  * to provide something in the test model allowing digital outputs to be
592  * identified if present.  If models are found which can utilise these
593  * outputs a more complete mixer control can be devised for those models if
594  * necessary.
595  */
596 #ifdef CONFIG_SND_DEBUG
597 #define alc_spdif_ctrl_info     snd_ctl_boolean_mono_info
598
599 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
600                               struct snd_ctl_elem_value *ucontrol)
601 {
602         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
603         hda_nid_t nid = kcontrol->private_value & 0xffff;
604         unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
605         long *valp = ucontrol->value.integer.value;
606         unsigned int val = snd_hda_codec_read(codec, nid, 0,
607                                               AC_VERB_GET_DIGI_CONVERT_1, 0x00);
608
609         *valp = (val & mask) != 0;
610         return 0;
611 }
612 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
613                               struct snd_ctl_elem_value *ucontrol)
614 {
615         signed int change;
616         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617         hda_nid_t nid = kcontrol->private_value & 0xffff;
618         unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
619         long val = *ucontrol->value.integer.value;
620         unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
621                                                     AC_VERB_GET_DIGI_CONVERT_1,
622                                                     0x00);
623
624         /* Set/unset the masked control bit(s) as needed */
625         change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
626         if (val==0)
627                 ctrl_data &= ~mask;
628         else
629                 ctrl_data |= mask;
630         snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
631                                   ctrl_data);
632
633         return change;
634 }
635 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
636         { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
637           .info = alc_spdif_ctrl_info, \
638           .get = alc_spdif_ctrl_get, \
639           .put = alc_spdif_ctrl_put, \
640           .private_value = nid | (mask<<16) }
641 #endif   /* CONFIG_SND_DEBUG */
642
643 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
644  * Again, this is only used in the ALC26x test models to help identify when
645  * the EAPD line must be asserted for features to work.
646  */
647 #ifdef CONFIG_SND_DEBUG
648 #define alc_eapd_ctrl_info      snd_ctl_boolean_mono_info
649
650 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
651                               struct snd_ctl_elem_value *ucontrol)
652 {
653         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
654         hda_nid_t nid = kcontrol->private_value & 0xffff;
655         unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
656         long *valp = ucontrol->value.integer.value;
657         unsigned int val = snd_hda_codec_read(codec, nid, 0,
658                                               AC_VERB_GET_EAPD_BTLENABLE, 0x00);
659
660         *valp = (val & mask) != 0;
661         return 0;
662 }
663
664 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
665                               struct snd_ctl_elem_value *ucontrol)
666 {
667         int change;
668         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
669         hda_nid_t nid = kcontrol->private_value & 0xffff;
670         unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
671         long val = *ucontrol->value.integer.value;
672         unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
673                                                     AC_VERB_GET_EAPD_BTLENABLE,
674                                                     0x00);
675
676         /* Set/unset the masked control bit(s) as needed */
677         change = (!val ? 0 : mask) != (ctrl_data & mask);
678         if (!val)
679                 ctrl_data &= ~mask;
680         else
681                 ctrl_data |= mask;
682         snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
683                                   ctrl_data);
684
685         return change;
686 }
687
688 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
689         { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0,  \
690           .info = alc_eapd_ctrl_info, \
691           .get = alc_eapd_ctrl_get, \
692           .put = alc_eapd_ctrl_put, \
693           .private_value = nid | (mask<<16) }
694 #endif   /* CONFIG_SND_DEBUG */
695
696 /*
697  * set up from the preset table
698  */
699 static void setup_preset(struct alc_spec *spec,
700                          const struct alc_config_preset *preset)
701 {
702         int i;
703
704         for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
705                 spec->mixers[spec->num_mixers++] = preset->mixers[i];
706         for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
707              i++)
708                 spec->init_verbs[spec->num_init_verbs++] =
709                         preset->init_verbs[i];
710         
711         spec->channel_mode = preset->channel_mode;
712         spec->num_channel_mode = preset->num_channel_mode;
713         spec->need_dac_fix = preset->need_dac_fix;
714
715         spec->multiout.max_channels = spec->channel_mode[0].channels;
716
717         spec->multiout.num_dacs = preset->num_dacs;
718         spec->multiout.dac_nids = preset->dac_nids;
719         spec->multiout.dig_out_nid = preset->dig_out_nid;
720         spec->multiout.hp_nid = preset->hp_nid;
721         
722         spec->num_mux_defs = preset->num_mux_defs;
723         if (!spec->num_mux_defs)
724                 spec->num_mux_defs = 1;
725         spec->input_mux = preset->input_mux;
726
727         spec->num_adc_nids = preset->num_adc_nids;
728         spec->adc_nids = preset->adc_nids;
729         spec->capsrc_nids = preset->capsrc_nids;
730         spec->dig_in_nid = preset->dig_in_nid;
731
732         spec->unsol_event = preset->unsol_event;
733         spec->init_hook = preset->init_hook;
734 #ifdef CONFIG_SND_HDA_POWER_SAVE
735         spec->loopback.amplist = preset->loopbacks;
736 #endif
737 }
738
739 /* Enable GPIO mask and set output */
740 static struct hda_verb alc_gpio1_init_verbs[] = {
741         {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
742         {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
743         {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
744         { }
745 };
746
747 static struct hda_verb alc_gpio2_init_verbs[] = {
748         {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
749         {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
750         {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
751         { }
752 };
753
754 static struct hda_verb alc_gpio3_init_verbs[] = {
755         {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
756         {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
757         {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
758         { }
759 };
760
761 /*
762  * Fix hardware PLL issue
763  * On some codecs, the analog PLL gating control must be off while
764  * the default value is 1.
765  */
766 static void alc_fix_pll(struct hda_codec *codec)
767 {
768         struct alc_spec *spec = codec->spec;
769         unsigned int val;
770
771         if (!spec->pll_nid)
772                 return;
773         snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
774                             spec->pll_coef_idx);
775         val = snd_hda_codec_read(codec, spec->pll_nid, 0,
776                                  AC_VERB_GET_PROC_COEF, 0);
777         snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
778                             spec->pll_coef_idx);
779         snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
780                             val & ~(1 << spec->pll_coef_bit));
781 }
782
783 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
784                              unsigned int coef_idx, unsigned int coef_bit)
785 {
786         struct alc_spec *spec = codec->spec;
787         spec->pll_nid = nid;
788         spec->pll_coef_idx = coef_idx;
789         spec->pll_coef_bit = coef_bit;
790         alc_fix_pll(codec);
791 }
792
793 static void alc_sku_automute(struct hda_codec *codec)
794 {
795         struct alc_spec *spec = codec->spec;
796         unsigned int present;
797         unsigned int hp_nid = spec->autocfg.hp_pins[0];
798         unsigned int sp_nid = spec->autocfg.speaker_pins[0];
799
800         /* need to execute and sync at first */
801         snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
802         present = snd_hda_codec_read(codec, hp_nid, 0,
803                                      AC_VERB_GET_PIN_SENSE, 0);
804         spec->jack_present = (present & 0x80000000) != 0;
805         snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
806                             spec->jack_present ? 0 : PIN_OUT);
807 }
808
809 /* unsolicited event for HP jack sensing */
810 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
811 {
812         if (codec->vendor_id == 0x10ec0880)
813                 res >>= 28;
814         else
815                 res >>= 26;
816         if (res != ALC880_HP_EVENT)
817                 return;
818
819         alc_sku_automute(codec);
820 }
821
822 /* additional initialization for ALC888 variants */
823 static void alc888_coef_init(struct hda_codec *codec)
824 {
825         unsigned int tmp;
826
827         snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
828         tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
829         snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
830         if ((tmp & 0xf0) == 2)
831                 /* alc888S-VC */
832                 snd_hda_codec_read(codec, 0x20, 0,
833                                    AC_VERB_SET_PROC_COEF, 0x830);
834          else
835                  /* alc888-VB */
836                  snd_hda_codec_read(codec, 0x20, 0,
837                                     AC_VERB_SET_PROC_COEF, 0x3030);
838 }
839
840 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
841  *      31 ~ 16 :       Manufacture ID
842  *      15 ~ 8  :       SKU ID
843  *      7  ~ 0  :       Assembly ID
844  *      port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
845  */
846 static void alc_subsystem_id(struct hda_codec *codec,
847                              unsigned int porta, unsigned int porte,
848                              unsigned int portd)
849 {
850         unsigned int ass, tmp, i;
851         unsigned nid;
852         struct alc_spec *spec = codec->spec;
853
854         ass = codec->subsystem_id & 0xffff;
855         if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
856                 goto do_sku;
857
858         /*      
859          * 31~30        : port conetcivity
860          * 29~21        : reserve
861          * 20           : PCBEEP input
862          * 19~16        : Check sum (15:1)
863          * 15~1         : Custom
864          * 0            : override
865         */
866         nid = 0x1d;
867         if (codec->vendor_id == 0x10ec0260)
868                 nid = 0x17;
869         ass = snd_hda_codec_read(codec, nid, 0,
870                                  AC_VERB_GET_CONFIG_DEFAULT, 0);
871         if (!(ass & 1) && !(ass & 0x100000))
872                 return;
873         if ((ass >> 30) != 1)   /* no physical connection */
874                 return;
875
876         /* check sum */
877         tmp = 0;
878         for (i = 1; i < 16; i++) {
879                 if ((ass >> i) & 1)
880                         tmp++;
881         }
882         if (((ass >> 16) & 0xf) != tmp)
883                 return;
884 do_sku:
885         /*
886          * 0 : override
887          * 1 :  Swap Jack
888          * 2 : 0 --> Desktop, 1 --> Laptop
889          * 3~5 : External Amplifier control
890          * 7~6 : Reserved
891         */
892         tmp = (ass & 0x38) >> 3;        /* external Amp control */
893         switch (tmp) {
894         case 1:
895                 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
896                 break;
897         case 3:
898                 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
899                 break;
900         case 7:
901                 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
902                 break;
903         case 5: /* set EAPD output high */
904                 switch (codec->vendor_id) {
905                 case 0x10ec0260:
906                         snd_hda_codec_write(codec, 0x0f, 0,
907                                             AC_VERB_SET_EAPD_BTLENABLE, 2);
908                         snd_hda_codec_write(codec, 0x10, 0,
909                                             AC_VERB_SET_EAPD_BTLENABLE, 2);
910                         break;
911                 case 0x10ec0262:
912                 case 0x10ec0267:
913                 case 0x10ec0268:
914                 case 0x10ec0269:
915                 case 0x10ec0660:
916                 case 0x10ec0662:
917                 case 0x10ec0663:
918                 case 0x10ec0862:
919                 case 0x10ec0889:
920                         snd_hda_codec_write(codec, 0x14, 0,
921                                             AC_VERB_SET_EAPD_BTLENABLE, 2);
922                         snd_hda_codec_write(codec, 0x15, 0,
923                                             AC_VERB_SET_EAPD_BTLENABLE, 2);
924                         break;
925                 }
926                 switch (codec->vendor_id) {
927                 case 0x10ec0260:
928                         snd_hda_codec_write(codec, 0x1a, 0,
929                                             AC_VERB_SET_COEF_INDEX, 7);
930                         tmp = snd_hda_codec_read(codec, 0x1a, 0,
931                                                  AC_VERB_GET_PROC_COEF, 0);
932                         snd_hda_codec_write(codec, 0x1a, 0,
933                                             AC_VERB_SET_COEF_INDEX, 7);
934                         snd_hda_codec_write(codec, 0x1a, 0,
935                                             AC_VERB_SET_PROC_COEF,
936                                             tmp | 0x2010);
937                         break;
938                 case 0x10ec0262:
939                 case 0x10ec0880:
940                 case 0x10ec0882:
941                 case 0x10ec0883:
942                 case 0x10ec0885:
943                 case 0x10ec0889:
944                         snd_hda_codec_write(codec, 0x20, 0,
945                                             AC_VERB_SET_COEF_INDEX, 7);
946                         tmp = snd_hda_codec_read(codec, 0x20, 0,
947                                                  AC_VERB_GET_PROC_COEF, 0);
948                         snd_hda_codec_write(codec, 0x20, 0,
949                                             AC_VERB_SET_COEF_INDEX, 7); 
950                         snd_hda_codec_write(codec, 0x20, 0,
951                                             AC_VERB_SET_PROC_COEF,
952                                             tmp | 0x2010);
953                         break;
954                 case 0x10ec0888:
955                         /*alc888_coef_init(codec);*/ /* called in alc_init() */
956                         break;
957                 case 0x10ec0267:
958                 case 0x10ec0268:
959                         snd_hda_codec_write(codec, 0x20, 0,
960                                             AC_VERB_SET_COEF_INDEX, 7);
961                         tmp = snd_hda_codec_read(codec, 0x20, 0,
962                                                  AC_VERB_GET_PROC_COEF, 0);
963                         snd_hda_codec_write(codec, 0x20, 0,
964                                             AC_VERB_SET_COEF_INDEX, 7); 
965                         snd_hda_codec_write(codec, 0x20, 0,
966                                             AC_VERB_SET_PROC_COEF,
967                                             tmp | 0x3000);
968                         break;
969                 }
970         default:
971                 break;
972         }
973         
974         /* is laptop or Desktop and enable the function "Mute internal speaker
975          * when the external headphone out jack is plugged"
976          */
977         if (!(ass & 0x8000))
978                 return;
979         /*
980          * 10~8 : Jack location
981          * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
982          * 14~13: Resvered
983          * 15   : 1 --> enable the function "Mute internal speaker
984          *              when the external headphone out jack is plugged"
985          */
986         if (!spec->autocfg.speaker_pins[0]) {
987                 if (spec->autocfg.line_out_pins[0])
988                         spec->autocfg.speaker_pins[0] =
989                                 spec->autocfg.line_out_pins[0];
990                 else
991                         return;
992         }
993
994         if (!spec->autocfg.hp_pins[0]) {
995                 tmp = (ass >> 11) & 0x3;        /* HP to chassis */
996                 if (tmp == 0)
997                         spec->autocfg.hp_pins[0] = porta;
998                 else if (tmp == 1)
999                         spec->autocfg.hp_pins[0] = porte;
1000                 else if (tmp == 2)
1001                         spec->autocfg.hp_pins[0] = portd;
1002                 else
1003                         return;
1004         }
1005
1006         snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1007                             AC_VERB_SET_UNSOLICITED_ENABLE,
1008                             AC_USRSP_EN | ALC880_HP_EVENT);
1009         spec->unsol_event = alc_sku_unsol_event;
1010 }
1011
1012 /*
1013  * Fix-up pin default configurations
1014  */
1015
1016 struct alc_pincfg {
1017         hda_nid_t nid;
1018         u32 val;
1019 };
1020
1021 static void alc_fix_pincfg(struct hda_codec *codec,
1022                            const struct snd_pci_quirk *quirk,
1023                            const struct alc_pincfg **pinfix)
1024 {
1025         const struct alc_pincfg *cfg;
1026
1027         quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1028         if (!quirk)
1029                 return;
1030
1031         cfg = pinfix[quirk->value];
1032         for (; cfg->nid; cfg++) {
1033                 int i;
1034                 u32 val = cfg->val;
1035                 for (i = 0; i < 4; i++) {
1036                         snd_hda_codec_write(codec, cfg->nid, 0,
1037                                     AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1038                                     val & 0xff);
1039                         val >>= 8;
1040                 }
1041         }
1042 }
1043
1044 /*
1045  * ALC880 3-stack model
1046  *
1047  * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1048  * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1049  *                 F-Mic = 0x1b, HP = 0x19
1050  */
1051
1052 static hda_nid_t alc880_dac_nids[4] = {
1053         /* front, rear, clfe, rear_surr */
1054         0x02, 0x05, 0x04, 0x03
1055 };
1056
1057 static hda_nid_t alc880_adc_nids[3] = {
1058         /* ADC0-2 */
1059         0x07, 0x08, 0x09,
1060 };
1061
1062 /* The datasheet says the node 0x07 is connected from inputs,
1063  * but it shows zero connection in the real implementation on some devices.
1064  * Note: this is a 915GAV bug, fixed on 915GLV
1065  */
1066 static hda_nid_t alc880_adc_nids_alt[2] = {
1067         /* ADC1-2 */
1068         0x08, 0x09,
1069 };
1070
1071 #define ALC880_DIGOUT_NID       0x06
1072 #define ALC880_DIGIN_NID        0x0a
1073
1074 static struct hda_input_mux alc880_capture_source = {
1075         .num_items = 4,
1076         .items = {
1077                 { "Mic", 0x0 },
1078                 { "Front Mic", 0x3 },
1079                 { "Line", 0x2 },
1080                 { "CD", 0x4 },
1081         },
1082 };
1083
1084 /* channel source setting (2/6 channel selection for 3-stack) */
1085 /* 2ch mode */
1086 static struct hda_verb alc880_threestack_ch2_init[] = {
1087         /* set line-in to input, mute it */
1088         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1089         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1090         /* set mic-in to input vref 80%, mute it */
1091         { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1092         { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1093         { } /* end */
1094 };
1095
1096 /* 6ch mode */
1097 static struct hda_verb alc880_threestack_ch6_init[] = {
1098         /* set line-in to output, unmute it */
1099         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1100         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1101         /* set mic-in to output, unmute it */
1102         { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1103         { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1104         { } /* end */
1105 };
1106
1107 static struct hda_channel_mode alc880_threestack_modes[2] = {
1108         { 2, alc880_threestack_ch2_init },
1109         { 6, alc880_threestack_ch6_init },
1110 };
1111
1112 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1113         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1114         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1115         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1116         HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1117         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1118         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1119         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1120         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1121         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1122         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1123         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1124         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1125         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1126         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1127         HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1128         HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1129         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1130         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1131         HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1132         {
1133                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1134                 .name = "Channel Mode",
1135                 .info = alc_ch_mode_info,
1136                 .get = alc_ch_mode_get,
1137                 .put = alc_ch_mode_put,
1138         },
1139         { } /* end */
1140 };
1141
1142 /* capture mixer elements */
1143 static struct snd_kcontrol_new alc880_capture_mixer[] = {
1144         HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1145         HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1146         HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1147         HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1148         HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1149         HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1150         {
1151                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1152                 /* The multiple "Capture Source" controls confuse alsamixer
1153                  * So call somewhat different..
1154                  */
1155                 /* .name = "Capture Source", */
1156                 .name = "Input Source",
1157                 .count = 3,
1158                 .info = alc_mux_enum_info,
1159                 .get = alc_mux_enum_get,
1160                 .put = alc_mux_enum_put,
1161         },
1162         { } /* end */
1163 };
1164
1165 /* capture mixer elements (in case NID 0x07 not available) */
1166 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
1167         HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1168         HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1169         HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1170         HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1171         {
1172                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1173                 /* The multiple "Capture Source" controls confuse alsamixer
1174                  * So call somewhat different..
1175                  */
1176                 /* .name = "Capture Source", */
1177                 .name = "Input Source",
1178                 .count = 2,
1179                 .info = alc_mux_enum_info,
1180                 .get = alc_mux_enum_get,
1181                 .put = alc_mux_enum_put,
1182         },
1183         { } /* end */
1184 };
1185
1186
1187
1188 /*
1189  * ALC880 5-stack model
1190  *
1191  * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1192  *      Side = 0x02 (0xd)
1193  * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1194  *                 Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1195  */
1196
1197 /* additional mixers to alc880_three_stack_mixer */
1198 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1199         HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1200         HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1201         { } /* end */
1202 };
1203
1204 /* channel source setting (6/8 channel selection for 5-stack) */
1205 /* 6ch mode */
1206 static struct hda_verb alc880_fivestack_ch6_init[] = {
1207         /* set line-in to input, mute it */
1208         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1209         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1210         { } /* end */
1211 };
1212
1213 /* 8ch mode */
1214 static struct hda_verb alc880_fivestack_ch8_init[] = {
1215         /* set line-in to output, unmute it */
1216         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1217         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1218         { } /* end */
1219 };
1220
1221 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1222         { 6, alc880_fivestack_ch6_init },
1223         { 8, alc880_fivestack_ch8_init },
1224 };
1225
1226
1227 /*
1228  * ALC880 6-stack model
1229  *
1230  * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1231  *      Side = 0x05 (0x0f)
1232  * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1233  *   Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1234  */
1235
1236 static hda_nid_t alc880_6st_dac_nids[4] = {
1237         /* front, rear, clfe, rear_surr */
1238         0x02, 0x03, 0x04, 0x05
1239 };
1240
1241 static struct hda_input_mux alc880_6stack_capture_source = {
1242         .num_items = 4,
1243         .items = {
1244                 { "Mic", 0x0 },
1245                 { "Front Mic", 0x1 },
1246                 { "Line", 0x2 },
1247                 { "CD", 0x4 },
1248         },
1249 };
1250
1251 /* fixed 8-channels */
1252 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1253         { 8, NULL },
1254 };
1255
1256 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1257         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1258         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1259         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1260         HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1261         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1262         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1263         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1264         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1265         HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1266         HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1267         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1268         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1269         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1270         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1271         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1272         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1273         HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1274         HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1275         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1276         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1277         {
1278                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1279                 .name = "Channel Mode",
1280                 .info = alc_ch_mode_info,
1281                 .get = alc_ch_mode_get,
1282                 .put = alc_ch_mode_put,
1283         },
1284         { } /* end */
1285 };
1286
1287
1288 /*
1289  * ALC880 W810 model
1290  *
1291  * W810 has rear IO for:
1292  * Front (DAC 02)
1293  * Surround (DAC 03)
1294  * Center/LFE (DAC 04)
1295  * Digital out (06)
1296  *
1297  * The system also has a pair of internal speakers, and a headphone jack.
1298  * These are both connected to Line2 on the codec, hence to DAC 02.
1299  * 
1300  * There is a variable resistor to control the speaker or headphone
1301  * volume. This is a hardware-only device without a software API.
1302  *
1303  * Plugging headphones in will disable the internal speakers. This is
1304  * implemented in hardware, not via the driver using jack sense. In
1305  * a similar fashion, plugging into the rear socket marked "front" will
1306  * disable both the speakers and headphones.
1307  *
1308  * For input, there's a microphone jack, and an "audio in" jack.
1309  * These may not do anything useful with this driver yet, because I
1310  * haven't setup any initialization verbs for these yet...
1311  */
1312
1313 static hda_nid_t alc880_w810_dac_nids[3] = {
1314         /* front, rear/surround, clfe */
1315         0x02, 0x03, 0x04
1316 };
1317
1318 /* fixed 6 channels */
1319 static struct hda_channel_mode alc880_w810_modes[1] = {
1320         { 6, NULL }
1321 };
1322
1323 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1324 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1325         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1326         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1327         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1328         HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1329         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1330         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1331         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1332         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1333         HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1334         { } /* end */
1335 };
1336
1337
1338 /*
1339  * Z710V model
1340  *
1341  * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1342  * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1343  *                 Line = 0x1a
1344  */
1345
1346 static hda_nid_t alc880_z71v_dac_nids[1] = {
1347         0x02
1348 };
1349 #define ALC880_Z71V_HP_DAC      0x03
1350
1351 /* fixed 2 channels */
1352 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1353         { 2, NULL }
1354 };
1355
1356 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1357         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1358         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1359         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1360         HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1361         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1362         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1363         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1364         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1365         { } /* end */
1366 };
1367
1368
1369 /*
1370  * ALC880 F1734 model
1371  *
1372  * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1373  * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1374  */
1375
1376 static hda_nid_t alc880_f1734_dac_nids[1] = {
1377         0x03
1378 };
1379 #define ALC880_F1734_HP_DAC     0x02
1380
1381 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1382         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1383         HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1384         HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1385         HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1386         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1387         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1388         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1389         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1390         { } /* end */
1391 };
1392
1393 static struct hda_input_mux alc880_f1734_capture_source = {
1394         .num_items = 2,
1395         .items = {
1396                 { "Mic", 0x1 },
1397                 { "CD", 0x4 },
1398         },
1399 };
1400
1401
1402 /*
1403  * ALC880 ASUS model
1404  *
1405  * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1406  * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1407  *  Mic = 0x18, Line = 0x1a
1408  */
1409
1410 #define alc880_asus_dac_nids    alc880_w810_dac_nids    /* identical with w810 */
1411 #define alc880_asus_modes       alc880_threestack_modes /* 2/6 channel mode */
1412
1413 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1414         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1415         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1416         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1417         HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1418         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1419         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1420         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1421         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1422         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1423         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1424         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1425         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1426         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1427         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1428         {
1429                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1430                 .name = "Channel Mode",
1431                 .info = alc_ch_mode_info,
1432                 .get = alc_ch_mode_get,
1433                 .put = alc_ch_mode_put,
1434         },
1435         { } /* end */
1436 };
1437
1438 /*
1439  * ALC880 ASUS W1V model
1440  *
1441  * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1442  * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1443  *  Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1444  */
1445
1446 /* additional mixers to alc880_asus_mixer */
1447 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1448         HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1449         HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1450         { } /* end */
1451 };
1452
1453 /* additional mixers to alc880_asus_mixer */
1454 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1455         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1456         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1457         { } /* end */
1458 };
1459
1460 /* TCL S700 */
1461 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1462         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1463         HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1464         HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1465         HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1466         HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1467         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1468         HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1469         HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1470         HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1471         {
1472                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1473                 /* The multiple "Capture Source" controls confuse alsamixer
1474                  * So call somewhat different..
1475                  */
1476                 /* .name = "Capture Source", */
1477                 .name = "Input Source",
1478                 .count = 1,
1479                 .info = alc_mux_enum_info,
1480                 .get = alc_mux_enum_get,
1481                 .put = alc_mux_enum_put,
1482         },
1483         { } /* end */
1484 };
1485
1486 /* Uniwill */
1487 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1488         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1489         HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1490         HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1491         HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1492         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1493         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1494         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1495         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1496         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1497         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1498         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1499         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1500         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1501         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1502         HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1503         HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1504         HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1505         HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1506         {
1507                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1508                 .name = "Channel Mode",
1509                 .info = alc_ch_mode_info,
1510                 .get = alc_ch_mode_get,
1511                 .put = alc_ch_mode_put,
1512         },
1513         { } /* end */
1514 };
1515
1516 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1517         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1518         HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1519         HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1520         HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1521         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1522         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1523         HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1524         HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1525         HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1526         HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1527         { } /* end */
1528 };
1529
1530 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1531         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1532         HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1533         HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1534         HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1535         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1536         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1537         { } /* end */
1538 };
1539
1540 /*
1541  * virtual master controls
1542  */
1543
1544 /*
1545  * slave controls for virtual master
1546  */
1547 static const char *alc_slave_vols[] = {
1548         "Front Playback Volume",
1549         "Surround Playback Volume",
1550         "Center Playback Volume",
1551         "LFE Playback Volume",
1552         "Side Playback Volume",
1553         "Headphone Playback Volume",
1554         "Speaker Playback Volume",
1555         "Mono Playback Volume",
1556         "Line-Out Playback Volume",
1557         NULL,
1558 };
1559
1560 static const char *alc_slave_sws[] = {
1561         "Front Playback Switch",
1562         "Surround Playback Switch",
1563         "Center Playback Switch",
1564         "LFE Playback Switch",
1565         "Side Playback Switch",
1566         "Headphone Playback Switch",
1567         "Speaker Playback Switch",
1568         "Mono Playback Switch",
1569         "IEC958 Playback Switch",
1570         NULL,
1571 };
1572
1573 /*
1574  * build control elements
1575  */
1576 static int alc_build_controls(struct hda_codec *codec)
1577 {
1578         struct alc_spec *spec = codec->spec;
1579         int err;
1580         int i;
1581
1582         for (i = 0; i < spec->num_mixers; i++) {
1583                 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1584                 if (err < 0)
1585                         return err;
1586         }
1587
1588         if (spec->multiout.dig_out_nid) {
1589                 err = snd_hda_create_spdif_out_ctls(codec,
1590                                                     spec->multiout.dig_out_nid);
1591                 if (err < 0)
1592                         return err;
1593                 err = snd_hda_create_spdif_share_sw(codec,
1594                                                     &spec->multiout);
1595                 if (err < 0)
1596                         return err;
1597                 spec->multiout.share_spdif = 1;
1598         }
1599         if (spec->dig_in_nid) {
1600                 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1601                 if (err < 0)
1602                         return err;
1603         }
1604
1605         /* if we have no master control, let's create it */
1606         if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1607                 unsigned int vmaster_tlv[4];
1608                 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1609                                         HDA_OUTPUT, vmaster_tlv);
1610                 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1611                                           vmaster_tlv, alc_slave_vols);
1612                 if (err < 0)
1613                         return err;
1614         }
1615         if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1616                 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1617                                           NULL, alc_slave_sws);
1618                 if (err < 0)
1619                         return err;
1620         }
1621
1622         return 0;
1623 }
1624
1625
1626 /*
1627  * initialize the codec volumes, etc
1628  */
1629
1630 /*
1631  * generic initialization of ADC, input mixers and output mixers
1632  */
1633 static struct hda_verb alc880_volume_init_verbs[] = {
1634         /*
1635          * Unmute ADC0-2 and set the default input to mic-in
1636          */
1637         {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1638         {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1639         {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1640         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1641         {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1642         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1643
1644         /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1645          * mixer widget
1646          * Note: PASD motherboards uses the Line In 2 as the input for front
1647          * panel mic (mic 2)
1648          */
1649         /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1650         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1651         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1652         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1653         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1654         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1655         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1656         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1657
1658         /*
1659          * Set up output mixers (0x0c - 0x0f)
1660          */
1661         /* set vol=0 to output mixers */
1662         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1663         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1664         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1665         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1666         /* set up input amps for analog loopback */
1667         /* Amp Indices: DAC = 0, mixer = 1 */
1668         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1669         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1670         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1671         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1672         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1673         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1674         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1675         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1676
1677         { }
1678 };
1679
1680 /*
1681  * 3-stack pin configuration:
1682  * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1683  */
1684 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1685         /*
1686          * preset connection lists of input pins
1687          * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1688          */
1689         {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1690         {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1691         {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1692
1693         /*
1694          * Set pin mode and muting
1695          */
1696         /* set front pin widgets 0x14 for output */
1697         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1698         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1699         /* Mic1 (rear panel) pin widget for input and vref at 80% */
1700         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1701         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1702         /* Mic2 (as headphone out) for HP output */
1703         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1704         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705         /* Line In pin widget for input */
1706         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1707         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1708         /* Line2 (as front mic) pin widget for input and vref at 80% */
1709         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1710         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1711         /* CD pin widget for input */
1712         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1713
1714         { }
1715 };
1716
1717 /*
1718  * 5-stack pin configuration:
1719  * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1720  * line-in/side = 0x1a, f-mic = 0x1b
1721  */
1722 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1723         /*
1724          * preset connection lists of input pins
1725          * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1726          */
1727         {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1728         {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1729
1730         /*
1731          * Set pin mode and muting
1732          */
1733         /* set pin widgets 0x14-0x17 for output */
1734         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1735         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1736         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1737         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1738         /* unmute pins for output (no gain on this amp) */
1739         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1740         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1741         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1742         {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1743
1744         /* Mic1 (rear panel) pin widget for input and vref at 80% */
1745         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1746         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1747         /* Mic2 (as headphone out) for HP output */
1748         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1749         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1750         /* Line In pin widget for input */
1751         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1752         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1753         /* Line2 (as front mic) pin widget for input and vref at 80% */
1754         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1755         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1756         /* CD pin widget for input */
1757         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1758
1759         { }
1760 };
1761
1762 /*
1763  * W810 pin configuration:
1764  * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1765  */
1766 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1767         /* hphone/speaker input selector: front DAC */
1768         {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1769
1770         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1771         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1772         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1773         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1774         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1775         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1776
1777         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1778         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1779
1780         { }
1781 };
1782
1783 /*
1784  * Z71V pin configuration:
1785  * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1786  */
1787 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1788         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1789         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1790         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1791         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1792
1793         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1794         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1795         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1796         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1797
1798         { }
1799 };
1800
1801 /*
1802  * 6-stack pin configuration:
1803  * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1804  * f-mic = 0x19, line = 0x1a, HP = 0x1b
1805  */
1806 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1807         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1808
1809         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1810         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1811         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1812         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1813         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1814         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1815         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1816         {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1817
1818         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1819         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1820         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1821         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1822         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1823         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1824         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1825         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1826         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1827         
1828         { }
1829 };
1830
1831 /*
1832  * Uniwill pin configuration:
1833  * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1834  * line = 0x1a
1835  */
1836 static struct hda_verb alc880_uniwill_init_verbs[] = {
1837         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1838
1839         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1840         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1841         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1842         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1843         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1844         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1845         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1846         {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1847         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1848         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1849         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1850         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1851         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1852         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1853
1854         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1855         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1856         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1857         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1858         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1859         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1860         /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1861         /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1862         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1863
1864         {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1865         {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1866
1867         { }
1868 };
1869
1870 /*
1871 * Uniwill P53
1872 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19, 
1873  */
1874 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1875         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1876
1877         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1878         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1879         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1880         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1881         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1882         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1883         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1884         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1885         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1886         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1887         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1888         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1889
1890         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1891         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1892         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1893         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1894         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1895         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1896
1897         {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1898         {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1899
1900         { }
1901 };
1902
1903 static struct hda_verb alc880_beep_init_verbs[] = {
1904         { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1905         { }
1906 };
1907
1908 /* toggle speaker-output according to the hp-jack state */
1909 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1910 {
1911         unsigned int present;
1912         unsigned char bits;
1913
1914         present = snd_hda_codec_read(codec, 0x14, 0,
1915                                      AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1916         bits = present ? HDA_AMP_MUTE : 0;
1917         snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1918                                  HDA_AMP_MUTE, bits);
1919         snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1920                                  HDA_AMP_MUTE, bits);
1921 }
1922
1923 /* auto-toggle front mic */
1924 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1925 {
1926         unsigned int present;
1927         unsigned char bits;
1928
1929         present = snd_hda_codec_read(codec, 0x18, 0,
1930                                      AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1931         bits = present ? HDA_AMP_MUTE : 0;
1932         snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1933 }
1934
1935 static void alc880_uniwill_automute(struct hda_codec *codec)
1936 {
1937         alc880_uniwill_hp_automute(codec);
1938         alc880_uniwill_mic_automute(codec);
1939 }
1940
1941 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1942                                        unsigned int res)
1943 {
1944         /* Looks like the unsol event is incompatible with the standard
1945          * definition.  4bit tag is placed at 28 bit!
1946          */
1947         switch (res >> 28) {
1948         case ALC880_HP_EVENT:
1949                 alc880_uniwill_hp_automute(codec);
1950                 break;
1951         case ALC880_MIC_EVENT:
1952                 alc880_uniwill_mic_automute(codec);
1953                 break;
1954         }
1955 }
1956
1957 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1958 {
1959         unsigned int present;
1960         unsigned char bits;
1961
1962         present = snd_hda_codec_read(codec, 0x14, 0,
1963                                      AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1964         bits = present ? HDA_AMP_MUTE : 0;
1965         snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
1966 }
1967
1968 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1969 {
1970         unsigned int present;
1971         
1972         present = snd_hda_codec_read(codec, 0x21, 0,
1973                                      AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1974         present &= HDA_AMP_VOLMASK;
1975         snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1976                                  HDA_AMP_VOLMASK, present);
1977         snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1978                                  HDA_AMP_VOLMASK, present);
1979 }
1980
1981 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1982                                            unsigned int res)
1983 {
1984         /* Looks like the unsol event is incompatible with the standard
1985          * definition.  4bit tag is placed at 28 bit!
1986          */
1987         if ((res >> 28) == ALC880_HP_EVENT)
1988                 alc880_uniwill_p53_hp_automute(codec);
1989         if ((res >> 28) == ALC880_DCVOL_EVENT)
1990                 alc880_uniwill_p53_dcvol_automute(codec);
1991 }
1992
1993 /*
1994  * F1734 pin configuration:
1995  * HP = 0x14, speaker-out = 0x15, mic = 0x18
1996  */
1997 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1998         {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
1999         {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2000         {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2001         {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2002         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2003
2004         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2005         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2006         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2007         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2008
2009         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2010         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2011         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2012         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2013         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2014         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2015         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2016         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2017         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2018
2019         {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2020         {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2021
2022         { }
2023 };
2024
2025 /*
2026  * ASUS pin configuration:
2027  * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2028  */
2029 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2030         {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2031         {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2032         {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2033         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2034
2035         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2036         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2037         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2038         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2039         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2040         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2041         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2042         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2043
2044         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2045         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2046         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2047         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2048         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2049         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2050         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2051         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2052         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2053         
2054         { }
2055 };
2056
2057 /* Enable GPIO mask and set output */
2058 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2059 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2060
2061 /* Clevo m520g init */
2062 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2063         /* headphone output */
2064         {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2065         /* line-out */
2066         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2067         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2068         /* Line-in */
2069         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2070         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2071         /* CD */
2072         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2073         {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2074         /* Mic1 (rear panel) */
2075         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2076         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2077         /* Mic2 (front panel) */
2078         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2079         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2080         /* headphone */
2081         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2082         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2083         /* change to EAPD mode */
2084         {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2085         {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
2086
2087         { }
2088 };
2089
2090 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2091         /* change to EAPD mode */
2092         {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2093         {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
2094
2095         /* Headphone output */
2096         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2097         /* Front output*/
2098         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2099         {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2100
2101         /* Line In pin widget for input */
2102         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2103         /* CD pin widget for input */
2104         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2105         /* Mic1 (rear panel) pin widget for input and vref at 80% */
2106         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2107
2108         /* change to EAPD mode */
2109         {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2110         {0x20, AC_VERB_SET_PROC_COEF,  0x3070},
2111
2112         { }
2113 };
2114
2115 /*
2116  * LG m1 express dual
2117  *
2118  * Pin assignment:
2119  *   Rear Line-In/Out (blue): 0x14
2120  *   Build-in Mic-In: 0x15
2121  *   Speaker-out: 0x17
2122  *   HP-Out (green): 0x1b
2123  *   Mic-In/Out (red): 0x19
2124  *   SPDIF-Out: 0x1e
2125  */
2126
2127 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2128 static hda_nid_t alc880_lg_dac_nids[3] = {
2129         0x05, 0x02, 0x03
2130 };
2131
2132 /* seems analog CD is not working */
2133 static struct hda_input_mux alc880_lg_capture_source = {
2134         .num_items = 3,
2135         .items = {
2136                 { "Mic", 0x1 },
2137                 { "Line", 0x5 },
2138                 { "Internal Mic", 0x6 },
2139         },
2140 };
2141
2142 /* 2,4,6 channel modes */
2143 static struct hda_verb alc880_lg_ch2_init[] = {
2144         /* set line-in and mic-in to input */
2145         { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2146         { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2147         { }
2148 };
2149
2150 static struct hda_verb alc880_lg_ch4_init[] = {
2151         /* set line-in to out and mic-in to input */
2152         { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2153         { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2154         { }
2155 };
2156
2157 static struct hda_verb alc880_lg_ch6_init[] = {
2158         /* set line-in and mic-in to output */
2159         { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2160         { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2161         { }
2162 };
2163
2164 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2165         { 2, alc880_lg_ch2_init },
2166         { 4, alc880_lg_ch4_init },
2167         { 6, alc880_lg_ch6_init },
2168 };
2169
2170 static struct snd_kcontrol_new alc880_lg_mixer[] = {
2171         HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2172         HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2173         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2174         HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2175         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2176         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2177         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2178         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2179         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2180         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2181         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2182         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2183         HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2184         HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2185         {
2186                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2187                 .name = "Channel Mode",
2188                 .info = alc_ch_mode_info,
2189                 .get = alc_ch_mode_get,
2190                 .put = alc_ch_mode_put,
2191         },
2192         { } /* end */
2193 };
2194
2195 static struct hda_verb alc880_lg_init_verbs[] = {
2196         /* set capture source to mic-in */
2197         {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2198         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2199         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2200         /* mute all amp mixer inputs */
2201         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2202         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2203         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2204         /* line-in to input */
2205         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2206         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2207         /* built-in mic */
2208         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2209         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2210         /* speaker-out */
2211         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2212         {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2213         /* mic-in to input */
2214         {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2215         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2216         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2217         /* HP-out */
2218         {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2219         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2220         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2221         /* jack sense */
2222         {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2223         { }
2224 };
2225
2226 /* toggle speaker-output according to the hp-jack state */
2227 static void alc880_lg_automute(struct hda_codec *codec)
2228 {
2229         unsigned int present;
2230         unsigned char bits;
2231
2232         present = snd_hda_codec_read(codec, 0x1b, 0,
2233                                      AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2234         bits = present ? HDA_AMP_MUTE : 0;
2235         snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2236                                  HDA_AMP_MUTE, bits);
2237 }
2238
2239 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2240 {
2241         /* Looks like the unsol event is incompatible with the standard
2242          * definition.  4bit tag is placed at 28 bit!
2243          */
2244         if ((res >> 28) == 0x01)
2245                 alc880_lg_automute(codec);
2246 }
2247
2248 /*
2249  * LG LW20
2250  *
2251  * Pin assignment:
2252  *   Speaker-out: 0x14
2253  *   Mic-In: 0x18
2254  *   Built-in Mic-In: 0x19
2255  *   Line-In: 0x1b
2256  *   HP-Out: 0x1a
2257  *   SPDIF-Out: 0x1e
2258  */
2259
2260 static struct hda_input_mux alc880_lg_lw_capture_source = {
2261         .num_items = 3,
2262         .items = {
2263                 { "Mic", 0x0 },
2264                 { "Internal Mic", 0x1 },
2265                 { "Line In", 0x2 },
2266         },
2267 };
2268
2269 #define alc880_lg_lw_modes alc880_threestack_modes
2270
2271 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2272         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2273         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2274         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2275         HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2276         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2277         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2278         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2279         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2280         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2281         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2282         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2283         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2284         HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2285         HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2286         {
2287                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2288                 .name = "Channel Mode",
2289                 .info = alc_ch_mode_info,
2290                 .get = alc_ch_mode_get,
2291                 .put = alc_ch_mode_put,
2292         },
2293         { } /* end */
2294 };
2295
2296 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2297         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2298         {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2299         {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2300
2301         /* set capture source to mic-in */
2302         {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2303         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2304         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2305         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2306         /* speaker-out */
2307         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2308         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2309         /* HP-out */
2310         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2311         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2312         /* mic-in to input */
2313         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2314         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2315         /* built-in mic */
2316         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2317         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2318         /* jack sense */
2319         {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2320         { }
2321 };
2322
2323 /* toggle speaker-output according to the hp-jack state */
2324 static void alc880_lg_lw_automute(struct hda_codec *codec)
2325 {
2326         unsigned int present;
2327         unsigned char bits;
2328
2329         present = snd_hda_codec_read(codec, 0x1b, 0,
2330                                      AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2331         bits = present ? HDA_AMP_MUTE : 0;
2332         snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2333                                  HDA_AMP_MUTE, bits);
2334 }
2335
2336 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2337 {
2338         /* Looks like the unsol event is incompatible with the standard
2339          * definition.  4bit tag is placed at 28 bit!
2340          */
2341         if ((res >> 28) == 0x01)
2342                 alc880_lg_lw_automute(codec);
2343 }
2344
2345 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2346         HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2347         HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2348         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2349         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2350         HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2351         HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2352         { } /* end */
2353 };
2354
2355 static struct hda_input_mux alc880_medion_rim_capture_source = {
2356         .num_items = 2,
2357         .items = {
2358                 { "Mic", 0x0 },
2359                 { "Internal Mic", 0x1 },
2360         },
2361 };
2362
2363 static struct hda_verb alc880_medion_rim_init_verbs[] = {
2364         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2365
2366         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2367         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2368
2369         /* Mic1 (rear panel) pin widget for input and vref at 80% */
2370         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2371         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2372         /* Mic2 (as headphone out) for HP output */
2373         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2374         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2375         /* Internal Speaker */
2376         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2377         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2378
2379         {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2380         {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
2381
2382         {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2383         { }
2384 };
2385
2386 /* toggle speaker-output according to the hp-jack state */
2387 static void alc880_medion_rim_automute(struct hda_codec *codec)
2388 {
2389         unsigned int present;
2390         unsigned char bits;
2391
2392         present = snd_hda_codec_read(codec, 0x14, 0,
2393                                      AC_VERB_GET_PIN_SENSE, 0)
2394                 & AC_PINSENSE_PRESENCE;
2395         bits = present ? HDA_AMP_MUTE : 0;
2396         snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2397                                  HDA_AMP_MUTE, bits);
2398         if (present)
2399                 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2400         else
2401                 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2402 }
2403
2404 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2405                                           unsigned int res)
2406 {
2407         /* Looks like the unsol event is incompatible with the standard
2408          * definition.  4bit tag is placed at 28 bit!
2409          */
2410         if ((res >> 28) == ALC880_HP_EVENT)
2411                 alc880_medion_rim_automute(codec);
2412 }
2413
2414 #ifdef CONFIG_SND_HDA_POWER_SAVE
2415 static struct hda_amp_list alc880_loopbacks[] = {
2416         { 0x0b, HDA_INPUT, 0 },
2417         { 0x0b, HDA_INPUT, 1 },
2418         { 0x0b, HDA_INPUT, 2 },
2419         { 0x0b, HDA_INPUT, 3 },
2420         { 0x0b, HDA_INPUT, 4 },
2421         { } /* end */
2422 };
2423
2424 static struct hda_amp_list alc880_lg_loopbacks[] = {
2425         { 0x0b, HDA_INPUT, 1 },
2426         { 0x0b, HDA_INPUT, 6 },
2427         { 0x0b, HDA_INPUT, 7 },
2428         { } /* end */
2429 };
2430 #endif
2431
2432 /*
2433  * Common callbacks
2434  */
2435
2436 static int alc_init(struct hda_codec *codec)
2437 {
2438         struct alc_spec *spec = codec->spec;
2439         unsigned int i;
2440
2441         alc_fix_pll(codec);
2442         if (codec->vendor_id == 0x10ec0888)
2443                 alc888_coef_init(codec);
2444
2445         for (i = 0; i < spec->num_init_verbs; i++)
2446                 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2447
2448         if (spec->init_hook)
2449                 spec->init_hook(codec);
2450
2451         return 0;
2452 }
2453
2454 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2455 {
2456         struct alc_spec *spec = codec->spec;
2457
2458         if (spec->unsol_event)
2459                 spec->unsol_event(codec, res);
2460 }
2461
2462 #ifdef CONFIG_SND_HDA_POWER_SAVE
2463 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2464 {
2465         struct alc_spec *spec = codec->spec;
2466         return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2467 }
2468 #endif
2469
2470 /*
2471  * Analog playback callbacks
2472  */
2473 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2474                                     struct hda_codec *codec,
2475                                     struct snd_pcm_substream *substream)
2476 {
2477         struct alc_spec *spec = codec->spec;
2478         return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2479                                              hinfo);
2480 }
2481
2482 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2483                                        struct hda_codec *codec,
2484                                        unsigned int stream_tag,
2485                                        unsigned int format,
2486                                        struct snd_pcm_substream *substream)
2487 {
2488         struct alc_spec *spec = codec->spec;
2489         return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2490                                                 stream_tag, format, substream);
2491 }
2492
2493 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2494                                        struct hda_codec *codec,
2495                                        struct snd_pcm_substream *substream)
2496 {
2497         struct alc_spec *spec = codec->spec;
2498         return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2499 }
2500
2501 /*
2502  * Digital out
2503  */
2504 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2505                                         struct hda_codec *codec,
2506                                         struct snd_pcm_substream *substream)
2507 {
2508         struct alc_spec *spec = codec->spec;
2509         return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2510 }
2511
2512 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2513                                            struct hda_codec *codec,
2514                                            unsigned int stream_tag,
2515                                            unsigned int format,
2516                                            struct snd_pcm_substream *substream)
2517 {
2518         struct alc_spec *spec = codec->spec;
2519         return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2520                                              stream_tag, format, substream);
2521 }
2522
2523 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2524                                          struct hda_codec *codec,
2525                                          struct snd_pcm_substream *substream)
2526 {
2527         struct alc_spec *spec = codec->spec;
2528         return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2529 }
2530
2531 /*
2532  * Analog capture
2533  */
2534 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2535                                       struct hda_codec *codec,
2536                                       unsigned int stream_tag,
2537                                       unsigned int format,
2538                                       struct snd_pcm_substream *substream)
2539 {
2540         struct alc_spec *spec = codec->spec;
2541
2542         snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2543                                    stream_tag, 0, format);
2544         return 0;
2545 }
2546
2547 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2548                                       struct hda_codec *codec,
2549                                       struct snd_pcm_substream *substream)
2550 {
2551         struct alc_spec *spec = codec->spec;
2552
2553         snd_hda_codec_cleanup_stream(codec,
2554                                      spec->adc_nids[substream->number + 1]);
2555         return 0;
2556 }
2557
2558
2559 /*
2560  */
2561 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2562         .substreams = 1,
2563         .channels_min = 2,
2564         .channels_max = 8,
2565         /* NID is set in alc_build_pcms */
2566         .ops = {
2567                 .open = alc880_playback_pcm_open,
2568                 .prepare = alc880_playback_pcm_prepare,
2569                 .cleanup = alc880_playback_pcm_cleanup
2570         },
2571 };
2572
2573 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2574         .substreams = 1,
2575         .channels_min = 2,
2576         .channels_max = 2,
2577         /* NID is set in alc_build_pcms */
2578 };
2579
2580 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2581         .substreams = 1,
2582         .channels_min = 2,
2583         .channels_max = 2,
2584         /* NID is set in alc_build_pcms */
2585 };
2586
2587 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2588         .substreams = 2, /* can be overridden */
2589         .channels_min = 2,
2590         .channels_max = 2,
2591         /* NID is set in alc_build_pcms */
2592         .ops = {
2593                 .prepare = alc880_alt_capture_pcm_prepare,
2594                 .cleanup = alc880_alt_capture_pcm_cleanup
2595         },
2596 };
2597
2598 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2599         .substreams = 1,
2600         .channels_min = 2,
2601         .channels_max = 2,
2602         /* NID is set in alc_build_pcms */
2603         .ops = {
2604                 .open = alc880_dig_playback_pcm_open,
2605                 .close = alc880_dig_playback_pcm_close,
2606                 .prepare = alc880_dig_playback_pcm_prepare
2607         },
2608 };
2609
2610 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2611         .substreams = 1,
2612         .channels_min = 2,
2613         .channels_max = 2,
2614         /* NID is set in alc_build_pcms */
2615 };
2616
2617 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2618 static struct hda_pcm_stream alc_pcm_null_stream = {
2619         .substreams = 0,
2620         .channels_min = 0,
2621         .channels_max = 0,
2622 };
2623
2624 static int alc_build_pcms(struct hda_codec *codec)
2625 {
2626         struct alc_spec *spec = codec->spec;
2627         struct hda_pcm *info = spec->pcm_rec;
2628         int i;
2629
2630         codec->num_pcms = 1;
2631         codec->pcm_info = info;
2632
2633         info->name = spec->stream_name_analog;
2634         if (spec->stream_analog_playback) {
2635                 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2636                 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2637                 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2638         }
2639         if (spec->stream_analog_capture) {
2640                 snd_assert(spec->adc_nids, return -EINVAL);
2641                 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2642                 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2643         }
2644
2645         if (spec->channel_mode) {
2646                 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2647                 for (i = 0; i < spec->num_channel_mode; i++) {
2648                         if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2649                                 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2650                         }
2651                 }
2652         }
2653
2654         /* SPDIF for stream index #1 */
2655         if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2656                 codec->num_pcms = 2;
2657                 info = spec->pcm_rec + 1;
2658                 info->name = spec->stream_name_digital;
2659                 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2660                 if (spec->multiout.dig_out_nid &&
2661                     spec->stream_digital_playback) {
2662                         info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2663                         info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2664                 }
2665                 if (spec->dig_in_nid &&
2666                     spec->stream_digital_capture) {
2667                         info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2668                         info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2669                 }
2670         }
2671
2672         /* If the use of more than one ADC is requested for the current
2673          * model, configure a second analog capture-only PCM.
2674          */
2675         /* Additional Analaog capture for index #2 */
2676         if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2677             (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
2678                 codec->num_pcms = 3;
2679                 info = spec->pcm_rec + 2;
2680                 info->name = spec->stream_name_analog;
2681                 if (spec->alt_dac_nid) {
2682                         info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2683                                 *spec->stream_analog_alt_playback;
2684                         info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2685                                 spec->alt_dac_nid;
2686                 } else {
2687                         info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2688                                 alc_pcm_null_stream;
2689                         info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2690                 }
2691                 if (spec->num_adc_nids > 1) {
2692                         info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2693                                 *spec->stream_analog_alt_capture;
2694                         info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2695                                 spec->adc_nids[1];
2696                         info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2697                                 spec->num_adc_nids - 1;
2698                 } else {
2699                         info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2700                                 alc_pcm_null_stream;
2701                         info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2702                 }
2703         }
2704
2705         return 0;
2706 }
2707
2708 static void alc_free(struct hda_codec *codec)
2709 {
2710         struct alc_spec *spec = codec->spec;
2711         unsigned int i;
2712
2713         if (!spec)
2714                 return;
2715
2716         if (spec->kctl_alloc) {
2717                 for (i = 0; i < spec->num_kctl_used; i++)
2718                         kfree(spec->kctl_alloc[i].name);
2719                 kfree(spec->kctl_alloc);
2720         }
2721         kfree(spec);
2722         codec->spec = NULL; /* to be sure */
2723 }
2724
2725 /*
2726  */
2727 static struct hda_codec_ops alc_patch_ops = {
2728         .build_controls = alc_build_controls,
2729         .build_pcms = alc_build_pcms,
2730         .init = alc_init,
2731         .free = alc_free,
2732         .unsol_event = alc_unsol_event,
2733 #ifdef CONFIG_SND_HDA_POWER_SAVE
2734         .check_power_status = alc_check_power_status,
2735 #endif
2736 };
2737
2738
2739 /*
2740  * Test configuration for debugging
2741  *
2742  * Almost all inputs/outputs are enabled.  I/O pins can be configured via
2743  * enum controls.
2744  */
2745 #ifdef CONFIG_SND_DEBUG
2746 static hda_nid_t alc880_test_dac_nids[4] = {
2747         0x02, 0x03, 0x04, 0x05
2748 };
2749
2750 static struct hda_input_mux alc880_test_capture_source = {
2751         .num_items = 7,
2752         .items = {
2753                 { "In-1", 0x0 },
2754                 { "In-2", 0x1 },
2755                 { "In-3", 0x2 },
2756                 { "In-4", 0x3 },
2757                 { "CD", 0x4 },
2758                 { "Front", 0x5 },
2759                 { "Surround", 0x6 },
2760         },
2761 };
2762
2763 static struct hda_channel_mode alc880_test_modes[4] = {
2764         { 2, NULL },
2765         { 4, NULL },
2766         { 6, NULL },
2767         { 8, NULL },
2768 };
2769
2770 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2771                                  struct snd_ctl_elem_info *uinfo)
2772 {
2773         static char *texts[] = {
2774                 "N/A", "Line Out", "HP Out",
2775                 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2776         };
2777         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2778         uinfo->count = 1;
2779         uinfo->value.enumerated.items = 8;
2780         if (uinfo->value.enumerated.item >= 8)
2781                 uinfo->value.enumerated.item = 7;
2782         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2783         return 0;
2784 }
2785
2786 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2787                                 struct snd_ctl_elem_value *ucontrol)
2788 {
2789         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2790         hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2791         unsigned int pin_ctl, item = 0;
2792
2793         pin_ctl = snd_hda_codec_read(codec, nid, 0,
2794                                      AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2795         if (pin_ctl & AC_PINCTL_OUT_EN) {
2796                 if (pin_ctl & AC_PINCTL_HP_EN)
2797                         item = 2;
2798                 else
2799                         item = 1;
2800         } else if (pin_ctl & AC_PINCTL_IN_EN) {
2801                 switch (pin_ctl & AC_PINCTL_VREFEN) {
2802                 case AC_PINCTL_VREF_HIZ: item = 3; break;
2803                 case AC_PINCTL_VREF_50:  item = 4; break;
2804                 case AC_PINCTL_VREF_GRD: item = 5; break;
2805                 case AC_PINCTL_VREF_80:  item = 6; break;
2806                 case AC_PINCTL_VREF_100: item = 7; break;
2807                 }
2808         }
2809         ucontrol->value.enumerated.item[0] = item;
2810         return 0;
2811 }
2812
2813 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2814                                 struct snd_ctl_elem_value *ucontrol)
2815 {
2816         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2817         hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2818         static unsigned int ctls[] = {
2819                 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2820                 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2821                 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2822                 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2823                 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2824                 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2825         };
2826         unsigned int old_ctl, new_ctl;
2827
2828         old_ctl = snd_hda_codec_read(codec, nid, 0,
2829                                      AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2830         new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2831         if (old_ctl != new_ctl) {
2832                 int val;
2833                 snd_hda_codec_write_cache(codec, nid, 0,
2834                                           AC_VERB_SET_PIN_WIDGET_CONTROL,
2835                                           new_ctl);
2836                 val = ucontrol->value.enumerated.item[0] >= 3 ?
2837                         HDA_AMP_MUTE : 0;
2838                 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2839                                          HDA_AMP_MUTE, val);
2840                 return 1;
2841         }
2842         return 0;
2843 }
2844
2845 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2846                                  struct snd_ctl_elem_info *uinfo)
2847 {
2848         static char *texts[] = {
2849                 "Front", "Surround", "CLFE", "Side"
2850         };
2851         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2852         uinfo->count = 1;
2853         uinfo->value.enumerated.items = 4;
2854         if (uinfo->value.enumerated.item >= 4)
2855                 uinfo->value.enumerated.item = 3;
2856         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2857         return 0;
2858 }
2859
2860 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2861                                 struct snd_ctl_elem_value *ucontrol)
2862 {
2863         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2864         hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2865         unsigned int sel;
2866
2867         sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2868         ucontrol->value.enumerated.item[0] = sel & 3;
2869         return 0;
2870 }
2871
2872 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2873                                 struct snd_ctl_elem_value *ucontrol)
2874 {
2875         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2876         hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2877         unsigned int sel;
2878
2879         sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2880         if (ucontrol->value.enumerated.item[0] != sel) {
2881                 sel = ucontrol->value.enumerated.item[0] & 3;
2882                 snd_hda_codec_write_cache(codec, nid, 0,
2883                                           AC_VERB_SET_CONNECT_SEL, sel);
2884                 return 1;
2885         }
2886         return 0;
2887 }
2888
2889 #define PIN_CTL_TEST(xname,nid) {                       \
2890                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,    \
2891                         .name = xname,                 \
2892                         .info = alc_test_pin_ctl_info, \
2893                         .get = alc_test_pin_ctl_get,   \
2894                         .put = alc_test_pin_ctl_put,   \
2895                         .private_value = nid           \
2896                         }
2897
2898 #define PIN_SRC_TEST(xname,nid) {                       \
2899                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,    \
2900                         .name = xname,                 \
2901                         .info = alc_test_pin_src_info, \
2902                         .get = alc_test_pin_src_get,   \
2903                         .put = alc_test_pin_src_put,   \
2904                         .private_value = nid           \
2905                         }
2906
2907 static struct snd_kcontrol_new alc880_test_mixer[] = {
2908         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2909         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2910         HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2911         HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2912         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2913         HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2914         HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2915         HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2916         PIN_CTL_TEST("Front Pin Mode", 0x14),
2917         PIN_CTL_TEST("Surround Pin Mode", 0x15),
2918         PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2919         PIN_CTL_TEST("Side Pin Mode", 0x17),
2920         PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2921         PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2922         PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2923         PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2924         PIN_SRC_TEST("In-1 Pin Source", 0x18),
2925         PIN_SRC_TEST("In-2 Pin Source", 0x19),
2926         PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2927         PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2928         HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2929         HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2930         HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2931         HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2932         HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2933         HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2934         HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2935         HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2936         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2937         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2938         {
2939                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2940                 .name = "Channel Mode",
2941                 .info = alc_ch_mode_info,
2942                 .get = alc_ch_mode_get,
2943                 .put = alc_ch_mode_put,
2944         },
2945         { } /* end */
2946 };
2947
2948 static struct hda_verb alc880_test_init_verbs[] = {
2949         /* Unmute inputs of 0x0c - 0x0f */
2950         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2951         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2952         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2953         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2954         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2955         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2956         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2957         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2958         /* Vol output for 0x0c-0x0f */
2959         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2960         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2961         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2962         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2963         /* Set output pins 0x14-0x17 */
2964         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2965         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2966         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2967         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2968         /* Unmute output pins 0x14-0x17 */
2969         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2970         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2971         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2972         {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2973         /* Set input pins 0x18-0x1c */
2974         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2975         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2976         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2977         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2978         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2979         /* Mute input pins 0x18-0x1b */
2980         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2981         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2982         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2983         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2984         /* ADC set up */
2985         {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2986         {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2987         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2988         {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2989         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2990         {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2991         /* Analog input/passthru */
2992         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2993         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2994         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2995         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2996         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2997         { }
2998 };
2999 #endif
3000
3001 /*
3002  */
3003
3004 static const char *alc880_models[ALC880_MODEL_LAST] = {
3005         [ALC880_3ST]            = "3stack",
3006         [ALC880_TCL_S700]       = "tcl",
3007         [ALC880_3ST_DIG]        = "3stack-digout",
3008         [ALC880_CLEVO]          = "clevo",
3009         [ALC880_5ST]            = "5stack",
3010         [ALC880_5ST_DIG]        = "5stack-digout",
3011         [ALC880_W810]           = "w810",
3012         [ALC880_Z71V]           = "z71v",
3013         [ALC880_6ST]            = "6stack",
3014         [ALC880_6ST_DIG]        = "6stack-digout",
3015         [ALC880_ASUS]           = "asus",
3016         [ALC880_ASUS_W1V]       = "asus-w1v",
3017         [ALC880_ASUS_DIG]       = "asus-dig",
3018         [ALC880_ASUS_DIG2]      = "asus-dig2",
3019         [ALC880_UNIWILL_DIG]    = "uniwill",
3020         [ALC880_UNIWILL_P53]    = "uniwill-p53",
3021         [ALC880_FUJITSU]        = "fujitsu",
3022         [ALC880_F1734]          = "F1734",
3023         [ALC880_LG]             = "lg",
3024         [ALC880_LG_LW]          = "lg-lw",
3025         [ALC880_MEDION_RIM]     = "medion",
3026 #ifdef CONFIG_SND_DEBUG
3027         [ALC880_TEST]           = "test",
3028 #endif
3029         [ALC880_AUTO]           = "auto",
3030 };
3031
3032 static struct snd_pci_quirk alc880_cfg_tbl[] = {
3033         SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
3034         SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3035         SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3036         SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3037         SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3038         SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3039         SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3040         SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3041         SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
3042         SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3043         SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
3044         SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3045         SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3046         SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3047         SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3048         SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3049         SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3050         SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3051         /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3052         SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3053         SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
3054         SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
3055         SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3056         SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3057         SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
3058         SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
3059         SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
3060         SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3061         SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
3062         SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3063         SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
3064         SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3065         SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3066         SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3067         SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
3068         SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3069         SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
3070         SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
3071         SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
3072         SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
3073         SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
3074         SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3075         SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
3076         SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
3077         SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
3078         SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
3079         SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
3080         SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
3081         SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
3082         SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
3083         SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
3084         SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
3085         SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3086         SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
3087         SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
3088         SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3089         SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3090         SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3091         SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
3092         SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3093         SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
3094         SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
3095         SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
3096         SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3097         SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
3098         SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3099         SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3100         SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
3101         SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3102         SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3103         SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
3104         {}
3105 };
3106
3107 /*
3108  * ALC880 codec presets
3109  */
3110 static struct alc_config_preset alc880_presets[] = {
3111         [ALC880_3ST] = {
3112                 .mixers = { alc880_three_stack_mixer },
3113                 .init_verbs = { alc880_volume_init_verbs,
3114                                 alc880_pin_3stack_init_verbs },
3115                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3116                 .dac_nids = alc880_dac_nids,
3117                 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3118                 .channel_mode = alc880_threestack_modes,
3119                 .need_dac_fix = 1,
3120                 .input_mux = &alc880_capture_source,
3121         },
3122         [ALC880_3ST_DIG] = {
3123                 .mixers = { alc880_three_stack_mixer },
3124                 .init_verbs = { alc880_volume_init_verbs,
3125                                 alc880_pin_3stack_init_verbs },
3126                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3127                 .dac_nids = alc880_dac_nids,
3128                 .dig_out_nid = ALC880_DIGOUT_NID,
3129                 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3130                 .channel_mode = alc880_threestack_modes,
3131                 .need_dac_fix = 1,
3132                 .input_mux = &alc880_capture_source,
3133         },
3134         [ALC880_TCL_S700] = {
3135                 .mixers = { alc880_tcl_s700_mixer },
3136                 .init_verbs = { alc880_volume_init_verbs,
3137                                 alc880_pin_tcl_S700_init_verbs,
3138                                 alc880_gpio2_init_verbs },
3139                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3140                 .dac_nids = alc880_dac_nids,
3141                 .hp_nid = 0x03,
3142                 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3143                 .channel_mode = alc880_2_jack_modes,
3144                 .input_mux = &alc880_capture_source,
3145         },
3146         [ALC880_5ST] = {
3147                 .mixers = { alc880_three_stack_mixer,
3148                             alc880_five_stack_mixer},
3149                 .init_verbs = { alc880_volume_init_verbs,
3150                                 alc880_pin_5stack_init_verbs },
3151                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3152                 .dac_nids = alc880_dac_nids,
3153                 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3154                 .channel_mode = alc880_fivestack_modes,
3155                 .input_mux = &alc880_capture_source,
3156         },
3157         [ALC880_5ST_DIG] = {
3158                 .mixers = { alc880_three_stack_mixer,
3159                             alc880_five_stack_mixer },
3160                 .init_verbs = { alc880_volume_init_verbs,
3161                                 alc880_pin_5stack_init_verbs },
3162                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3163                 .dac_nids = alc880_dac_nids,
3164                 .dig_out_nid = ALC880_DIGOUT_NID,
3165                 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3166                 .channel_mode = alc880_fivestack_modes,
3167                 .input_mux = &alc880_capture_source,
3168         },
3169         [ALC880_6ST] = {
3170                 .mixers = { alc880_six_stack_mixer },
3171                 .init_verbs = { alc880_volume_init_verbs,
3172                                 alc880_pin_6stack_init_verbs },
3173                 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3174                 .dac_nids = alc880_6st_dac_nids,
3175                 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3176                 .channel_mode = alc880_sixstack_modes,
3177                 .input_mux = &alc880_6stack_capture_source,
3178         },
3179         [ALC880_6ST_DIG] = {
3180                 .mixers = { alc880_six_stack_mixer },
3181                 .init_verbs = { alc880_volume_init_verbs,
3182                                 alc880_pin_6stack_init_verbs },
3183                 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3184                 .dac_nids = alc880_6st_dac_nids,
3185                 .dig_out_nid = ALC880_DIGOUT_NID,
3186                 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3187                 .channel_mode = alc880_sixstack_modes,
3188                 .input_mux = &alc880_6stack_capture_source,
3189         },
3190         [ALC880_W810] = {
3191                 .mixers = { alc880_w810_base_mixer },
3192                 .init_verbs = { alc880_volume_init_verbs,
3193                                 alc880_pin_w810_init_verbs,
3194                                 alc880_gpio2_init_verbs },
3195                 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3196                 .dac_nids = alc880_w810_dac_nids,
3197                 .dig_out_nid = ALC880_DIGOUT_NID,
3198                 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3199                 .channel_mode = alc880_w810_modes,
3200                 .input_mux = &alc880_capture_source,
3201         },
3202         [ALC880_Z71V] = {
3203                 .mixers = { alc880_z71v_mixer },
3204                 .init_verbs = { alc880_volume_init_verbs,
3205                                 alc880_pin_z71v_init_verbs },
3206                 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3207                 .dac_nids = alc880_z71v_dac_nids,
3208                 .dig_out_nid = ALC880_DIGOUT_NID,
3209                 .hp_nid = 0x03,
3210                 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3211                 .channel_mode = alc880_2_jack_modes,
3212                 .input_mux = &alc880_capture_source,
3213         },
3214         [ALC880_F1734] = {
3215                 .mixers = { alc880_f1734_mixer },
3216                 .init_verbs = { alc880_volume_init_verbs,
3217                                 alc880_pin_f1734_init_verbs },
3218                 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3219                 .dac_nids = alc880_f1734_dac_nids,
3220                 .hp_nid = 0x02,
3221                 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3222                 .channel_mode = alc880_2_jack_modes,
3223                 .input_mux = &alc880_f1734_capture_source,
3224                 .unsol_event = alc880_uniwill_p53_unsol_event,
3225                 .init_hook = alc880_uniwill_p53_hp_automute,
3226         },
3227         [ALC880_ASUS] = {
3228                 .mixers = { alc880_asus_mixer },
3229                 .init_verbs = { alc880_volume_init_verbs,
3230                                 alc880_pin_asus_init_verbs,
3231                                 alc880_gpio1_init_verbs },
3232                 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3233                 .dac_nids = alc880_asus_dac_nids,
3234                 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3235                 .channel_mode = alc880_asus_modes,
3236                 .need_dac_fix = 1,
3237                 .input_mux = &alc880_capture_source,
3238         },
3239         [ALC880_ASUS_DIG] = {