ALSA: hda - Fix wrong gpio_dir & gpio_mask hint setups for IDT/STAC codecs
[pandora-kernel.git] / sound / pci / hda / alc880_quirks.c
1 /*
2  * ALC880 quirk models
3  * included by patch_realtek.c
4  */
5
6 /* ALC880 board config type */
7 enum {
8         ALC880_AUTO,
9         ALC880_3ST,
10         ALC880_3ST_DIG,
11         ALC880_5ST,
12         ALC880_5ST_DIG,
13         ALC880_W810,
14         ALC880_Z71V,
15         ALC880_6ST,
16         ALC880_6ST_DIG,
17         ALC880_F1734,
18         ALC880_ASUS,
19         ALC880_ASUS_DIG,
20         ALC880_ASUS_W1V,
21         ALC880_ASUS_DIG2,
22         ALC880_FUJITSU,
23         ALC880_UNIWILL_DIG,
24         ALC880_UNIWILL,
25         ALC880_UNIWILL_P53,
26         ALC880_CLEVO,
27         ALC880_TCL_S700,
28         ALC880_LG,
29         ALC880_LG_LW,
30         ALC880_MEDION_RIM,
31 #ifdef CONFIG_SND_DEBUG
32         ALC880_TEST,
33 #endif
34         ALC880_MODEL_LAST /* last tag */
35 };
36
37 /*
38  * ALC880 3-stack model
39  *
40  * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
41  * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
42  *                 F-Mic = 0x1b, HP = 0x19
43  */
44
45 static const hda_nid_t alc880_dac_nids[4] = {
46         /* front, rear, clfe, rear_surr */
47         0x02, 0x05, 0x04, 0x03
48 };
49
50 static const hda_nid_t alc880_adc_nids[3] = {
51         /* ADC0-2 */
52         0x07, 0x08, 0x09,
53 };
54
55 /* The datasheet says the node 0x07 is connected from inputs,
56  * but it shows zero connection in the real implementation on some devices.
57  * Note: this is a 915GAV bug, fixed on 915GLV
58  */
59 static const hda_nid_t alc880_adc_nids_alt[2] = {
60         /* ADC1-2 */
61         0x08, 0x09,
62 };
63
64 #define ALC880_DIGOUT_NID       0x06
65 #define ALC880_DIGIN_NID        0x0a
66 #define ALC880_PIN_CD_NID       0x1c
67
68 static const struct hda_input_mux alc880_capture_source = {
69         .num_items = 4,
70         .items = {
71                 { "Mic", 0x0 },
72                 { "Front Mic", 0x3 },
73                 { "Line", 0x2 },
74                 { "CD", 0x4 },
75         },
76 };
77
78 /* channel source setting (2/6 channel selection for 3-stack) */
79 /* 2ch mode */
80 static const struct hda_verb alc880_threestack_ch2_init[] = {
81         /* set line-in to input, mute it */
82         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
83         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
84         /* set mic-in to input vref 80%, mute it */
85         { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
86         { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
87         { } /* end */
88 };
89
90 /* 6ch mode */
91 static const struct hda_verb alc880_threestack_ch6_init[] = {
92         /* set line-in to output, unmute it */
93         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
94         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
95         /* set mic-in to output, unmute it */
96         { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
97         { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
98         { } /* end */
99 };
100
101 static const struct hda_channel_mode alc880_threestack_modes[2] = {
102         { 2, alc880_threestack_ch2_init },
103         { 6, alc880_threestack_ch6_init },
104 };
105
106 static const struct snd_kcontrol_new alc880_three_stack_mixer[] = {
107         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
108         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
109         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
110         HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
111         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
112         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
113         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
114         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
115         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
116         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
117         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
118         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
119         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
120         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
121         HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
122         HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
123         HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
124         {
125                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
126                 .name = "Channel Mode",
127                 .info = alc_ch_mode_info,
128                 .get = alc_ch_mode_get,
129                 .put = alc_ch_mode_put,
130         },
131         { } /* end */
132 };
133
134 /*
135  * ALC880 5-stack model
136  *
137  * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
138  *      Side = 0x02 (0xd)
139  * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
140  *                 Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
141  */
142
143 /* additional mixers to alc880_three_stack_mixer */
144 static const struct snd_kcontrol_new alc880_five_stack_mixer[] = {
145         HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
146         HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
147         { } /* end */
148 };
149
150 /* channel source setting (6/8 channel selection for 5-stack) */
151 /* 6ch mode */
152 static const struct hda_verb alc880_fivestack_ch6_init[] = {
153         /* set line-in to input, mute it */
154         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
155         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
156         { } /* end */
157 };
158
159 /* 8ch mode */
160 static const struct hda_verb alc880_fivestack_ch8_init[] = {
161         /* set line-in to output, unmute it */
162         { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
163         { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
164         { } /* end */
165 };
166
167 static const struct hda_channel_mode alc880_fivestack_modes[2] = {
168         { 6, alc880_fivestack_ch6_init },
169         { 8, alc880_fivestack_ch8_init },
170 };
171
172
173 /*
174  * ALC880 6-stack model
175  *
176  * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
177  *      Side = 0x05 (0x0f)
178  * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
179  *   Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
180  */
181
182 static const hda_nid_t alc880_6st_dac_nids[4] = {
183         /* front, rear, clfe, rear_surr */
184         0x02, 0x03, 0x04, 0x05
185 };
186
187 static const struct hda_input_mux alc880_6stack_capture_source = {
188         .num_items = 4,
189         .items = {
190                 { "Mic", 0x0 },
191                 { "Front Mic", 0x1 },
192                 { "Line", 0x2 },
193                 { "CD", 0x4 },
194         },
195 };
196
197 /* fixed 8-channels */
198 static const struct hda_channel_mode alc880_sixstack_modes[1] = {
199         { 8, NULL },
200 };
201
202 static const struct snd_kcontrol_new alc880_six_stack_mixer[] = {
203         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
204         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
205         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
206         HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
207         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
208         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
209         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
210         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
211         HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
212         HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
213         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
214         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
215         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
216         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
217         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
218         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
219         HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
220         HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
221         {
222                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
223                 .name = "Channel Mode",
224                 .info = alc_ch_mode_info,
225                 .get = alc_ch_mode_get,
226                 .put = alc_ch_mode_put,
227         },
228         { } /* end */
229 };
230
231
232 /*
233  * ALC880 W810 model
234  *
235  * W810 has rear IO for:
236  * Front (DAC 02)
237  * Surround (DAC 03)
238  * Center/LFE (DAC 04)
239  * Digital out (06)
240  *
241  * The system also has a pair of internal speakers, and a headphone jack.
242  * These are both connected to Line2 on the codec, hence to DAC 02.
243  *
244  * There is a variable resistor to control the speaker or headphone
245  * volume. This is a hardware-only device without a software API.
246  *
247  * Plugging headphones in will disable the internal speakers. This is
248  * implemented in hardware, not via the driver using jack sense. In
249  * a similar fashion, plugging into the rear socket marked "front" will
250  * disable both the speakers and headphones.
251  *
252  * For input, there's a microphone jack, and an "audio in" jack.
253  * These may not do anything useful with this driver yet, because I
254  * haven't setup any initialization verbs for these yet...
255  */
256
257 static const hda_nid_t alc880_w810_dac_nids[3] = {
258         /* front, rear/surround, clfe */
259         0x02, 0x03, 0x04
260 };
261
262 /* fixed 6 channels */
263 static const struct hda_channel_mode alc880_w810_modes[1] = {
264         { 6, NULL }
265 };
266
267 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
268 static const struct snd_kcontrol_new alc880_w810_base_mixer[] = {
269         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
270         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
271         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
272         HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
273         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
274         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
275         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
276         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
277         HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
278         { } /* end */
279 };
280
281
282 /*
283  * Z710V model
284  *
285  * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
286  * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
287  *                 Line = 0x1a
288  */
289
290 static const hda_nid_t alc880_z71v_dac_nids[1] = {
291         0x02
292 };
293 #define ALC880_Z71V_HP_DAC      0x03
294
295 /* fixed 2 channels */
296 static const struct hda_channel_mode alc880_2_jack_modes[1] = {
297         { 2, NULL }
298 };
299
300 static const struct snd_kcontrol_new alc880_z71v_mixer[] = {
301         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
302         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
303         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
304         HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
305         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
306         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
307         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
308         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
309         { } /* end */
310 };
311
312
313 /*
314  * ALC880 F1734 model
315  *
316  * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
317  * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
318  */
319
320 static const hda_nid_t alc880_f1734_dac_nids[1] = {
321         0x03
322 };
323 #define ALC880_F1734_HP_DAC     0x02
324
325 static const struct snd_kcontrol_new alc880_f1734_mixer[] = {
326         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
327         HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
328         HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
329         HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
330         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
331         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
332         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
333         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
334         { } /* end */
335 };
336
337 static const struct hda_input_mux alc880_f1734_capture_source = {
338         .num_items = 2,
339         .items = {
340                 { "Mic", 0x1 },
341                 { "CD", 0x4 },
342         },
343 };
344
345
346 /*
347  * ALC880 ASUS model
348  *
349  * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
350  * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
351  *  Mic = 0x18, Line = 0x1a
352  */
353
354 #define alc880_asus_dac_nids    alc880_w810_dac_nids    /* identical with w810 */
355 #define alc880_asus_modes       alc880_threestack_modes /* 2/6 channel mode */
356
357 static const struct snd_kcontrol_new alc880_asus_mixer[] = {
358         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
359         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
360         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
361         HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
362         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
363         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
364         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
365         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
366         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
367         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
368         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
369         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
370         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
371         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
372         {
373                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
374                 .name = "Channel Mode",
375                 .info = alc_ch_mode_info,
376                 .get = alc_ch_mode_get,
377                 .put = alc_ch_mode_put,
378         },
379         { } /* end */
380 };
381
382 /*
383  * ALC880 ASUS W1V model
384  *
385  * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
386  * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
387  *  Mic = 0x18, Line = 0x1a, Line2 = 0x1b
388  */
389
390 /* additional mixers to alc880_asus_mixer */
391 static const struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
392         HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
393         HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
394         { } /* end */
395 };
396
397 /* TCL S700 */
398 static const struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
399         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
400         HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
401         HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
402         HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
403         HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
404         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
405         HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
406         HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
407         HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
408         { } /* end */
409 };
410
411 /* Uniwill */
412 static const struct snd_kcontrol_new alc880_uniwill_mixer[] = {
413         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
414         HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
415         HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
416         HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
417         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
418         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
419         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
420         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
421         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
422         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
423         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
424         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
425         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
426         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
427         HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
428         HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
429         {
430                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
431                 .name = "Channel Mode",
432                 .info = alc_ch_mode_info,
433                 .get = alc_ch_mode_get,
434                 .put = alc_ch_mode_put,
435         },
436         { } /* end */
437 };
438
439 static const struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
440         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
441         HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
442         HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
443         HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
444         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
445         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
446         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
447         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
448         HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
449         HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
450         { } /* end */
451 };
452
453 static const struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
454         HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
455         HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
456         HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
457         HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
458         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
459         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
460         { } /* end */
461 };
462
463 /*
464  * initialize the codec volumes, etc
465  */
466
467 /*
468  * generic initialization of ADC, input mixers and output mixers
469  */
470 static const struct hda_verb alc880_volume_init_verbs[] = {
471         /*
472          * Unmute ADC0-2 and set the default input to mic-in
473          */
474         {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
475         {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
476         {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
477         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
478         {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
479         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
480
481         /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
482          * mixer widget
483          * Note: PASD motherboards uses the Line In 2 as the input for front
484          * panel mic (mic 2)
485          */
486         /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
487         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
488         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
489         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
490         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
491         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
492         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
493         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
494
495         /*
496          * Set up output mixers (0x0c - 0x0f)
497          */
498         /* set vol=0 to output mixers */
499         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
500         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
501         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
502         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
503         /* set up input amps for analog loopback */
504         /* Amp Indices: DAC = 0, mixer = 1 */
505         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
506         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
507         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
508         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
509         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
510         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
511         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
512         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
513
514         { }
515 };
516
517 /*
518  * 3-stack pin configuration:
519  * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
520  */
521 static const struct hda_verb alc880_pin_3stack_init_verbs[] = {
522         /*
523          * preset connection lists of input pins
524          * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
525          */
526         {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
527         {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
528         {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
529
530         /*
531          * Set pin mode and muting
532          */
533         /* set front pin widgets 0x14 for output */
534         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
535         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
536         /* Mic1 (rear panel) pin widget for input and vref at 80% */
537         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
538         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
539         /* Mic2 (as headphone out) for HP output */
540         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
541         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
542         /* Line In pin widget for input */
543         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
544         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
545         /* Line2 (as front mic) pin widget for input and vref at 80% */
546         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
547         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
548         /* CD pin widget for input */
549         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
550
551         { }
552 };
553
554 /*
555  * 5-stack pin configuration:
556  * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
557  * line-in/side = 0x1a, f-mic = 0x1b
558  */
559 static const struct hda_verb alc880_pin_5stack_init_verbs[] = {
560         /*
561          * preset connection lists of input pins
562          * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
563          */
564         {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
565         {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
566
567         /*
568          * Set pin mode and muting
569          */
570         /* set pin widgets 0x14-0x17 for output */
571         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
572         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
573         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
574         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
575         /* unmute pins for output (no gain on this amp) */
576         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
577         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
578         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
579         {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
580
581         /* Mic1 (rear panel) pin widget for input and vref at 80% */
582         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
583         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
584         /* Mic2 (as headphone out) for HP output */
585         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
586         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
587         /* Line In pin widget for input */
588         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
589         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
590         /* Line2 (as front mic) pin widget for input and vref at 80% */
591         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
592         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
593         /* CD pin widget for input */
594         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
595
596         { }
597 };
598
599 /*
600  * W810 pin configuration:
601  * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
602  */
603 static const struct hda_verb alc880_pin_w810_init_verbs[] = {
604         /* hphone/speaker input selector: front DAC */
605         {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
606
607         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
608         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
609         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
610         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
611         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
612         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
613
614         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
615         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
616
617         { }
618 };
619
620 /*
621  * Z71V pin configuration:
622  * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
623  */
624 static const struct hda_verb alc880_pin_z71v_init_verbs[] = {
625         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
626         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
627         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
628         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
629
630         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
631         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
632         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
633         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
634
635         { }
636 };
637
638 /*
639  * 6-stack pin configuration:
640  * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
641  * f-mic = 0x19, line = 0x1a, HP = 0x1b
642  */
643 static const struct hda_verb alc880_pin_6stack_init_verbs[] = {
644         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
645
646         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
647         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
648         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
649         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
650         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
651         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
652         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
653         {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
654
655         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
656         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
657         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
658         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
659         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
660         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
661         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
662         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
663         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
664
665         { }
666 };
667
668 /*
669  * Uniwill pin configuration:
670  * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
671  * line = 0x1a
672  */
673 static const struct hda_verb alc880_uniwill_init_verbs[] = {
674         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
675
676         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
677         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
678         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
679         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
680         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
681         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
682         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
683         {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
684         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
685         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
686         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
687         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
688         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
689         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
690
691         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
692         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
693         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
694         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
695         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
696         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
697         /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
698         /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
699         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
700
701         {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
702         {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_MIC_EVENT},
703
704         { }
705 };
706
707 /*
708 * Uniwill P53
709 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
710  */
711 static const struct hda_verb alc880_uniwill_p53_init_verbs[] = {
712         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
713
714         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
715         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
716         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
717         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
718         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
719         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
720         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
721         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
722         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
723         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
724         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
725         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
726
727         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
728         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
729         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
730         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
731         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
732         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
733
734         {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
735         {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_DCVOL_EVENT},
736
737         { }
738 };
739
740 static const struct hda_verb alc880_beep_init_verbs[] = {
741         { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
742         { }
743 };
744
745 static void alc880_uniwill_setup(struct hda_codec *codec)
746 {
747         struct alc_spec *spec = codec->spec;
748
749         spec->autocfg.hp_pins[0] = 0x14;
750         spec->autocfg.speaker_pins[0] = 0x15;
751         spec->autocfg.speaker_pins[0] = 0x16;
752         alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
753 }
754
755 static void alc880_uniwill_init_hook(struct hda_codec *codec)
756 {
757         alc_hp_automute(codec);
758         alc88x_simple_mic_automute(codec);
759 }
760
761 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
762                                        unsigned int res)
763 {
764         /* Looks like the unsol event is incompatible with the standard
765          * definition.  4bit tag is placed at 28 bit!
766          */
767         switch (res >> 28) {
768         case ALC_MIC_EVENT:
769                 alc88x_simple_mic_automute(codec);
770                 break;
771         default:
772                 alc_sku_unsol_event(codec, res);
773                 break;
774         }
775 }
776
777 static void alc880_uniwill_p53_setup(struct hda_codec *codec)
778 {
779         struct alc_spec *spec = codec->spec;
780
781         spec->autocfg.hp_pins[0] = 0x14;
782         spec->autocfg.speaker_pins[0] = 0x15;
783         alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
784 }
785
786 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
787 {
788         unsigned int present;
789
790         present = snd_hda_codec_read(codec, 0x21, 0,
791                                      AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
792         present &= HDA_AMP_VOLMASK;
793         snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
794                                  HDA_AMP_VOLMASK, present);
795         snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
796                                  HDA_AMP_VOLMASK, present);
797 }
798
799 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
800                                            unsigned int res)
801 {
802         /* Looks like the unsol event is incompatible with the standard
803          * definition.  4bit tag is placed at 28 bit!
804          */
805         if ((res >> 28) == ALC_DCVOL_EVENT)
806                 alc880_uniwill_p53_dcvol_automute(codec);
807         else
808                 alc_sku_unsol_event(codec, res);
809 }
810
811 /*
812  * F1734 pin configuration:
813  * HP = 0x14, speaker-out = 0x15, mic = 0x18
814  */
815 static const struct hda_verb alc880_pin_f1734_init_verbs[] = {
816         {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
817         {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
818         {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
819         {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
820         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
821
822         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
823         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
824         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
825         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
826
827         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
828         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
829         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
830         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
831         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
832         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
833         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
834         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
835         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
836
837         {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC_HP_EVENT},
838         {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC_DCVOL_EVENT},
839
840         { }
841 };
842
843 /*
844  * ASUS pin configuration:
845  * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
846  */
847 static const struct hda_verb alc880_pin_asus_init_verbs[] = {
848         {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
849         {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
850         {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
851         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
852
853         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
854         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
855         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
856         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
857         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
858         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
859         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
860         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
861
862         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
863         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
864         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
865         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
866         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
867         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
868         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
869         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
870         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
871
872         { }
873 };
874
875 /* Enable GPIO mask and set output */
876 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
877 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
878 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
879
880 /* Clevo m520g init */
881 static const struct hda_verb alc880_pin_clevo_init_verbs[] = {
882         /* headphone output */
883         {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
884         /* line-out */
885         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
886         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
887         /* Line-in */
888         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
889         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
890         /* CD */
891         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
892         {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
893         /* Mic1 (rear panel) */
894         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
895         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
896         /* Mic2 (front panel) */
897         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
898         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
899         /* headphone */
900         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
901         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
902         /* change to EAPD mode */
903         {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
904         {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
905
906         { }
907 };
908
909 static const struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
910         /* change to EAPD mode */
911         {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
912         {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
913
914         /* Headphone output */
915         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
916         /* Front output*/
917         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
918         {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
919
920         /* Line In pin widget for input */
921         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
922         /* CD pin widget for input */
923         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
924         /* Mic1 (rear panel) pin widget for input and vref at 80% */
925         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
926
927         /* change to EAPD mode */
928         {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
929         {0x20, AC_VERB_SET_PROC_COEF,  0x3070},
930
931         { }
932 };
933
934 /*
935  * LG m1 express dual
936  *
937  * Pin assignment:
938  *   Rear Line-In/Out (blue): 0x14
939  *   Build-in Mic-In: 0x15
940  *   Speaker-out: 0x17
941  *   HP-Out (green): 0x1b
942  *   Mic-In/Out (red): 0x19
943  *   SPDIF-Out: 0x1e
944  */
945
946 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
947 static const hda_nid_t alc880_lg_dac_nids[3] = {
948         0x05, 0x02, 0x03
949 };
950
951 /* seems analog CD is not working */
952 static const struct hda_input_mux alc880_lg_capture_source = {
953         .num_items = 3,
954         .items = {
955                 { "Mic", 0x1 },
956                 { "Line", 0x5 },
957                 { "Internal Mic", 0x6 },
958         },
959 };
960
961 /* 2,4,6 channel modes */
962 static const struct hda_verb alc880_lg_ch2_init[] = {
963         /* set line-in and mic-in to input */
964         { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
965         { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
966         { }
967 };
968
969 static const struct hda_verb alc880_lg_ch4_init[] = {
970         /* set line-in to out and mic-in to input */
971         { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
972         { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
973         { }
974 };
975
976 static const struct hda_verb alc880_lg_ch6_init[] = {
977         /* set line-in and mic-in to output */
978         { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
979         { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
980         { }
981 };
982
983 static const struct hda_channel_mode alc880_lg_ch_modes[3] = {
984         { 2, alc880_lg_ch2_init },
985         { 4, alc880_lg_ch4_init },
986         { 6, alc880_lg_ch6_init },
987 };
988
989 static const struct snd_kcontrol_new alc880_lg_mixer[] = {
990         HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
991         HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
992         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
993         HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
994         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
995         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
996         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
997         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
998         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
999         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1000         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1001         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1002         HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1003         HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1004         {
1005                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1006                 .name = "Channel Mode",
1007                 .info = alc_ch_mode_info,
1008                 .get = alc_ch_mode_get,
1009                 .put = alc_ch_mode_put,
1010         },
1011         { } /* end */
1012 };
1013
1014 static const struct hda_verb alc880_lg_init_verbs[] = {
1015         /* set capture source to mic-in */
1016         {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1017         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1018         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1019         /* mute all amp mixer inputs */
1020         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1021         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1022         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1023         /* line-in to input */
1024         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1025         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1026         /* built-in mic */
1027         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1028         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1029         /* speaker-out */
1030         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1031         {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1032         /* mic-in to input */
1033         {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1034         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1035         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1036         /* HP-out */
1037         {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1038         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1039         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1040         /* jack sense */
1041         {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
1042         { }
1043 };
1044
1045 /* toggle speaker-output according to the hp-jack state */
1046 static void alc880_lg_setup(struct hda_codec *codec)
1047 {
1048         struct alc_spec *spec = codec->spec;
1049
1050         spec->autocfg.hp_pins[0] = 0x1b;
1051         spec->autocfg.speaker_pins[0] = 0x17;
1052         alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1053 }
1054
1055 /*
1056  * LG LW20
1057  *
1058  * Pin assignment:
1059  *   Speaker-out: 0x14
1060  *   Mic-In: 0x18
1061  *   Built-in Mic-In: 0x19
1062  *   Line-In: 0x1b
1063  *   HP-Out: 0x1a
1064  *   SPDIF-Out: 0x1e
1065  */
1066
1067 static const struct hda_input_mux alc880_lg_lw_capture_source = {
1068         .num_items = 3,
1069         .items = {
1070                 { "Mic", 0x0 },
1071                 { "Internal Mic", 0x1 },
1072                 { "Line In", 0x2 },
1073         },
1074 };
1075
1076 #define alc880_lg_lw_modes alc880_threestack_modes
1077
1078 static const struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1079         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1080         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1081         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1082         HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1083         HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1084         HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1085         HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1086         HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1087         HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1088         HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1089         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1090         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1091         HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1092         HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1093         {
1094                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1095                 .name = "Channel Mode",
1096                 .info = alc_ch_mode_info,
1097                 .get = alc_ch_mode_get,
1098                 .put = alc_ch_mode_put,
1099         },
1100         { } /* end */
1101 };
1102
1103 static const struct hda_verb alc880_lg_lw_init_verbs[] = {
1104         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1105         {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1106         {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1107
1108         /* set capture source to mic-in */
1109         {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1110         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1111         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1112         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1113         /* speaker-out */
1114         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1115         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1116         /* HP-out */
1117         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1118         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1119         /* mic-in to input */
1120         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1121         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1122         /* built-in mic */
1123         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1124         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1125         /* jack sense */
1126         {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
1127         { }
1128 };
1129
1130 /* toggle speaker-output according to the hp-jack state */
1131 static void alc880_lg_lw_setup(struct hda_codec *codec)
1132 {
1133         struct alc_spec *spec = codec->spec;
1134
1135         spec->autocfg.hp_pins[0] = 0x1b;
1136         spec->autocfg.speaker_pins[0] = 0x14;
1137         alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1138 }
1139
1140 static const struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
1141         HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1142         HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
1143         HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1144         HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1145         HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1146         HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
1147         { } /* end */
1148 };
1149
1150 static const struct hda_input_mux alc880_medion_rim_capture_source = {
1151         .num_items = 2,
1152         .items = {
1153                 { "Mic", 0x0 },
1154                 { "Internal Mic", 0x1 },
1155         },
1156 };
1157
1158 static const struct hda_verb alc880_medion_rim_init_verbs[] = {
1159         {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1160
1161         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1162         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1163
1164         /* Mic1 (rear panel) pin widget for input and vref at 80% */
1165         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1166         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1167         /* Mic2 (as headphone out) for HP output */
1168         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1169         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1170         /* Internal Speaker */
1171         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1172         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1173
1174         {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1175         {0x20, AC_VERB_SET_PROC_COEF,  0x3060},
1176
1177         {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
1178         { }
1179 };
1180
1181 /* toggle speaker-output according to the hp-jack state */
1182 static void alc880_medion_rim_automute(struct hda_codec *codec)
1183 {
1184         struct alc_spec *spec = codec->spec;
1185         alc_hp_automute(codec);
1186         /* toggle EAPD */
1187         if (spec->hp_jack_present)
1188                 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
1189         else
1190                 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
1191 }
1192
1193 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
1194                                           unsigned int res)
1195 {
1196         /* Looks like the unsol event is incompatible with the standard
1197          * definition.  4bit tag is placed at 28 bit!
1198          */
1199         if ((res >> 28) == ALC_HP_EVENT)
1200                 alc880_medion_rim_automute(codec);
1201 }
1202
1203 static void alc880_medion_rim_setup(struct hda_codec *codec)
1204 {
1205         struct alc_spec *spec = codec->spec;
1206
1207         spec->autocfg.hp_pins[0] = 0x14;
1208         spec->autocfg.speaker_pins[0] = 0x1b;
1209         alc_simple_setup_automute(spec, ALC_AUTOMUTE_AMP);
1210 }
1211
1212 #ifdef CONFIG_SND_HDA_POWER_SAVE
1213 static const struct hda_amp_list alc880_lg_loopbacks[] = {
1214         { 0x0b, HDA_INPUT, 1 },
1215         { 0x0b, HDA_INPUT, 6 },
1216         { 0x0b, HDA_INPUT, 7 },
1217         { } /* end */
1218 };
1219 #endif
1220
1221 /*
1222  * Test configuration for debugging
1223  *
1224  * Almost all inputs/outputs are enabled.  I/O pins can be configured via
1225  * enum controls.
1226  */
1227 #ifdef CONFIG_SND_DEBUG
1228 static const hda_nid_t alc880_test_dac_nids[4] = {
1229         0x02, 0x03, 0x04, 0x05
1230 };
1231
1232 static const struct hda_input_mux alc880_test_capture_source = {
1233         .num_items = 7,
1234         .items = {
1235                 { "In-1", 0x0 },
1236                 { "In-2", 0x1 },
1237                 { "In-3", 0x2 },
1238                 { "In-4", 0x3 },
1239                 { "CD", 0x4 },
1240                 { "Front", 0x5 },
1241                 { "Surround", 0x6 },
1242         },
1243 };
1244
1245 static const struct hda_channel_mode alc880_test_modes[4] = {
1246         { 2, NULL },
1247         { 4, NULL },
1248         { 6, NULL },
1249         { 8, NULL },
1250 };
1251
1252 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
1253                                  struct snd_ctl_elem_info *uinfo)
1254 {
1255         static const char * const texts[] = {
1256                 "N/A", "Line Out", "HP Out",
1257                 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
1258         };
1259         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1260         uinfo->count = 1;
1261         uinfo->value.enumerated.items = 8;
1262         if (uinfo->value.enumerated.item >= 8)
1263                 uinfo->value.enumerated.item = 7;
1264         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1265         return 0;
1266 }
1267
1268 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
1269                                 struct snd_ctl_elem_value *ucontrol)
1270 {
1271         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1272         hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1273         unsigned int pin_ctl, item = 0;
1274
1275         pin_ctl = snd_hda_codec_read(codec, nid, 0,
1276                                      AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1277         if (pin_ctl & AC_PINCTL_OUT_EN) {
1278                 if (pin_ctl & AC_PINCTL_HP_EN)
1279                         item = 2;
1280                 else
1281                         item = 1;
1282         } else if (pin_ctl & AC_PINCTL_IN_EN) {
1283                 switch (pin_ctl & AC_PINCTL_VREFEN) {
1284                 case AC_PINCTL_VREF_HIZ: item = 3; break;
1285                 case AC_PINCTL_VREF_50:  item = 4; break;
1286                 case AC_PINCTL_VREF_GRD: item = 5; break;
1287                 case AC_PINCTL_VREF_80:  item = 6; break;
1288                 case AC_PINCTL_VREF_100: item = 7; break;
1289                 }
1290         }
1291         ucontrol->value.enumerated.item[0] = item;
1292         return 0;
1293 }
1294
1295 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
1296                                 struct snd_ctl_elem_value *ucontrol)
1297 {
1298         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1299         hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1300         static const unsigned int ctls[] = {
1301                 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
1302                 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
1303                 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
1304                 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
1305                 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
1306                 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
1307         };
1308         unsigned int old_ctl, new_ctl;
1309
1310         old_ctl = snd_hda_codec_read(codec, nid, 0,
1311                                      AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1312         new_ctl = ctls[ucontrol->value.enumerated.item[0]];
1313         if (old_ctl != new_ctl) {
1314                 int val;
1315                 snd_hda_codec_write_cache(codec, nid, 0,
1316                                           AC_VERB_SET_PIN_WIDGET_CONTROL,
1317                                           new_ctl);
1318                 val = ucontrol->value.enumerated.item[0] >= 3 ?
1319                         HDA_AMP_MUTE : 0;
1320                 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1321                                          HDA_AMP_MUTE, val);
1322                 return 1;
1323         }
1324         return 0;
1325 }
1326
1327 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
1328                                  struct snd_ctl_elem_info *uinfo)
1329 {
1330         static const char * const texts[] = {
1331                 "Front", "Surround", "CLFE", "Side"
1332         };
1333         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1334         uinfo->count = 1;
1335         uinfo->value.enumerated.items = 4;
1336         if (uinfo->value.enumerated.item >= 4)
1337                 uinfo->value.enumerated.item = 3;
1338         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
1339         return 0;
1340 }
1341
1342 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
1343                                 struct snd_ctl_elem_value *ucontrol)
1344 {
1345         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1346         hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1347         unsigned int sel;
1348
1349         sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
1350         ucontrol->value.enumerated.item[0] = sel & 3;
1351         return 0;
1352 }
1353
1354 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
1355                                 struct snd_ctl_elem_value *ucontrol)
1356 {
1357         struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1358         hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
1359         unsigned int sel;
1360
1361         sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
1362         if (ucontrol->value.enumerated.item[0] != sel) {
1363                 sel = ucontrol->value.enumerated.item[0] & 3;
1364                 snd_hda_codec_write_cache(codec, nid, 0,
1365                                           AC_VERB_SET_CONNECT_SEL, sel);
1366                 return 1;
1367         }
1368         return 0;
1369 }
1370
1371 #define PIN_CTL_TEST(xname,nid) {                       \
1372                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,    \
1373                         .name = xname,                 \
1374                         .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
1375                         .info = alc_test_pin_ctl_info, \
1376                         .get = alc_test_pin_ctl_get,   \
1377                         .put = alc_test_pin_ctl_put,   \
1378                         .private_value = nid           \
1379                         }
1380
1381 #define PIN_SRC_TEST(xname,nid) {                       \
1382                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,    \
1383                         .name = xname,                 \
1384                         .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
1385                         .info = alc_test_pin_src_info, \
1386                         .get = alc_test_pin_src_get,   \
1387                         .put = alc_test_pin_src_put,   \
1388                         .private_value = nid           \
1389                         }
1390
1391 static const struct snd_kcontrol_new alc880_test_mixer[] = {
1392         HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1393         HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1394         HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
1395         HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1396         HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1397         HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1398         HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
1399         HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1400         PIN_CTL_TEST("Front Pin Mode", 0x14),
1401         PIN_CTL_TEST("Surround Pin Mode", 0x15),
1402         PIN_CTL_TEST("CLFE Pin Mode", 0x16),
1403         PIN_CTL_TEST("Side Pin Mode", 0x17),
1404         PIN_CTL_TEST("In-1 Pin Mode", 0x18),
1405         PIN_CTL_TEST("In-2 Pin Mode", 0x19),
1406         PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
1407         PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
1408         PIN_SRC_TEST("In-1 Pin Source", 0x18),
1409         PIN_SRC_TEST("In-2 Pin Source", 0x19),
1410         PIN_SRC_TEST("In-3 Pin Source", 0x1a),
1411         PIN_SRC_TEST("In-4 Pin Source", 0x1b),
1412         HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
1413         HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
1414         HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
1415         HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
1416         HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
1417         HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
1418         HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
1419         HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
1420         HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
1421         HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
1422         {
1423                 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1424                 .name = "Channel Mode",
1425                 .info = alc_ch_mode_info,
1426                 .get = alc_ch_mode_get,
1427                 .put = alc_ch_mode_put,
1428         },
1429         { } /* end */
1430 };
1431
1432 static const struct hda_verb alc880_test_init_verbs[] = {
1433         /* Unmute inputs of 0x0c - 0x0f */
1434         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1435         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1436         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1437         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1438         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1439         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1440         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1441         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1442         /* Vol output for 0x0c-0x0f */
1443         {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1444         {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1445         {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1446         {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1447         /* Set output pins 0x14-0x17 */
1448         {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1449         {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1450         {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1451         {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1452         /* Unmute output pins 0x14-0x17 */
1453         {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1454         {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1455         {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1456         {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1457         /* Set input pins 0x18-0x1c */
1458         {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1459         {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1460         {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1461         {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1462         {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1463         /* Mute input pins 0x18-0x1b */
1464         {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1465         {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1466         {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1467         {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1468         /* ADC set up */
1469         {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1470         {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1471         {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1472         {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1473         {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1474         {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1475         /* Analog input/passthru */
1476         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1477         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1478         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1479         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1480         {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1481         { }
1482 };
1483 #endif
1484
1485 /*
1486  */
1487
1488 static const char * const alc880_models[ALC880_MODEL_LAST] = {
1489         [ALC880_3ST]            = "3stack",
1490         [ALC880_TCL_S700]       = "tcl",
1491         [ALC880_3ST_DIG]        = "3stack-digout",
1492         [ALC880_CLEVO]          = "clevo",
1493         [ALC880_5ST]            = "5stack",
1494         [ALC880_5ST_DIG]        = "5stack-digout",
1495         [ALC880_W810]           = "w810",
1496         [ALC880_Z71V]           = "z71v",
1497         [ALC880_6ST]            = "6stack",
1498         [ALC880_6ST_DIG]        = "6stack-digout",
1499         [ALC880_ASUS]           = "asus",
1500         [ALC880_ASUS_W1V]       = "asus-w1v",
1501         [ALC880_ASUS_DIG]       = "asus-dig",
1502         [ALC880_ASUS_DIG2]      = "asus-dig2",
1503         [ALC880_UNIWILL_DIG]    = "uniwill",
1504         [ALC880_UNIWILL_P53]    = "uniwill-p53",
1505         [ALC880_FUJITSU]        = "fujitsu",
1506         [ALC880_F1734]          = "F1734",
1507         [ALC880_LG]             = "lg",
1508         [ALC880_LG_LW]          = "lg-lw",
1509         [ALC880_MEDION_RIM]     = "medion",
1510 #ifdef CONFIG_SND_DEBUG
1511         [ALC880_TEST]           = "test",
1512 #endif
1513         [ALC880_AUTO]           = "auto",
1514 };
1515
1516 static const struct snd_pci_quirk alc880_cfg_tbl[] = {
1517         SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
1518         SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
1519         SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
1520         SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
1521         SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
1522         SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
1523         SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
1524         SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
1525         SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
1526         SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
1527         SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
1528         SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
1529         SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
1530         SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
1531         SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
1532         SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
1533         SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
1534         /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
1535         SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
1536         SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
1537         SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
1538         SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
1539         SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
1540         SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
1541         SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
1542         SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
1543         SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
1544         SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
1545         SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
1546         SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
1547         SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
1548         SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
1549         SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
1550         SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
1551         SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
1552         SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
1553         SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
1554         SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
1555         SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
1556         SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_F1734),
1557         SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
1558         SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
1559         SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
1560         SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
1561         SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
1562         SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
1563         SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
1564         SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
1565         SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
1566         SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
1567         SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
1568         SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
1569         SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
1570         SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
1571         SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
1572         SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
1573         SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
1574         SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
1575         SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
1576         SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
1577         SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
1578         SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
1579         SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
1580         SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
1581         SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
1582         SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
1583         SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
1584         SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
1585         /* default Intel */
1586         SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
1587         SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
1588         SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
1589         {}
1590 };
1591
1592 /*
1593  * ALC880 codec presets
1594  */
1595 static const struct alc_config_preset alc880_presets[] = {
1596         [ALC880_3ST] = {
1597                 .mixers = { alc880_three_stack_mixer },
1598                 .init_verbs = { alc880_volume_init_verbs,
1599                                 alc880_pin_3stack_init_verbs },
1600                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1601                 .dac_nids = alc880_dac_nids,
1602                 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1603                 .channel_mode = alc880_threestack_modes,
1604                 .need_dac_fix = 1,
1605                 .input_mux = &alc880_capture_source,
1606         },
1607         [ALC880_3ST_DIG] = {
1608                 .mixers = { alc880_three_stack_mixer },
1609                 .init_verbs = { alc880_volume_init_verbs,
1610                                 alc880_pin_3stack_init_verbs },
1611                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1612                 .dac_nids = alc880_dac_nids,
1613                 .dig_out_nid = ALC880_DIGOUT_NID,
1614                 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1615                 .channel_mode = alc880_threestack_modes,
1616                 .need_dac_fix = 1,
1617                 .input_mux = &alc880_capture_source,
1618         },
1619         [ALC880_TCL_S700] = {
1620                 .mixers = { alc880_tcl_s700_mixer },
1621                 .init_verbs = { alc880_volume_init_verbs,
1622                                 alc880_pin_tcl_S700_init_verbs,
1623                                 alc880_gpio2_init_verbs },
1624                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1625                 .dac_nids = alc880_dac_nids,
1626                 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
1627                 .num_adc_nids = 1, /* single ADC */
1628                 .hp_nid = 0x03,
1629                 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1630                 .channel_mode = alc880_2_jack_modes,
1631                 .input_mux = &alc880_capture_source,
1632         },
1633         [ALC880_5ST] = {
1634                 .mixers = { alc880_three_stack_mixer,
1635                             alc880_five_stack_mixer},
1636                 .init_verbs = { alc880_volume_init_verbs,
1637                                 alc880_pin_5stack_init_verbs },
1638                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1639                 .dac_nids = alc880_dac_nids,
1640                 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1641                 .channel_mode = alc880_fivestack_modes,
1642                 .input_mux = &alc880_capture_source,
1643         },
1644         [ALC880_5ST_DIG] = {
1645                 .mixers = { alc880_three_stack_mixer,
1646                             alc880_five_stack_mixer },
1647                 .init_verbs = { alc880_volume_init_verbs,
1648                                 alc880_pin_5stack_init_verbs },
1649                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1650                 .dac_nids = alc880_dac_nids,
1651                 .dig_out_nid = ALC880_DIGOUT_NID,
1652                 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
1653                 .channel_mode = alc880_fivestack_modes,
1654                 .input_mux = &alc880_capture_source,
1655         },
1656         [ALC880_6ST] = {
1657                 .mixers = { alc880_six_stack_mixer },
1658                 .init_verbs = { alc880_volume_init_verbs,
1659                                 alc880_pin_6stack_init_verbs },
1660                 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1661                 .dac_nids = alc880_6st_dac_nids,
1662                 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1663                 .channel_mode = alc880_sixstack_modes,
1664                 .input_mux = &alc880_6stack_capture_source,
1665         },
1666         [ALC880_6ST_DIG] = {
1667                 .mixers = { alc880_six_stack_mixer },
1668                 .init_verbs = { alc880_volume_init_verbs,
1669                                 alc880_pin_6stack_init_verbs },
1670                 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
1671                 .dac_nids = alc880_6st_dac_nids,
1672                 .dig_out_nid = ALC880_DIGOUT_NID,
1673                 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
1674                 .channel_mode = alc880_sixstack_modes,
1675                 .input_mux = &alc880_6stack_capture_source,
1676         },
1677         [ALC880_W810] = {
1678                 .mixers = { alc880_w810_base_mixer },
1679                 .init_verbs = { alc880_volume_init_verbs,
1680                                 alc880_pin_w810_init_verbs,
1681                                 alc880_gpio2_init_verbs },
1682                 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
1683                 .dac_nids = alc880_w810_dac_nids,
1684                 .dig_out_nid = ALC880_DIGOUT_NID,
1685                 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1686                 .channel_mode = alc880_w810_modes,
1687                 .input_mux = &alc880_capture_source,
1688         },
1689         [ALC880_Z71V] = {
1690                 .mixers = { alc880_z71v_mixer },
1691                 .init_verbs = { alc880_volume_init_verbs,
1692                                 alc880_pin_z71v_init_verbs },
1693                 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
1694                 .dac_nids = alc880_z71v_dac_nids,
1695                 .dig_out_nid = ALC880_DIGOUT_NID,
1696                 .hp_nid = 0x03,
1697                 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1698                 .channel_mode = alc880_2_jack_modes,
1699                 .input_mux = &alc880_capture_source,
1700         },
1701         [ALC880_F1734] = {
1702                 .mixers = { alc880_f1734_mixer },
1703                 .init_verbs = { alc880_volume_init_verbs,
1704                                 alc880_pin_f1734_init_verbs },
1705                 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
1706                 .dac_nids = alc880_f1734_dac_nids,
1707                 .hp_nid = 0x02,
1708                 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1709                 .channel_mode = alc880_2_jack_modes,
1710                 .input_mux = &alc880_f1734_capture_source,
1711                 .unsol_event = alc880_uniwill_p53_unsol_event,
1712                 .setup = alc880_uniwill_p53_setup,
1713                 .init_hook = alc_hp_automute,
1714         },
1715         [ALC880_ASUS] = {
1716                 .mixers = { alc880_asus_mixer },
1717                 .init_verbs = { alc880_volume_init_verbs,
1718                                 alc880_pin_asus_init_verbs,
1719                                 alc880_gpio1_init_verbs },
1720                 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1721                 .dac_nids = alc880_asus_dac_nids,
1722                 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1723                 .channel_mode = alc880_asus_modes,
1724                 .need_dac_fix = 1,
1725                 .input_mux = &alc880_capture_source,
1726         },
1727         [ALC880_ASUS_DIG] = {
1728                 .mixers = { alc880_asus_mixer },
1729                 .init_verbs = { alc880_volume_init_verbs,
1730                                 alc880_pin_asus_init_verbs,
1731                                 alc880_gpio1_init_verbs },
1732                 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1733                 .dac_nids = alc880_asus_dac_nids,
1734                 .dig_out_nid = ALC880_DIGOUT_NID,
1735                 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1736                 .channel_mode = alc880_asus_modes,
1737                 .need_dac_fix = 1,
1738                 .input_mux = &alc880_capture_source,
1739         },
1740         [ALC880_ASUS_DIG2] = {
1741                 .mixers = { alc880_asus_mixer },
1742                 .init_verbs = { alc880_volume_init_verbs,
1743                                 alc880_pin_asus_init_verbs,
1744                                 alc880_gpio2_init_verbs }, /* use GPIO2 */
1745                 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1746                 .dac_nids = alc880_asus_dac_nids,
1747                 .dig_out_nid = ALC880_DIGOUT_NID,
1748                 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1749                 .channel_mode = alc880_asus_modes,
1750                 .need_dac_fix = 1,
1751                 .input_mux = &alc880_capture_source,
1752         },
1753         [ALC880_ASUS_W1V] = {
1754                 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
1755                 .init_verbs = { alc880_volume_init_verbs,
1756                                 alc880_pin_asus_init_verbs,
1757                                 alc880_gpio1_init_verbs },
1758                 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1759                 .dac_nids = alc880_asus_dac_nids,
1760                 .dig_out_nid = ALC880_DIGOUT_NID,
1761                 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1762                 .channel_mode = alc880_asus_modes,
1763                 .need_dac_fix = 1,
1764                 .input_mux = &alc880_capture_source,
1765         },
1766         [ALC880_UNIWILL_DIG] = {
1767                 .mixers = { alc880_asus_mixer },
1768                 .init_verbs = { alc880_volume_init_verbs,
1769                                 alc880_pin_asus_init_verbs },
1770                 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1771                 .dac_nids = alc880_asus_dac_nids,
1772                 .dig_out_nid = ALC880_DIGOUT_NID,
1773                 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
1774                 .channel_mode = alc880_asus_modes,
1775                 .need_dac_fix = 1,
1776                 .input_mux = &alc880_capture_source,
1777         },
1778         [ALC880_UNIWILL] = {
1779                 .mixers = { alc880_uniwill_mixer },
1780                 .init_verbs = { alc880_volume_init_verbs,
1781                                 alc880_uniwill_init_verbs },
1782                 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1783                 .dac_nids = alc880_asus_dac_nids,
1784                 .dig_out_nid = ALC880_DIGOUT_NID,
1785                 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1786                 .channel_mode = alc880_threestack_modes,
1787                 .need_dac_fix = 1,
1788                 .input_mux = &alc880_capture_source,
1789                 .unsol_event = alc880_uniwill_unsol_event,
1790                 .setup = alc880_uniwill_setup,
1791                 .init_hook = alc880_uniwill_init_hook,
1792         },
1793         [ALC880_UNIWILL_P53] = {
1794                 .mixers = { alc880_uniwill_p53_mixer },
1795                 .init_verbs = { alc880_volume_init_verbs,
1796                                 alc880_uniwill_p53_init_verbs },
1797                 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
1798                 .dac_nids = alc880_asus_dac_nids,
1799                 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
1800                 .channel_mode = alc880_threestack_modes,
1801                 .input_mux = &alc880_capture_source,
1802                 .unsol_event = alc880_uniwill_p53_unsol_event,
1803                 .setup = alc880_uniwill_p53_setup,
1804                 .init_hook = alc_hp_automute,
1805         },
1806         [ALC880_FUJITSU] = {
1807                 .mixers = { alc880_fujitsu_mixer },
1808                 .init_verbs = { alc880_volume_init_verbs,
1809                                 alc880_uniwill_p53_init_verbs,
1810                                 alc880_beep_init_verbs },
1811                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1812                 .dac_nids = alc880_dac_nids,
1813                 .dig_out_nid = ALC880_DIGOUT_NID,
1814                 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1815                 .channel_mode = alc880_2_jack_modes,
1816                 .input_mux = &alc880_capture_source,
1817                 .unsol_event = alc880_uniwill_p53_unsol_event,
1818                 .setup = alc880_uniwill_p53_setup,
1819                 .init_hook = alc_hp_automute,
1820         },
1821         [ALC880_CLEVO] = {
1822                 .mixers = { alc880_three_stack_mixer },
1823                 .init_verbs = { alc880_volume_init_verbs,
1824                                 alc880_pin_clevo_init_verbs },
1825                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1826                 .dac_nids = alc880_dac_nids,
1827                 .hp_nid = 0x03,
1828                 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
1829                 .channel_mode = alc880_threestack_modes,
1830                 .need_dac_fix = 1,
1831                 .input_mux = &alc880_capture_source,
1832         },
1833         [ALC880_LG] = {
1834                 .mixers = { alc880_lg_mixer },
1835                 .init_verbs = { alc880_volume_init_verbs,
1836                                 alc880_lg_init_verbs },
1837                 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
1838                 .dac_nids = alc880_lg_dac_nids,
1839                 .dig_out_nid = ALC880_DIGOUT_NID,
1840                 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
1841                 .channel_mode = alc880_lg_ch_modes,
1842                 .need_dac_fix = 1,
1843                 .input_mux = &alc880_lg_capture_source,
1844                 .unsol_event = alc_sku_unsol_event,
1845                 .setup = alc880_lg_setup,
1846                 .init_hook = alc_hp_automute,
1847 #ifdef CONFIG_SND_HDA_POWER_SAVE
1848                 .loopbacks = alc880_lg_loopbacks,
1849 #endif
1850         },
1851         [ALC880_LG_LW] = {
1852                 .mixers = { alc880_lg_lw_mixer },
1853                 .init_verbs = { alc880_volume_init_verbs,
1854                                 alc880_lg_lw_init_verbs },
1855                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1856                 .dac_nids = alc880_dac_nids,
1857                 .dig_out_nid = ALC880_DIGOUT_NID,
1858                 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
1859                 .channel_mode = alc880_lg_lw_modes,
1860                 .input_mux = &alc880_lg_lw_capture_source,
1861                 .unsol_event = alc_sku_unsol_event,
1862                 .setup = alc880_lg_lw_setup,
1863                 .init_hook = alc_hp_automute,
1864         },
1865         [ALC880_MEDION_RIM] = {
1866                 .mixers = { alc880_medion_rim_mixer },
1867                 .init_verbs = { alc880_volume_init_verbs,
1868                                 alc880_medion_rim_init_verbs,
1869                                 alc_gpio2_init_verbs },
1870                 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
1871                 .dac_nids = alc880_dac_nids,
1872                 .dig_out_nid = ALC880_DIGOUT_NID,
1873                 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
1874                 .channel_mode = alc880_2_jack_modes,
1875                 .input_mux = &alc880_medion_rim_capture_source,
1876                 .unsol_event = alc880_medion_rim_unsol_event,
1877                 .setup = alc880_medion_rim_setup,
1878                 .init_hook = alc880_medion_rim_automute,
1879         },
1880 #ifdef CONFIG_SND_DEBUG
1881         [ALC880_TEST] = {
1882                 .mixers = { alc880_test_mixer },
1883                 .init_verbs = { alc880_test_init_verbs },
1884                 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
1885                 .dac_nids = alc880_test_dac_nids,
1886                 .dig_out_nid = ALC880_DIGOUT_NID,
1887                 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
1888                 .channel_mode = alc880_test_modes,
1889                 .input_mux = &alc880_test_capture_source,
1890         },
1891 #endif
1892 };
1893