]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - sound/pci/hda/patch_realtek.c
[ALSA] hda-codec - Remove superfluous code
[mirror_ubuntu-bionic-kernel.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 <sound/driver.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include "hda_codec.h"
33 #include "hda_local.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 #ifdef CONFIG_SND_DEBUG
64 ALC880_TEST,
65 #endif
66 ALC880_AUTO,
67 ALC880_MODEL_LAST /* last tag */
68 };
69
70 /* ALC260 models */
71 enum {
72 ALC260_BASIC,
73 ALC260_HP,
74 ALC260_HP_3013,
75 ALC260_FUJITSU_S702X,
76 ALC260_ACER,
77 ALC260_WILL,
78 ALC260_REPLACER_672V,
79 #ifdef CONFIG_SND_DEBUG
80 ALC260_TEST,
81 #endif
82 ALC260_AUTO,
83 ALC260_MODEL_LAST /* last tag */
84 };
85
86 /* ALC262 models */
87 enum {
88 ALC262_BASIC,
89 ALC262_HIPPO,
90 ALC262_HIPPO_1,
91 ALC262_FUJITSU,
92 ALC262_HP_BPC,
93 ALC262_HP_BPC_D7000_WL,
94 ALC262_HP_BPC_D7000_WF,
95 ALC262_BENQ_ED8,
96 ALC262_SONY_ASSAMD,
97 ALC262_BENQ_T31,
98 ALC262_AUTO,
99 ALC262_MODEL_LAST /* last tag */
100 };
101
102 /* ALC268 models */
103 enum {
104 ALC268_3ST,
105 ALC268_TOSHIBA,
106 ALC268_ACER,
107 ALC268_AUTO,
108 ALC268_MODEL_LAST /* last tag */
109 };
110
111 /* ALC861 models */
112 enum {
113 ALC861_3ST,
114 ALC660_3ST,
115 ALC861_3ST_DIG,
116 ALC861_6ST_DIG,
117 ALC861_UNIWILL_M31,
118 ALC861_TOSHIBA,
119 ALC861_ASUS,
120 ALC861_ASUS_LAPTOP,
121 ALC861_AUTO,
122 ALC861_MODEL_LAST,
123 };
124
125 /* ALC861-VD models */
126 enum {
127 ALC660VD_3ST,
128 ALC660VD_3ST_DIG,
129 ALC861VD_3ST,
130 ALC861VD_3ST_DIG,
131 ALC861VD_6ST_DIG,
132 ALC861VD_LENOVO,
133 ALC861VD_DALLAS,
134 ALC861VD_HP,
135 ALC861VD_AUTO,
136 ALC861VD_MODEL_LAST,
137 };
138
139 /* ALC662 models */
140 enum {
141 ALC662_3ST_2ch_DIG,
142 ALC662_3ST_6ch_DIG,
143 ALC662_3ST_6ch,
144 ALC662_5ST_DIG,
145 ALC662_LENOVO_101E,
146 ALC662_AUTO,
147 ALC662_MODEL_LAST,
148 };
149
150 /* ALC882 models */
151 enum {
152 ALC882_3ST_DIG,
153 ALC882_6ST_DIG,
154 ALC882_ARIMA,
155 ALC882_W2JC,
156 ALC882_TARGA,
157 ALC882_ASUS_A7J,
158 ALC885_MACPRO,
159 ALC885_IMAC24,
160 ALC882_AUTO,
161 ALC882_MODEL_LAST,
162 };
163
164 /* ALC883 models */
165 enum {
166 ALC883_3ST_2ch_DIG,
167 ALC883_3ST_6ch_DIG,
168 ALC883_3ST_6ch,
169 ALC883_6ST_DIG,
170 ALC883_TARGA_DIG,
171 ALC883_TARGA_2ch_DIG,
172 ALC883_ACER,
173 ALC883_ACER_ASPIRE,
174 ALC883_MEDION,
175 ALC883_MEDION_MD2,
176 ALC883_LAPTOP_EAPD,
177 ALC883_LENOVO_101E_2ch,
178 ALC883_LENOVO_NB0763,
179 ALC888_LENOVO_MS7195_DIG,
180 ALC888_6ST_HP,
181 ALC888_3ST_HP,
182 ALC883_AUTO,
183 ALC883_MODEL_LAST,
184 };
185
186 /* for GPIO Poll */
187 #define GPIO_MASK 0x03
188
189 struct alc_spec {
190 /* codec parameterization */
191 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
192 unsigned int num_mixers;
193
194 const struct hda_verb *init_verbs[5]; /* initialization verbs
195 * don't forget NULL
196 * termination!
197 */
198 unsigned int num_init_verbs;
199
200 char *stream_name_analog; /* analog PCM stream */
201 struct hda_pcm_stream *stream_analog_playback;
202 struct hda_pcm_stream *stream_analog_capture;
203
204 char *stream_name_digital; /* digital PCM stream */
205 struct hda_pcm_stream *stream_digital_playback;
206 struct hda_pcm_stream *stream_digital_capture;
207
208 /* playback */
209 struct hda_multi_out multiout; /* playback set-up
210 * max_channels, dacs must be set
211 * dig_out_nid and hp_nid are optional
212 */
213
214 /* capture */
215 unsigned int num_adc_nids;
216 hda_nid_t *adc_nids;
217 hda_nid_t dig_in_nid; /* digital-in NID; optional */
218
219 /* capture source */
220 unsigned int num_mux_defs;
221 const struct hda_input_mux *input_mux;
222 unsigned int cur_mux[3];
223
224 /* channel model */
225 const struct hda_channel_mode *channel_mode;
226 int num_channel_mode;
227 int need_dac_fix;
228
229 /* PCM information */
230 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
231
232 /* dynamic controls, init_verbs and input_mux */
233 struct auto_pin_cfg autocfg;
234 unsigned int num_kctl_alloc, num_kctl_used;
235 struct snd_kcontrol_new *kctl_alloc;
236 struct hda_input_mux private_imux;
237 hda_nid_t private_dac_nids[5];
238
239 /* hooks */
240 void (*init_hook)(struct hda_codec *codec);
241 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
242
243 /* for pin sensing */
244 unsigned int sense_updated: 1;
245 unsigned int jack_present: 1;
246
247 #ifdef CONFIG_SND_HDA_POWER_SAVE
248 struct hda_loopback_check loopback;
249 #endif
250 };
251
252 /*
253 * configuration template - to be copied to the spec instance
254 */
255 struct alc_config_preset {
256 struct snd_kcontrol_new *mixers[5]; /* should be identical size
257 * with spec
258 */
259 const struct hda_verb *init_verbs[5];
260 unsigned int num_dacs;
261 hda_nid_t *dac_nids;
262 hda_nid_t dig_out_nid; /* optional */
263 hda_nid_t hp_nid; /* optional */
264 unsigned int num_adc_nids;
265 hda_nid_t *adc_nids;
266 hda_nid_t dig_in_nid;
267 unsigned int num_channel_mode;
268 const struct hda_channel_mode *channel_mode;
269 int need_dac_fix;
270 unsigned int num_mux_defs;
271 const struct hda_input_mux *input_mux;
272 void (*unsol_event)(struct hda_codec *, unsigned int);
273 void (*init_hook)(struct hda_codec *);
274 #ifdef CONFIG_SND_HDA_POWER_SAVE
275 struct hda_amp_list *loopbacks;
276 #endif
277 };
278
279
280 /*
281 * input MUX handling
282 */
283 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
284 struct snd_ctl_elem_info *uinfo)
285 {
286 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
287 struct alc_spec *spec = codec->spec;
288 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
289 if (mux_idx >= spec->num_mux_defs)
290 mux_idx = 0;
291 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
292 }
293
294 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
295 struct snd_ctl_elem_value *ucontrol)
296 {
297 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
298 struct alc_spec *spec = codec->spec;
299 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
300
301 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
302 return 0;
303 }
304
305 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
306 struct snd_ctl_elem_value *ucontrol)
307 {
308 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
309 struct alc_spec *spec = codec->spec;
310 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
311 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
312 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
313 spec->adc_nids[adc_idx],
314 &spec->cur_mux[adc_idx]);
315 }
316
317
318 /*
319 * channel mode setting
320 */
321 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
322 struct snd_ctl_elem_info *uinfo)
323 {
324 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
325 struct alc_spec *spec = codec->spec;
326 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
327 spec->num_channel_mode);
328 }
329
330 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
331 struct snd_ctl_elem_value *ucontrol)
332 {
333 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
334 struct alc_spec *spec = codec->spec;
335 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
336 spec->num_channel_mode,
337 spec->multiout.max_channels);
338 }
339
340 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
341 struct snd_ctl_elem_value *ucontrol)
342 {
343 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
344 struct alc_spec *spec = codec->spec;
345 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
346 spec->num_channel_mode,
347 &spec->multiout.max_channels);
348 if (err >= 0 && spec->need_dac_fix)
349 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
350 return err;
351 }
352
353 /*
354 * Control the mode of pin widget settings via the mixer. "pc" is used
355 * instead of "%" to avoid consequences of accidently treating the % as
356 * being part of a format specifier. Maximum allowed length of a value is
357 * 63 characters plus NULL terminator.
358 *
359 * Note: some retasking pin complexes seem to ignore requests for input
360 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
361 * are requested. Therefore order this list so that this behaviour will not
362 * cause problems when mixer clients move through the enum sequentially.
363 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
364 * March 2006.
365 */
366 static char *alc_pin_mode_names[] = {
367 "Mic 50pc bias", "Mic 80pc bias",
368 "Line in", "Line out", "Headphone out",
369 };
370 static unsigned char alc_pin_mode_values[] = {
371 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
372 };
373 /* The control can present all 5 options, or it can limit the options based
374 * in the pin being assumed to be exclusively an input or an output pin. In
375 * addition, "input" pins may or may not process the mic bias option
376 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
377 * accept requests for bias as of chip versions up to March 2006) and/or
378 * wiring in the computer.
379 */
380 #define ALC_PIN_DIR_IN 0x00
381 #define ALC_PIN_DIR_OUT 0x01
382 #define ALC_PIN_DIR_INOUT 0x02
383 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
384 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
385
386 /* Info about the pin modes supported by the different pin direction modes.
387 * For each direction the minimum and maximum values are given.
388 */
389 static signed char alc_pin_mode_dir_info[5][2] = {
390 { 0, 2 }, /* ALC_PIN_DIR_IN */
391 { 3, 4 }, /* ALC_PIN_DIR_OUT */
392 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
393 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
394 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
395 };
396 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
397 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
398 #define alc_pin_mode_n_items(_dir) \
399 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
400
401 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
402 struct snd_ctl_elem_info *uinfo)
403 {
404 unsigned int item_num = uinfo->value.enumerated.item;
405 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
406
407 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
408 uinfo->count = 1;
409 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
410
411 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
412 item_num = alc_pin_mode_min(dir);
413 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
414 return 0;
415 }
416
417 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_value *ucontrol)
419 {
420 unsigned int i;
421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
422 hda_nid_t nid = kcontrol->private_value & 0xffff;
423 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
424 long *valp = ucontrol->value.integer.value;
425 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
426 AC_VERB_GET_PIN_WIDGET_CONTROL,
427 0x00);
428
429 /* Find enumerated value for current pinctl setting */
430 i = alc_pin_mode_min(dir);
431 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
432 i++;
433 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
434 return 0;
435 }
436
437 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
438 struct snd_ctl_elem_value *ucontrol)
439 {
440 signed int change;
441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
442 hda_nid_t nid = kcontrol->private_value & 0xffff;
443 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
444 long val = *ucontrol->value.integer.value;
445 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
446 AC_VERB_GET_PIN_WIDGET_CONTROL,
447 0x00);
448
449 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
450 val = alc_pin_mode_min(dir);
451
452 change = pinctl != alc_pin_mode_values[val];
453 if (change) {
454 /* Set pin mode to that requested */
455 snd_hda_codec_write_cache(codec, nid, 0,
456 AC_VERB_SET_PIN_WIDGET_CONTROL,
457 alc_pin_mode_values[val]);
458
459 /* Also enable the retasking pin's input/output as required
460 * for the requested pin mode. Enum values of 2 or less are
461 * input modes.
462 *
463 * Dynamically switching the input/output buffers probably
464 * reduces noise slightly (particularly on input) so we'll
465 * do it. However, having both input and output buffers
466 * enabled simultaneously doesn't seem to be problematic if
467 * this turns out to be necessary in the future.
468 */
469 if (val <= 2) {
470 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
471 HDA_AMP_MUTE, HDA_AMP_MUTE);
472 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
473 HDA_AMP_MUTE, 0);
474 } else {
475 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
476 HDA_AMP_MUTE, HDA_AMP_MUTE);
477 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
478 HDA_AMP_MUTE, 0);
479 }
480 }
481 return change;
482 }
483
484 #define ALC_PIN_MODE(xname, nid, dir) \
485 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
486 .info = alc_pin_mode_info, \
487 .get = alc_pin_mode_get, \
488 .put = alc_pin_mode_put, \
489 .private_value = nid | (dir<<16) }
490
491 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
492 * together using a mask with more than one bit set. This control is
493 * currently used only by the ALC260 test model. At this stage they are not
494 * needed for any "production" models.
495 */
496 #ifdef CONFIG_SND_DEBUG
497 #define alc_gpio_data_info snd_ctl_boolean_mono_info
498
499 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_value *ucontrol)
501 {
502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
503 hda_nid_t nid = kcontrol->private_value & 0xffff;
504 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
505 long *valp = ucontrol->value.integer.value;
506 unsigned int val = snd_hda_codec_read(codec, nid, 0,
507 AC_VERB_GET_GPIO_DATA, 0x00);
508
509 *valp = (val & mask) != 0;
510 return 0;
511 }
512 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
513 struct snd_ctl_elem_value *ucontrol)
514 {
515 signed int change;
516 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
517 hda_nid_t nid = kcontrol->private_value & 0xffff;
518 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
519 long val = *ucontrol->value.integer.value;
520 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
521 AC_VERB_GET_GPIO_DATA,
522 0x00);
523
524 /* Set/unset the masked GPIO bit(s) as needed */
525 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
526 if (val == 0)
527 gpio_data &= ~mask;
528 else
529 gpio_data |= mask;
530 snd_hda_codec_write_cache(codec, nid, 0,
531 AC_VERB_SET_GPIO_DATA, gpio_data);
532
533 return change;
534 }
535 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
536 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
537 .info = alc_gpio_data_info, \
538 .get = alc_gpio_data_get, \
539 .put = alc_gpio_data_put, \
540 .private_value = nid | (mask<<16) }
541 #endif /* CONFIG_SND_DEBUG */
542
543 /* A switch control to allow the enabling of the digital IO pins on the
544 * ALC260. This is incredibly simplistic; the intention of this control is
545 * to provide something in the test model allowing digital outputs to be
546 * identified if present. If models are found which can utilise these
547 * outputs a more complete mixer control can be devised for those models if
548 * necessary.
549 */
550 #ifdef CONFIG_SND_DEBUG
551 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
552
553 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
554 struct snd_ctl_elem_value *ucontrol)
555 {
556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
557 hda_nid_t nid = kcontrol->private_value & 0xffff;
558 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
559 long *valp = ucontrol->value.integer.value;
560 unsigned int val = snd_hda_codec_read(codec, nid, 0,
561 AC_VERB_GET_DIGI_CONVERT, 0x00);
562
563 *valp = (val & mask) != 0;
564 return 0;
565 }
566 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
567 struct snd_ctl_elem_value *ucontrol)
568 {
569 signed int change;
570 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
571 hda_nid_t nid = kcontrol->private_value & 0xffff;
572 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
573 long val = *ucontrol->value.integer.value;
574 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
575 AC_VERB_GET_DIGI_CONVERT,
576 0x00);
577
578 /* Set/unset the masked control bit(s) as needed */
579 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
580 if (val==0)
581 ctrl_data &= ~mask;
582 else
583 ctrl_data |= mask;
584 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
585 ctrl_data);
586
587 return change;
588 }
589 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
590 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
591 .info = alc_spdif_ctrl_info, \
592 .get = alc_spdif_ctrl_get, \
593 .put = alc_spdif_ctrl_put, \
594 .private_value = nid | (mask<<16) }
595 #endif /* CONFIG_SND_DEBUG */
596
597 /*
598 * set up from the preset table
599 */
600 static void setup_preset(struct alc_spec *spec,
601 const struct alc_config_preset *preset)
602 {
603 int i;
604
605 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
606 spec->mixers[spec->num_mixers++] = preset->mixers[i];
607 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
608 i++)
609 spec->init_verbs[spec->num_init_verbs++] =
610 preset->init_verbs[i];
611
612 spec->channel_mode = preset->channel_mode;
613 spec->num_channel_mode = preset->num_channel_mode;
614 spec->need_dac_fix = preset->need_dac_fix;
615
616 spec->multiout.max_channels = spec->channel_mode[0].channels;
617
618 spec->multiout.num_dacs = preset->num_dacs;
619 spec->multiout.dac_nids = preset->dac_nids;
620 spec->multiout.dig_out_nid = preset->dig_out_nid;
621 spec->multiout.hp_nid = preset->hp_nid;
622
623 spec->num_mux_defs = preset->num_mux_defs;
624 if (!spec->num_mux_defs)
625 spec->num_mux_defs = 1;
626 spec->input_mux = preset->input_mux;
627
628 spec->num_adc_nids = preset->num_adc_nids;
629 spec->adc_nids = preset->adc_nids;
630 spec->dig_in_nid = preset->dig_in_nid;
631
632 spec->unsol_event = preset->unsol_event;
633 spec->init_hook = preset->init_hook;
634 #ifdef CONFIG_SND_HDA_POWER_SAVE
635 spec->loopback.amplist = preset->loopbacks;
636 #endif
637 }
638
639 /* Enable GPIO mask and set output */
640 static struct hda_verb alc_gpio1_init_verbs[] = {
641 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
642 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
643 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
644 { }
645 };
646
647 static struct hda_verb alc_gpio2_init_verbs[] = {
648 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
649 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
650 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
651 { }
652 };
653
654 static struct hda_verb alc_gpio3_init_verbs[] = {
655 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
656 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
657 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
658 { }
659 };
660
661 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
662 * 31 ~ 16 : Manufacture ID
663 * 15 ~ 8 : SKU ID
664 * 7 ~ 0 : Assembly ID
665 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
666 */
667 static void alc_subsystem_id(struct hda_codec *codec,
668 unsigned int porta, unsigned int porte,
669 unsigned int portd)
670 {
671 unsigned int ass, tmp;
672
673 ass = codec->subsystem_id;
674 if (!(ass & 1))
675 return;
676
677 /* Override */
678 tmp = (ass & 0x38) >> 3; /* external Amp control */
679 switch (tmp) {
680 case 1:
681 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
682 break;
683 case 3:
684 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
685 break;
686 case 7:
687 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
688 break;
689 case 5:
690 switch (codec->vendor_id) {
691 case 0x10ec0862:
692 case 0x10ec0660:
693 case 0x10ec0662:
694 case 0x10ec0267:
695 case 0x10ec0268:
696 snd_hda_codec_write(codec, 0x14, 0,
697 AC_VERB_SET_EAPD_BTLENABLE, 2);
698 snd_hda_codec_write(codec, 0x15, 0,
699 AC_VERB_SET_EAPD_BTLENABLE, 2);
700 return;
701 }
702 case 6:
703 if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
704 hda_nid_t port = 0;
705 tmp = (ass & 0x1800) >> 11;
706 switch (tmp) {
707 case 0: port = porta; break;
708 case 1: port = porte; break;
709 case 2: port = portd; break;
710 }
711 if (port)
712 snd_hda_codec_write(codec, port, 0,
713 AC_VERB_SET_EAPD_BTLENABLE,
714 2);
715 }
716 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
717 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
718 (tmp == 5 ? 0x3040 : 0x3050));
719 break;
720 }
721 }
722
723 /*
724 * Fix-up pin default configurations
725 */
726
727 struct alc_pincfg {
728 hda_nid_t nid;
729 u32 val;
730 };
731
732 static void alc_fix_pincfg(struct hda_codec *codec,
733 const struct snd_pci_quirk *quirk,
734 const struct alc_pincfg **pinfix)
735 {
736 const struct alc_pincfg *cfg;
737
738 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
739 if (!quirk)
740 return;
741
742 cfg = pinfix[quirk->value];
743 for (; cfg->nid; cfg++) {
744 int i;
745 u32 val = cfg->val;
746 for (i = 0; i < 4; i++) {
747 snd_hda_codec_write(codec, cfg->nid, 0,
748 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
749 val & 0xff);
750 val >>= 8;
751 }
752 }
753 }
754
755 /*
756 * ALC880 3-stack model
757 *
758 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
759 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
760 * F-Mic = 0x1b, HP = 0x19
761 */
762
763 static hda_nid_t alc880_dac_nids[4] = {
764 /* front, rear, clfe, rear_surr */
765 0x02, 0x05, 0x04, 0x03
766 };
767
768 static hda_nid_t alc880_adc_nids[3] = {
769 /* ADC0-2 */
770 0x07, 0x08, 0x09,
771 };
772
773 /* The datasheet says the node 0x07 is connected from inputs,
774 * but it shows zero connection in the real implementation on some devices.
775 * Note: this is a 915GAV bug, fixed on 915GLV
776 */
777 static hda_nid_t alc880_adc_nids_alt[2] = {
778 /* ADC1-2 */
779 0x08, 0x09,
780 };
781
782 #define ALC880_DIGOUT_NID 0x06
783 #define ALC880_DIGIN_NID 0x0a
784
785 static struct hda_input_mux alc880_capture_source = {
786 .num_items = 4,
787 .items = {
788 { "Mic", 0x0 },
789 { "Front Mic", 0x3 },
790 { "Line", 0x2 },
791 { "CD", 0x4 },
792 },
793 };
794
795 /* channel source setting (2/6 channel selection for 3-stack) */
796 /* 2ch mode */
797 static struct hda_verb alc880_threestack_ch2_init[] = {
798 /* set line-in to input, mute it */
799 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
800 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
801 /* set mic-in to input vref 80%, mute it */
802 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
803 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
804 { } /* end */
805 };
806
807 /* 6ch mode */
808 static struct hda_verb alc880_threestack_ch6_init[] = {
809 /* set line-in to output, unmute it */
810 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
811 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
812 /* set mic-in to output, unmute it */
813 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
814 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
815 { } /* end */
816 };
817
818 static struct hda_channel_mode alc880_threestack_modes[2] = {
819 { 2, alc880_threestack_ch2_init },
820 { 6, alc880_threestack_ch6_init },
821 };
822
823 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
824 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
825 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
826 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
827 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
828 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
829 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
830 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
831 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
832 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
833 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
834 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
835 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
838 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
839 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
840 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
841 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
843 {
844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
845 .name = "Channel Mode",
846 .info = alc_ch_mode_info,
847 .get = alc_ch_mode_get,
848 .put = alc_ch_mode_put,
849 },
850 { } /* end */
851 };
852
853 /* capture mixer elements */
854 static struct snd_kcontrol_new alc880_capture_mixer[] = {
855 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
856 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
857 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
858 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
859 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
860 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
861 {
862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
863 /* The multiple "Capture Source" controls confuse alsamixer
864 * So call somewhat different..
865 * FIXME: the controls appear in the "playback" view!
866 */
867 /* .name = "Capture Source", */
868 .name = "Input Source",
869 .count = 3,
870 .info = alc_mux_enum_info,
871 .get = alc_mux_enum_get,
872 .put = alc_mux_enum_put,
873 },
874 { } /* end */
875 };
876
877 /* capture mixer elements (in case NID 0x07 not available) */
878 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
879 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
880 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
881 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
882 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
883 {
884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
885 /* The multiple "Capture Source" controls confuse alsamixer
886 * So call somewhat different..
887 * FIXME: the controls appear in the "playback" view!
888 */
889 /* .name = "Capture Source", */
890 .name = "Input Source",
891 .count = 2,
892 .info = alc_mux_enum_info,
893 .get = alc_mux_enum_get,
894 .put = alc_mux_enum_put,
895 },
896 { } /* end */
897 };
898
899
900
901 /*
902 * ALC880 5-stack model
903 *
904 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
905 * Side = 0x02 (0xd)
906 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
907 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
908 */
909
910 /* additional mixers to alc880_three_stack_mixer */
911 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
912 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
913 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
914 { } /* end */
915 };
916
917 /* channel source setting (6/8 channel selection for 5-stack) */
918 /* 6ch mode */
919 static struct hda_verb alc880_fivestack_ch6_init[] = {
920 /* set line-in to input, mute it */
921 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
922 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
923 { } /* end */
924 };
925
926 /* 8ch mode */
927 static struct hda_verb alc880_fivestack_ch8_init[] = {
928 /* set line-in to output, unmute it */
929 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
930 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
931 { } /* end */
932 };
933
934 static struct hda_channel_mode alc880_fivestack_modes[2] = {
935 { 6, alc880_fivestack_ch6_init },
936 { 8, alc880_fivestack_ch8_init },
937 };
938
939
940 /*
941 * ALC880 6-stack model
942 *
943 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
944 * Side = 0x05 (0x0f)
945 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
946 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
947 */
948
949 static hda_nid_t alc880_6st_dac_nids[4] = {
950 /* front, rear, clfe, rear_surr */
951 0x02, 0x03, 0x04, 0x05
952 };
953
954 static struct hda_input_mux alc880_6stack_capture_source = {
955 .num_items = 4,
956 .items = {
957 { "Mic", 0x0 },
958 { "Front Mic", 0x1 },
959 { "Line", 0x2 },
960 { "CD", 0x4 },
961 },
962 };
963
964 /* fixed 8-channels */
965 static struct hda_channel_mode alc880_sixstack_modes[1] = {
966 { 8, NULL },
967 };
968
969 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
970 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
971 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
972 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
973 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
974 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
975 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
976 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
977 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
978 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
979 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
980 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
981 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
982 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
983 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
984 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
985 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
986 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
987 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
988 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
989 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
990 {
991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
992 .name = "Channel Mode",
993 .info = alc_ch_mode_info,
994 .get = alc_ch_mode_get,
995 .put = alc_ch_mode_put,
996 },
997 { } /* end */
998 };
999
1000
1001 /*
1002 * ALC880 W810 model
1003 *
1004 * W810 has rear IO for:
1005 * Front (DAC 02)
1006 * Surround (DAC 03)
1007 * Center/LFE (DAC 04)
1008 * Digital out (06)
1009 *
1010 * The system also has a pair of internal speakers, and a headphone jack.
1011 * These are both connected to Line2 on the codec, hence to DAC 02.
1012 *
1013 * There is a variable resistor to control the speaker or headphone
1014 * volume. This is a hardware-only device without a software API.
1015 *
1016 * Plugging headphones in will disable the internal speakers. This is
1017 * implemented in hardware, not via the driver using jack sense. In
1018 * a similar fashion, plugging into the rear socket marked "front" will
1019 * disable both the speakers and headphones.
1020 *
1021 * For input, there's a microphone jack, and an "audio in" jack.
1022 * These may not do anything useful with this driver yet, because I
1023 * haven't setup any initialization verbs for these yet...
1024 */
1025
1026 static hda_nid_t alc880_w810_dac_nids[3] = {
1027 /* front, rear/surround, clfe */
1028 0x02, 0x03, 0x04
1029 };
1030
1031 /* fixed 6 channels */
1032 static struct hda_channel_mode alc880_w810_modes[1] = {
1033 { 6, NULL }
1034 };
1035
1036 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1037 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1038 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1039 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1040 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1041 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1042 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1043 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1044 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1045 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1047 { } /* end */
1048 };
1049
1050
1051 /*
1052 * Z710V model
1053 *
1054 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1055 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1056 * Line = 0x1a
1057 */
1058
1059 static hda_nid_t alc880_z71v_dac_nids[1] = {
1060 0x02
1061 };
1062 #define ALC880_Z71V_HP_DAC 0x03
1063
1064 /* fixed 2 channels */
1065 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1066 { 2, NULL }
1067 };
1068
1069 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1070 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1071 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1072 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1073 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1074 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1075 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1076 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1077 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1078 { } /* end */
1079 };
1080
1081
1082 /* FIXME! */
1083 /*
1084 * ALC880 F1734 model
1085 *
1086 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1087 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1088 */
1089
1090 static hda_nid_t alc880_f1734_dac_nids[1] = {
1091 0x03
1092 };
1093 #define ALC880_F1734_HP_DAC 0x02
1094
1095 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1096 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1097 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1098 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1099 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1100 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1101 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1102 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1103 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1104 { } /* end */
1105 };
1106
1107
1108 /* FIXME! */
1109 /*
1110 * ALC880 ASUS model
1111 *
1112 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1113 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1114 * Mic = 0x18, Line = 0x1a
1115 */
1116
1117 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1118 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1119
1120 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1121 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1122 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1123 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1124 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1125 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1126 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1127 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1128 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1129 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1130 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1131 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1132 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1134 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1135 {
1136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1137 .name = "Channel Mode",
1138 .info = alc_ch_mode_info,
1139 .get = alc_ch_mode_get,
1140 .put = alc_ch_mode_put,
1141 },
1142 { } /* end */
1143 };
1144
1145 /* FIXME! */
1146 /*
1147 * ALC880 ASUS W1V model
1148 *
1149 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1150 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1151 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1152 */
1153
1154 /* additional mixers to alc880_asus_mixer */
1155 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1156 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1157 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1158 { } /* end */
1159 };
1160
1161 /* additional mixers to alc880_asus_mixer */
1162 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1163 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1164 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1165 { } /* end */
1166 };
1167
1168 /* TCL S700 */
1169 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1170 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1171 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1173 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1174 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1176 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1177 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1178 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1179 {
1180 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1181 /* The multiple "Capture Source" controls confuse alsamixer
1182 * So call somewhat different..
1183 * FIXME: the controls appear in the "playback" view!
1184 */
1185 /* .name = "Capture Source", */
1186 .name = "Input Source",
1187 .count = 1,
1188 .info = alc_mux_enum_info,
1189 .get = alc_mux_enum_get,
1190 .put = alc_mux_enum_put,
1191 },
1192 { } /* end */
1193 };
1194
1195 /* Uniwill */
1196 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1197 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1198 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1199 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1200 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1201 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1202 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1203 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1204 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1205 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1206 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1207 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1208 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1209 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1210 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1212 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1213 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1214 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1215 {
1216 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1217 .name = "Channel Mode",
1218 .info = alc_ch_mode_info,
1219 .get = alc_ch_mode_get,
1220 .put = alc_ch_mode_put,
1221 },
1222 { } /* end */
1223 };
1224
1225 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1226 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1227 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1228 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1229 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1230 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1231 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1232 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1233 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1234 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1235 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1236 { } /* end */
1237 };
1238
1239 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1240 HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1241 HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
1242 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1243 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
1244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1246 { } /* end */
1247 };
1248
1249 /*
1250 * build control elements
1251 */
1252 static int alc_build_controls(struct hda_codec *codec)
1253 {
1254 struct alc_spec *spec = codec->spec;
1255 int err;
1256 int i;
1257
1258 for (i = 0; i < spec->num_mixers; i++) {
1259 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1260 if (err < 0)
1261 return err;
1262 }
1263
1264 if (spec->multiout.dig_out_nid) {
1265 err = snd_hda_create_spdif_out_ctls(codec,
1266 spec->multiout.dig_out_nid);
1267 if (err < 0)
1268 return err;
1269 }
1270 if (spec->dig_in_nid) {
1271 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1272 if (err < 0)
1273 return err;
1274 }
1275 return 0;
1276 }
1277
1278
1279 /*
1280 * initialize the codec volumes, etc
1281 */
1282
1283 /*
1284 * generic initialization of ADC, input mixers and output mixers
1285 */
1286 static struct hda_verb alc880_volume_init_verbs[] = {
1287 /*
1288 * Unmute ADC0-2 and set the default input to mic-in
1289 */
1290 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1292 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1293 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1294 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1295 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1296
1297 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1298 * mixer widget
1299 * Note: PASD motherboards uses the Line In 2 as the input for front
1300 * panel mic (mic 2)
1301 */
1302 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1303 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1304 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1305 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1310
1311 /*
1312 * Set up output mixers (0x0c - 0x0f)
1313 */
1314 /* set vol=0 to output mixers */
1315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1316 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1319 /* set up input amps for analog loopback */
1320 /* Amp Indices: DAC = 0, mixer = 1 */
1321 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1323 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1327 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1329
1330 { }
1331 };
1332
1333 /*
1334 * 3-stack pin configuration:
1335 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1336 */
1337 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1338 /*
1339 * preset connection lists of input pins
1340 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1341 */
1342 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1343 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1344 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1345
1346 /*
1347 * Set pin mode and muting
1348 */
1349 /* set front pin widgets 0x14 for output */
1350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1352 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1353 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1354 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1355 /* Mic2 (as headphone out) for HP output */
1356 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1357 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1358 /* Line In pin widget for input */
1359 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1360 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1361 /* Line2 (as front mic) pin widget for input and vref at 80% */
1362 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1363 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1364 /* CD pin widget for input */
1365 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1366
1367 { }
1368 };
1369
1370 /*
1371 * 5-stack pin configuration:
1372 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1373 * line-in/side = 0x1a, f-mic = 0x1b
1374 */
1375 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1376 /*
1377 * preset connection lists of input pins
1378 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1379 */
1380 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1381 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1382
1383 /*
1384 * Set pin mode and muting
1385 */
1386 /* set pin widgets 0x14-0x17 for output */
1387 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1388 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1389 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1390 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1391 /* unmute pins for output (no gain on this amp) */
1392 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1394 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1395 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1396
1397 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1398 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1399 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1400 /* Mic2 (as headphone out) for HP output */
1401 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1402 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1403 /* Line In pin widget for input */
1404 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1405 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1406 /* Line2 (as front mic) pin widget for input and vref at 80% */
1407 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1408 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1409 /* CD pin widget for input */
1410 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1411
1412 { }
1413 };
1414
1415 /*
1416 * W810 pin configuration:
1417 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1418 */
1419 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1420 /* hphone/speaker input selector: front DAC */
1421 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1422
1423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1424 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1425 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1427 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1428 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1429
1430 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1431 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1432
1433 { }
1434 };
1435
1436 /*
1437 * Z71V pin configuration:
1438 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1439 */
1440 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1445
1446 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1447 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1448 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1449 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1450
1451 { }
1452 };
1453
1454 /*
1455 * 6-stack pin configuration:
1456 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1457 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1458 */
1459 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1460 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1461
1462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1466 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1467 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1468 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1469 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1470
1471 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1472 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1473 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1474 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1475 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1477 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1478 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1479 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1480
1481 { }
1482 };
1483
1484 /*
1485 * Uniwill pin configuration:
1486 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1487 * line = 0x1a
1488 */
1489 static struct hda_verb alc880_uniwill_init_verbs[] = {
1490 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1491
1492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1494 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1497 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1502 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1503 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1504 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1505 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1506
1507 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1508 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1509 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1511 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1512 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1513 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1514 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1515 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1516
1517 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1518 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1519
1520 { }
1521 };
1522
1523 /*
1524 * Uniwill P53
1525 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1526 */
1527 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1528 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1529
1530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1531 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1532 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1533 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1534 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1535 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1542
1543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1545 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1547 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1548 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1549
1550 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1551 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1552
1553 { }
1554 };
1555
1556 static struct hda_verb alc880_beep_init_verbs[] = {
1557 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1558 { }
1559 };
1560
1561 /* toggle speaker-output according to the hp-jack state */
1562 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1563 {
1564 unsigned int present;
1565 unsigned char bits;
1566
1567 present = snd_hda_codec_read(codec, 0x14, 0,
1568 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1569 bits = present ? HDA_AMP_MUTE : 0;
1570 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1571 HDA_AMP_MUTE, bits);
1572 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1573 HDA_AMP_MUTE, bits);
1574 }
1575
1576 /* auto-toggle front mic */
1577 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1578 {
1579 unsigned int present;
1580 unsigned char bits;
1581
1582 present = snd_hda_codec_read(codec, 0x18, 0,
1583 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1584 bits = present ? HDA_AMP_MUTE : 0;
1585 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1586 }
1587
1588 static void alc880_uniwill_automute(struct hda_codec *codec)
1589 {
1590 alc880_uniwill_hp_automute(codec);
1591 alc880_uniwill_mic_automute(codec);
1592 }
1593
1594 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1595 unsigned int res)
1596 {
1597 /* Looks like the unsol event is incompatible with the standard
1598 * definition. 4bit tag is placed at 28 bit!
1599 */
1600 switch (res >> 28) {
1601 case ALC880_HP_EVENT:
1602 alc880_uniwill_hp_automute(codec);
1603 break;
1604 case ALC880_MIC_EVENT:
1605 alc880_uniwill_mic_automute(codec);
1606 break;
1607 }
1608 }
1609
1610 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1611 {
1612 unsigned int present;
1613 unsigned char bits;
1614
1615 present = snd_hda_codec_read(codec, 0x14, 0,
1616 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1617 bits = present ? HDA_AMP_MUTE : 0;
1618 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
1619 }
1620
1621 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1622 {
1623 unsigned int present;
1624
1625 present = snd_hda_codec_read(codec, 0x21, 0,
1626 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1627 present &= HDA_AMP_VOLMASK;
1628 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1629 HDA_AMP_VOLMASK, present);
1630 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1631 HDA_AMP_VOLMASK, present);
1632 }
1633
1634 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1635 unsigned int res)
1636 {
1637 /* Looks like the unsol event is incompatible with the standard
1638 * definition. 4bit tag is placed at 28 bit!
1639 */
1640 if ((res >> 28) == ALC880_HP_EVENT)
1641 alc880_uniwill_p53_hp_automute(codec);
1642 if ((res >> 28) == ALC880_DCVOL_EVENT)
1643 alc880_uniwill_p53_dcvol_automute(codec);
1644 }
1645
1646 /* FIXME! */
1647 /*
1648 * F1734 pin configuration:
1649 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1650 */
1651 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1652 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1653 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1654 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1655 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1656
1657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1658 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661
1662 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1664 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1665 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1666 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1667 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1668 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1669 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1670 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1671
1672 { }
1673 };
1674
1675 /* FIXME! */
1676 /*
1677 * ASUS pin configuration:
1678 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1679 */
1680 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1681 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1682 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1683 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1684 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1685
1686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1687 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1690 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694
1695 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1696 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1697 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1698 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1699 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1700 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1701 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1703 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1704
1705 { }
1706 };
1707
1708 /* Enable GPIO mask and set output */
1709 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1710 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1711
1712 /* Clevo m520g init */
1713 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1714 /* headphone output */
1715 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1716 /* line-out */
1717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1718 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1719 /* Line-in */
1720 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1721 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1722 /* CD */
1723 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1724 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1725 /* Mic1 (rear panel) */
1726 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1727 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1728 /* Mic2 (front panel) */
1729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1730 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1731 /* headphone */
1732 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1734 /* change to EAPD mode */
1735 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1736 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1737
1738 { }
1739 };
1740
1741 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
1742 /* change to EAPD mode */
1743 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1744 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
1745
1746 /* Headphone output */
1747 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1748 /* Front output*/
1749 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1750 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1751
1752 /* Line In pin widget for input */
1753 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1754 /* CD pin widget for input */
1755 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1756 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1757 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1758
1759 /* change to EAPD mode */
1760 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
1761 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
1762
1763 { }
1764 };
1765
1766 /*
1767 * LG m1 express dual
1768 *
1769 * Pin assignment:
1770 * Rear Line-In/Out (blue): 0x14
1771 * Build-in Mic-In: 0x15
1772 * Speaker-out: 0x17
1773 * HP-Out (green): 0x1b
1774 * Mic-In/Out (red): 0x19
1775 * SPDIF-Out: 0x1e
1776 */
1777
1778 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
1779 static hda_nid_t alc880_lg_dac_nids[3] = {
1780 0x05, 0x02, 0x03
1781 };
1782
1783 /* seems analog CD is not working */
1784 static struct hda_input_mux alc880_lg_capture_source = {
1785 .num_items = 3,
1786 .items = {
1787 { "Mic", 0x1 },
1788 { "Line", 0x5 },
1789 { "Internal Mic", 0x6 },
1790 },
1791 };
1792
1793 /* 2,4,6 channel modes */
1794 static struct hda_verb alc880_lg_ch2_init[] = {
1795 /* set line-in and mic-in to input */
1796 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1797 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1798 { }
1799 };
1800
1801 static struct hda_verb alc880_lg_ch4_init[] = {
1802 /* set line-in to out and mic-in to input */
1803 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1804 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1805 { }
1806 };
1807
1808 static struct hda_verb alc880_lg_ch6_init[] = {
1809 /* set line-in and mic-in to output */
1810 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1811 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1812 { }
1813 };
1814
1815 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
1816 { 2, alc880_lg_ch2_init },
1817 { 4, alc880_lg_ch4_init },
1818 { 6, alc880_lg_ch6_init },
1819 };
1820
1821 static struct snd_kcontrol_new alc880_lg_mixer[] = {
1822 /* FIXME: it's not really "master" but front channels */
1823 HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1824 HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
1825 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1826 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
1827 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1828 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
1829 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
1830 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
1831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1833 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
1834 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
1835 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
1836 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
1837 {
1838 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1839 .name = "Channel Mode",
1840 .info = alc_ch_mode_info,
1841 .get = alc_ch_mode_get,
1842 .put = alc_ch_mode_put,
1843 },
1844 { } /* end */
1845 };
1846
1847 static struct hda_verb alc880_lg_init_verbs[] = {
1848 /* set capture source to mic-in */
1849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1850 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1851 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1852 /* mute all amp mixer inputs */
1853 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
1854 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1855 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1856 /* line-in to input */
1857 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1858 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1859 /* built-in mic */
1860 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1861 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1862 /* speaker-out */
1863 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1864 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1865 /* mic-in to input */
1866 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1867 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1868 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1869 /* HP-out */
1870 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
1871 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1872 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1873 /* jack sense */
1874 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1875 { }
1876 };
1877
1878 /* toggle speaker-output according to the hp-jack state */
1879 static void alc880_lg_automute(struct hda_codec *codec)
1880 {
1881 unsigned int present;
1882 unsigned char bits;
1883
1884 present = snd_hda_codec_read(codec, 0x1b, 0,
1885 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1886 bits = present ? HDA_AMP_MUTE : 0;
1887 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
1888 HDA_AMP_MUTE, bits);
1889 }
1890
1891 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
1892 {
1893 /* Looks like the unsol event is incompatible with the standard
1894 * definition. 4bit tag is placed at 28 bit!
1895 */
1896 if ((res >> 28) == 0x01)
1897 alc880_lg_automute(codec);
1898 }
1899
1900 /*
1901 * LG LW20
1902 *
1903 * Pin assignment:
1904 * Speaker-out: 0x14
1905 * Mic-In: 0x18
1906 * Built-in Mic-In: 0x19
1907 * Line-In: 0x1b
1908 * HP-Out: 0x1a
1909 * SPDIF-Out: 0x1e
1910 */
1911
1912 static struct hda_input_mux alc880_lg_lw_capture_source = {
1913 .num_items = 3,
1914 .items = {
1915 { "Mic", 0x0 },
1916 { "Internal Mic", 0x1 },
1917 { "Line In", 0x2 },
1918 },
1919 };
1920
1921 #define alc880_lg_lw_modes alc880_threestack_modes
1922
1923 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
1924 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1925 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1926 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1927 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1928 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1929 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1930 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1931 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1932 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1933 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1934 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1935 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1936 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
1937 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
1938 {
1939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1940 .name = "Channel Mode",
1941 .info = alc_ch_mode_info,
1942 .get = alc_ch_mode_get,
1943 .put = alc_ch_mode_put,
1944 },
1945 { } /* end */
1946 };
1947
1948 static struct hda_verb alc880_lg_lw_init_verbs[] = {
1949 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1950 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1951 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1952
1953 /* set capture source to mic-in */
1954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1956 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1957 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1958 /* speaker-out */
1959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1961 /* HP-out */
1962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1964 /* mic-in to input */
1965 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1966 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1967 /* built-in mic */
1968 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1969 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1970 /* jack sense */
1971 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
1972 { }
1973 };
1974
1975 /* toggle speaker-output according to the hp-jack state */
1976 static void alc880_lg_lw_automute(struct hda_codec *codec)
1977 {
1978 unsigned int present;
1979 unsigned char bits;
1980
1981 present = snd_hda_codec_read(codec, 0x1b, 0,
1982 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1983 bits = present ? HDA_AMP_MUTE : 0;
1984 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
1985 HDA_AMP_MUTE, bits);
1986 }
1987
1988 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
1989 {
1990 /* Looks like the unsol event is incompatible with the standard
1991 * definition. 4bit tag is placed at 28 bit!
1992 */
1993 if ((res >> 28) == 0x01)
1994 alc880_lg_lw_automute(codec);
1995 }
1996
1997 #ifdef CONFIG_SND_HDA_POWER_SAVE
1998 static struct hda_amp_list alc880_loopbacks[] = {
1999 { 0x0b, HDA_INPUT, 0 },
2000 { 0x0b, HDA_INPUT, 1 },
2001 { 0x0b, HDA_INPUT, 2 },
2002 { 0x0b, HDA_INPUT, 3 },
2003 { 0x0b, HDA_INPUT, 4 },
2004 { } /* end */
2005 };
2006
2007 static struct hda_amp_list alc880_lg_loopbacks[] = {
2008 { 0x0b, HDA_INPUT, 1 },
2009 { 0x0b, HDA_INPUT, 6 },
2010 { 0x0b, HDA_INPUT, 7 },
2011 { } /* end */
2012 };
2013 #endif
2014
2015 /*
2016 * Common callbacks
2017 */
2018
2019 static int alc_init(struct hda_codec *codec)
2020 {
2021 struct alc_spec *spec = codec->spec;
2022 unsigned int i;
2023
2024 for (i = 0; i < spec->num_init_verbs; i++)
2025 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2026
2027 if (spec->init_hook)
2028 spec->init_hook(codec);
2029
2030 return 0;
2031 }
2032
2033 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2034 {
2035 struct alc_spec *spec = codec->spec;
2036
2037 if (spec->unsol_event)
2038 spec->unsol_event(codec, res);
2039 }
2040
2041 #ifdef CONFIG_SND_HDA_POWER_SAVE
2042 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2043 {
2044 struct alc_spec *spec = codec->spec;
2045 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2046 }
2047 #endif
2048
2049 /*
2050 * Analog playback callbacks
2051 */
2052 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2053 struct hda_codec *codec,
2054 struct snd_pcm_substream *substream)
2055 {
2056 struct alc_spec *spec = codec->spec;
2057 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2058 }
2059
2060 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2061 struct hda_codec *codec,
2062 unsigned int stream_tag,
2063 unsigned int format,
2064 struct snd_pcm_substream *substream)
2065 {
2066 struct alc_spec *spec = codec->spec;
2067 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2068 stream_tag, format, substream);
2069 }
2070
2071 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2072 struct hda_codec *codec,
2073 struct snd_pcm_substream *substream)
2074 {
2075 struct alc_spec *spec = codec->spec;
2076 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2077 }
2078
2079 /*
2080 * Digital out
2081 */
2082 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2083 struct hda_codec *codec,
2084 struct snd_pcm_substream *substream)
2085 {
2086 struct alc_spec *spec = codec->spec;
2087 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2088 }
2089
2090 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2091 struct hda_codec *codec,
2092 unsigned int stream_tag,
2093 unsigned int format,
2094 struct snd_pcm_substream *substream)
2095 {
2096 struct alc_spec *spec = codec->spec;
2097 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2098 stream_tag, format, substream);
2099 }
2100
2101 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2102 struct hda_codec *codec,
2103 struct snd_pcm_substream *substream)
2104 {
2105 struct alc_spec *spec = codec->spec;
2106 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2107 }
2108
2109 /*
2110 * Analog capture
2111 */
2112 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2113 struct hda_codec *codec,
2114 unsigned int stream_tag,
2115 unsigned int format,
2116 struct snd_pcm_substream *substream)
2117 {
2118 struct alc_spec *spec = codec->spec;
2119
2120 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2121 stream_tag, 0, format);
2122 return 0;
2123 }
2124
2125 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2126 struct hda_codec *codec,
2127 struct snd_pcm_substream *substream)
2128 {
2129 struct alc_spec *spec = codec->spec;
2130
2131 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
2132 0, 0, 0);
2133 return 0;
2134 }
2135
2136
2137 /*
2138 */
2139 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2140 .substreams = 1,
2141 .channels_min = 2,
2142 .channels_max = 8,
2143 /* NID is set in alc_build_pcms */
2144 .ops = {
2145 .open = alc880_playback_pcm_open,
2146 .prepare = alc880_playback_pcm_prepare,
2147 .cleanup = alc880_playback_pcm_cleanup
2148 },
2149 };
2150
2151 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2152 .substreams = 2,
2153 .channels_min = 2,
2154 .channels_max = 2,
2155 /* NID is set in alc_build_pcms */
2156 .ops = {
2157 .prepare = alc880_capture_pcm_prepare,
2158 .cleanup = alc880_capture_pcm_cleanup
2159 },
2160 };
2161
2162 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2163 .substreams = 1,
2164 .channels_min = 2,
2165 .channels_max = 2,
2166 /* NID is set in alc_build_pcms */
2167 .ops = {
2168 .open = alc880_dig_playback_pcm_open,
2169 .close = alc880_dig_playback_pcm_close,
2170 .prepare = alc880_dig_playback_pcm_prepare
2171 },
2172 };
2173
2174 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2175 .substreams = 1,
2176 .channels_min = 2,
2177 .channels_max = 2,
2178 /* NID is set in alc_build_pcms */
2179 };
2180
2181 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2182 static struct hda_pcm_stream alc_pcm_null_playback = {
2183 .substreams = 0,
2184 .channels_min = 0,
2185 .channels_max = 0,
2186 };
2187
2188 static int alc_build_pcms(struct hda_codec *codec)
2189 {
2190 struct alc_spec *spec = codec->spec;
2191 struct hda_pcm *info = spec->pcm_rec;
2192 int i;
2193
2194 codec->num_pcms = 1;
2195 codec->pcm_info = info;
2196
2197 info->name = spec->stream_name_analog;
2198 if (spec->stream_analog_playback) {
2199 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2200 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2201 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2202 }
2203 if (spec->stream_analog_capture) {
2204 snd_assert(spec->adc_nids, return -EINVAL);
2205 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2206 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2207 }
2208
2209 if (spec->channel_mode) {
2210 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2211 for (i = 0; i < spec->num_channel_mode; i++) {
2212 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2213 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2214 }
2215 }
2216 }
2217
2218 /* SPDIF for stream index #1 */
2219 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2220 codec->num_pcms = 2;
2221 info = spec->pcm_rec + 1;
2222 info->name = spec->stream_name_digital;
2223 if (spec->multiout.dig_out_nid &&
2224 spec->stream_digital_playback) {
2225 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2226 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2227 }
2228 if (spec->dig_in_nid &&
2229 spec->stream_digital_capture) {
2230 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2231 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2232 }
2233 }
2234
2235 /* If the use of more than one ADC is requested for the current
2236 * model, configure a second analog capture-only PCM.
2237 */
2238 /* Additional Analaog capture for index #2 */
2239 if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
2240 spec->adc_nids) {
2241 codec->num_pcms = 3;
2242 info = spec->pcm_rec + 2;
2243 info->name = spec->stream_name_analog;
2244 /* No playback stream for second PCM */
2245 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
2246 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2247 if (spec->stream_analog_capture) {
2248 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2249 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
2250 }
2251 }
2252
2253 return 0;
2254 }
2255
2256 static void alc_free(struct hda_codec *codec)
2257 {
2258 struct alc_spec *spec = codec->spec;
2259 unsigned int i;
2260
2261 if (!spec)
2262 return;
2263
2264 if (spec->kctl_alloc) {
2265 for (i = 0; i < spec->num_kctl_used; i++)
2266 kfree(spec->kctl_alloc[i].name);
2267 kfree(spec->kctl_alloc);
2268 }
2269 kfree(spec);
2270 }
2271
2272 /*
2273 */
2274 static struct hda_codec_ops alc_patch_ops = {
2275 .build_controls = alc_build_controls,
2276 .build_pcms = alc_build_pcms,
2277 .init = alc_init,
2278 .free = alc_free,
2279 .unsol_event = alc_unsol_event,
2280 #ifdef CONFIG_SND_HDA_POWER_SAVE
2281 .check_power_status = alc_check_power_status,
2282 #endif
2283 };
2284
2285
2286 /*
2287 * Test configuration for debugging
2288 *
2289 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2290 * enum controls.
2291 */
2292 #ifdef CONFIG_SND_DEBUG
2293 static hda_nid_t alc880_test_dac_nids[4] = {
2294 0x02, 0x03, 0x04, 0x05
2295 };
2296
2297 static struct hda_input_mux alc880_test_capture_source = {
2298 .num_items = 7,
2299 .items = {
2300 { "In-1", 0x0 },
2301 { "In-2", 0x1 },
2302 { "In-3", 0x2 },
2303 { "In-4", 0x3 },
2304 { "CD", 0x4 },
2305 { "Front", 0x5 },
2306 { "Surround", 0x6 },
2307 },
2308 };
2309
2310 static struct hda_channel_mode alc880_test_modes[4] = {
2311 { 2, NULL },
2312 { 4, NULL },
2313 { 6, NULL },
2314 { 8, NULL },
2315 };
2316
2317 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2318 struct snd_ctl_elem_info *uinfo)
2319 {
2320 static char *texts[] = {
2321 "N/A", "Line Out", "HP Out",
2322 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2323 };
2324 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2325 uinfo->count = 1;
2326 uinfo->value.enumerated.items = 8;
2327 if (uinfo->value.enumerated.item >= 8)
2328 uinfo->value.enumerated.item = 7;
2329 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2330 return 0;
2331 }
2332
2333 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2334 struct snd_ctl_elem_value *ucontrol)
2335 {
2336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2337 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2338 unsigned int pin_ctl, item = 0;
2339
2340 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2341 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2342 if (pin_ctl & AC_PINCTL_OUT_EN) {
2343 if (pin_ctl & AC_PINCTL_HP_EN)
2344 item = 2;
2345 else
2346 item = 1;
2347 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2348 switch (pin_ctl & AC_PINCTL_VREFEN) {
2349 case AC_PINCTL_VREF_HIZ: item = 3; break;
2350 case AC_PINCTL_VREF_50: item = 4; break;
2351 case AC_PINCTL_VREF_GRD: item = 5; break;
2352 case AC_PINCTL_VREF_80: item = 6; break;
2353 case AC_PINCTL_VREF_100: item = 7; break;
2354 }
2355 }
2356 ucontrol->value.enumerated.item[0] = item;
2357 return 0;
2358 }
2359
2360 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2361 struct snd_ctl_elem_value *ucontrol)
2362 {
2363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2364 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2365 static unsigned int ctls[] = {
2366 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2367 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2368 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2369 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2370 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2371 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2372 };
2373 unsigned int old_ctl, new_ctl;
2374
2375 old_ctl = snd_hda_codec_read(codec, nid, 0,
2376 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2377 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2378 if (old_ctl != new_ctl) {
2379 int val;
2380 snd_hda_codec_write_cache(codec, nid, 0,
2381 AC_VERB_SET_PIN_WIDGET_CONTROL,
2382 new_ctl);
2383 val = ucontrol->value.enumerated.item[0] >= 3 ?
2384 HDA_AMP_MUTE : 0;
2385 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2386 HDA_AMP_MUTE, val);
2387 return 1;
2388 }
2389 return 0;
2390 }
2391
2392 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2393 struct snd_ctl_elem_info *uinfo)
2394 {
2395 static char *texts[] = {
2396 "Front", "Surround", "CLFE", "Side"
2397 };
2398 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2399 uinfo->count = 1;
2400 uinfo->value.enumerated.items = 4;
2401 if (uinfo->value.enumerated.item >= 4)
2402 uinfo->value.enumerated.item = 3;
2403 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2404 return 0;
2405 }
2406
2407 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2408 struct snd_ctl_elem_value *ucontrol)
2409 {
2410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2411 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2412 unsigned int sel;
2413
2414 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2415 ucontrol->value.enumerated.item[0] = sel & 3;
2416 return 0;
2417 }
2418
2419 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2420 struct snd_ctl_elem_value *ucontrol)
2421 {
2422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2423 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2424 unsigned int sel;
2425
2426 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2427 if (ucontrol->value.enumerated.item[0] != sel) {
2428 sel = ucontrol->value.enumerated.item[0] & 3;
2429 snd_hda_codec_write_cache(codec, nid, 0,
2430 AC_VERB_SET_CONNECT_SEL, sel);
2431 return 1;
2432 }
2433 return 0;
2434 }
2435
2436 #define PIN_CTL_TEST(xname,nid) { \
2437 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2438 .name = xname, \
2439 .info = alc_test_pin_ctl_info, \
2440 .get = alc_test_pin_ctl_get, \
2441 .put = alc_test_pin_ctl_put, \
2442 .private_value = nid \
2443 }
2444
2445 #define PIN_SRC_TEST(xname,nid) { \
2446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2447 .name = xname, \
2448 .info = alc_test_pin_src_info, \
2449 .get = alc_test_pin_src_get, \
2450 .put = alc_test_pin_src_put, \
2451 .private_value = nid \
2452 }
2453
2454 static struct snd_kcontrol_new alc880_test_mixer[] = {
2455 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2456 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2457 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2458 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2459 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2460 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2461 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2462 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2463 PIN_CTL_TEST("Front Pin Mode", 0x14),
2464 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2465 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2466 PIN_CTL_TEST("Side Pin Mode", 0x17),
2467 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2468 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2469 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2470 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2471 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2472 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2473 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2474 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2475 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2476 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2477 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2478 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2479 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2480 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2481 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2482 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2483 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2484 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2485 {
2486 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2487 .name = "Channel Mode",
2488 .info = alc_ch_mode_info,
2489 .get = alc_ch_mode_get,
2490 .put = alc_ch_mode_put,
2491 },
2492 { } /* end */
2493 };
2494
2495 static struct hda_verb alc880_test_init_verbs[] = {
2496 /* Unmute inputs of 0x0c - 0x0f */
2497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2498 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2499 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2500 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2501 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2502 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2503 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2504 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2505 /* Vol output for 0x0c-0x0f */
2506 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2507 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2509 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2510 /* Set output pins 0x14-0x17 */
2511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2513 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2514 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2515 /* Unmute output pins 0x14-0x17 */
2516 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2517 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2518 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2519 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2520 /* Set input pins 0x18-0x1c */
2521 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2522 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2523 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2525 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2526 /* Mute input pins 0x18-0x1b */
2527 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2528 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2529 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2530 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2531 /* ADC set up */
2532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2533 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2534 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2535 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2538 /* Analog input/passthru */
2539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2544 { }
2545 };
2546 #endif
2547
2548 /*
2549 */
2550
2551 static const char *alc880_models[ALC880_MODEL_LAST] = {
2552 [ALC880_3ST] = "3stack",
2553 [ALC880_TCL_S700] = "tcl",
2554 [ALC880_3ST_DIG] = "3stack-digout",
2555 [ALC880_CLEVO] = "clevo",
2556 [ALC880_5ST] = "5stack",
2557 [ALC880_5ST_DIG] = "5stack-digout",
2558 [ALC880_W810] = "w810",
2559 [ALC880_Z71V] = "z71v",
2560 [ALC880_6ST] = "6stack",
2561 [ALC880_6ST_DIG] = "6stack-digout",
2562 [ALC880_ASUS] = "asus",
2563 [ALC880_ASUS_W1V] = "asus-w1v",
2564 [ALC880_ASUS_DIG] = "asus-dig",
2565 [ALC880_ASUS_DIG2] = "asus-dig2",
2566 [ALC880_UNIWILL_DIG] = "uniwill",
2567 [ALC880_UNIWILL_P53] = "uniwill-p53",
2568 [ALC880_FUJITSU] = "fujitsu",
2569 [ALC880_F1734] = "F1734",
2570 [ALC880_LG] = "lg",
2571 [ALC880_LG_LW] = "lg-lw",
2572 #ifdef CONFIG_SND_DEBUG
2573 [ALC880_TEST] = "test",
2574 #endif
2575 [ALC880_AUTO] = "auto",
2576 };
2577
2578 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2579 /* Broken BIOS configuration */
2580 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
2581 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2582
2583 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2584 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2585 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2586 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2587 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2588 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2589 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2590 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2591 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2592
2593 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2594 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2595
2596 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2597 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2598 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2599 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2600 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2601 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2602 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2603 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2604 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2605 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2606 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2607 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2608 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2609 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2610 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
2611
2612 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2613 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2614 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2615 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2616 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2617 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2618 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2619 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2620 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2621 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2622 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2623 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2624 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2625 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2626 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2627 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2628 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2629 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2630
2631 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2632 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2633 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2634 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2635
2636 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2637 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2638 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2639 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2640
2641 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2642 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2643 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2644 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2645
2646 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2647 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2648 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2649 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2650 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2651 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2652 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2653 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2654 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2655 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2656 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
2657
2658 {}
2659 };
2660
2661 /*
2662 * ALC880 codec presets
2663 */
2664 static struct alc_config_preset alc880_presets[] = {
2665 [ALC880_3ST] = {
2666 .mixers = { alc880_three_stack_mixer },
2667 .init_verbs = { alc880_volume_init_verbs,
2668 alc880_pin_3stack_init_verbs },
2669 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2670 .dac_nids = alc880_dac_nids,
2671 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2672 .channel_mode = alc880_threestack_modes,
2673 .need_dac_fix = 1,
2674 .input_mux = &alc880_capture_source,
2675 },
2676 [ALC880_3ST_DIG] = {
2677 .mixers = { alc880_three_stack_mixer },
2678 .init_verbs = { alc880_volume_init_verbs,
2679 alc880_pin_3stack_init_verbs },
2680 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2681 .dac_nids = alc880_dac_nids,
2682 .dig_out_nid = ALC880_DIGOUT_NID,
2683 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2684 .channel_mode = alc880_threestack_modes,
2685 .need_dac_fix = 1,
2686 .input_mux = &alc880_capture_source,
2687 },
2688 [ALC880_TCL_S700] = {
2689 .mixers = { alc880_tcl_s700_mixer },
2690 .init_verbs = { alc880_volume_init_verbs,
2691 alc880_pin_tcl_S700_init_verbs,
2692 alc880_gpio2_init_verbs },
2693 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2694 .dac_nids = alc880_dac_nids,
2695 .hp_nid = 0x03,
2696 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2697 .channel_mode = alc880_2_jack_modes,
2698 .input_mux = &alc880_capture_source,
2699 },
2700 [ALC880_5ST] = {
2701 .mixers = { alc880_three_stack_mixer,
2702 alc880_five_stack_mixer},
2703 .init_verbs = { alc880_volume_init_verbs,
2704 alc880_pin_5stack_init_verbs },
2705 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2706 .dac_nids = alc880_dac_nids,
2707 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2708 .channel_mode = alc880_fivestack_modes,
2709 .input_mux = &alc880_capture_source,
2710 },
2711 [ALC880_5ST_DIG] = {
2712 .mixers = { alc880_three_stack_mixer,
2713 alc880_five_stack_mixer },
2714 .init_verbs = { alc880_volume_init_verbs,
2715 alc880_pin_5stack_init_verbs },
2716 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2717 .dac_nids = alc880_dac_nids,
2718 .dig_out_nid = ALC880_DIGOUT_NID,
2719 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2720 .channel_mode = alc880_fivestack_modes,
2721 .input_mux = &alc880_capture_source,
2722 },
2723 [ALC880_6ST] = {
2724 .mixers = { alc880_six_stack_mixer },
2725 .init_verbs = { alc880_volume_init_verbs,
2726 alc880_pin_6stack_init_verbs },
2727 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2728 .dac_nids = alc880_6st_dac_nids,
2729 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2730 .channel_mode = alc880_sixstack_modes,
2731 .input_mux = &alc880_6stack_capture_source,
2732 },
2733 [ALC880_6ST_DIG] = {
2734 .mixers = { alc880_six_stack_mixer },
2735 .init_verbs = { alc880_volume_init_verbs,
2736 alc880_pin_6stack_init_verbs },
2737 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
2738 .dac_nids = alc880_6st_dac_nids,
2739 .dig_out_nid = ALC880_DIGOUT_NID,
2740 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
2741 .channel_mode = alc880_sixstack_modes,
2742 .input_mux = &alc880_6stack_capture_source,
2743 },
2744 [ALC880_W810] = {
2745 .mixers = { alc880_w810_base_mixer },
2746 .init_verbs = { alc880_volume_init_verbs,
2747 alc880_pin_w810_init_verbs,
2748 alc880_gpio2_init_verbs },
2749 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
2750 .dac_nids = alc880_w810_dac_nids,
2751 .dig_out_nid = ALC880_DIGOUT_NID,
2752 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2753 .channel_mode = alc880_w810_modes,
2754 .input_mux = &alc880_capture_source,
2755 },
2756 [ALC880_Z71V] = {
2757 .mixers = { alc880_z71v_mixer },
2758 .init_verbs = { alc880_volume_init_verbs,
2759 alc880_pin_z71v_init_verbs },
2760 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
2761 .dac_nids = alc880_z71v_dac_nids,
2762 .dig_out_nid = ALC880_DIGOUT_NID,
2763 .hp_nid = 0x03,
2764 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2765 .channel_mode = alc880_2_jack_modes,
2766 .input_mux = &alc880_capture_source,
2767 },
2768 [ALC880_F1734] = {
2769 .mixers = { alc880_f1734_mixer },
2770 .init_verbs = { alc880_volume_init_verbs,
2771 alc880_pin_f1734_init_verbs },
2772 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
2773 .dac_nids = alc880_f1734_dac_nids,
2774 .hp_nid = 0x02,
2775 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2776 .channel_mode = alc880_2_jack_modes,
2777 .input_mux = &alc880_capture_source,
2778 },
2779 [ALC880_ASUS] = {
2780 .mixers = { alc880_asus_mixer },
2781 .init_verbs = { alc880_volume_init_verbs,
2782 alc880_pin_asus_init_verbs,
2783 alc880_gpio1_init_verbs },
2784 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2785 .dac_nids = alc880_asus_dac_nids,
2786 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2787 .channel_mode = alc880_asus_modes,
2788 .need_dac_fix = 1,
2789 .input_mux = &alc880_capture_source,
2790 },
2791 [ALC880_ASUS_DIG] = {
2792 .mixers = { alc880_asus_mixer },
2793 .init_verbs = { alc880_volume_init_verbs,
2794 alc880_pin_asus_init_verbs,
2795 alc880_gpio1_init_verbs },
2796 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2797 .dac_nids = alc880_asus_dac_nids,
2798 .dig_out_nid = ALC880_DIGOUT_NID,
2799 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2800 .channel_mode = alc880_asus_modes,
2801 .need_dac_fix = 1,
2802 .input_mux = &alc880_capture_source,
2803 },
2804 [ALC880_ASUS_DIG2] = {
2805 .mixers = { alc880_asus_mixer },
2806 .init_verbs = { alc880_volume_init_verbs,
2807 alc880_pin_asus_init_verbs,
2808 alc880_gpio2_init_verbs }, /* use GPIO2 */
2809 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2810 .dac_nids = alc880_asus_dac_nids,
2811 .dig_out_nid = ALC880_DIGOUT_NID,
2812 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2813 .channel_mode = alc880_asus_modes,
2814 .need_dac_fix = 1,
2815 .input_mux = &alc880_capture_source,
2816 },
2817 [ALC880_ASUS_W1V] = {
2818 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
2819 .init_verbs = { alc880_volume_init_verbs,
2820 alc880_pin_asus_init_verbs,
2821 alc880_gpio1_init_verbs },
2822 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2823 .dac_nids = alc880_asus_dac_nids,
2824 .dig_out_nid = ALC880_DIGOUT_NID,
2825 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2826 .channel_mode = alc880_asus_modes,
2827 .need_dac_fix = 1,
2828 .input_mux = &alc880_capture_source,
2829 },
2830 [ALC880_UNIWILL_DIG] = {
2831 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
2832 .init_verbs = { alc880_volume_init_verbs,
2833 alc880_pin_asus_init_verbs },
2834 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2835 .dac_nids = alc880_asus_dac_nids,
2836 .dig_out_nid = ALC880_DIGOUT_NID,
2837 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
2838 .channel_mode = alc880_asus_modes,
2839 .need_dac_fix = 1,
2840 .input_mux = &alc880_capture_source,
2841 },
2842 [ALC880_UNIWILL] = {
2843 .mixers = { alc880_uniwill_mixer },
2844 .init_verbs = { alc880_volume_init_verbs,
2845 alc880_uniwill_init_verbs },
2846 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2847 .dac_nids = alc880_asus_dac_nids,
2848 .dig_out_nid = ALC880_DIGOUT_NID,
2849 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2850 .channel_mode = alc880_threestack_modes,
2851 .need_dac_fix = 1,
2852 .input_mux = &alc880_capture_source,
2853 .unsol_event = alc880_uniwill_unsol_event,
2854 .init_hook = alc880_uniwill_automute,
2855 },
2856 [ALC880_UNIWILL_P53] = {
2857 .mixers = { alc880_uniwill_p53_mixer },
2858 .init_verbs = { alc880_volume_init_verbs,
2859 alc880_uniwill_p53_init_verbs },
2860 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
2861 .dac_nids = alc880_asus_dac_nids,
2862 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
2863 .channel_mode = alc880_threestack_modes,
2864 .input_mux = &alc880_capture_source,
2865 .unsol_event = alc880_uniwill_p53_unsol_event,
2866 .init_hook = alc880_uniwill_p53_hp_automute,
2867 },
2868 [ALC880_FUJITSU] = {
2869 .mixers = { alc880_fujitsu_mixer,
2870 alc880_pcbeep_mixer, },
2871 .init_verbs = { alc880_volume_init_verbs,
2872 alc880_uniwill_p53_init_verbs,
2873 alc880_beep_init_verbs },
2874 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2875 .dac_nids = alc880_dac_nids,
2876 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2877 .channel_mode = alc880_2_jack_modes,
2878 .input_mux = &alc880_capture_source,
2879 .unsol_event = alc880_uniwill_p53_unsol_event,
2880 .init_hook = alc880_uniwill_p53_hp_automute,
2881 },
2882 [ALC880_CLEVO] = {
2883 .mixers = { alc880_three_stack_mixer },
2884 .init_verbs = { alc880_volume_init_verbs,
2885 alc880_pin_clevo_init_verbs },
2886 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2887 .dac_nids = alc880_dac_nids,
2888 .hp_nid = 0x03,
2889 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2890 .channel_mode = alc880_threestack_modes,
2891 .need_dac_fix = 1,
2892 .input_mux = &alc880_capture_source,
2893 },
2894 [ALC880_LG] = {
2895 .mixers = { alc880_lg_mixer },
2896 .init_verbs = { alc880_volume_init_verbs,
2897 alc880_lg_init_verbs },
2898 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
2899 .dac_nids = alc880_lg_dac_nids,
2900 .dig_out_nid = ALC880_DIGOUT_NID,
2901 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
2902 .channel_mode = alc880_lg_ch_modes,
2903 .need_dac_fix = 1,
2904 .input_mux = &alc880_lg_capture_source,
2905 .unsol_event = alc880_lg_unsol_event,
2906 .init_hook = alc880_lg_automute,
2907 #ifdef CONFIG_SND_HDA_POWER_SAVE
2908 .loopbacks = alc880_lg_loopbacks,
2909 #endif
2910 },
2911 [ALC880_LG_LW] = {
2912 .mixers = { alc880_lg_lw_mixer },
2913 .init_verbs = { alc880_volume_init_verbs,
2914 alc880_lg_lw_init_verbs },
2915 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2916 .dac_nids = alc880_dac_nids,
2917 .dig_out_nid = ALC880_DIGOUT_NID,
2918 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
2919 .channel_mode = alc880_lg_lw_modes,
2920 .input_mux = &alc880_lg_lw_capture_source,
2921 .unsol_event = alc880_lg_lw_unsol_event,
2922 .init_hook = alc880_lg_lw_automute,
2923 },
2924 #ifdef CONFIG_SND_DEBUG
2925 [ALC880_TEST] = {
2926 .mixers = { alc880_test_mixer },
2927 .init_verbs = { alc880_test_init_verbs },
2928 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
2929 .dac_nids = alc880_test_dac_nids,
2930 .dig_out_nid = ALC880_DIGOUT_NID,
2931 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
2932 .channel_mode = alc880_test_modes,
2933 .input_mux = &alc880_test_capture_source,
2934 },
2935 #endif
2936 };
2937
2938 /*
2939 * Automatic parse of I/O pins from the BIOS configuration
2940 */
2941
2942 #define NUM_CONTROL_ALLOC 32
2943 #define NUM_VERB_ALLOC 32
2944
2945 enum {
2946 ALC_CTL_WIDGET_VOL,
2947 ALC_CTL_WIDGET_MUTE,
2948 ALC_CTL_BIND_MUTE,
2949 };
2950 static struct snd_kcontrol_new alc880_control_templates[] = {
2951 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2952 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2953 HDA_BIND_MUTE(NULL, 0, 0, 0),
2954 };
2955
2956 /* add dynamic controls */
2957 static int add_control(struct alc_spec *spec, int type, const char *name,
2958 unsigned long val)
2959 {
2960 struct snd_kcontrol_new *knew;
2961
2962 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2963 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2964
2965 /* array + terminator */
2966 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
2967 if (!knew)
2968 return -ENOMEM;
2969 if (spec->kctl_alloc) {
2970 memcpy(knew, spec->kctl_alloc,
2971 sizeof(*knew) * spec->num_kctl_alloc);
2972 kfree(spec->kctl_alloc);
2973 }
2974 spec->kctl_alloc = knew;
2975 spec->num_kctl_alloc = num;
2976 }
2977
2978 knew = &spec->kctl_alloc[spec->num_kctl_used];
2979 *knew = alc880_control_templates[type];
2980 knew->name = kstrdup(name, GFP_KERNEL);
2981 if (!knew->name)
2982 return -ENOMEM;
2983 knew->private_value = val;
2984 spec->num_kctl_used++;
2985 return 0;
2986 }
2987
2988 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
2989 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
2990 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
2991 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
2992 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
2993 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
2994 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
2995 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
2996 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
2997 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
2998 #define ALC880_PIN_CD_NID 0x1c
2999
3000 /* fill in the dac_nids table from the parsed pin configuration */
3001 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3002 const struct auto_pin_cfg *cfg)
3003 {
3004 hda_nid_t nid;
3005 int assigned[4];
3006 int i, j;
3007
3008 memset(assigned, 0, sizeof(assigned));
3009 spec->multiout.dac_nids = spec->private_dac_nids;
3010
3011 /* check the pins hardwired to audio widget */
3012 for (i = 0; i < cfg->line_outs; i++) {
3013 nid = cfg->line_out_pins[i];
3014 if (alc880_is_fixed_pin(nid)) {
3015 int idx = alc880_fixed_pin_idx(nid);
3016 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3017 assigned[idx] = 1;
3018 }
3019 }
3020 /* left pins can be connect to any audio widget */
3021 for (i = 0; i < cfg->line_outs; i++) {
3022 nid = cfg->line_out_pins[i];
3023 if (alc880_is_fixed_pin(nid))
3024 continue;
3025 /* search for an empty channel */
3026 for (j = 0; j < cfg->line_outs; j++) {
3027 if (!assigned[j]) {
3028 spec->multiout.dac_nids[i] =
3029 alc880_idx_to_dac(j);
3030 assigned[j] = 1;
3031 break;
3032 }
3033 }
3034 }
3035 spec->multiout.num_dacs = cfg->line_outs;
3036 return 0;
3037 }
3038
3039 /* add playback controls from the parsed DAC table */
3040 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3041 const struct auto_pin_cfg *cfg)
3042 {
3043 char name[32];
3044 static const char *chname[4] = {
3045 "Front", "Surround", NULL /*CLFE*/, "Side"
3046 };
3047 hda_nid_t nid;
3048 int i, err;
3049
3050 for (i = 0; i < cfg->line_outs; i++) {
3051 if (!spec->multiout.dac_nids[i])
3052 continue;
3053 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3054 if (i == 2) {
3055 /* Center/LFE */
3056 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3057 "Center Playback Volume",
3058 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3059 HDA_OUTPUT));
3060 if (err < 0)
3061 return err;
3062 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3063 "LFE Playback Volume",
3064 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3065 HDA_OUTPUT));
3066 if (err < 0)
3067 return err;
3068 err = add_control(spec, ALC_CTL_BIND_MUTE,
3069 "Center Playback Switch",
3070 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3071 HDA_INPUT));
3072 if (err < 0)
3073 return err;
3074 err = add_control(spec, ALC_CTL_BIND_MUTE,
3075 "LFE Playback Switch",
3076 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3077 HDA_INPUT));
3078 if (err < 0)
3079 return err;
3080 } else {
3081 sprintf(name, "%s Playback Volume", chname[i]);
3082 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3083 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3084 HDA_OUTPUT));
3085 if (err < 0)
3086 return err;
3087 sprintf(name, "%s Playback Switch", chname[i]);
3088 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3089 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3090 HDA_INPUT));
3091 if (err < 0)
3092 return err;
3093 }
3094 }
3095 return 0;
3096 }
3097
3098 /* add playback controls for speaker and HP outputs */
3099 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3100 const char *pfx)
3101 {
3102 hda_nid_t nid;
3103 int err;
3104 char name[32];
3105
3106 if (!pin)
3107 return 0;
3108
3109 if (alc880_is_fixed_pin(pin)) {
3110 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3111 /* specify the DAC as the extra output */
3112 if (!spec->multiout.hp_nid)
3113 spec->multiout.hp_nid = nid;
3114 else
3115 spec->multiout.extra_out_nid[0] = nid;
3116 /* control HP volume/switch on the output mixer amp */
3117 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3118 sprintf(name, "%s Playback Volume", pfx);
3119 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3120 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3121 if (err < 0)
3122 return err;
3123 sprintf(name, "%s Playback Switch", pfx);
3124 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3125 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3126 if (err < 0)
3127 return err;
3128 } else if (alc880_is_multi_pin(pin)) {
3129 /* set manual connection */
3130 /* we have only a switch on HP-out PIN */
3131 sprintf(name, "%s Playback Switch", pfx);
3132 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3133 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3134 if (err < 0)
3135 return err;
3136 }
3137 return 0;
3138 }
3139
3140 /* create input playback/capture controls for the given pin */
3141 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3142 const char *ctlname,
3143 int idx, hda_nid_t mix_nid)
3144 {
3145 char name[32];
3146 int err;
3147
3148 sprintf(name, "%s Playback Volume", ctlname);
3149 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3150 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3151 if (err < 0)
3152 return err;
3153 sprintf(name, "%s Playback Switch", ctlname);
3154 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3155 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3156 if (err < 0)
3157 return err;
3158 return 0;
3159 }
3160
3161 /* create playback/capture controls for input pins */
3162 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3163 const struct auto_pin_cfg *cfg)
3164 {
3165 struct hda_input_mux *imux = &spec->private_imux;
3166 int i, err, idx;
3167
3168 for (i = 0; i < AUTO_PIN_LAST; i++) {
3169 if (alc880_is_input_pin(cfg->input_pins[i])) {
3170 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3171 err = new_analog_input(spec, cfg->input_pins[i],
3172 auto_pin_cfg_labels[i],
3173 idx, 0x0b);
3174 if (err < 0)
3175 return err;
3176 imux->items[imux->num_items].label =
3177 auto_pin_cfg_labels[i];
3178 imux->items[imux->num_items].index =
3179 alc880_input_pin_idx(cfg->input_pins[i]);
3180 imux->num_items++;
3181 }
3182 }
3183 return 0;
3184 }
3185
3186 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3187 hda_nid_t nid, int pin_type,
3188 int dac_idx)
3189 {
3190 /* set as output */
3191 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3192 pin_type);
3193 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3194 AMP_OUT_UNMUTE);
3195 /* need the manual connection? */
3196 if (alc880_is_multi_pin(nid)) {
3197 struct alc_spec *spec = codec->spec;
3198 int idx = alc880_multi_pin_idx(nid);
3199 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3200 AC_VERB_SET_CONNECT_SEL,
3201 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3202 }
3203 }
3204
3205 static int get_pin_type(int line_out_type)
3206 {
3207 if (line_out_type == AUTO_PIN_HP_OUT)
3208 return PIN_HP;
3209 else
3210 return PIN_OUT;
3211 }
3212
3213 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3214 {
3215 struct alc_spec *spec = codec->spec;
3216 int i;
3217
3218 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3219 for (i = 0; i < spec->autocfg.line_outs; i++) {
3220 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3221 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3222 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3223 }
3224 }
3225
3226 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3227 {
3228 struct alc_spec *spec = codec->spec;
3229 hda_nid_t pin;
3230
3231 pin = spec->autocfg.speaker_pins[0];
3232 if (pin) /* connect to front */
3233 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3234 pin = spec->autocfg.hp_pins[0];
3235 if (pin) /* connect to front */
3236 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3237 }
3238
3239 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3240 {
3241 struct alc_spec *spec = codec->spec;
3242 int i;
3243
3244 for (i = 0; i < AUTO_PIN_LAST; i++) {
3245 hda_nid_t nid = spec->autocfg.input_pins[i];
3246 if (alc880_is_input_pin(nid)) {
3247 snd_hda_codec_write(codec, nid, 0,
3248 AC_VERB_SET_PIN_WIDGET_CONTROL,
3249 i <= AUTO_PIN_FRONT_MIC ?
3250 PIN_VREF80 : PIN_IN);
3251 if (nid != ALC880_PIN_CD_NID)
3252 snd_hda_codec_write(codec, nid, 0,
3253 AC_VERB_SET_AMP_GAIN_MUTE,
3254 AMP_OUT_MUTE);
3255 }
3256 }
3257 }
3258
3259 /* parse the BIOS configuration and set up the alc_spec */
3260 /* return 1 if successful, 0 if the proper config is not found,
3261 * or a negative error code
3262 */
3263 static int alc880_parse_auto_config(struct hda_codec *codec)
3264 {
3265 struct alc_spec *spec = codec->spec;
3266 int err;
3267 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3268
3269 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3270 alc880_ignore);
3271 if (err < 0)
3272 return err;
3273 if (!spec->autocfg.line_outs)
3274 return 0; /* can't find valid BIOS pin config */
3275
3276 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3277 if (err < 0)
3278 return err;
3279 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3280 if (err < 0)
3281 return err;
3282 err = alc880_auto_create_extra_out(spec,
3283 spec->autocfg.speaker_pins[0],
3284 "Speaker");
3285 if (err < 0)
3286 return err;
3287 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3288 "Headphone");
3289 if (err < 0)
3290 return err;
3291 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3292 if (err < 0)
3293 return err;
3294
3295 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3296
3297 if (spec->autocfg.dig_out_pin)
3298 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3299 if (spec->autocfg.dig_in_pin)
3300 spec->dig_in_nid = ALC880_DIGIN_NID;
3301
3302 if (spec->kctl_alloc)
3303 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3304
3305 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3306
3307 spec->num_mux_defs = 1;
3308 spec->input_mux = &spec->private_imux;
3309
3310 return 1;
3311 }
3312
3313 /* additional initialization for auto-configuration model */
3314 static void alc880_auto_init(struct hda_codec *codec)
3315 {
3316 alc880_auto_init_multi_out(codec);
3317 alc880_auto_init_extra_out(codec);
3318 alc880_auto_init_analog_input(codec);
3319 }
3320
3321 /*
3322 * OK, here we have finally the patch for ALC880
3323 */
3324
3325 static int patch_alc880(struct hda_codec *codec)
3326 {
3327 struct alc_spec *spec;
3328 int board_config;
3329 int err;
3330
3331 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3332 if (spec == NULL)
3333 return -ENOMEM;
3334
3335 codec->spec = spec;
3336
3337 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3338 alc880_models,
3339 alc880_cfg_tbl);
3340 if (board_config < 0) {
3341 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3342 "trying auto-probe from BIOS...\n");
3343 board_config = ALC880_AUTO;
3344 }
3345
3346 if (board_config == ALC880_AUTO) {
3347 /* automatic parse from the BIOS config */
3348 err = alc880_parse_auto_config(codec);
3349 if (err < 0) {
3350 alc_free(codec);
3351 return err;
3352 } else if (!err) {
3353 printk(KERN_INFO
3354 "hda_codec: Cannot set up configuration "
3355 "from BIOS. Using 3-stack mode...\n");
3356 board_config = ALC880_3ST;
3357 }
3358 }
3359
3360 if (board_config != ALC880_AUTO)
3361 setup_preset(spec, &alc880_presets[board_config]);
3362
3363 spec->stream_name_analog = "ALC880 Analog";
3364 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3365 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3366
3367 spec->stream_name_digital = "ALC880 Digital";
3368 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3369 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3370
3371 if (!spec->adc_nids && spec->input_mux) {
3372 /* check whether NID 0x07 is valid */
3373 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3374 /* get type */
3375 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3376 if (wcap != AC_WID_AUD_IN) {
3377 spec->adc_nids = alc880_adc_nids_alt;
3378 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3379 spec->mixers[spec->num_mixers] =
3380 alc880_capture_alt_mixer;
3381 spec->num_mixers++;
3382 } else {
3383 spec->adc_nids = alc880_adc_nids;
3384 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3385 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3386 spec->num_mixers++;
3387 }
3388 }
3389
3390 codec->patch_ops = alc_patch_ops;
3391 if (board_config == ALC880_AUTO)
3392 spec->init_hook = alc880_auto_init;
3393 #ifdef CONFIG_SND_HDA_POWER_SAVE
3394 if (!spec->loopback.amplist)
3395 spec->loopback.amplist = alc880_loopbacks;
3396 #endif
3397
3398 return 0;
3399 }
3400
3401
3402 /*
3403 * ALC260 support
3404 */
3405
3406 static hda_nid_t alc260_dac_nids[1] = {
3407 /* front */
3408 0x02,
3409 };
3410
3411 static hda_nid_t alc260_adc_nids[1] = {
3412 /* ADC0 */
3413 0x04,
3414 };
3415
3416 static hda_nid_t alc260_adc_nids_alt[1] = {
3417 /* ADC1 */
3418 0x05,
3419 };
3420
3421 static hda_nid_t alc260_hp_adc_nids[2] = {
3422 /* ADC1, 0 */
3423 0x05, 0x04
3424 };
3425
3426 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3427 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3428 */
3429 static hda_nid_t alc260_dual_adc_nids[2] = {
3430 /* ADC0, ADC1 */
3431 0x04, 0x05
3432 };
3433
3434 #define ALC260_DIGOUT_NID 0x03
3435 #define ALC260_DIGIN_NID 0x06
3436
3437 static struct hda_input_mux alc260_capture_source = {
3438 .num_items = 4,
3439 .items = {
3440 { "Mic", 0x0 },
3441 { "Front Mic", 0x1 },
3442 { "Line", 0x2 },
3443 { "CD", 0x4 },
3444 },
3445 };
3446
3447 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3448 * headphone jack and the internal CD lines since these are the only pins at
3449 * which audio can appear. For flexibility, also allow the option of
3450 * recording the mixer output on the second ADC (ADC0 doesn't have a
3451 * connection to the mixer output).
3452 */
3453 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3454 {
3455 .num_items = 3,
3456 .items = {
3457 { "Mic/Line", 0x0 },
3458 { "CD", 0x4 },
3459 { "Headphone", 0x2 },
3460 },
3461 },
3462 {
3463 .num_items = 4,
3464 .items = {
3465 { "Mic/Line", 0x0 },
3466 { "CD", 0x4 },
3467 { "Headphone", 0x2 },
3468 { "Mixer", 0x5 },
3469 },
3470 },
3471
3472 };
3473
3474 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3475 * the Fujitsu S702x, but jacks are marked differently.
3476 */
3477 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3478 {
3479 .num_items = 4,
3480 .items = {
3481 { "Mic", 0x0 },
3482 { "Line", 0x2 },
3483 { "CD", 0x4 },
3484 { "Headphone", 0x5 },
3485 },
3486 },
3487 {
3488 .num_items = 5,
3489 .items = {
3490 { "Mic", 0x0 },
3491 { "Line", 0x2 },
3492 { "CD", 0x4 },
3493 { "Headphone", 0x6 },
3494 { "Mixer", 0x5 },
3495 },
3496 },
3497 };
3498 /*
3499 * This is just place-holder, so there's something for alc_build_pcms to look
3500 * at when it calculates the maximum number of channels. ALC260 has no mixer
3501 * element which allows changing the channel mode, so the verb list is
3502 * never used.
3503 */
3504 static struct hda_channel_mode alc260_modes[1] = {
3505 { 2, NULL },
3506 };
3507
3508
3509 /* Mixer combinations
3510 *
3511 * basic: base_output + input + pc_beep + capture
3512 * HP: base_output + input + capture_alt
3513 * HP_3013: hp_3013 + input + capture
3514 * fujitsu: fujitsu + capture
3515 * acer: acer + capture
3516 */
3517
3518 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3519 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3520 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3521 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3522 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3523 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3524 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3525 { } /* end */
3526 };
3527
3528 static struct snd_kcontrol_new alc260_input_mixer[] = {
3529 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3530 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3531 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3532 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3533 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3534 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3535 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3536 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3537 { } /* end */
3538 };
3539
3540 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3541 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3542 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3543 { } /* end */
3544 };
3545
3546 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3547 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3548 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3549 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3550 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3551 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3553 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3554 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3555 { } /* end */
3556 };
3557
3558 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3559 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3560 */
3561 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3562 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3563 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3564 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3565 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3566 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3567 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3568 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3569 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3570 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3571 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3572 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3573 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3574 { } /* end */
3575 };
3576
3577 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3578 * versions of the ALC260 don't act on requests to enable mic bias from NID
3579 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3580 * datasheet doesn't mention this restriction. At this stage it's not clear
3581 * whether this behaviour is intentional or is a hardware bug in chip
3582 * revisions available in early 2006. Therefore for now allow the
3583 * "Headphone Jack Mode" control to span all choices, but if it turns out
3584 * that the lack of mic bias for this NID is intentional we could change the
3585 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3586 *
3587 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3588 * don't appear to make the mic bias available from the "line" jack, even
3589 * though the NID used for this jack (0x14) can supply it. The theory is
3590 * that perhaps Acer have included blocking capacitors between the ALC260
3591 * and the output jack. If this turns out to be the case for all such
3592 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3593 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3594 *
3595 * The C20x Tablet series have a mono internal speaker which is controlled
3596 * via the chip's Mono sum widget and pin complex, so include the necessary
3597 * controls for such models. On models without a "mono speaker" the control
3598 * won't do anything.
3599 */
3600 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3601 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3602 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3603 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3604 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3605 HDA_OUTPUT),
3606 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3607 HDA_INPUT),
3608 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3609 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3611 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3612 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3613 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3614 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3615 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3616 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3617 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3618 { } /* end */
3619 };
3620
3621 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3622 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3623 */
3624 static struct snd_kcontrol_new alc260_will_mixer[] = {
3625 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3626 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3628 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3629 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3630 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3631 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3632 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3633 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3634 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3635 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3636 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3637 { } /* end */
3638 };
3639
3640 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3641 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3642 */
3643 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3644 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3645 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3647 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3648 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3649 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3650 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3651 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3652 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3653 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3654 { } /* end */
3655 };
3656
3657 /* capture mixer elements */
3658 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3659 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3660 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3661 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3662 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3663 {
3664 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3665 /* The multiple "Capture Source" controls confuse alsamixer
3666 * So call somewhat different..
3667 * FIXME: the controls appear in the "playback" view!
3668 */
3669 /* .name = "Capture Source", */
3670 .name = "Input Source",
3671 .count = 2,
3672 .info = alc_mux_enum_info,
3673 .get = alc_mux_enum_get,
3674 .put = alc_mux_enum_put,
3675 },
3676 { } /* end */
3677 };
3678
3679 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3680 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3681 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3682 {
3683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3684 /* The multiple "Capture Source" controls confuse alsamixer
3685 * So call somewhat different..
3686 * FIXME: the controls appear in the "playback" view!
3687 */
3688 /* .name = "Capture Source", */
3689 .name = "Input Source",
3690 .count = 1,
3691 .info = alc_mux_enum_info,
3692 .get = alc_mux_enum_get,
3693 .put = alc_mux_enum_put,
3694 },
3695 { } /* end */
3696 };
3697
3698 /*
3699 * initialization verbs
3700 */
3701 static struct hda_verb alc260_init_verbs[] = {
3702 /* Line In pin widget for input */
3703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3704 /* CD pin widget for input */
3705 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3706 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3707 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3708 /* Mic2 (front panel) pin widget for input and vref at 80% */
3709 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3710 /* LINE-2 is used for line-out in rear */
3711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3712 /* select line-out */
3713 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3714 /* LINE-OUT pin */
3715 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3716 /* enable HP */
3717 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3718 /* enable Mono */
3719 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3720 /* mute capture amp left and right */
3721 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3722 /* set connection select to line in (default select for this ADC) */
3723 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3724 /* mute capture amp left and right */
3725 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3726 /* set connection select to line in (default select for this ADC) */
3727 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
3728 /* set vol=0 Line-Out mixer amp left and right */
3729 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3730 /* unmute pin widget amp left and right (no gain on this amp) */
3731 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3732 /* set vol=0 HP mixer amp left and right */
3733 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3734 /* unmute pin widget amp left and right (no gain on this amp) */
3735 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3736 /* set vol=0 Mono mixer amp left and right */
3737 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3738 /* unmute pin widget amp left and right (no gain on this amp) */
3739 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3740 /* unmute LINE-2 out pin */
3741 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3742 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3743 * Line In 2 = 0x03
3744 */
3745 /* mute analog inputs */
3746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3751 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3752 /* mute Front out path */
3753 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3754 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3755 /* mute Headphone out path */
3756 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3757 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3758 /* mute Mono out path */
3759 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3760 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3761 { }
3762 };
3763
3764 #if 0 /* should be identical with alc260_init_verbs? */
3765 static struct hda_verb alc260_hp_init_verbs[] = {
3766 /* Headphone and output */
3767 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3768 /* mono output */
3769 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3770 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3771 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3772 /* Mic2 (front panel) pin widget for input and vref at 80% */
3773 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3774 /* Line In pin widget for input */
3775 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3776 /* Line-2 pin widget for output */
3777 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3778 /* CD pin widget for input */
3779 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3780 /* unmute amp left and right */
3781 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3782 /* set connection select to line in (default select for this ADC) */
3783 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3784 /* unmute Line-Out mixer amp left and right (volume = 0) */
3785 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3786 /* mute pin widget amp left and right (no gain on this amp) */
3787 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3788 /* unmute HP mixer amp left and right (volume = 0) */
3789 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3790 /* mute pin widget amp left and right (no gain on this amp) */
3791 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3792 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3793 * Line In 2 = 0x03
3794 */
3795 /* mute analog inputs */
3796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3801 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3802 /* Unmute Front out path */
3803 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3804 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3805 /* Unmute Headphone out path */
3806 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3807 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3808 /* Unmute Mono out path */
3809 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3810 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3811 { }
3812 };
3813 #endif
3814
3815 static struct hda_verb alc260_hp_3013_init_verbs[] = {
3816 /* Line out and output */
3817 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3818 /* mono output */
3819 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
3820 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3821 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3822 /* Mic2 (front panel) pin widget for input and vref at 80% */
3823 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
3824 /* Line In pin widget for input */
3825 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3826 /* Headphone pin widget for output */
3827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
3828 /* CD pin widget for input */
3829 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
3830 /* unmute amp left and right */
3831 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
3832 /* set connection select to line in (default select for this ADC) */
3833 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
3834 /* unmute Line-Out mixer amp left and right (volume = 0) */
3835 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3836 /* mute pin widget amp left and right (no gain on this amp) */
3837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3838 /* unmute HP mixer amp left and right (volume = 0) */
3839 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
3840 /* mute pin widget amp left and right (no gain on this amp) */
3841 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
3842 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
3843 * Line In 2 = 0x03
3844 */
3845 /* mute analog inputs */
3846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3849 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3850 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3851 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
3852 /* Unmute Front out path */
3853 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3855 /* Unmute Headphone out path */
3856 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3858 /* Unmute Mono out path */
3859 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3860 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3861 { }
3862 };
3863
3864 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
3865 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
3866 * audio = 0x16, internal speaker = 0x10.
3867 */
3868 static struct hda_verb alc260_fujitsu_init_verbs[] = {
3869 /* Disable all GPIOs */
3870 {0x01, AC_VERB_SET_GPIO_MASK, 0},
3871 /* Internal speaker is connected to headphone pin */
3872 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3873 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
3874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3875 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
3876 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3877 /* Ensure all other unused pins are disabled and muted. */
3878 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3879 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3880 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3881 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3882 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3883 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3886
3887 /* Disable digital (SPDIF) pins */
3888 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3889 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3890
3891 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
3892 * when acting as an output.
3893 */
3894 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3895
3896 /* Start with output sum widgets muted and their output gains at min */
3897 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3898 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3899 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3900 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3901 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3902 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3903 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3904 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3905 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3906
3907 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
3908 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3909 /* Unmute Line1 pin widget output buffer since it starts as an output.
3910 * If the pin mode is changed by the user the pin mode control will
3911 * take care of enabling the pin's input/output buffers as needed.
3912 * Therefore there's no need to enable the input buffer at this
3913 * stage.
3914 */
3915 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3916 /* Unmute input buffer of pin widget used for Line-in (no equiv
3917 * mixer ctrl)
3918 */
3919 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3920
3921 /* Mute capture amp left and right */
3922 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3923 /* Set ADC connection select to match default mixer setting - line
3924 * in (on mic1 pin)
3925 */
3926 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
3927
3928 /* Do the same for the second ADC: mute capture input amp and
3929 * set ADC connection to line in (on mic1 pin)
3930 */
3931 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3932 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
3933
3934 /* Mute all inputs to mixer widget (even unconnected ones) */
3935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
3936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
3937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
3938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
3939 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
3940 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
3941 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
3942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
3943
3944 { }
3945 };
3946
3947 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
3948 * similar laptops (adapted from Fujitsu init verbs).
3949 */
3950 static struct hda_verb alc260_acer_init_verbs[] = {
3951 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
3952 * the headphone jack. Turn this on and rely on the standard mute
3953 * methods whenever the user wants to turn these outputs off.
3954 */
3955 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
3956 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
3957 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
3958 /* Internal speaker/Headphone jack is connected to Line-out pin */
3959 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3960 /* Internal microphone/Mic jack is connected to Mic1 pin */
3961 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
3962 /* Line In jack is connected to Line1 pin */
3963 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3964 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
3965 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3966 /* Ensure all other unused pins are disabled and muted. */
3967 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3968 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3969 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3970 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
3972 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3973 /* Disable digital (SPDIF) pins */
3974 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
3975 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
3976
3977 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
3978 * bus when acting as outputs.
3979 */
3980 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
3981 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
3982
3983 /* Start with output sum widgets muted and their output gains at min */
3984 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3987 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3988 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3990 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3991 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3992 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3993
3994 /* Unmute Line-out pin widget amp left and right
3995 * (no equiv mixer ctrl)
3996 */
3997 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3998 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
3999 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4000 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4001 * inputs. If the pin mode is changed by the user the pin mode control
4002 * will take care of enabling the pin's input/output buffers as needed.
4003 * Therefore there's no need to enable the input buffer at this
4004 * stage.
4005 */
4006 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4008
4009 /* Mute capture amp left and right */
4010 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4011 /* Set ADC connection select to match default mixer setting - mic
4012 * (on mic1 pin)
4013 */
4014 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4015
4016 /* Do similar with the second ADC: mute capture input amp and
4017 * set ADC connection to mic to match ALSA's default state.
4018 */
4019 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4020 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4021
4022 /* Mute all inputs to mixer widget (even unconnected ones) */
4023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4025 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4026 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4031
4032 { }
4033 };
4034
4035 static struct hda_verb alc260_will_verbs[] = {
4036 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4037 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4038 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4039 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4040 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4041 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4042 {}
4043 };
4044
4045 static struct hda_verb alc260_replacer_672v_verbs[] = {
4046 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4047 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4048 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4049
4050 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4051 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4052 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4053
4054 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4055 {}
4056 };
4057
4058 /* toggle speaker-output according to the hp-jack state */
4059 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4060 {
4061 unsigned int present;
4062
4063 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4064 present = snd_hda_codec_read(codec, 0x0f, 0,
4065 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4066 if (present) {
4067 snd_hda_codec_write_cache(codec, 0x01, 0,
4068 AC_VERB_SET_GPIO_DATA, 1);
4069 snd_hda_codec_write_cache(codec, 0x0f, 0,
4070 AC_VERB_SET_PIN_WIDGET_CONTROL,
4071 PIN_HP);
4072 } else {
4073 snd_hda_codec_write_cache(codec, 0x01, 0,
4074 AC_VERB_SET_GPIO_DATA, 0);
4075 snd_hda_codec_write_cache(codec, 0x0f, 0,
4076 AC_VERB_SET_PIN_WIDGET_CONTROL,
4077 PIN_OUT);
4078 }
4079 }
4080
4081 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4082 unsigned int res)
4083 {
4084 if ((res >> 26) == ALC880_HP_EVENT)
4085 alc260_replacer_672v_automute(codec);
4086 }
4087
4088 /* Test configuration for debugging, modelled after the ALC880 test
4089 * configuration.
4090 */
4091 #ifdef CONFIG_SND_DEBUG
4092 static hda_nid_t alc260_test_dac_nids[1] = {
4093 0x02,
4094 };
4095 static hda_nid_t alc260_test_adc_nids[2] = {
4096 0x04, 0x05,
4097 };
4098 /* For testing the ALC260, each input MUX needs its own definition since
4099 * the signal assignments are different. This assumes that the first ADC
4100 * is NID 0x04.
4101 */
4102 static struct hda_input_mux alc260_test_capture_sources[2] = {
4103 {
4104 .num_items = 7,
4105 .items = {
4106 { "MIC1 pin", 0x0 },
4107 { "MIC2 pin", 0x1 },
4108 { "LINE1 pin", 0x2 },
4109 { "LINE2 pin", 0x3 },
4110 { "CD pin", 0x4 },
4111 { "LINE-OUT pin", 0x5 },
4112 { "HP-OUT pin", 0x6 },
4113 },
4114 },
4115 {
4116 .num_items = 8,
4117 .items = {
4118 { "MIC1 pin", 0x0 },
4119 { "MIC2 pin", 0x1 },
4120 { "LINE1 pin", 0x2 },
4121 { "LINE2 pin", 0x3 },
4122 { "CD pin", 0x4 },
4123 { "Mixer", 0x5 },
4124 { "LINE-OUT pin", 0x6 },
4125 { "HP-OUT pin", 0x7 },
4126 },
4127 },
4128 };
4129 static struct snd_kcontrol_new alc260_test_mixer[] = {
4130 /* Output driver widgets */
4131 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4132 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4133 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4134 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4135 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4136 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4137
4138 /* Modes for retasking pin widgets
4139 * Note: the ALC260 doesn't seem to act on requests to enable mic
4140 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4141 * mention this restriction. At this stage it's not clear whether
4142 * this behaviour is intentional or is a hardware bug in chip
4143 * revisions available at least up until early 2006. Therefore for
4144 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4145 * choices, but if it turns out that the lack of mic bias for these
4146 * NIDs is intentional we could change their modes from
4147 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4148 */
4149 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4150 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4151 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4152 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4153 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4154 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4155
4156 /* Loopback mixer controls */
4157 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4158 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4159 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4160 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4161 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4162 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4163 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4164 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4165 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4166 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4167 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4168 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4169 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4170 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4171 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4172 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4173
4174 /* Controls for GPIO pins, assuming they are configured as outputs */
4175 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4176 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4177 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4178 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4179
4180 /* Switches to allow the digital IO pins to be enabled. The datasheet
4181 * is ambigious as to which NID is which; testing on laptops which
4182 * make this output available should provide clarification.
4183 */
4184 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4185 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4186
4187 { } /* end */
4188 };
4189 static struct hda_verb alc260_test_init_verbs[] = {
4190 /* Enable all GPIOs as outputs with an initial value of 0 */
4191 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4192 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4193 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4194
4195 /* Enable retasking pins as output, initially without power amp */
4196 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4197 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4199 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4200 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4201 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4202
4203 /* Disable digital (SPDIF) pins initially, but users can enable
4204 * them via a mixer switch. In the case of SPDIF-out, this initverb
4205 * payload also sets the generation to 0, output to be in "consumer"
4206 * PCM format, copyright asserted, no pre-emphasis and no validity
4207 * control.
4208 */
4209 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4210 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4211
4212 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4213 * OUT1 sum bus when acting as an output.
4214 */
4215 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4216 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4217 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4218 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4219
4220 /* Start with output sum widgets muted and their output gains at min */
4221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4226 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4227 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4228 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4229 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4230
4231 /* Unmute retasking pin widget output buffers since the default
4232 * state appears to be output. As the pin mode is changed by the
4233 * user the pin mode control will take care of enabling the pin's
4234 * input/output buffers as needed.
4235 */
4236 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4239 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4240 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4241 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4242 /* Also unmute the mono-out pin widget */
4243 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4244
4245 /* Mute capture amp left and right */
4246 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4247 /* Set ADC connection select to match default mixer setting (mic1
4248 * pin)
4249 */
4250 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4251
4252 /* Do the same for the second ADC: mute capture input amp and
4253 * set ADC connection to mic1 pin
4254 */
4255 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4256 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4257
4258 /* Mute all inputs to mixer widget (even unconnected ones) */
4259 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4261 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4262 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4267
4268 { }
4269 };
4270 #endif
4271
4272 static struct hda_pcm_stream alc260_pcm_analog_playback = {
4273 .substreams = 1,
4274 .channels_min = 2,
4275 .channels_max = 2,
4276 };
4277
4278 static struct hda_pcm_stream alc260_pcm_analog_capture = {
4279 .substreams = 1,
4280 .channels_min = 2,
4281 .channels_max = 2,
4282 };
4283
4284 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4285 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4286
4287 /*
4288 * for BIOS auto-configuration
4289 */
4290
4291 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4292 const char *pfx)
4293 {
4294 hda_nid_t nid_vol;
4295 unsigned long vol_val, sw_val;
4296 char name[32];
4297 int err;
4298
4299 if (nid >= 0x0f && nid < 0x11) {
4300 nid_vol = nid - 0x7;
4301 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4302 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4303 } else if (nid == 0x11) {
4304 nid_vol = nid - 0x7;
4305 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4306 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4307 } else if (nid >= 0x12 && nid <= 0x15) {
4308 nid_vol = 0x08;
4309 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4310 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4311 } else
4312 return 0; /* N/A */
4313
4314 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4315 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4316 if (err < 0)
4317 return err;
4318 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4319 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4320 if (err < 0)
4321 return err;
4322 return 1;
4323 }
4324
4325 /* add playback controls from the parsed DAC table */
4326 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4327 const struct auto_pin_cfg *cfg)
4328 {
4329 hda_nid_t nid;
4330 int err;
4331
4332 spec->multiout.num_dacs = 1;
4333 spec->multiout.dac_nids = spec->private_dac_nids;
4334 spec->multiout.dac_nids[0] = 0x02;
4335
4336 nid = cfg->line_out_pins[0];
4337 if (nid) {
4338 err = alc260_add_playback_controls(spec, nid, "Front");
4339 if (err < 0)
4340 return err;
4341 }
4342
4343 nid = cfg->speaker_pins[0];
4344 if (nid) {
4345 err = alc260_add_playback_controls(spec, nid, "Speaker");
4346 if (err < 0)
4347 return err;
4348 }
4349
4350 nid = cfg->hp_pins[0];
4351 if (nid) {
4352 err = alc260_add_playback_controls(spec, nid, "Headphone");
4353 if (err < 0)
4354 return err;
4355 }
4356 return 0;
4357 }
4358
4359 /* create playback/capture controls for input pins */
4360 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4361 const struct auto_pin_cfg *cfg)
4362 {
4363 struct hda_input_mux *imux = &spec->private_imux;
4364 int i, err, idx;
4365
4366 for (i = 0; i < AUTO_PIN_LAST; i++) {
4367 if (cfg->input_pins[i] >= 0x12) {
4368 idx = cfg->input_pins[i] - 0x12;
4369 err = new_analog_input(spec, cfg->input_pins[i],
4370 auto_pin_cfg_labels[i], idx,
4371 0x07);
4372 if (err < 0)
4373 return err;
4374 imux->items[imux->num_items].label =
4375 auto_pin_cfg_labels[i];
4376 imux->items[imux->num_items].index = idx;
4377 imux->num_items++;
4378 }
4379 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4380 idx = cfg->input_pins[i] - 0x09;
4381 err = new_analog_input(spec, cfg->input_pins[i],
4382 auto_pin_cfg_labels[i], idx,
4383 0x07);
4384 if (err < 0)
4385 return err;
4386 imux->items[imux->num_items].label =
4387 auto_pin_cfg_labels[i];
4388 imux->items[imux->num_items].index = idx;
4389 imux->num_items++;
4390 }
4391 }
4392 return 0;
4393 }
4394
4395 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4396 hda_nid_t nid, int pin_type,
4397 int sel_idx)
4398 {
4399 /* set as output */
4400 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4401 pin_type);
4402 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4403 AMP_OUT_UNMUTE);
4404 /* need the manual connection? */
4405 if (nid >= 0x12) {
4406 int idx = nid - 0x12;
4407 snd_hda_codec_write(codec, idx + 0x0b, 0,
4408 AC_VERB_SET_CONNECT_SEL, sel_idx);
4409 }
4410 }
4411
4412 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4413 {
4414 struct alc_spec *spec = codec->spec;
4415 hda_nid_t nid;
4416
4417 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4418 nid = spec->autocfg.line_out_pins[0];
4419 if (nid) {
4420 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4421 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4422 }
4423
4424 nid = spec->autocfg.speaker_pins[0];
4425 if (nid)
4426 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4427
4428 nid = spec->autocfg.hp_pins[0];
4429 if (nid)
4430 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4431 }
4432
4433 #define ALC260_PIN_CD_NID 0x16
4434 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4435 {
4436 struct alc_spec *spec = codec->spec;
4437 int i;
4438
4439 for (i = 0; i < AUTO_PIN_LAST; i++) {
4440 hda_nid_t nid = spec->autocfg.input_pins[i];
4441 if (nid >= 0x12) {
4442 snd_hda_codec_write(codec, nid, 0,
4443 AC_VERB_SET_PIN_WIDGET_CONTROL,
4444 i <= AUTO_PIN_FRONT_MIC ?
4445 PIN_VREF80 : PIN_IN);
4446 if (nid != ALC260_PIN_CD_NID)
4447 snd_hda_codec_write(codec, nid, 0,
4448 AC_VERB_SET_AMP_GAIN_MUTE,
4449 AMP_OUT_MUTE);
4450 }
4451 }
4452 }
4453
4454 /*
4455 * generic initialization of ADC, input mixers and output mixers
4456 */
4457 static struct hda_verb alc260_volume_init_verbs[] = {
4458 /*
4459 * Unmute ADC0-1 and set the default input to mic-in
4460 */
4461 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4462 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4463 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4464 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4465
4466 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4467 * mixer widget
4468 * Note: PASD motherboards uses the Line In 2 as the input for
4469 * front panel mic (mic 2)
4470 */
4471 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4472 /* mute analog inputs */
4473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4475 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4476 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4477 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4478
4479 /*
4480 * Set up output mixers (0x08 - 0x0a)
4481 */
4482 /* set vol=0 to output mixers */
4483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4484 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4485 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4486 /* set up input amps for analog loopback */
4487 /* Amp Indices: DAC = 0, mixer = 1 */
4488 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4490 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4492 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4493 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4494
4495 { }
4496 };
4497
4498 static int alc260_parse_auto_config(struct hda_codec *codec)
4499 {
4500 struct alc_spec *spec = codec->spec;
4501 unsigned int wcap;
4502 int err;
4503 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4504
4505 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4506 alc260_ignore);
4507 if (err < 0)
4508 return err;
4509 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4510 if (err < 0)
4511 return err;
4512 if (!spec->kctl_alloc)
4513 return 0; /* can't find valid BIOS pin config */
4514 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4515 if (err < 0)
4516 return err;
4517
4518 spec->multiout.max_channels = 2;
4519
4520 if (spec->autocfg.dig_out_pin)
4521 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4522 if (spec->kctl_alloc)
4523 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4524
4525 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4526
4527 spec->num_mux_defs = 1;
4528 spec->input_mux = &spec->private_imux;
4529
4530 /* check whether NID 0x04 is valid */
4531 wcap = get_wcaps(codec, 0x04);
4532 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4533 if (wcap != AC_WID_AUD_IN) {
4534 spec->adc_nids = alc260_adc_nids_alt;
4535 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4536 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4537 } else {
4538 spec->adc_nids = alc260_adc_nids;
4539 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4540 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4541 }
4542 spec->num_mixers++;
4543
4544 return 1;
4545 }
4546
4547 /* additional initialization for auto-configuration model */
4548 static void alc260_auto_init(struct hda_codec *codec)
4549 {
4550 alc260_auto_init_multi_out(codec);
4551 alc260_auto_init_analog_input(codec);
4552 }
4553
4554 #ifdef CONFIG_SND_HDA_POWER_SAVE
4555 static struct hda_amp_list alc260_loopbacks[] = {
4556 { 0x07, HDA_INPUT, 0 },
4557 { 0x07, HDA_INPUT, 1 },
4558 { 0x07, HDA_INPUT, 2 },
4559 { 0x07, HDA_INPUT, 3 },
4560 { 0x07, HDA_INPUT, 4 },
4561 { } /* end */
4562 };
4563 #endif
4564
4565 /*
4566 * ALC260 configurations
4567 */
4568 static const char *alc260_models[ALC260_MODEL_LAST] = {
4569 [ALC260_BASIC] = "basic",
4570 [ALC260_HP] = "hp",
4571 [ALC260_HP_3013] = "hp-3013",
4572 [ALC260_FUJITSU_S702X] = "fujitsu",
4573 [ALC260_ACER] = "acer",
4574 [ALC260_WILL] = "will",
4575 [ALC260_REPLACER_672V] = "replacer",
4576 #ifdef CONFIG_SND_DEBUG
4577 [ALC260_TEST] = "test",
4578 #endif
4579 [ALC260_AUTO] = "auto",
4580 };
4581
4582 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4583 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4584 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4585 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4586 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4587 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4588 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4589 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4590 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4591 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4592 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4593 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4594 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4595 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4596 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4597 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4598 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4599 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4600 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4601 {}
4602 };
4603
4604 static struct alc_config_preset alc260_presets[] = {
4605 [ALC260_BASIC] = {
4606 .mixers = { alc260_base_output_mixer,
4607 alc260_input_mixer,
4608 alc260_pc_beep_mixer,
4609 alc260_capture_mixer },
4610 .init_verbs = { alc260_init_verbs },
4611 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4612 .dac_nids = alc260_dac_nids,
4613 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4614 .adc_nids = alc260_adc_nids,
4615 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4616 .channel_mode = alc260_modes,
4617 .input_mux = &alc260_capture_source,
4618 },
4619 [ALC260_HP] = {
4620 .mixers = { alc260_base_output_mixer,
4621 alc260_input_mixer,
4622 alc260_capture_alt_mixer },
4623 .init_verbs = { alc260_init_verbs },
4624 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4625 .dac_nids = alc260_dac_nids,
4626 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4627 .adc_nids = alc260_hp_adc_nids,
4628 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4629 .channel_mode = alc260_modes,
4630 .input_mux = &alc260_capture_source,
4631 },
4632 [ALC260_HP_3013] = {
4633 .mixers = { alc260_hp_3013_mixer,
4634 alc260_input_mixer,
4635 alc260_capture_alt_mixer },
4636 .init_verbs = { alc260_hp_3013_init_verbs },
4637 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4638 .dac_nids = alc260_dac_nids,
4639 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4640 .adc_nids = alc260_hp_adc_nids,
4641 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4642 .channel_mode = alc260_modes,
4643 .input_mux = &alc260_capture_source,
4644 },
4645 [ALC260_FUJITSU_S702X] = {
4646 .mixers = { alc260_fujitsu_mixer,
4647 alc260_capture_mixer },
4648 .init_verbs = { alc260_fujitsu_init_verbs },
4649 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4650 .dac_nids = alc260_dac_nids,
4651 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4652 .adc_nids = alc260_dual_adc_nids,
4653 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4654 .channel_mode = alc260_modes,
4655 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4656 .input_mux = alc260_fujitsu_capture_sources,
4657 },
4658 [ALC260_ACER] = {
4659 .mixers = { alc260_acer_mixer,
4660 alc260_capture_mixer },
4661 .init_verbs = { alc260_acer_init_verbs },
4662 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4663 .dac_nids = alc260_dac_nids,
4664 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4665 .adc_nids = alc260_dual_adc_nids,
4666 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4667 .channel_mode = alc260_modes,
4668 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4669 .input_mux = alc260_acer_capture_sources,
4670 },
4671 [ALC260_WILL] = {
4672 .mixers = { alc260_will_mixer,
4673 alc260_capture_mixer },
4674 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4675 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4676 .dac_nids = alc260_dac_nids,
4677 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4678 .adc_nids = alc260_adc_nids,
4679 .dig_out_nid = ALC260_DIGOUT_NID,
4680 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4681 .channel_mode = alc260_modes,
4682 .input_mux = &alc260_capture_source,
4683 },
4684 [ALC260_REPLACER_672V] = {
4685 .mixers = { alc260_replacer_672v_mixer,
4686 alc260_capture_mixer },
4687 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4688 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4689 .dac_nids = alc260_dac_nids,
4690 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4691 .adc_nids = alc260_adc_nids,
4692 .dig_out_nid = ALC260_DIGOUT_NID,
4693 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4694 .channel_mode = alc260_modes,
4695 .input_mux = &alc260_capture_source,
4696 .unsol_event = alc260_replacer_672v_unsol_event,
4697 .init_hook = alc260_replacer_672v_automute,
4698 },
4699 #ifdef CONFIG_SND_DEBUG
4700 [ALC260_TEST] = {
4701 .mixers = { alc260_test_mixer,
4702 alc260_capture_mixer },
4703 .init_verbs = { alc260_test_init_verbs },
4704 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4705 .dac_nids = alc260_test_dac_nids,
4706 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4707 .adc_nids = alc260_test_adc_nids,
4708 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4709 .channel_mode = alc260_modes,
4710 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4711 .input_mux = alc260_test_capture_sources,
4712 },
4713 #endif
4714 };
4715
4716 static int patch_alc260(struct hda_codec *codec)
4717 {
4718 struct alc_spec *spec;
4719 int err, board_config;
4720
4721 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4722 if (spec == NULL)
4723 return -ENOMEM;
4724
4725 codec->spec = spec;
4726
4727 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
4728 alc260_models,
4729 alc260_cfg_tbl);
4730 if (board_config < 0) {
4731 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
4732 "trying auto-probe from BIOS...\n");
4733 board_config = ALC260_AUTO;
4734 }
4735
4736 if (board_config == ALC260_AUTO) {
4737 /* automatic parse from the BIOS config */
4738 err = alc260_parse_auto_config(codec);
4739 if (err < 0) {
4740 alc_free(codec);
4741 return err;
4742 } else if (!err) {
4743 printk(KERN_INFO
4744 "hda_codec: Cannot set up configuration "
4745 "from BIOS. Using base mode...\n");
4746 board_config = ALC260_BASIC;
4747 }
4748 }
4749
4750 if (board_config != ALC260_AUTO)
4751 setup_preset(spec, &alc260_presets[board_config]);
4752
4753 spec->stream_name_analog = "ALC260 Analog";
4754 spec->stream_analog_playback = &alc260_pcm_analog_playback;
4755 spec->stream_analog_capture = &alc260_pcm_analog_capture;
4756
4757 spec->stream_name_digital = "ALC260 Digital";
4758 spec->stream_digital_playback = &alc260_pcm_digital_playback;
4759 spec->stream_digital_capture = &alc260_pcm_digital_capture;
4760
4761 codec->patch_ops = alc_patch_ops;
4762 if (board_config == ALC260_AUTO)
4763 spec->init_hook = alc260_auto_init;
4764 #ifdef CONFIG_SND_HDA_POWER_SAVE
4765 if (!spec->loopback.amplist)
4766 spec->loopback.amplist = alc260_loopbacks;
4767 #endif
4768
4769 return 0;
4770 }
4771
4772
4773 /*
4774 * ALC882 support
4775 *
4776 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
4777 * configuration. Each pin widget can choose any input DACs and a mixer.
4778 * Each ADC is connected from a mixer of all inputs. This makes possible
4779 * 6-channel independent captures.
4780 *
4781 * In addition, an independent DAC for the multi-playback (not used in this
4782 * driver yet).
4783 */
4784 #define ALC882_DIGOUT_NID 0x06
4785 #define ALC882_DIGIN_NID 0x0a
4786
4787 static struct hda_channel_mode alc882_ch_modes[1] = {
4788 { 8, NULL }
4789 };
4790
4791 static hda_nid_t alc882_dac_nids[4] = {
4792 /* front, rear, clfe, rear_surr */
4793 0x02, 0x03, 0x04, 0x05
4794 };
4795
4796 /* identical with ALC880 */
4797 #define alc882_adc_nids alc880_adc_nids
4798 #define alc882_adc_nids_alt alc880_adc_nids_alt
4799
4800 /* input MUX */
4801 /* FIXME: should be a matrix-type input source selection */
4802
4803 static struct hda_input_mux alc882_capture_source = {
4804 .num_items = 4,
4805 .items = {
4806 { "Mic", 0x0 },
4807 { "Front Mic", 0x1 },
4808 { "Line", 0x2 },
4809 { "CD", 0x4 },
4810 },
4811 };
4812 #define alc882_mux_enum_info alc_mux_enum_info
4813 #define alc882_mux_enum_get alc_mux_enum_get
4814
4815 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
4816 struct snd_ctl_elem_value *ucontrol)
4817 {
4818 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4819 struct alc_spec *spec = codec->spec;
4820 const struct hda_input_mux *imux = spec->input_mux;
4821 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
4822 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
4823 hda_nid_t nid = capture_mixers[adc_idx];
4824 unsigned int *cur_val = &spec->cur_mux[adc_idx];
4825 unsigned int i, idx;
4826
4827 idx = ucontrol->value.enumerated.item[0];
4828 if (idx >= imux->num_items)
4829 idx = imux->num_items - 1;
4830 if (*cur_val == idx)
4831 return 0;
4832 for (i = 0; i < imux->num_items; i++) {
4833 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
4834 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
4835 imux->items[i].index,
4836 HDA_AMP_MUTE, v);
4837 }
4838 *cur_val = idx;
4839 return 1;
4840 }
4841
4842 /*
4843 * 2ch mode
4844 */
4845 static struct hda_verb alc882_3ST_ch2_init[] = {
4846 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
4847 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
4849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
4850 { } /* end */
4851 };
4852
4853 /*
4854 * 6ch mode
4855 */
4856 static struct hda_verb alc882_3ST_ch6_init[] = {
4857 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4858 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4859 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
4860 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4861 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
4862 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
4863 { } /* end */
4864 };
4865
4866 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
4867 { 2, alc882_3ST_ch2_init },
4868 { 6, alc882_3ST_ch6_init },
4869 };
4870
4871 /*
4872 * 6ch mode
4873 */
4874 static struct hda_verb alc882_sixstack_ch6_init[] = {
4875 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
4876 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4877 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4878 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4879 { } /* end */
4880 };
4881
4882 /*
4883 * 8ch mode
4884 */
4885 static struct hda_verb alc882_sixstack_ch8_init[] = {
4886 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4887 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4888 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4889 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
4890 { } /* end */
4891 };
4892
4893 static struct hda_channel_mode alc882_sixstack_modes[2] = {
4894 { 6, alc882_sixstack_ch6_init },
4895 { 8, alc882_sixstack_ch8_init },
4896 };
4897
4898 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
4899 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
4900 */
4901 static struct snd_kcontrol_new alc882_base_mixer[] = {
4902 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4903 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4904 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4905 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4906 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
4907 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
4908 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
4909 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
4910 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
4911 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
4912 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4913 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4914 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4915 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4916 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4918 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4919 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4920 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4921 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
4922 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4923 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4924 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4925 { } /* end */
4926 };
4927
4928 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
4929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4930 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
4937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4938 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
4939 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
4940 { } /* end */
4941 };
4942
4943 static struct snd_kcontrol_new alc882_targa_mixer[] = {
4944 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4945 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4946 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
4947 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4948 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4949 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4950 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4951 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4952 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4953 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
4954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
4955 { } /* end */
4956 };
4957
4958 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
4959 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
4960 */
4961 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
4962 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4963 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
4964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4965 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
4966 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
4967 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
4968 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
4969 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
4970 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
4971 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
4972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
4973 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
4974 { } /* end */
4975 };
4976
4977 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
4978 {
4979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4980 .name = "Channel Mode",
4981 .info = alc_ch_mode_info,
4982 .get = alc_ch_mode_get,
4983 .put = alc_ch_mode_put,
4984 },
4985 { } /* end */
4986 };
4987
4988 static struct hda_verb alc882_init_verbs[] = {
4989 /* Front mixer: unmute input/output amp left and right (volume = 0) */
4990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4993 /* Rear mixer */
4994 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4995 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4996 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4997 /* CLFE mixer */
4998 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4999 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5001 /* Side mixer */
5002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5003 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5004 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5005
5006 /* Front Pin: output 0 (0x0c) */
5007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5008 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5009 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5010 /* Rear Pin: output 1 (0x0d) */
5011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5014 /* CLFE Pin: output 2 (0x0e) */
5015 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5016 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5017 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5018 /* Side Pin: output 3 (0x0f) */
5019 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5020 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5021 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5022 /* Mic (rear) pin: input vref at 80% */
5023 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5024 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5025 /* Front Mic pin: input vref at 80% */
5026 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5027 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5028 /* Line In pin: input */
5029 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5030 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5031 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5032 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5033 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5034 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5035 /* CD pin widget for input */
5036 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5037
5038 /* FIXME: use matrix-type input source selection */
5039 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5040 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5041 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5042 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5043 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5044 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5045 /* Input mixer2 */
5046 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5047 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5048 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5049 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5050 /* Input mixer3 */
5051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5053 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5054 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5055 /* ADC1: mute amp left and right */
5056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5057 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5058 /* ADC2: mute amp left and right */
5059 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5060 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5061 /* ADC3: mute amp left and right */
5062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5063 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5064
5065 { }
5066 };
5067
5068 static struct hda_verb alc882_eapd_verbs[] = {
5069 /* change to EAPD mode */
5070 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5071 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5072 { }
5073 };
5074
5075 /* Mac Pro test */
5076 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5077 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5078 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5079 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5080 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5081 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5082 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5083 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5084 { } /* end */
5085 };
5086
5087 static struct hda_verb alc882_macpro_init_verbs[] = {
5088 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5092 /* Front Pin: output 0 (0x0c) */
5093 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5094 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5095 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5096 /* Front Mic pin: input vref at 80% */
5097 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5098 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5099 /* Speaker: output */
5100 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5101 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5102 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5103 /* Headphone output (output 0 - 0x0c) */
5104 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5105 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5106 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5107
5108 /* FIXME: use matrix-type input source selection */
5109 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5110 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5111 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5112 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5113 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5114 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5115 /* Input mixer2 */
5116 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5117 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5118 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5119 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5120 /* Input mixer3 */
5121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5125 /* ADC1: mute amp left and right */
5126 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5127 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5128 /* ADC2: mute amp left and right */
5129 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5130 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5131 /* ADC3: mute amp left and right */
5132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5133 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5134
5135 { }
5136 };
5137
5138 /* iMac 24 mixer. */
5139 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5140 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5141 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5142 { } /* end */
5143 };
5144
5145 /* iMac 24 init verbs. */
5146 static struct hda_verb alc885_imac24_init_verbs[] = {
5147 /* Internal speakers: output 0 (0x0c) */
5148 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5149 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5150 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5151 /* Internal speakers: output 0 (0x0c) */
5152 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5153 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5154 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5155 /* Headphone: output 0 (0x0c) */
5156 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5157 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5158 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5159 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5160 /* Front Mic: input vref at 80% */
5161 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5162 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5163 { }
5164 };
5165
5166 /* Toggle speaker-output according to the hp-jack state */
5167 static void alc885_imac24_automute(struct hda_codec *codec)
5168 {
5169 unsigned int present;
5170
5171 present = snd_hda_codec_read(codec, 0x14, 0,
5172 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5173 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5174 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5175 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5176 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5177 }
5178
5179 /* Processes unsolicited events. */
5180 static void alc885_imac24_unsol_event(struct hda_codec *codec,
5181 unsigned int res)
5182 {
5183 /* Headphone insertion or removal. */
5184 if ((res >> 26) == ALC880_HP_EVENT)
5185 alc885_imac24_automute(codec);
5186 }
5187
5188 static struct hda_verb alc882_targa_verbs[] = {
5189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5191
5192 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5194
5195 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5196 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5197 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5198
5199 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5200 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5201 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5202 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5203 { } /* end */
5204 };
5205
5206 /* toggle speaker-output according to the hp-jack state */
5207 static void alc882_targa_automute(struct hda_codec *codec)
5208 {
5209 unsigned int present;
5210
5211 present = snd_hda_codec_read(codec, 0x14, 0,
5212 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5213 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5214 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5215 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5216 present ? 1 : 3);
5217 }
5218
5219 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5220 {
5221 /* Looks like the unsol event is incompatible with the standard
5222 * definition. 4bit tag is placed at 26 bit!
5223 */
5224 if (((res >> 26) == ALC880_HP_EVENT)) {
5225 alc882_targa_automute(codec);
5226 }
5227 }
5228
5229 static struct hda_verb alc882_asus_a7j_verbs[] = {
5230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5232
5233 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5235 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5236
5237 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5239 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5240
5241 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5242 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5243 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5244 { } /* end */
5245 };
5246
5247 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5248 {
5249 unsigned int gpiostate, gpiomask, gpiodir;
5250
5251 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5252 AC_VERB_GET_GPIO_DATA, 0);
5253
5254 if (!muted)
5255 gpiostate |= (1 << pin);
5256 else
5257 gpiostate &= ~(1 << pin);
5258
5259 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5260 AC_VERB_GET_GPIO_MASK, 0);
5261 gpiomask |= (1 << pin);
5262
5263 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5264 AC_VERB_GET_GPIO_DIRECTION, 0);
5265 gpiodir |= (1 << pin);
5266
5267
5268 snd_hda_codec_write(codec, codec->afg, 0,
5269 AC_VERB_SET_GPIO_MASK, gpiomask);
5270 snd_hda_codec_write(codec, codec->afg, 0,
5271 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5272
5273 msleep(1);
5274
5275 snd_hda_codec_write(codec, codec->afg, 0,
5276 AC_VERB_SET_GPIO_DATA, gpiostate);
5277 }
5278
5279 /* set up GPIO at initialization */
5280 static void alc885_macpro_init_hook(struct hda_codec *codec)
5281 {
5282 alc882_gpio_mute(codec, 0, 0);
5283 alc882_gpio_mute(codec, 1, 0);
5284 }
5285
5286 /* set up GPIO and update auto-muting at initialization */
5287 static void alc885_imac24_init_hook(struct hda_codec *codec)
5288 {
5289 alc885_macpro_init_hook(codec);
5290 alc885_imac24_automute(codec);
5291 }
5292
5293 /*
5294 * generic initialization of ADC, input mixers and output mixers
5295 */
5296 static struct hda_verb alc882_auto_init_verbs[] = {
5297 /*
5298 * Unmute ADC0-2 and set the default input to mic-in
5299 */
5300 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5301 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5302 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5303 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5304 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5305 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5306
5307 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5308 * mixer widget
5309 * Note: PASD motherboards uses the Line In 2 as the input for
5310 * front panel mic (mic 2)
5311 */
5312 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5313 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5314 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5315 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5318
5319 /*
5320 * Set up output mixers (0x0c - 0x0f)
5321 */
5322 /* set vol=0 to output mixers */
5323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5324 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5325 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5326 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5327 /* set up input amps for analog loopback */
5328 /* Amp Indices: DAC = 0, mixer = 1 */
5329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5336 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5337 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5338 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5339
5340 /* FIXME: use matrix-type input source selection */
5341 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5342 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5347 /* Input mixer2 */
5348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5352 /* Input mixer3 */
5353 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5354 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5355 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5357
5358 { }
5359 };
5360
5361 /* capture mixer elements */
5362 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5363 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5364 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5365 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5366 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5367 {
5368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5369 /* The multiple "Capture Source" controls confuse alsamixer
5370 * So call somewhat different..
5371 * FIXME: the controls appear in the "playback" view!
5372 */
5373 /* .name = "Capture Source", */
5374 .name = "Input Source",
5375 .count = 2,
5376 .info = alc882_mux_enum_info,
5377 .get = alc882_mux_enum_get,
5378 .put = alc882_mux_enum_put,
5379 },
5380 { } /* end */
5381 };
5382
5383 static struct snd_kcontrol_new alc882_capture_mixer[] = {
5384 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5385 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5386 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5387 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5388 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5389 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5390 {
5391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5392 /* The multiple "Capture Source" controls confuse alsamixer
5393 * So call somewhat different..
5394 * FIXME: the controls appear in the "playback" view!
5395 */
5396 /* .name = "Capture Source", */
5397 .name = "Input Source",
5398 .count = 3,
5399 .info = alc882_mux_enum_info,
5400 .get = alc882_mux_enum_get,
5401 .put = alc882_mux_enum_put,
5402 },
5403 { } /* end */
5404 };
5405
5406 #ifdef CONFIG_SND_HDA_POWER_SAVE
5407 #define alc882_loopbacks alc880_loopbacks
5408 #endif
5409
5410 /* pcm configuration: identiacal with ALC880 */
5411 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
5412 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
5413 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
5414 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
5415
5416 /*
5417 * configuration and preset
5418 */
5419 static const char *alc882_models[ALC882_MODEL_LAST] = {
5420 [ALC882_3ST_DIG] = "3stack-dig",
5421 [ALC882_6ST_DIG] = "6stack-dig",
5422 [ALC882_ARIMA] = "arima",
5423 [ALC882_W2JC] = "w2jc",
5424 [ALC885_MACPRO] = "macpro",
5425 [ALC885_IMAC24] = "imac24",
5426 [ALC882_AUTO] = "auto",
5427 };
5428
5429 static struct snd_pci_quirk alc882_cfg_tbl[] = {
5430 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5431 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5432 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5433 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5434 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5435 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5436 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
5437 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5438 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
5439 {}
5440 };
5441
5442 static struct alc_config_preset alc882_presets[] = {
5443 [ALC882_3ST_DIG] = {
5444 .mixers = { alc882_base_mixer },
5445 .init_verbs = { alc882_init_verbs },
5446 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5447 .dac_nids = alc882_dac_nids,
5448 .dig_out_nid = ALC882_DIGOUT_NID,
5449 .dig_in_nid = ALC882_DIGIN_NID,
5450 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5451 .channel_mode = alc882_ch_modes,
5452 .need_dac_fix = 1,
5453 .input_mux = &alc882_capture_source,
5454 },
5455 [ALC882_6ST_DIG] = {
5456 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5457 .init_verbs = { alc882_init_verbs },
5458 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5459 .dac_nids = alc882_dac_nids,
5460 .dig_out_nid = ALC882_DIGOUT_NID,
5461 .dig_in_nid = ALC882_DIGIN_NID,
5462 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5463 .channel_mode = alc882_sixstack_modes,
5464 .input_mux = &alc882_capture_source,
5465 },
5466 [ALC882_ARIMA] = {
5467 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5468 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5469 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5470 .dac_nids = alc882_dac_nids,
5471 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5472 .channel_mode = alc882_sixstack_modes,
5473 .input_mux = &alc882_capture_source,
5474 },
5475 [ALC882_W2JC] = {
5476 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5477 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5478 alc880_gpio1_init_verbs },
5479 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5480 .dac_nids = alc882_dac_nids,
5481 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5482 .channel_mode = alc880_threestack_modes,
5483 .need_dac_fix = 1,
5484 .input_mux = &alc882_capture_source,
5485 .dig_out_nid = ALC882_DIGOUT_NID,
5486 },
5487 [ALC885_MACPRO] = {
5488 .mixers = { alc882_macpro_mixer },
5489 .init_verbs = { alc882_macpro_init_verbs },
5490 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5491 .dac_nids = alc882_dac_nids,
5492 .dig_out_nid = ALC882_DIGOUT_NID,
5493 .dig_in_nid = ALC882_DIGIN_NID,
5494 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5495 .channel_mode = alc882_ch_modes,
5496 .input_mux = &alc882_capture_source,
5497 .init_hook = alc885_macpro_init_hook,
5498 },
5499 [ALC885_IMAC24] = {
5500 .mixers = { alc885_imac24_mixer },
5501 .init_verbs = { alc885_imac24_init_verbs },
5502 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5503 .dac_nids = alc882_dac_nids,
5504 .dig_out_nid = ALC882_DIGOUT_NID,
5505 .dig_in_nid = ALC882_DIGIN_NID,
5506 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5507 .channel_mode = alc882_ch_modes,
5508 .input_mux = &alc882_capture_source,
5509 .unsol_event = alc885_imac24_unsol_event,
5510 .init_hook = alc885_imac24_init_hook,
5511 },
5512 [ALC882_TARGA] = {
5513 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5514 alc882_capture_mixer },
5515 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5516 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5517 .dac_nids = alc882_dac_nids,
5518 .dig_out_nid = ALC882_DIGOUT_NID,
5519 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5520 .adc_nids = alc882_adc_nids,
5521 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5522 .channel_mode = alc882_3ST_6ch_modes,
5523 .need_dac_fix = 1,
5524 .input_mux = &alc882_capture_source,
5525 .unsol_event = alc882_targa_unsol_event,
5526 .init_hook = alc882_targa_automute,
5527 },
5528 [ALC882_ASUS_A7J] = {
5529 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5530 alc882_capture_mixer },
5531 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5532 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5533 .dac_nids = alc882_dac_nids,
5534 .dig_out_nid = ALC882_DIGOUT_NID,
5535 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5536 .adc_nids = alc882_adc_nids,
5537 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5538 .channel_mode = alc882_3ST_6ch_modes,
5539 .need_dac_fix = 1,
5540 .input_mux = &alc882_capture_source,
5541 },
5542 };
5543
5544
5545 /*
5546 * Pin config fixes
5547 */
5548 enum {
5549 PINFIX_ABIT_AW9D_MAX
5550 };
5551
5552 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
5553 { 0x15, 0x01080104 }, /* side */
5554 { 0x16, 0x01011012 }, /* rear */
5555 { 0x17, 0x01016011 }, /* clfe */
5556 { }
5557 };
5558
5559 static const struct alc_pincfg *alc882_pin_fixes[] = {
5560 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
5561 };
5562
5563 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
5564 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
5565 {}
5566 };
5567
5568 /*
5569 * BIOS auto configuration
5570 */
5571 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
5572 hda_nid_t nid, int pin_type,
5573 int dac_idx)
5574 {
5575 /* set as output */
5576 struct alc_spec *spec = codec->spec;
5577 int idx;
5578
5579 if (spec->multiout.dac_nids[dac_idx] == 0x25)
5580 idx = 4;
5581 else
5582 idx = spec->multiout.dac_nids[dac_idx] - 2;
5583
5584 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5585 pin_type);
5586 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5587 AMP_OUT_UNMUTE);
5588 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
5589
5590 }
5591
5592 static void alc882_auto_init_multi_out(struct hda_codec *codec)
5593 {
5594 struct alc_spec *spec = codec->spec;
5595 int i;
5596
5597 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
5598 for (i = 0; i <= HDA_SIDE; i++) {
5599 hda_nid_t nid = spec->autocfg.line_out_pins[i];
5600 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5601 if (nid)
5602 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
5603 i);
5604 }
5605 }
5606
5607 static void alc882_auto_init_hp_out(struct hda_codec *codec)
5608 {
5609 struct alc_spec *spec = codec->spec;
5610 hda_nid_t pin;
5611
5612 pin = spec->autocfg.hp_pins[0];
5613 if (pin) /* connect to front */
5614 /* use dac 0 */
5615 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5616 }
5617
5618 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
5619 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
5620
5621 static void alc882_auto_init_analog_input(struct hda_codec *codec)
5622 {
5623 struct alc_spec *spec = codec->spec;
5624 int i;
5625
5626 for (i = 0; i < AUTO_PIN_LAST; i++) {
5627 hda_nid_t nid = spec->autocfg.input_pins[i];
5628 if (alc882_is_input_pin(nid)) {
5629 snd_hda_codec_write(codec, nid, 0,
5630 AC_VERB_SET_PIN_WIDGET_CONTROL,
5631 i <= AUTO_PIN_FRONT_MIC ?
5632 PIN_VREF80 : PIN_IN);
5633 if (nid != ALC882_PIN_CD_NID)
5634 snd_hda_codec_write(codec, nid, 0,
5635 AC_VERB_SET_AMP_GAIN_MUTE,
5636 AMP_OUT_MUTE);
5637 }
5638 }
5639 }
5640
5641 /* almost identical with ALC880 parser... */
5642 static int alc882_parse_auto_config(struct hda_codec *codec)
5643 {
5644 struct alc_spec *spec = codec->spec;
5645 int err = alc880_parse_auto_config(codec);
5646
5647 if (err < 0)
5648 return err;
5649 else if (err > 0)
5650 /* hack - override the init verbs */
5651 spec->init_verbs[0] = alc882_auto_init_verbs;
5652 return err;
5653 }
5654
5655 /* additional initialization for auto-configuration model */
5656 static void alc882_auto_init(struct hda_codec *codec)
5657 {
5658 alc882_auto_init_multi_out(codec);
5659 alc882_auto_init_hp_out(codec);
5660 alc882_auto_init_analog_input(codec);
5661 }
5662
5663 static int patch_alc882(struct hda_codec *codec)
5664 {
5665 struct alc_spec *spec;
5666 int err, board_config;
5667
5668 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5669 if (spec == NULL)
5670 return -ENOMEM;
5671
5672 codec->spec = spec;
5673
5674 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
5675 alc882_models,
5676 alc882_cfg_tbl);
5677
5678 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
5679 /* Pick up systems that don't supply PCI SSID */
5680 switch (codec->subsystem_id) {
5681 case 0x106b0c00: /* Mac Pro */
5682 board_config = ALC885_MACPRO;
5683 break;
5684 case 0x106b1000: /* iMac 24 */
5685 board_config = ALC885_IMAC24;
5686 break;
5687 default:
5688 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
5689 "trying auto-probe from BIOS...\n");
5690 board_config = ALC882_AUTO;
5691 }
5692 }
5693
5694 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
5695
5696 if (board_config == ALC882_AUTO) {
5697 /* automatic parse from the BIOS config */
5698 err = alc882_parse_auto_config(codec);
5699 if (err < 0) {
5700 alc_free(codec);
5701 return err;
5702 } else if (!err) {
5703 printk(KERN_INFO
5704 "hda_codec: Cannot set up configuration "
5705 "from BIOS. Using base mode...\n");
5706 board_config = ALC882_3ST_DIG;
5707 }
5708 }
5709
5710 if (board_config != ALC882_AUTO)
5711 setup_preset(spec, &alc882_presets[board_config]);
5712
5713 spec->stream_name_analog = "ALC882 Analog";
5714 spec->stream_analog_playback = &alc882_pcm_analog_playback;
5715 spec->stream_analog_capture = &alc882_pcm_analog_capture;
5716
5717 spec->stream_name_digital = "ALC882 Digital";
5718 spec->stream_digital_playback = &alc882_pcm_digital_playback;
5719 spec->stream_digital_capture = &alc882_pcm_digital_capture;
5720
5721 if (!spec->adc_nids && spec->input_mux) {
5722 /* check whether NID 0x07 is valid */
5723 unsigned int wcap = get_wcaps(codec, 0x07);
5724 /* get type */
5725 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5726 if (wcap != AC_WID_AUD_IN) {
5727 spec->adc_nids = alc882_adc_nids_alt;
5728 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
5729 spec->mixers[spec->num_mixers] =
5730 alc882_capture_alt_mixer;
5731 spec->num_mixers++;
5732 } else {
5733 spec->adc_nids = alc882_adc_nids;
5734 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
5735 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
5736 spec->num_mixers++;
5737 }
5738 }
5739
5740 codec->patch_ops = alc_patch_ops;
5741 if (board_config == ALC882_AUTO)
5742 spec->init_hook = alc882_auto_init;
5743 #ifdef CONFIG_SND_HDA_POWER_SAVE
5744 if (!spec->loopback.amplist)
5745 spec->loopback.amplist = alc882_loopbacks;
5746 #endif
5747
5748 return 0;
5749 }
5750
5751 /*
5752 * ALC883 support
5753 *
5754 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
5755 * configuration. Each pin widget can choose any input DACs and a mixer.
5756 * Each ADC is connected from a mixer of all inputs. This makes possible
5757 * 6-channel independent captures.
5758 *
5759 * In addition, an independent DAC for the multi-playback (not used in this
5760 * driver yet).
5761 */
5762 #define ALC883_DIGOUT_NID 0x06
5763 #define ALC883_DIGIN_NID 0x0a
5764
5765 static hda_nid_t alc883_dac_nids[4] = {
5766 /* front, rear, clfe, rear_surr */
5767 0x02, 0x04, 0x03, 0x05
5768 };
5769
5770 static hda_nid_t alc883_adc_nids[2] = {
5771 /* ADC1-2 */
5772 0x08, 0x09,
5773 };
5774
5775 /* input MUX */
5776 /* FIXME: should be a matrix-type input source selection */
5777
5778 static struct hda_input_mux alc883_capture_source = {
5779 .num_items = 4,
5780 .items = {
5781 { "Mic", 0x0 },
5782 { "Front Mic", 0x1 },
5783 { "Line", 0x2 },
5784 { "CD", 0x4 },
5785 },
5786 };
5787
5788 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
5789 .num_items = 2,
5790 .items = {
5791 { "Mic", 0x1 },
5792 { "Line", 0x2 },
5793 },
5794 };
5795
5796 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
5797 .num_items = 4,
5798 .items = {
5799 { "Mic", 0x0 },
5800 { "iMic", 0x1 },
5801 { "Line", 0x2 },
5802 { "CD", 0x4 },
5803 },
5804 };
5805
5806 #define alc883_mux_enum_info alc_mux_enum_info
5807 #define alc883_mux_enum_get alc_mux_enum_get
5808
5809 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
5810 struct snd_ctl_elem_value *ucontrol)
5811 {
5812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5813 struct alc_spec *spec = codec->spec;
5814 const struct hda_input_mux *imux = spec->input_mux;
5815 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5816 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5817 hda_nid_t nid = capture_mixers[adc_idx];
5818 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5819 unsigned int i, idx;
5820
5821 idx = ucontrol->value.enumerated.item[0];
5822 if (idx >= imux->num_items)
5823 idx = imux->num_items - 1;
5824 if (*cur_val == idx)
5825 return 0;
5826 for (i = 0; i < imux->num_items; i++) {
5827 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5828 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
5829 imux->items[i].index,
5830 HDA_AMP_MUTE, v);
5831 }
5832 *cur_val = idx;
5833 return 1;
5834 }
5835
5836 /*
5837 * 2ch mode
5838 */
5839 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
5840 { 2, NULL }
5841 };
5842
5843 /*
5844 * 2ch mode
5845 */
5846 static struct hda_verb alc883_3ST_ch2_init[] = {
5847 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5848 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5851 { } /* end */
5852 };
5853
5854 /*
5855 * 6ch mode
5856 */
5857 static struct hda_verb alc883_3ST_ch6_init[] = {
5858 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5859 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5860 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5861 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5862 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5863 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5864 { } /* end */
5865 };
5866
5867 static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
5868 { 2, alc883_3ST_ch2_init },
5869 { 6, alc883_3ST_ch6_init },
5870 };
5871
5872 /*
5873 * 6ch mode
5874 */
5875 static struct hda_verb alc883_sixstack_ch6_init[] = {
5876 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5877 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5878 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5879 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5880 { } /* end */
5881 };
5882
5883 /*
5884 * 8ch mode
5885 */
5886 static struct hda_verb alc883_sixstack_ch8_init[] = {
5887 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5888 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5889 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5890 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5891 { } /* end */
5892 };
5893
5894 static struct hda_channel_mode alc883_sixstack_modes[2] = {
5895 { 6, alc883_sixstack_ch6_init },
5896 { 8, alc883_sixstack_ch8_init },
5897 };
5898
5899 static struct hda_verb alc883_medion_eapd_verbs[] = {
5900 /* eanable EAPD on medion laptop */
5901 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5902 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
5903 { }
5904 };
5905
5906 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5907 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5908 */
5909
5910 static struct snd_kcontrol_new alc883_base_mixer[] = {
5911 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5912 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5913 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5914 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5915 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5916 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5917 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5918 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5919 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5920 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5921 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5922 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5923 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5924 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5925 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5927 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5930 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5931 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5932 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5933 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5934 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5935 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5936 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5937 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5938 {
5939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5940 /* .name = "Capture Source", */
5941 .name = "Input Source",
5942 .count = 2,
5943 .info = alc883_mux_enum_info,
5944 .get = alc883_mux_enum_get,
5945 .put = alc883_mux_enum_put,
5946 },
5947 { } /* end */
5948 };
5949
5950 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
5951 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5952 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5953 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5954 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5955 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5956 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5957 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5959 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5961 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5962 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5963 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5964 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5965 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5966 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5967 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5968 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5969 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5970 {
5971 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5972 /* .name = "Capture Source", */
5973 .name = "Input Source",
5974 .count = 2,
5975 .info = alc883_mux_enum_info,
5976 .get = alc883_mux_enum_get,
5977 .put = alc883_mux_enum_put,
5978 },
5979 { } /* end */
5980 };
5981
5982 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
5983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5984 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5985 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5986 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5987 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5988 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5989 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5990 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5991 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5992 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5993 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5994 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5995 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5999 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6000 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6001 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6002 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6003 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6004 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6005 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6006 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6007 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6008 {
6009 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6010 /* .name = "Capture Source", */
6011 .name = "Input Source",
6012 .count = 2,
6013 .info = alc883_mux_enum_info,
6014 .get = alc883_mux_enum_get,
6015 .put = alc883_mux_enum_put,
6016 },
6017 { } /* end */
6018 };
6019
6020 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
6021 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6022 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6023 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6024 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6025 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6026 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6027 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6028 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6030 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6031 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6032 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6033 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6036 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6037 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6038 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6039 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6040 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6041 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6042 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6043 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6044
6045 {
6046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6047 /* .name = "Capture Source", */
6048 .name = "Input Source",
6049 .count = 1,
6050 .info = alc883_mux_enum_info,
6051 .get = alc883_mux_enum_get,
6052 .put = alc883_mux_enum_put,
6053 },
6054 { } /* end */
6055 };
6056
6057 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6058 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6059 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6060 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6061 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6062 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6063 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6064 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6065 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6066 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6067 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6068 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6069 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6070 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6072 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6074 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6075 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6076 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6077 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6078 {
6079 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6080 /* .name = "Capture Source", */
6081 .name = "Input Source",
6082 .count = 2,
6083 .info = alc883_mux_enum_info,
6084 .get = alc883_mux_enum_get,
6085 .put = alc883_mux_enum_put,
6086 },
6087 { } /* end */
6088 };
6089
6090 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6092 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6093 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6094 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6095 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6099 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6100 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6101 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6102 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6103 {
6104 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6105 /* .name = "Capture Source", */
6106 .name = "Input Source",
6107 .count = 2,
6108 .info = alc883_mux_enum_info,
6109 .get = alc883_mux_enum_get,
6110 .put = alc883_mux_enum_put,
6111 },
6112 { } /* end */
6113 };
6114
6115 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6116 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6117 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6118 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6119 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6121 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6122 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6124 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6125 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6126 {
6127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6128 /* .name = "Capture Source", */
6129 .name = "Input Source",
6130 .count = 1,
6131 .info = alc883_mux_enum_info,
6132 .get = alc883_mux_enum_get,
6133 .put = alc883_mux_enum_put,
6134 },
6135 { } /* end */
6136 };
6137
6138 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6139 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6140 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6142 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6143 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6146 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6147 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6148 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6149 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6150 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6151 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6152 {
6153 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6154 /* .name = "Capture Source", */
6155 .name = "Input Source",
6156 .count = 2,
6157 .info = alc883_mux_enum_info,
6158 .get = alc883_mux_enum_get,
6159 .put = alc883_mux_enum_put,
6160 },
6161 { } /* end */
6162 };
6163
6164 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6165 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6166 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6167 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6168 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6169 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6170 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6172 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6173 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6174 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6175 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6176 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6177 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6178 {
6179 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6180 /* .name = "Capture Source", */
6181 .name = "Input Source",
6182 .count = 2,
6183 .info = alc883_mux_enum_info,
6184 .get = alc883_mux_enum_get,
6185 .put = alc883_mux_enum_put,
6186 },
6187 { } /* end */
6188 };
6189
6190 static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6191 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6192 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6193 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6194 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6195 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6196 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6197 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6198 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6199 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6200 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6201 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6202 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6203 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6204 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6205 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6206 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6207 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6208 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6209 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6210 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6211 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6212 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6213 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6214 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6215 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6216 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6217 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6218 {
6219 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6220 /* .name = "Capture Source", */
6221 .name = "Input Source",
6222 .count = 2,
6223 .info = alc883_mux_enum_info,
6224 .get = alc883_mux_enum_get,
6225 .put = alc883_mux_enum_put,
6226 },
6227 { } /* end */
6228 };
6229
6230 static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6231 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6232 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6233 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6234 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6235 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6236 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6237 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6238 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6239 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6242 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6243 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6245 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6246 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6247 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6248 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6249 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6250 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6251 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6252 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6253 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6254 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6255 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6256 {
6257 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6258 /* .name = "Capture Source", */
6259 .name = "Input Source",
6260 .count = 2,
6261 .info = alc883_mux_enum_info,
6262 .get = alc883_mux_enum_get,
6263 .put = alc883_mux_enum_put,
6264 },
6265 { } /* end */
6266 };
6267
6268 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
6269 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6270 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6271 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6273 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6275 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6276 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6277 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6278 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6279 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6280 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6281 {
6282 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6283 /* .name = "Capture Source", */
6284 .name = "Input Source",
6285 .count = 2,
6286 .info = alc883_mux_enum_info,
6287 .get = alc883_mux_enum_get,
6288 .put = alc883_mux_enum_put,
6289 },
6290 { } /* end */
6291 };
6292
6293 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6294 {
6295 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6296 .name = "Channel Mode",
6297 .info = alc_ch_mode_info,
6298 .get = alc_ch_mode_get,
6299 .put = alc_ch_mode_put,
6300 },
6301 { } /* end */
6302 };
6303
6304 static struct hda_verb alc883_init_verbs[] = {
6305 /* ADC1: mute amp left and right */
6306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6307 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6308 /* ADC2: mute amp left and right */
6309 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6310 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6311 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6315 /* Rear mixer */
6316 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6317 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6318 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6319 /* CLFE mixer */
6320 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6321 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6322 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6323 /* Side mixer */
6324 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6325 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6326 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6327
6328 /* mute analog input loopbacks */
6329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6333 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6334
6335 /* Front Pin: output 0 (0x0c) */
6336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6337 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6338 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6339 /* Rear Pin: output 1 (0x0d) */
6340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6342 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6343 /* CLFE Pin: output 2 (0x0e) */
6344 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6345 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6346 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6347 /* Side Pin: output 3 (0x0f) */
6348 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6349 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6350 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6351 /* Mic (rear) pin: input vref at 80% */
6352 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6353 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6354 /* Front Mic pin: input vref at 80% */
6355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6357 /* Line In pin: input */
6358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6359 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6360 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6361 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6362 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6363 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6364 /* CD pin widget for input */
6365 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6366
6367 /* FIXME: use matrix-type input source selection */
6368 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6369 /* Input mixer2 */
6370 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6374 /* Input mixer3 */
6375 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6379 { }
6380 };
6381
6382 static struct hda_verb alc883_tagra_verbs[] = {
6383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6385
6386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6387 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6388
6389 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6390 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6391 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6392
6393 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6394 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6395 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6396 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6397
6398 { } /* end */
6399 };
6400
6401 static struct hda_verb alc883_lenovo_101e_verbs[] = {
6402 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6403 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
6404 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
6405 { } /* end */
6406 };
6407
6408 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
6409 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6410 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6411 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6413 { } /* end */
6414 };
6415
6416 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
6417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6418 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6419 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6420 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
6421 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6422 { } /* end */
6423 };
6424
6425 static struct hda_verb alc888_6st_hp_verbs[] = {
6426 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6427 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
6428 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
6429 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
6430 { }
6431 };
6432
6433 static struct hda_verb alc888_3st_hp_verbs[] = {
6434 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
6435 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
6436 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
6437 { }
6438 };
6439
6440 static struct hda_verb alc888_3st_hp_2ch_init[] = {
6441 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6442 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6443 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6444 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6445 { }
6446 };
6447
6448 static struct hda_verb alc888_3st_hp_6ch_init[] = {
6449 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6450 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6451 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6452 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6453 { }
6454 };
6455
6456 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
6457 { 2, alc888_3st_hp_2ch_init },
6458 { 6, alc888_3st_hp_6ch_init },
6459 };
6460
6461 /* toggle front-jack and RCA according to the hp-jack state */
6462 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
6463 {
6464 unsigned int present;
6465
6466 present = snd_hda_codec_read(codec, 0x1b, 0,
6467 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6468 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6469 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6470 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6471 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6472 }
6473
6474 /* toggle RCA according to the front-jack state */
6475 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
6476 {
6477 unsigned int present;
6478
6479 present = snd_hda_codec_read(codec, 0x14, 0,
6480 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6481 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6482 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6483 }
6484
6485 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
6486 unsigned int res)
6487 {
6488 if ((res >> 26) == ALC880_HP_EVENT)
6489 alc888_lenovo_ms7195_front_automute(codec);
6490 if ((res >> 26) == ALC880_FRONT_EVENT)
6491 alc888_lenovo_ms7195_rca_automute(codec);
6492 }
6493
6494 static struct hda_verb alc883_medion_md2_verbs[] = {
6495 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6496 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6497
6498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6499
6500 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6501 { } /* end */
6502 };
6503
6504 /* toggle speaker-output according to the hp-jack state */
6505 static void alc883_medion_md2_automute(struct hda_codec *codec)
6506 {
6507 unsigned int present;
6508
6509 present = snd_hda_codec_read(codec, 0x14, 0,
6510 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6511 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6512 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6513 }
6514
6515 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
6516 unsigned int res)
6517 {
6518 if ((res >> 26) == ALC880_HP_EVENT)
6519 alc883_medion_md2_automute(codec);
6520 }
6521
6522 /* toggle speaker-output according to the hp-jack state */
6523 static void alc883_tagra_automute(struct hda_codec *codec)
6524 {
6525 unsigned int present;
6526 unsigned char bits;
6527
6528 present = snd_hda_codec_read(codec, 0x14, 0,
6529 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6530 bits = present ? HDA_AMP_MUTE : 0;
6531 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6532 HDA_AMP_MUTE, bits);
6533 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6534 present ? 1 : 3);
6535 }
6536
6537 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
6538 {
6539 if ((res >> 26) == ALC880_HP_EVENT)
6540 alc883_tagra_automute(codec);
6541 }
6542
6543 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
6544 {
6545 unsigned int present;
6546 unsigned char bits;
6547
6548 present = snd_hda_codec_read(codec, 0x14, 0,
6549 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6550 bits = present ? HDA_AMP_MUTE : 0;
6551 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6552 HDA_AMP_MUTE, bits);
6553 }
6554
6555 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
6556 {
6557 unsigned int present;
6558 unsigned char bits;
6559
6560 present = snd_hda_codec_read(codec, 0x1b, 0,
6561 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6562 bits = present ? HDA_AMP_MUTE : 0;
6563 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6564 HDA_AMP_MUTE, bits);
6565 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6566 HDA_AMP_MUTE, bits);
6567 }
6568
6569 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
6570 unsigned int res)
6571 {
6572 if ((res >> 26) == ALC880_HP_EVENT)
6573 alc883_lenovo_101e_all_automute(codec);
6574 if ((res >> 26) == ALC880_FRONT_EVENT)
6575 alc883_lenovo_101e_ispeaker_automute(codec);
6576 }
6577
6578 static struct hda_verb alc883_acer_eapd_verbs[] = {
6579 /* HP Pin: output 0 (0x0c) */
6580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6581 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6582 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6583 /* Front Pin: output 0 (0x0c) */
6584 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6585 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6586 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
6587 /* eanable EAPD on medion laptop */
6588 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6589 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
6590 { }
6591 };
6592
6593 /*
6594 * generic initialization of ADC, input mixers and output mixers
6595 */
6596 static struct hda_verb alc883_auto_init_verbs[] = {
6597 /*
6598 * Unmute ADC0-2 and set the default input to mic-in
6599 */
6600 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6601 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6602 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6603 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6604
6605 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6606 * mixer widget
6607 * Note: PASD motherboards uses the Line In 2 as the input for
6608 * front panel mic (mic 2)
6609 */
6610 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6611 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6612 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6613 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6614 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6616
6617 /*
6618 * Set up output mixers (0x0c - 0x0f)
6619 */
6620 /* set vol=0 to output mixers */
6621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6622 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6623 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6624 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6625 /* set up input amps for analog loopback */
6626 /* Amp Indices: DAC = 0, mixer = 1 */
6627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6629 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6630 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6631 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6632 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6633 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6634 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6635 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6636 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6637
6638 /* FIXME: use matrix-type input source selection */
6639 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6640 /* Input mixer1 */
6641 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6642 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6643 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6644 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6645 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6646 /* Input mixer2 */
6647 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6648 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6649 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6650 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
6651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6652
6653 { }
6654 };
6655
6656 /* capture mixer elements */
6657 static struct snd_kcontrol_new alc883_capture_mixer[] = {
6658 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6659 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6660 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6661 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6662 {
6663 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6664 /* The multiple "Capture Source" controls confuse alsamixer
6665 * So call somewhat different..
6666 * FIXME: the controls appear in the "playback" view!
6667 */
6668 /* .name = "Capture Source", */
6669 .name = "Input Source",
6670 .count = 2,
6671 .info = alc882_mux_enum_info,
6672 .get = alc882_mux_enum_get,
6673 .put = alc882_mux_enum_put,
6674 },
6675 { } /* end */
6676 };
6677
6678 #ifdef CONFIG_SND_HDA_POWER_SAVE
6679 #define alc883_loopbacks alc880_loopbacks
6680 #endif
6681
6682 /* pcm configuration: identiacal with ALC880 */
6683 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
6684 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
6685 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
6686 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
6687
6688 /*
6689 * configuration and preset
6690 */
6691 static const char *alc883_models[ALC883_MODEL_LAST] = {
6692 [ALC883_3ST_2ch_DIG] = "3stack-dig",
6693 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
6694 [ALC883_3ST_6ch] = "3stack-6ch",
6695 [ALC883_6ST_DIG] = "6stack-dig",
6696 [ALC883_TARGA_DIG] = "targa-dig",
6697 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
6698 [ALC883_ACER] = "acer",
6699 [ALC883_ACER_ASPIRE] = "acer-aspire",
6700 [ALC883_MEDION] = "medion",
6701 [ALC883_MEDION_MD2] = "medion-md2",
6702 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
6703 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
6704 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
6705 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
6706 [ALC888_6ST_HP] = "6stack-hp",
6707 [ALC888_3ST_HP] = "3stack-hp",
6708 [ALC883_AUTO] = "auto",
6709 };
6710
6711 static struct snd_pci_quirk alc883_cfg_tbl[] = {
6712 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
6713 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
6714 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
6715 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
6716 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
6717 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
6718 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
6719 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
6720 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
6721 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
6722 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
6723 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
6724 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
6725 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
6726 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
6727 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
6728 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
6729 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
6730 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
6731 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
6732 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
6733 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
6734 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
6735 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
6736 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
6737 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
6738 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
6739 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
6740 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
6741 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
6742 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
6743 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6744 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
6745 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
6746 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
6747 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
6748 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
6749 {}
6750 };
6751
6752 static struct alc_config_preset alc883_presets[] = {
6753 [ALC883_3ST_2ch_DIG] = {
6754 .mixers = { alc883_3ST_2ch_mixer },
6755 .init_verbs = { alc883_init_verbs },
6756 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6757 .dac_nids = alc883_dac_nids,
6758 .dig_out_nid = ALC883_DIGOUT_NID,
6759 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6760 .adc_nids = alc883_adc_nids,
6761 .dig_in_nid = ALC883_DIGIN_NID,
6762 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6763 .channel_mode = alc883_3ST_2ch_modes,
6764 .input_mux = &alc883_capture_source,
6765 },
6766 [ALC883_3ST_6ch_DIG] = {
6767 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6768 .init_verbs = { alc883_init_verbs },
6769 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6770 .dac_nids = alc883_dac_nids,
6771 .dig_out_nid = ALC883_DIGOUT_NID,
6772 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6773 .adc_nids = alc883_adc_nids,
6774 .dig_in_nid = ALC883_DIGIN_NID,
6775 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6776 .channel_mode = alc883_3ST_6ch_modes,
6777 .need_dac_fix = 1,
6778 .input_mux = &alc883_capture_source,
6779 },
6780 [ALC883_3ST_6ch] = {
6781 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6782 .init_verbs = { alc883_init_verbs },
6783 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6784 .dac_nids = alc883_dac_nids,
6785 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6786 .adc_nids = alc883_adc_nids,
6787 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6788 .channel_mode = alc883_3ST_6ch_modes,
6789 .need_dac_fix = 1,
6790 .input_mux = &alc883_capture_source,
6791 },
6792 [ALC883_6ST_DIG] = {
6793 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
6794 .init_verbs = { alc883_init_verbs },
6795 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6796 .dac_nids = alc883_dac_nids,
6797 .dig_out_nid = ALC883_DIGOUT_NID,
6798 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6799 .adc_nids = alc883_adc_nids,
6800 .dig_in_nid = ALC883_DIGIN_NID,
6801 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6802 .channel_mode = alc883_sixstack_modes,
6803 .input_mux = &alc883_capture_source,
6804 },
6805 [ALC883_TARGA_DIG] = {
6806 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
6807 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6808 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6809 .dac_nids = alc883_dac_nids,
6810 .dig_out_nid = ALC883_DIGOUT_NID,
6811 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6812 .adc_nids = alc883_adc_nids,
6813 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6814 .channel_mode = alc883_3ST_6ch_modes,
6815 .need_dac_fix = 1,
6816 .input_mux = &alc883_capture_source,
6817 .unsol_event = alc883_tagra_unsol_event,
6818 .init_hook = alc883_tagra_automute,
6819 },
6820 [ALC883_TARGA_2ch_DIG] = {
6821 .mixers = { alc883_tagra_2ch_mixer},
6822 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
6823 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6824 .dac_nids = alc883_dac_nids,
6825 .dig_out_nid = ALC883_DIGOUT_NID,
6826 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6827 .adc_nids = alc883_adc_nids,
6828 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6829 .channel_mode = alc883_3ST_2ch_modes,
6830 .input_mux = &alc883_capture_source,
6831 .unsol_event = alc883_tagra_unsol_event,
6832 .init_hook = alc883_tagra_automute,
6833 },
6834 [ALC883_ACER] = {
6835 .mixers = { alc883_base_mixer,
6836 alc883_chmode_mixer },
6837 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6838 * and the headphone jack. Turn this on and rely on the
6839 * standard mute methods whenever the user wants to turn
6840 * these outputs off.
6841 */
6842 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
6843 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6844 .dac_nids = alc883_dac_nids,
6845 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6846 .adc_nids = alc883_adc_nids,
6847 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6848 .channel_mode = alc883_3ST_2ch_modes,
6849 .input_mux = &alc883_capture_source,
6850 },
6851 [ALC883_ACER_ASPIRE] = {
6852 .mixers = { alc883_acer_aspire_mixer, alc883_chmode_mixer },
6853 /* On TravelMate laptops, GPIO 0 enables the internal speaker
6854 * and the headphone jack. Turn this on and rely on the
6855 * standard mute methods whenever the user wants to turn
6856 * these outputs off.
6857 */
6858 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
6859 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6860 .dac_nids = alc883_dac_nids,
6861 .dig_out_nid = ALC883_DIGOUT_NID,
6862 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6863 .adc_nids = alc883_adc_nids,
6864 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6865 .channel_mode = alc883_3ST_2ch_modes,
6866 .input_mux = &alc883_capture_source,
6867 },
6868 [ALC883_MEDION] = {
6869 .mixers = { alc883_fivestack_mixer,
6870 alc883_chmode_mixer },
6871 .init_verbs = { alc883_init_verbs,
6872 alc883_medion_eapd_verbs },
6873 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6874 .dac_nids = alc883_dac_nids,
6875 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6876 .adc_nids = alc883_adc_nids,
6877 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6878 .channel_mode = alc883_sixstack_modes,
6879 .input_mux = &alc883_capture_source,
6880 },
6881 [ALC883_MEDION_MD2] = {
6882 .mixers = { alc883_medion_md2_mixer},
6883 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
6884 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6885 .dac_nids = alc883_dac_nids,
6886 .dig_out_nid = ALC883_DIGOUT_NID,
6887 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6888 .adc_nids = alc883_adc_nids,
6889 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6890 .channel_mode = alc883_3ST_2ch_modes,
6891 .input_mux = &alc883_capture_source,
6892 .unsol_event = alc883_medion_md2_unsol_event,
6893 .init_hook = alc883_medion_md2_automute,
6894 },
6895 [ALC883_LAPTOP_EAPD] = {
6896 .mixers = { alc883_base_mixer,
6897 alc883_chmode_mixer },
6898 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
6899 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6900 .dac_nids = alc883_dac_nids,
6901 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6902 .adc_nids = alc883_adc_nids,
6903 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6904 .channel_mode = alc883_3ST_2ch_modes,
6905 .input_mux = &alc883_capture_source,
6906 },
6907 [ALC883_LENOVO_101E_2ch] = {
6908 .mixers = { alc883_lenovo_101e_2ch_mixer},
6909 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
6910 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6911 .dac_nids = alc883_dac_nids,
6912 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6913 .adc_nids = alc883_adc_nids,
6914 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6915 .channel_mode = alc883_3ST_2ch_modes,
6916 .input_mux = &alc883_lenovo_101e_capture_source,
6917 .unsol_event = alc883_lenovo_101e_unsol_event,
6918 .init_hook = alc883_lenovo_101e_all_automute,
6919 },
6920 [ALC883_LENOVO_NB0763] = {
6921 .mixers = { alc883_lenovo_nb0763_mixer },
6922 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
6923 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6924 .dac_nids = alc883_dac_nids,
6925 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6926 .adc_nids = alc883_adc_nids,
6927 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
6928 .channel_mode = alc883_3ST_2ch_modes,
6929 .need_dac_fix = 1,
6930 .input_mux = &alc883_lenovo_nb0763_capture_source,
6931 .unsol_event = alc883_medion_md2_unsol_event,
6932 .init_hook = alc883_medion_md2_automute,
6933 },
6934 [ALC888_LENOVO_MS7195_DIG] = {
6935 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
6936 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
6937 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6938 .dac_nids = alc883_dac_nids,
6939 .dig_out_nid = ALC883_DIGOUT_NID,
6940 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6941 .adc_nids = alc883_adc_nids,
6942 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
6943 .channel_mode = alc883_3ST_6ch_modes,
6944 .need_dac_fix = 1,
6945 .input_mux = &alc883_capture_source,
6946 .unsol_event = alc883_lenovo_ms7195_unsol_event,
6947 .init_hook = alc888_lenovo_ms7195_front_automute,
6948 },
6949 [ALC888_6ST_HP] = {
6950 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
6951 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
6952 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6953 .dac_nids = alc883_dac_nids,
6954 .dig_out_nid = ALC883_DIGOUT_NID,
6955 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6956 .adc_nids = alc883_adc_nids,
6957 .dig_in_nid = ALC883_DIGIN_NID,
6958 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
6959 .channel_mode = alc883_sixstack_modes,
6960 .input_mux = &alc883_capture_source,
6961 },
6962 [ALC888_3ST_HP] = {
6963 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
6964 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
6965 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
6966 .dac_nids = alc883_dac_nids,
6967 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
6968 .adc_nids = alc883_adc_nids,
6969 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
6970 .channel_mode = alc888_3st_hp_modes,
6971 .need_dac_fix = 1,
6972 .input_mux = &alc883_capture_source,
6973 },
6974 };
6975
6976
6977 /*
6978 * BIOS auto configuration
6979 */
6980 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
6981 hda_nid_t nid, int pin_type,
6982 int dac_idx)
6983 {
6984 /* set as output */
6985 struct alc_spec *spec = codec->spec;
6986 int idx;
6987
6988 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6989 idx = 4;
6990 else
6991 idx = spec->multiout.dac_nids[dac_idx] - 2;
6992
6993 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6994 pin_type);
6995 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6996 AMP_OUT_UNMUTE);
6997 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6998
6999 }
7000
7001 static void alc883_auto_init_multi_out(struct hda_codec *codec)
7002 {
7003 struct alc_spec *spec = codec->spec;
7004 int i;
7005
7006 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
7007 for (i = 0; i <= HDA_SIDE; i++) {
7008 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7009 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7010 if (nid)
7011 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
7012 i);
7013 }
7014 }
7015
7016 static void alc883_auto_init_hp_out(struct hda_codec *codec)
7017 {
7018 struct alc_spec *spec = codec->spec;
7019 hda_nid_t pin;
7020
7021 pin = spec->autocfg.hp_pins[0];
7022 if (pin) /* connect to front */
7023 /* use dac 0 */
7024 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7025 }
7026
7027 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7028 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7029
7030 static void alc883_auto_init_analog_input(struct hda_codec *codec)
7031 {
7032 struct alc_spec *spec = codec->spec;
7033 int i;
7034
7035 for (i = 0; i < AUTO_PIN_LAST; i++) {
7036 hda_nid_t nid = spec->autocfg.input_pins[i];
7037 if (alc883_is_input_pin(nid)) {
7038 snd_hda_codec_write(codec, nid, 0,
7039 AC_VERB_SET_PIN_WIDGET_CONTROL,
7040 (i <= AUTO_PIN_FRONT_MIC ?
7041 PIN_VREF80 : PIN_IN));
7042 if (nid != ALC883_PIN_CD_NID)
7043 snd_hda_codec_write(codec, nid, 0,
7044 AC_VERB_SET_AMP_GAIN_MUTE,
7045 AMP_OUT_MUTE);
7046 }
7047 }
7048 }
7049
7050 /* almost identical with ALC880 parser... */
7051 static int alc883_parse_auto_config(struct hda_codec *codec)
7052 {
7053 struct alc_spec *spec = codec->spec;
7054 int err = alc880_parse_auto_config(codec);
7055
7056 if (err < 0)
7057 return err;
7058 else if (err > 0)
7059 /* hack - override the init verbs */
7060 spec->init_verbs[0] = alc883_auto_init_verbs;
7061 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7062 spec->num_mixers++;
7063 return err;
7064 }
7065
7066 /* additional initialization for auto-configuration model */
7067 static void alc883_auto_init(struct hda_codec *codec)
7068 {
7069 alc883_auto_init_multi_out(codec);
7070 alc883_auto_init_hp_out(codec);
7071 alc883_auto_init_analog_input(codec);
7072 }
7073
7074 static int patch_alc883(struct hda_codec *codec)
7075 {
7076 struct alc_spec *spec;
7077 int err, board_config;
7078
7079 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7080 if (spec == NULL)
7081 return -ENOMEM;
7082
7083 codec->spec = spec;
7084
7085 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7086 alc883_models,
7087 alc883_cfg_tbl);
7088 if (board_config < 0) {
7089 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7090 "trying auto-probe from BIOS...\n");
7091 board_config = ALC883_AUTO;
7092 }
7093
7094 if (board_config == ALC883_AUTO) {
7095 /* automatic parse from the BIOS config */
7096 err = alc883_parse_auto_config(codec);
7097 if (err < 0) {
7098 alc_free(codec);
7099 return err;
7100 } else if (!err) {
7101 printk(KERN_INFO
7102 "hda_codec: Cannot set up configuration "
7103 "from BIOS. Using base mode...\n");
7104 board_config = ALC883_3ST_2ch_DIG;
7105 }
7106 }
7107
7108 if (board_config != ALC883_AUTO)
7109 setup_preset(spec, &alc883_presets[board_config]);
7110
7111 spec->stream_name_analog = "ALC883 Analog";
7112 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7113 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7114
7115 spec->stream_name_digital = "ALC883 Digital";
7116 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7117 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7118
7119 if (!spec->adc_nids && spec->input_mux) {
7120 spec->adc_nids = alc883_adc_nids;
7121 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7122 }
7123
7124 codec->patch_ops = alc_patch_ops;
7125 if (board_config == ALC883_AUTO)
7126 spec->init_hook = alc883_auto_init;
7127 #ifdef CONFIG_SND_HDA_POWER_SAVE
7128 if (!spec->loopback.amplist)
7129 spec->loopback.amplist = alc883_loopbacks;
7130 #endif
7131
7132 return 0;
7133 }
7134
7135 /*
7136 * ALC262 support
7137 */
7138
7139 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7140 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
7141
7142 #define alc262_dac_nids alc260_dac_nids
7143 #define alc262_adc_nids alc882_adc_nids
7144 #define alc262_adc_nids_alt alc882_adc_nids_alt
7145
7146 #define alc262_modes alc260_modes
7147 #define alc262_capture_source alc882_capture_source
7148
7149 static struct snd_kcontrol_new alc262_base_mixer[] = {
7150 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7151 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7152 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7153 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7154 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7155 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7158 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7159 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7160 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7161 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7162 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7163 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7164 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7165 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7166 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7167 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7168 { } /* end */
7169 };
7170
7171 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7172 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7173 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7174 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7175 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7176 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7177 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7180 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7181 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7182 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7183 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7184 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7185 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7186 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
7187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7188 { } /* end */
7189 };
7190
7191 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
7192 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7193 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7194 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7195 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7196 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7197
7198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7200 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7201 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7202 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7203 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7204 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7205 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7206 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7207 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7208 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7209 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7210 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
7211 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
7212 { } /* end */
7213 };
7214
7215 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
7216 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7217 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7218 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7219 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7220 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7221 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7222 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
7223 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
7224 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
7225 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7226 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7227 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7228 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7229 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7230 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
7231 { } /* end */
7232 };
7233
7234 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
7235 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7236 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7237 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
7238 { } /* end */
7239 };
7240
7241 static struct hda_bind_ctls alc262_sony_bind_sw = {
7242 .ops = &snd_hda_bind_sw,
7243 .values = {
7244 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
7245 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7246 0,
7247 },
7248 };
7249
7250 static struct snd_kcontrol_new alc262_sony_mixer[] = {
7251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7252 HDA_BIND_SW("Front Playback Switch", &alc262_sony_bind_sw),
7253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7255 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7256 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7257 { } /* end */
7258 };
7259
7260 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
7261 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7262 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7263 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7265 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7266 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7267 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7268 { } /* end */
7269 };
7270
7271 #define alc262_capture_mixer alc882_capture_mixer
7272 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
7273
7274 /*
7275 * generic initialization of ADC, input mixers and output mixers
7276 */
7277 static struct hda_verb alc262_init_verbs[] = {
7278 /*
7279 * Unmute ADC0-2 and set the default input to mic-in
7280 */
7281 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7282 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7283 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7284 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7285 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7286 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7287
7288 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7289 * mixer widget
7290 * Note: PASD motherboards uses the Line In 2 as the input for
7291 * front panel mic (mic 2)
7292 */
7293 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7299
7300 /*
7301 * Set up output mixers (0x0c - 0x0e)
7302 */
7303 /* set vol=0 to output mixers */
7304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7305 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7307 /* set up input amps for analog loopback */
7308 /* Amp Indices: DAC = 0, mixer = 1 */
7309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7311 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7312 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7313 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7314 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7315
7316 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7318 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
7319 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7320 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7322
7323 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7325 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7326 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7327 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7328
7329 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7330 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7331
7332 /* FIXME: use matrix-type input source selection */
7333 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7334 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7336 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7337 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7338 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7339 /* Input mixer2 */
7340 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7341 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7342 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7343 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7344 /* Input mixer3 */
7345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7346 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7348 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7349
7350 { }
7351 };
7352
7353 static struct hda_verb alc262_hippo_unsol_verbs[] = {
7354 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7355 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7356 {}
7357 };
7358
7359 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
7360 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7361 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7362 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
7363
7364 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7365 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7366 {}
7367 };
7368
7369 static struct hda_verb alc262_sony_unsol_verbs[] = {
7370 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7372 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
7373
7374 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7375 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7376 };
7377
7378 /* mute/unmute internal speaker according to the hp jack and mute state */
7379 static void alc262_hippo_automute(struct hda_codec *codec)
7380 {
7381 struct alc_spec *spec = codec->spec;
7382 unsigned int mute;
7383 unsigned int present;
7384
7385 /* need to execute and sync at first */
7386 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
7387 present = snd_hda_codec_read(codec, 0x15, 0,
7388 AC_VERB_GET_PIN_SENSE, 0);
7389 spec->jack_present = (present & 0x80000000) != 0;
7390 if (spec->jack_present) {
7391 /* mute internal speaker */
7392 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7393 HDA_AMP_MUTE, HDA_AMP_MUTE);
7394 } else {
7395 /* unmute internal speaker if necessary */
7396 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
7397 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7398 HDA_AMP_MUTE, mute);
7399 }
7400 }
7401
7402 /* unsolicited event for HP jack sensing */
7403 static void alc262_hippo_unsol_event(struct hda_codec *codec,
7404 unsigned int res)
7405 {
7406 if ((res >> 26) != ALC880_HP_EVENT)
7407 return;
7408 alc262_hippo_automute(codec);
7409 }
7410
7411 static void alc262_hippo1_automute(struct hda_codec *codec)
7412 {
7413 unsigned int mute;
7414 unsigned int present;
7415
7416 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
7417 present = snd_hda_codec_read(codec, 0x1b, 0,
7418 AC_VERB_GET_PIN_SENSE, 0);
7419 present = (present & 0x80000000) != 0;
7420 if (present) {
7421 /* mute internal speaker */
7422 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7423 HDA_AMP_MUTE, HDA_AMP_MUTE);
7424 } else {
7425 /* unmute internal speaker if necessary */
7426 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
7427 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7428 HDA_AMP_MUTE, mute);
7429 }
7430 }
7431
7432 /* unsolicited event for HP jack sensing */
7433 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
7434 unsigned int res)
7435 {
7436 if ((res >> 26) != ALC880_HP_EVENT)
7437 return;
7438 alc262_hippo1_automute(codec);
7439 }
7440
7441 /*
7442 * fujitsu model
7443 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
7444 */
7445
7446 #define ALC_HP_EVENT 0x37
7447
7448 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
7449 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
7450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7451 {}
7452 };
7453
7454 static struct hda_input_mux alc262_fujitsu_capture_source = {
7455 .num_items = 2,
7456 .items = {
7457 { "Mic", 0x0 },
7458 { "CD", 0x4 },
7459 },
7460 };
7461
7462 static struct hda_input_mux alc262_HP_capture_source = {
7463 .num_items = 5,
7464 .items = {
7465 { "Mic", 0x0 },
7466 { "Front Mic", 0x3 },
7467 { "Line", 0x2 },
7468 { "CD", 0x4 },
7469 { "AUX IN", 0x6 },
7470 },
7471 };
7472
7473 /* mute/unmute internal speaker according to the hp jack and mute state */
7474 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
7475 {
7476 struct alc_spec *spec = codec->spec;
7477 unsigned int mute;
7478
7479 if (force || !spec->sense_updated) {
7480 unsigned int present;
7481 /* need to execute and sync at first */
7482 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
7483 present = snd_hda_codec_read(codec, 0x14, 0,
7484 AC_VERB_GET_PIN_SENSE, 0);
7485 spec->jack_present = (present & 0x80000000) != 0;
7486 spec->sense_updated = 1;
7487 }
7488 if (spec->jack_present) {
7489 /* mute internal speaker */
7490 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7491 HDA_AMP_MUTE, HDA_AMP_MUTE);
7492 } else {
7493 /* unmute internal speaker if necessary */
7494 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
7495 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7496 HDA_AMP_MUTE, mute);
7497 }
7498 }
7499
7500 /* unsolicited event for HP jack sensing */
7501 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
7502 unsigned int res)
7503 {
7504 if ((res >> 26) != ALC_HP_EVENT)
7505 return;
7506 alc262_fujitsu_automute(codec, 1);
7507 }
7508
7509 /* bind volumes of both NID 0x0c and 0x0d */
7510 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
7511 .ops = &snd_hda_bind_vol,
7512 .values = {
7513 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
7514 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
7515 0
7516 },
7517 };
7518
7519 /* bind hp and internal speaker mute (with plug check) */
7520 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
7521 struct snd_ctl_elem_value *ucontrol)
7522 {
7523 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
7524 long *valp = ucontrol->value.integer.value;
7525 int change;
7526
7527 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
7528 HDA_AMP_MUTE,
7529 valp[0] ? 0 : HDA_AMP_MUTE);
7530 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
7531 HDA_AMP_MUTE,
7532 valp[1] ? 0 : HDA_AMP_MUTE);
7533 if (change)
7534 alc262_fujitsu_automute(codec, 0);
7535 return change;
7536 }
7537
7538 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
7539 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
7540 {
7541 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7542 .name = "Master Playback Switch",
7543 .info = snd_hda_mixer_amp_switch_info,
7544 .get = snd_hda_mixer_amp_switch_get,
7545 .put = alc262_fujitsu_master_sw_put,
7546 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
7547 },
7548 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7549 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7550 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7551 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7552 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7553 { } /* end */
7554 };
7555
7556 /* additional init verbs for Benq laptops */
7557 static struct hda_verb alc262_EAPD_verbs[] = {
7558 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7559 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7560 {}
7561 };
7562
7563 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
7564 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7565 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7566
7567 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7568 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7569 {}
7570 };
7571
7572 /* add playback controls from the parsed DAC table */
7573 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
7574 const struct auto_pin_cfg *cfg)
7575 {
7576 hda_nid_t nid;
7577 int err;
7578
7579 spec->multiout.num_dacs = 1; /* only use one dac */
7580 spec->multiout.dac_nids = spec->private_dac_nids;
7581 spec->multiout.dac_nids[0] = 2;
7582
7583 nid = cfg->line_out_pins[0];
7584 if (nid) {
7585 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7586 "Front Playback Volume",
7587 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
7588 if (err < 0)
7589 return err;
7590 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7591 "Front Playback Switch",
7592 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
7593 if (err < 0)
7594 return err;
7595 }
7596
7597 nid = cfg->speaker_pins[0];
7598 if (nid) {
7599 if (nid == 0x16) {
7600 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7601 "Speaker Playback Volume",
7602 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7603 HDA_OUTPUT));
7604 if (err < 0)
7605 return err;
7606 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7607 "Speaker Playback Switch",
7608 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7609 HDA_OUTPUT));
7610 if (err < 0)
7611 return err;
7612 } else {
7613 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7614 "Speaker Playback Switch",
7615 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7616 HDA_OUTPUT));
7617 if (err < 0)
7618 return err;
7619 }
7620 }
7621 nid = cfg->hp_pins[0];
7622 if (nid) {
7623 /* spec->multiout.hp_nid = 2; */
7624 if (nid == 0x16) {
7625 err = add_control(spec, ALC_CTL_WIDGET_VOL,
7626 "Headphone Playback Volume",
7627 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
7628 HDA_OUTPUT));
7629 if (err < 0)
7630 return err;
7631 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7632 "Headphone Playback Switch",
7633 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
7634 HDA_OUTPUT));
7635 if (err < 0)
7636 return err;
7637 } else {
7638 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
7639 "Headphone Playback Switch",
7640 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
7641 HDA_OUTPUT));
7642 if (err < 0)
7643 return err;
7644 }
7645 }
7646 return 0;
7647 }
7648
7649 /* identical with ALC880 */
7650 #define alc262_auto_create_analog_input_ctls \
7651 alc880_auto_create_analog_input_ctls
7652
7653 /*
7654 * generic initialization of ADC, input mixers and output mixers
7655 */
7656 static struct hda_verb alc262_volume_init_verbs[] = {
7657 /*
7658 * Unmute ADC0-2 and set the default input to mic-in
7659 */
7660 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7661 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7662 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7663 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7664 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7665 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7666
7667 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7668 * mixer widget
7669 * Note: PASD motherboards uses the Line In 2 as the input for
7670 * front panel mic (mic 2)
7671 */
7672 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7673 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7674 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7675 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7676 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7677 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7678
7679 /*
7680 * Set up output mixers (0x0c - 0x0f)
7681 */
7682 /* set vol=0 to output mixers */
7683 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7684 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7685 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7686
7687 /* set up input amps for analog loopback */
7688 /* Amp Indices: DAC = 0, mixer = 1 */
7689 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7690 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7691 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7692 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7693 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7694 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7695
7696 /* FIXME: use matrix-type input source selection */
7697 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7698 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7699 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7701 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7702 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7703 /* Input mixer2 */
7704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7706 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7707 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7708 /* Input mixer3 */
7709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7713
7714 { }
7715 };
7716
7717 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
7718 /*
7719 * Unmute ADC0-2 and set the default input to mic-in
7720 */
7721 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7722 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7723 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7724 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7725 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7726 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7727
7728 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7729 * mixer widget
7730 * Note: PASD motherboards uses the Line In 2 as the input for
7731 * front panel mic (mic 2)
7732 */
7733 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7734 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7735 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7736 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7737 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7738 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
7740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
7741
7742 /*
7743 * Set up output mixers (0x0c - 0x0e)
7744 */
7745 /* set vol=0 to output mixers */
7746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7748 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7749
7750 /* set up input amps for analog loopback */
7751 /* Amp Indices: DAC = 0, mixer = 1 */
7752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7755 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7758
7759 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
7760 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7761 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7762
7763 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7764 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7765
7766 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7767 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7768
7769 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7770 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7771 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
7772 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7773 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
7774
7775 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7776 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7778 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7779 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7780 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7781
7782
7783 /* FIXME: use matrix-type input source selection */
7784 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7785 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7786 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7787 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7788 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7789 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7790 /* Input mixer2 */
7791 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7792 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7793 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7794 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7795 /* Input mixer3 */
7796 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7797 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7798 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7799 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7800
7801 { }
7802 };
7803
7804 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
7805 /*
7806 * Unmute ADC0-2 and set the default input to mic-in
7807 */
7808 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7809 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7810 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7811 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7812 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7813 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7814
7815 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7816 * mixer widget
7817 * Note: PASD motherboards uses the Line In 2 as the input for front
7818 * panel mic (mic 2)
7819 */
7820 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7821 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7822 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7823 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7824 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7825 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
7827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
7828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
7829 /*
7830 * Set up output mixers (0x0c - 0x0e)
7831 */
7832 /* set vol=0 to output mixers */
7833 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7836
7837 /* set up input amps for analog loopback */
7838 /* Amp Indices: DAC = 0, mixer = 1 */
7839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7844 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7845
7846
7847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
7848 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
7849 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
7850 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
7851 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
7852 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
7853 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
7854
7855 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7857
7858 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7859 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7860
7861 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
7862 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7863 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7864 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
7865 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7866 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
7867
7868 /* FIXME: use matrix-type input source selection */
7869 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7870 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7871 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
7872 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
7873 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
7874 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
7875 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
7876 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7877 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
7878 /* Input mixer2 */
7879 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7880 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7881 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7882 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7883 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7884 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7885 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7886 /* Input mixer3 */
7887 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7888 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
7889 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
7890 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
7891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
7892 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
7893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
7894
7895 { }
7896 };
7897
7898 #ifdef CONFIG_SND_HDA_POWER_SAVE
7899 #define alc262_loopbacks alc880_loopbacks
7900 #endif
7901
7902 /* pcm configuration: identiacal with ALC880 */
7903 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
7904 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
7905 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
7906 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
7907
7908 /*
7909 * BIOS auto configuration
7910 */
7911 static int alc262_parse_auto_config(struct hda_codec *codec)
7912 {
7913 struct alc_spec *spec = codec->spec;
7914 int err;
7915 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
7916
7917 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7918 alc262_ignore);
7919 if (err < 0)
7920 return err;
7921 if (!spec->autocfg.line_outs)
7922 return 0; /* can't find valid BIOS pin config */
7923 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
7924 if (err < 0)
7925 return err;
7926 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
7927 if (err < 0)
7928 return err;
7929
7930 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
7931
7932 if (spec->autocfg.dig_out_pin)
7933 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
7934 if (spec->autocfg.dig_in_pin)
7935 spec->dig_in_nid = ALC262_DIGIN_NID;
7936
7937 if (spec->kctl_alloc)
7938 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
7939
7940 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
7941 spec->num_mux_defs = 1;
7942 spec->input_mux = &spec->private_imux;
7943
7944 return 1;
7945 }
7946
7947 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
7948 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
7949 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
7950
7951
7952 /* init callback for auto-configuration model -- overriding the default init */
7953 static void alc262_auto_init(struct hda_codec *codec)
7954 {
7955 alc262_auto_init_multi_out(codec);
7956 alc262_auto_init_hp_out(codec);
7957 alc262_auto_init_analog_input(codec);
7958 }
7959
7960 /*
7961 * configuration and preset
7962 */
7963 static const char *alc262_models[ALC262_MODEL_LAST] = {
7964 [ALC262_BASIC] = "basic",
7965 [ALC262_HIPPO] = "hippo",
7966 [ALC262_HIPPO_1] = "hippo_1",
7967 [ALC262_FUJITSU] = "fujitsu",
7968 [ALC262_HP_BPC] = "hp-bpc",
7969 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
7970 [ALC262_BENQ_ED8] = "benq",
7971 [ALC262_BENQ_T31] = "benq-t31",
7972 [ALC262_SONY_ASSAMD] = "sony-assamd",
7973 [ALC262_AUTO] = "auto",
7974 };
7975
7976 static struct snd_pci_quirk alc262_cfg_tbl[] = {
7977 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
7978 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
7979 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
7980 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
7981 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
7982 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
7983 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
7984 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
7985 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
7986 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
7987 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
7988 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
7989 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
7990 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
7991 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
7992 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
7993 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
7994 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
7995 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
7996 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
7997 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
7998 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
7999 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8000 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
8001 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8002 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
8003 {}
8004 };
8005
8006 static struct alc_config_preset alc262_presets[] = {
8007 [ALC262_BASIC] = {
8008 .mixers = { alc262_base_mixer },
8009 .init_verbs = { alc262_init_verbs },
8010 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8011 .dac_nids = alc262_dac_nids,
8012 .hp_nid = 0x03,
8013 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8014 .channel_mode = alc262_modes,
8015 .input_mux = &alc262_capture_source,
8016 },
8017 [ALC262_HIPPO] = {
8018 .mixers = { alc262_base_mixer },
8019 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
8020 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8021 .dac_nids = alc262_dac_nids,
8022 .hp_nid = 0x03,
8023 .dig_out_nid = ALC262_DIGOUT_NID,
8024 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8025 .channel_mode = alc262_modes,
8026 .input_mux = &alc262_capture_source,
8027 .unsol_event = alc262_hippo_unsol_event,
8028 .init_hook = alc262_hippo_automute,
8029 },
8030 [ALC262_HIPPO_1] = {
8031 .mixers = { alc262_hippo1_mixer },
8032 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
8033 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8034 .dac_nids = alc262_dac_nids,
8035 .hp_nid = 0x02,
8036 .dig_out_nid = ALC262_DIGOUT_NID,
8037 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8038 .channel_mode = alc262_modes,
8039 .input_mux = &alc262_capture_source,
8040 .unsol_event = alc262_hippo1_unsol_event,
8041 .init_hook = alc262_hippo1_automute,
8042 },
8043 [ALC262_FUJITSU] = {
8044 .mixers = { alc262_fujitsu_mixer },
8045 .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
8046 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8047 .dac_nids = alc262_dac_nids,
8048 .hp_nid = 0x03,
8049 .dig_out_nid = ALC262_DIGOUT_NID,
8050 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8051 .channel_mode = alc262_modes,
8052 .input_mux = &alc262_fujitsu_capture_source,
8053 .unsol_event = alc262_fujitsu_unsol_event,
8054 },
8055 [ALC262_HP_BPC] = {
8056 .mixers = { alc262_HP_BPC_mixer },
8057 .init_verbs = { alc262_HP_BPC_init_verbs },
8058 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8059 .dac_nids = alc262_dac_nids,
8060 .hp_nid = 0x03,
8061 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8062 .channel_mode = alc262_modes,
8063 .input_mux = &alc262_HP_capture_source,
8064 },
8065 [ALC262_HP_BPC_D7000_WF] = {
8066 .mixers = { alc262_HP_BPC_WildWest_mixer },
8067 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8068 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8069 .dac_nids = alc262_dac_nids,
8070 .hp_nid = 0x03,
8071 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8072 .channel_mode = alc262_modes,
8073 .input_mux = &alc262_HP_capture_source,
8074 },
8075 [ALC262_HP_BPC_D7000_WL] = {
8076 .mixers = { alc262_HP_BPC_WildWest_mixer,
8077 alc262_HP_BPC_WildWest_option_mixer },
8078 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
8079 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8080 .dac_nids = alc262_dac_nids,
8081 .hp_nid = 0x03,
8082 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8083 .channel_mode = alc262_modes,
8084 .input_mux = &alc262_HP_capture_source,
8085 },
8086 [ALC262_BENQ_ED8] = {
8087 .mixers = { alc262_base_mixer },
8088 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
8089 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8090 .dac_nids = alc262_dac_nids,
8091 .hp_nid = 0x03,
8092 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8093 .channel_mode = alc262_modes,
8094 .input_mux = &alc262_capture_source,
8095 },
8096 [ALC262_SONY_ASSAMD] = {
8097 .mixers = { alc262_sony_mixer },
8098 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
8099 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8100 .dac_nids = alc262_dac_nids,
8101 .hp_nid = 0x02,
8102 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8103 .channel_mode = alc262_modes,
8104 .input_mux = &alc262_capture_source,
8105 .unsol_event = alc262_hippo_unsol_event,
8106 .init_hook = alc262_hippo_automute,
8107 },
8108 [ALC262_BENQ_T31] = {
8109 .mixers = { alc262_benq_t31_mixer },
8110 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
8111 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
8112 .dac_nids = alc262_dac_nids,
8113 .hp_nid = 0x03,
8114 .num_channel_mode = ARRAY_SIZE(alc262_modes),
8115 .channel_mode = alc262_modes,
8116 .input_mux = &alc262_capture_source,
8117 .unsol_event = alc262_hippo_unsol_event,
8118 .init_hook = alc262_hippo_automute,
8119 },
8120 };
8121
8122 static int patch_alc262(struct hda_codec *codec)
8123 {
8124 struct alc_spec *spec;
8125 int board_config;
8126 int err;
8127
8128 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8129 if (spec == NULL)
8130 return -ENOMEM;
8131
8132 codec->spec = spec;
8133 #if 0
8134 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
8135 * under-run
8136 */
8137 {
8138 int tmp;
8139 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8140 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
8141 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
8142 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
8143 }
8144 #endif
8145
8146 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
8147 alc262_models,
8148 alc262_cfg_tbl);
8149
8150 if (board_config < 0) {
8151 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
8152 "trying auto-probe from BIOS...\n");
8153 board_config = ALC262_AUTO;
8154 }
8155
8156 if (board_config == ALC262_AUTO) {
8157 /* automatic parse from the BIOS config */
8158 err = alc262_parse_auto_config(codec);
8159 if (err < 0) {
8160 alc_free(codec);
8161 return err;
8162 } else if (!err) {
8163 printk(KERN_INFO
8164 "hda_codec: Cannot set up configuration "
8165 "from BIOS. Using base mode...\n");
8166 board_config = ALC262_BASIC;
8167 }
8168 }
8169
8170 if (board_config != ALC262_AUTO)
8171 setup_preset(spec, &alc262_presets[board_config]);
8172
8173 spec->stream_name_analog = "ALC262 Analog";
8174 spec->stream_analog_playback = &alc262_pcm_analog_playback;
8175 spec->stream_analog_capture = &alc262_pcm_analog_capture;
8176
8177 spec->stream_name_digital = "ALC262 Digital";
8178 spec->stream_digital_playback = &alc262_pcm_digital_playback;
8179 spec->stream_digital_capture = &alc262_pcm_digital_capture;
8180
8181 if (!spec->adc_nids && spec->input_mux) {
8182 /* check whether NID 0x07 is valid */
8183 unsigned int wcap = get_wcaps(codec, 0x07);
8184
8185 /* get type */
8186 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8187 if (wcap != AC_WID_AUD_IN) {
8188 spec->adc_nids = alc262_adc_nids_alt;
8189 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
8190 spec->mixers[spec->num_mixers] =
8191 alc262_capture_alt_mixer;
8192 spec->num_mixers++;
8193 } else {
8194 spec->adc_nids = alc262_adc_nids;
8195 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
8196 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
8197 spec->num_mixers++;
8198 }
8199 }
8200
8201 codec->patch_ops = alc_patch_ops;
8202 if (board_config == ALC262_AUTO)
8203 spec->init_hook = alc262_auto_init;
8204 #ifdef CONFIG_SND_HDA_POWER_SAVE
8205 if (!spec->loopback.amplist)
8206 spec->loopback.amplist = alc262_loopbacks;
8207 #endif
8208
8209 return 0;
8210 }
8211
8212 /*
8213 * ALC268 channel source setting (2 channel)
8214 */
8215 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
8216 #define alc268_modes alc260_modes
8217
8218 static hda_nid_t alc268_dac_nids[2] = {
8219 /* front, hp */
8220 0x02, 0x03
8221 };
8222
8223 static hda_nid_t alc268_adc_nids[2] = {
8224 /* ADC0-1 */
8225 0x08, 0x07
8226 };
8227
8228 static hda_nid_t alc268_adc_nids_alt[1] = {
8229 /* ADC0 */
8230 0x08
8231 };
8232
8233 static struct snd_kcontrol_new alc268_base_mixer[] = {
8234 /* output mixer control */
8235 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
8236 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8237 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
8238 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8239 { }
8240 };
8241
8242 static struct hda_verb alc268_eapd_verbs[] = {
8243 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8244 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8245 { }
8246 };
8247
8248 /* Toshiba specific */
8249 #define alc268_toshiba_automute alc262_hippo_automute
8250
8251 static struct hda_verb alc268_toshiba_verbs[] = {
8252 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8253 { } /* end */
8254 };
8255
8256 /* Acer specific */
8257 #define alc268_acer_bind_master_vol alc262_fujitsu_bind_master_vol
8258 #define alc268_acer_master_sw_put alc262_fujitsu_master_sw_put
8259 #define alc268_acer_automute alc262_fujitsu_automute
8260
8261 static struct snd_kcontrol_new alc268_acer_mixer[] = {
8262 /* output mixer control */
8263 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
8264 {
8265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8266 .name = "Master Playback Switch",
8267 .info = snd_hda_mixer_amp_switch_info,
8268 .get = snd_hda_mixer_amp_switch_get,
8269 .put = alc268_acer_master_sw_put,
8270 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8271 },
8272 { }
8273 };
8274
8275 static struct hda_verb alc268_acer_verbs[] = {
8276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8277 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8278
8279 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8280 { }
8281 };
8282
8283 /* unsolicited event for HP jack sensing */
8284 static void alc268_toshiba_unsol_event(struct hda_codec *codec,
8285 unsigned int res)
8286 {
8287 if ((res >> 28) != ALC880_HP_EVENT)
8288 return;
8289 alc268_toshiba_automute(codec);
8290 }
8291
8292 static void alc268_acer_unsol_event(struct hda_codec *codec,
8293 unsigned int res)
8294 {
8295 if ((res >> 28) != ALC880_HP_EVENT)
8296 return;
8297 alc268_acer_automute(codec, 1);
8298 }
8299
8300 /*
8301 * generic initialization of ADC, input mixers and output mixers
8302 */
8303 static struct hda_verb alc268_base_init_verbs[] = {
8304 /* Unmute DAC0-1 and set vol = 0 */
8305 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8306 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8307 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8308 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8309 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8310 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8311
8312 /*
8313 * Set up output mixers (0x0c - 0x0e)
8314 */
8315 /* set vol=0 to output mixers */
8316 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8317 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8318 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8319 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
8320
8321 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8322 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8323
8324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8326 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8327 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8328 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8329 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8330 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8331 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8332
8333 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8334 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8335 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8336 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8337 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8338 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8339 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8340 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8341
8342 /* FIXME: use matrix-type input source selection */
8343 /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
8344 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8345 /* Input mixer2 */
8346 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8347 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8350
8351 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8355 { }
8356 };
8357
8358 /*
8359 * generic initialization of ADC, input mixers and output mixers
8360 */
8361 static struct hda_verb alc268_volume_init_verbs[] = {
8362 /* set output DAC */
8363 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8364 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8365 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8366 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8367
8368 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8369 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8371 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8372 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8373
8374 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8376 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8377 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8378 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8379
8380 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8381 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8382 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8383 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8384
8385 /* set PCBEEP vol = 0 */
8386 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
8387
8388 { }
8389 };
8390
8391 #define alc268_mux_enum_info alc_mux_enum_info
8392 #define alc268_mux_enum_get alc_mux_enum_get
8393
8394 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
8395 struct snd_ctl_elem_value *ucontrol)
8396 {
8397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8398 struct alc_spec *spec = codec->spec;
8399 const struct hda_input_mux *imux = spec->input_mux;
8400 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
8401 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
8402 hda_nid_t nid = capture_mixers[adc_idx];
8403 unsigned int *cur_val = &spec->cur_mux[adc_idx];
8404 unsigned int i, idx;
8405
8406 idx = ucontrol->value.enumerated.item[0];
8407 if (idx >= imux->num_items)
8408 idx = imux->num_items - 1;
8409 if (*cur_val == idx)
8410 return 0;
8411 for (i = 0; i < imux->num_items; i++) {
8412 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
8413 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
8414 imux->items[i].index,
8415 HDA_AMP_MUTE, v);
8416 snd_hda_codec_write_cache(codec, nid, 0,
8417 AC_VERB_SET_CONNECT_SEL,
8418 idx );
8419 }
8420 *cur_val = idx;
8421 return 1;
8422 }
8423
8424 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
8425 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8426 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8427 {
8428 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8429 /* The multiple "Capture Source" controls confuse alsamixer
8430 * So call somewhat different..
8431 * FIXME: the controls appear in the "playback" view!
8432 */
8433 /* .name = "Capture Source", */
8434 .name = "Input Source",
8435 .count = 1,
8436 .info = alc268_mux_enum_info,
8437 .get = alc268_mux_enum_get,
8438 .put = alc268_mux_enum_put,
8439 },
8440 { } /* end */
8441 };
8442
8443 static struct snd_kcontrol_new alc268_capture_mixer[] = {
8444 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
8445 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
8446 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
8447 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
8448 {
8449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8450 /* The multiple "Capture Source" controls confuse alsamixer
8451 * So call somewhat different..
8452 * FIXME: the controls appear in the "playback" view!
8453 */
8454 /* .name = "Capture Source", */
8455 .name = "Input Source",
8456 .count = 2,
8457 .info = alc268_mux_enum_info,
8458 .get = alc268_mux_enum_get,
8459 .put = alc268_mux_enum_put,
8460 },
8461 { } /* end */
8462 };
8463
8464 static struct hda_input_mux alc268_capture_source = {
8465 .num_items = 4,
8466 .items = {
8467 { "Mic", 0x0 },
8468 { "Front Mic", 0x1 },
8469 { "Line", 0x2 },
8470 { "CD", 0x3 },
8471 },
8472 };
8473
8474 /* create input playback/capture controls for the given pin */
8475 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
8476 const char *ctlname, int idx)
8477 {
8478 char name[32];
8479 int err;
8480
8481 sprintf(name, "%s Playback Volume", ctlname);
8482 if (nid == 0x14) {
8483 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8484 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
8485 HDA_OUTPUT));
8486 if (err < 0)
8487 return err;
8488 } else if (nid == 0x15) {
8489 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
8490 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
8491 HDA_OUTPUT));
8492 if (err < 0)
8493 return err;
8494 } else
8495 return -1;
8496 sprintf(name, "%s Playback Switch", ctlname);
8497 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
8498 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
8499 if (err < 0)
8500 return err;
8501 return 0;
8502 }
8503
8504 /* add playback controls from the parsed DAC table */
8505 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
8506 const struct auto_pin_cfg *cfg)
8507 {
8508 hda_nid_t nid;
8509 int err;
8510
8511 spec->multiout.num_dacs = 2; /* only use one dac */
8512 spec->multiout.dac_nids = spec->private_dac_nids;
8513 spec->multiout.dac_nids[0] = 2;
8514 spec->multiout.dac_nids[1] = 3;
8515
8516 nid = cfg->line_out_pins[0];
8517 if (nid)
8518 alc268_new_analog_output(spec, nid, "Front", 0);
8519
8520 nid = cfg->speaker_pins[0];
8521 if (nid == 0x1d) {
8522 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8523 "Speaker Playback Volume",
8524 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
8525 if (err < 0)
8526 return err;
8527 }
8528 nid = cfg->hp_pins[0];
8529 if (nid)
8530 alc268_new_analog_output(spec, nid, "Headphone", 0);
8531
8532 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
8533 if (nid == 0x16) {
8534 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8535 "Mono Playback Switch",
8536 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
8537 if (err < 0)
8538 return err;
8539 }
8540 return 0;
8541 }
8542
8543 /* create playback/capture controls for input pins */
8544 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
8545 const struct auto_pin_cfg *cfg)
8546 {
8547 struct hda_input_mux *imux = &spec->private_imux;
8548 int i, idx1;
8549
8550 for (i = 0; i < AUTO_PIN_LAST; i++) {
8551 switch(cfg->input_pins[i]) {
8552 case 0x18:
8553 idx1 = 0; /* Mic 1 */
8554 break;
8555 case 0x19:
8556 idx1 = 1; /* Mic 2 */
8557 break;
8558 case 0x1a:
8559 idx1 = 2; /* Line In */
8560 break;
8561 case 0x1c:
8562 idx1 = 3; /* CD */
8563 break;
8564 default:
8565 continue;
8566 }
8567 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
8568 imux->items[imux->num_items].index = idx1;
8569 imux->num_items++;
8570 }
8571 return 0;
8572 }
8573
8574 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
8575 {
8576 struct alc_spec *spec = codec->spec;
8577 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
8578 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
8579 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
8580 unsigned int dac_vol1, dac_vol2;
8581
8582 if (speaker_nid) {
8583 snd_hda_codec_write(codec, speaker_nid, 0,
8584 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
8585 snd_hda_codec_write(codec, 0x0f, 0,
8586 AC_VERB_SET_AMP_GAIN_MUTE,
8587 AMP_IN_UNMUTE(1));
8588 snd_hda_codec_write(codec, 0x10, 0,
8589 AC_VERB_SET_AMP_GAIN_MUTE,
8590 AMP_IN_UNMUTE(1));
8591 } else {
8592 snd_hda_codec_write(codec, 0x0f, 0,
8593 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8594 snd_hda_codec_write(codec, 0x10, 0,
8595 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
8596 }
8597
8598 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
8599 if (line_nid == 0x14)
8600 dac_vol2 = AMP_OUT_ZERO;
8601 else if (line_nid == 0x15)
8602 dac_vol1 = AMP_OUT_ZERO;
8603 if (hp_nid == 0x14)
8604 dac_vol2 = AMP_OUT_ZERO;
8605 else if (hp_nid == 0x15)
8606 dac_vol1 = AMP_OUT_ZERO;
8607 if (line_nid != 0x16 || hp_nid != 0x16 ||
8608 spec->autocfg.line_out_pins[1] != 0x16 ||
8609 spec->autocfg.line_out_pins[2] != 0x16)
8610 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
8611
8612 snd_hda_codec_write(codec, 0x02, 0,
8613 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
8614 snd_hda_codec_write(codec, 0x03, 0,
8615 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
8616 }
8617
8618 /* pcm configuration: identiacal with ALC880 */
8619 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
8620 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
8621 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
8622
8623 /*
8624 * BIOS auto configuration
8625 */
8626 static int alc268_parse_auto_config(struct hda_codec *codec)
8627 {
8628 struct alc_spec *spec = codec->spec;
8629 int err;
8630 static hda_nid_t alc268_ignore[] = { 0 };
8631
8632 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8633 alc268_ignore);
8634 if (err < 0)
8635 return err;
8636 if (!spec->autocfg.line_outs)
8637 return 0; /* can't find valid BIOS pin config */
8638
8639 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
8640 if (err < 0)
8641 return err;
8642 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
8643 if (err < 0)
8644 return err;
8645
8646 spec->multiout.max_channels = 2;
8647
8648 /* digital only support output */
8649 if (spec->autocfg.dig_out_pin)
8650 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
8651
8652 if (spec->kctl_alloc)
8653 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8654
8655 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
8656 spec->num_mux_defs = 1;
8657 spec->input_mux = &spec->private_imux;
8658
8659 return 1;
8660 }
8661
8662 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
8663 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
8664 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
8665
8666 /* init callback for auto-configuration model -- overriding the default init */
8667 static void alc268_auto_init(struct hda_codec *codec)
8668 {
8669 alc268_auto_init_multi_out(codec);
8670 alc268_auto_init_hp_out(codec);
8671 alc268_auto_init_mono_speaker_out(codec);
8672 alc268_auto_init_analog_input(codec);
8673 }
8674
8675 /*
8676 * configuration and preset
8677 */
8678 static const char *alc268_models[ALC268_MODEL_LAST] = {
8679 [ALC268_3ST] = "3stack",
8680 [ALC268_TOSHIBA] = "toshiba",
8681 [ALC268_ACER] = "acer",
8682 [ALC268_AUTO] = "auto",
8683 };
8684
8685 static struct snd_pci_quirk alc268_cfg_tbl[] = {
8686 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
8687 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
8688 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
8689 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
8690 {}
8691 };
8692
8693 static struct alc_config_preset alc268_presets[] = {
8694 [ALC268_3ST] = {
8695 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8696 .init_verbs = { alc268_base_init_verbs },
8697 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8698 .dac_nids = alc268_dac_nids,
8699 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8700 .adc_nids = alc268_adc_nids_alt,
8701 .hp_nid = 0x03,
8702 .dig_out_nid = ALC268_DIGOUT_NID,
8703 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8704 .channel_mode = alc268_modes,
8705 .input_mux = &alc268_capture_source,
8706 },
8707 [ALC268_TOSHIBA] = {
8708 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
8709 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
8710 alc268_toshiba_verbs },
8711 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8712 .dac_nids = alc268_dac_nids,
8713 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8714 .adc_nids = alc268_adc_nids_alt,
8715 .hp_nid = 0x03,
8716 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8717 .channel_mode = alc268_modes,
8718 .input_mux = &alc268_capture_source,
8719 .input_mux = &alc268_capture_source,
8720 .unsol_event = alc268_toshiba_unsol_event,
8721 .init_hook = alc268_toshiba_automute,
8722 },
8723 [ALC268_ACER] = {
8724 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
8725 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
8726 alc268_acer_verbs },
8727 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
8728 .dac_nids = alc268_dac_nids,
8729 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
8730 .adc_nids = alc268_adc_nids_alt,
8731 .hp_nid = 0x02,
8732 .num_channel_mode = ARRAY_SIZE(alc268_modes),
8733 .channel_mode = alc268_modes,
8734 .input_mux = &alc268_capture_source,
8735 .unsol_event = alc268_acer_unsol_event,
8736 },
8737 };
8738
8739 static int patch_alc268(struct hda_codec *codec)
8740 {
8741 struct alc_spec *spec;
8742 int board_config;
8743 int err;
8744
8745 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
8746 if (spec == NULL)
8747 return -ENOMEM;
8748
8749 codec->spec = spec;
8750
8751 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
8752 alc268_models,
8753 alc268_cfg_tbl);
8754
8755 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
8756 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
8757 "trying auto-probe from BIOS...\n");
8758 board_config = ALC268_AUTO;
8759 }
8760
8761 if (board_config == ALC268_AUTO) {
8762 /* automatic parse from the BIOS config */
8763 err = alc268_parse_auto_config(codec);
8764 if (err < 0) {
8765 alc_free(codec);
8766 return err;
8767 } else if (!err) {
8768 printk(KERN_INFO
8769 "hda_codec: Cannot set up configuration "
8770 "from BIOS. Using base mode...\n");
8771 board_config = ALC268_3ST;
8772 }
8773 }
8774
8775 if (board_config != ALC268_AUTO)
8776 setup_preset(spec, &alc268_presets[board_config]);
8777
8778 spec->stream_name_analog = "ALC268 Analog";
8779 spec->stream_analog_playback = &alc268_pcm_analog_playback;
8780 spec->stream_analog_capture = &alc268_pcm_analog_capture;
8781
8782 spec->stream_name_digital = "ALC268 Digital";
8783 spec->stream_digital_playback = &alc268_pcm_digital_playback;
8784
8785 if (board_config == ALC268_AUTO) {
8786 if (!spec->adc_nids && spec->input_mux) {
8787 /* check whether NID 0x07 is valid */
8788 unsigned int wcap = get_wcaps(codec, 0x07);
8789
8790 /* get type */
8791 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
8792 if (wcap != AC_WID_AUD_IN) {
8793 spec->adc_nids = alc268_adc_nids_alt;
8794 spec->num_adc_nids =
8795 ARRAY_SIZE(alc268_adc_nids_alt);
8796 spec->mixers[spec->num_mixers] =
8797 alc268_capture_alt_mixer;
8798 spec->num_mixers++;
8799 } else {
8800 spec->adc_nids = alc268_adc_nids;
8801 spec->num_adc_nids =
8802 ARRAY_SIZE(alc268_adc_nids);
8803 spec->mixers[spec->num_mixers] =
8804 alc268_capture_mixer;
8805 spec->num_mixers++;
8806 }
8807 }
8808 }
8809 codec->patch_ops = alc_patch_ops;
8810 if (board_config == ALC268_AUTO)
8811 spec->init_hook = alc268_auto_init;
8812
8813 return 0;
8814 }
8815
8816 /*
8817 * ALC861 channel source setting (2/6 channel selection for 3-stack)
8818 */
8819
8820 /*
8821 * set the path ways for 2 channel output
8822 * need to set the codec line out and mic 1 pin widgets to inputs
8823 */
8824 static struct hda_verb alc861_threestack_ch2_init[] = {
8825 /* set pin widget 1Ah (line in) for input */
8826 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8827 /* set pin widget 18h (mic1/2) for input, for mic also enable
8828 * the vref
8829 */
8830 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8831
8832 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8833 #if 0
8834 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8835 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8836 #endif
8837 { } /* end */
8838 };
8839 /*
8840 * 6ch mode
8841 * need to set the codec line out and mic 1 pin widgets to outputs
8842 */
8843 static struct hda_verb alc861_threestack_ch6_init[] = {
8844 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8845 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8846 /* set pin widget 18h (mic1) for output (CLFE)*/
8847 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8848
8849 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8850 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8851
8852 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8853 #if 0
8854 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8855 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8856 #endif
8857 { } /* end */
8858 };
8859
8860 static struct hda_channel_mode alc861_threestack_modes[2] = {
8861 { 2, alc861_threestack_ch2_init },
8862 { 6, alc861_threestack_ch6_init },
8863 };
8864 /* Set mic1 as input and unmute the mixer */
8865 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
8866 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8867 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8868 { } /* end */
8869 };
8870 /* Set mic1 as output and mute mixer */
8871 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
8872 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8873 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8874 { } /* end */
8875 };
8876
8877 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
8878 { 2, alc861_uniwill_m31_ch2_init },
8879 { 4, alc861_uniwill_m31_ch4_init },
8880 };
8881
8882 /* Set mic1 and line-in as input and unmute the mixer */
8883 static struct hda_verb alc861_asus_ch2_init[] = {
8884 /* set pin widget 1Ah (line in) for input */
8885 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
8886 /* set pin widget 18h (mic1/2) for input, for mic also enable
8887 * the vref
8888 */
8889 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
8890
8891 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
8892 #if 0
8893 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
8894 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
8895 #endif
8896 { } /* end */
8897 };
8898 /* Set mic1 nad line-in as output and mute mixer */
8899 static struct hda_verb alc861_asus_ch6_init[] = {
8900 /* set pin widget 1Ah (line in) for output (Back Surround)*/
8901 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8902 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8903 /* set pin widget 18h (mic1) for output (CLFE)*/
8904 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
8905 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
8906 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
8907 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
8908
8909 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
8910 #if 0
8911 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
8912 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
8913 #endif
8914 { } /* end */
8915 };
8916
8917 static struct hda_channel_mode alc861_asus_modes[2] = {
8918 { 2, alc861_asus_ch2_init },
8919 { 6, alc861_asus_ch6_init },
8920 };
8921
8922 /* patch-ALC861 */
8923
8924 static struct snd_kcontrol_new alc861_base_mixer[] = {
8925 /* output mixer control */
8926 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8927 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8928 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8929 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8930 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
8931
8932 /*Input mixer control */
8933 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8934 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8935 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8936 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8937 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8938 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8939 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8940 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8941 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8943
8944 /* Capture mixer control */
8945 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8946 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8947 {
8948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8949 .name = "Capture Source",
8950 .count = 1,
8951 .info = alc_mux_enum_info,
8952 .get = alc_mux_enum_get,
8953 .put = alc_mux_enum_put,
8954 },
8955 { } /* end */
8956 };
8957
8958 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
8959 /* output mixer control */
8960 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
8961 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
8962 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
8963 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
8964 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
8965
8966 /* Input mixer control */
8967 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
8968 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
8969 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
8970 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
8971 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
8972 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
8973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
8974 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
8975 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
8976 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
8977
8978 /* Capture mixer control */
8979 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
8980 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
8981 {
8982 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8983 .name = "Capture Source",
8984 .count = 1,
8985 .info = alc_mux_enum_info,
8986 .get = alc_mux_enum_get,
8987 .put = alc_mux_enum_put,
8988 },
8989 {
8990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8991 .name = "Channel Mode",
8992 .info = alc_ch_mode_info,
8993 .get = alc_ch_mode_get,
8994 .put = alc_ch_mode_put,
8995 .private_value = ARRAY_SIZE(alc861_threestack_modes),
8996 },
8997 { } /* end */
8998 };
8999
9000 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
9001 /* output mixer control */
9002 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9004 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9005
9006 /*Capture mixer control */
9007 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9008 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9009 {
9010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9011 .name = "Capture Source",
9012 .count = 1,
9013 .info = alc_mux_enum_info,
9014 .get = alc_mux_enum_get,
9015 .put = alc_mux_enum_put,
9016 },
9017
9018 { } /* end */
9019 };
9020
9021 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
9022 /* output mixer control */
9023 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9024 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9025 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9026 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9027 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
9028
9029 /* Input mixer control */
9030 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9031 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
9032 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9033 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9034 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9035 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9036 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9037 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9038 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
9040
9041 /* Capture mixer control */
9042 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9043 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9044 {
9045 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9046 .name = "Capture Source",
9047 .count = 1,
9048 .info = alc_mux_enum_info,
9049 .get = alc_mux_enum_get,
9050 .put = alc_mux_enum_put,
9051 },
9052 {
9053 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9054 .name = "Channel Mode",
9055 .info = alc_ch_mode_info,
9056 .get = alc_ch_mode_get,
9057 .put = alc_ch_mode_put,
9058 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
9059 },
9060 { } /* end */
9061 };
9062
9063 static struct snd_kcontrol_new alc861_asus_mixer[] = {
9064 /* output mixer control */
9065 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
9066 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
9067 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
9068 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
9069 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
9070
9071 /* Input mixer control */
9072 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
9073 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9074 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9075 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9076 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
9077 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
9078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
9079 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
9080 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
9081 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
9082
9083 /* Capture mixer control */
9084 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9085 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9086 {
9087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9088 .name = "Capture Source",
9089 .count = 1,
9090 .info = alc_mux_enum_info,
9091 .get = alc_mux_enum_get,
9092 .put = alc_mux_enum_put,
9093 },
9094 {
9095 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9096 .name = "Channel Mode",
9097 .info = alc_ch_mode_info,
9098 .get = alc_ch_mode_get,
9099 .put = alc_ch_mode_put,
9100 .private_value = ARRAY_SIZE(alc861_asus_modes),
9101 },
9102 { }
9103 };
9104
9105 /* additional mixer */
9106 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
9107 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
9108 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
9109 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
9110 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
9111 { }
9112 };
9113
9114 /*
9115 * generic initialization of ADC, input mixers and output mixers
9116 */
9117 static struct hda_verb alc861_base_init_verbs[] = {
9118 /*
9119 * Unmute ADC0 and set the default input to mic-in
9120 */
9121 /* port-A for surround (rear panel) */
9122 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9123 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
9124 /* port-B for mic-in (rear panel) with vref */
9125 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9126 /* port-C for line-in (rear panel) */
9127 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9128 /* port-D for Front */
9129 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9130 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9131 /* port-E for HP out (front panel) */
9132 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9133 /* route front PCM to HP */
9134 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9135 /* port-F for mic-in (front panel) with vref */
9136 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9137 /* port-G for CLFE (rear panel) */
9138 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9139 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9140 /* port-H for side (rear panel) */
9141 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9142 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
9143 /* CD-in */
9144 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9145 /* route front mic to ADC1*/
9146 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9147 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9148
9149 /* Unmute DAC0~3 & spdif out*/
9150 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9151 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9152 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9153 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9155
9156 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9157 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9158 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9159 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9160 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9161
9162 /* Unmute Stereo Mixer 15 */
9163 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9164 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9165 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9166 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9167
9168 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9169 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9170 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9171 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9172 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9173 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9174 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9175 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9176 /* hp used DAC 3 (Front) */
9177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9178 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9179
9180 { }
9181 };
9182
9183 static struct hda_verb alc861_threestack_init_verbs[] = {
9184 /*
9185 * Unmute ADC0 and set the default input to mic-in
9186 */
9187 /* port-A for surround (rear panel) */
9188 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9189 /* port-B for mic-in (rear panel) with vref */
9190 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9191 /* port-C for line-in (rear panel) */
9192 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9193 /* port-D for Front */
9194 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9195 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9196 /* port-E for HP out (front panel) */
9197 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
9198 /* route front PCM to HP */
9199 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9200 /* port-F for mic-in (front panel) with vref */
9201 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9202 /* port-G for CLFE (rear panel) */
9203 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9204 /* port-H for side (rear panel) */
9205 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9206 /* CD-in */
9207 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9208 /* route front mic to ADC1*/
9209 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9210 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9211 /* Unmute DAC0~3 & spdif out*/
9212 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9213 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9214 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9215 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9217
9218 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9219 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9220 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9221 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9222 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9223
9224 /* Unmute Stereo Mixer 15 */
9225 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9226 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9227 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9228 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9229
9230 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9231 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9232 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9233 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9234 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9235 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9236 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9237 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9238 /* hp used DAC 3 (Front) */
9239 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9240 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9241 { }
9242 };
9243
9244 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
9245 /*
9246 * Unmute ADC0 and set the default input to mic-in
9247 */
9248 /* port-A for surround (rear panel) */
9249 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9250 /* port-B for mic-in (rear panel) with vref */
9251 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9252 /* port-C for line-in (rear panel) */
9253 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9254 /* port-D for Front */
9255 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9256 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9257 /* port-E for HP out (front panel) */
9258 /* this has to be set to VREF80 */
9259 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9260 /* route front PCM to HP */
9261 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9262 /* port-F for mic-in (front panel) with vref */
9263 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9264 /* port-G for CLFE (rear panel) */
9265 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9266 /* port-H for side (rear panel) */
9267 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
9268 /* CD-in */
9269 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9270 /* route front mic to ADC1*/
9271 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9272 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9273 /* Unmute DAC0~3 & spdif out*/
9274 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9275 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9276 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9277 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9279
9280 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9281 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9282 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9283 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9284 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9285
9286 /* Unmute Stereo Mixer 15 */
9287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9290 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9291
9292 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9293 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9294 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9295 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9296 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9298 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9299 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9300 /* hp used DAC 3 (Front) */
9301 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9302 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9303 { }
9304 };
9305
9306 static struct hda_verb alc861_asus_init_verbs[] = {
9307 /*
9308 * Unmute ADC0 and set the default input to mic-in
9309 */
9310 /* port-A for surround (rear panel)
9311 * according to codec#0 this is the HP jack
9312 */
9313 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
9314 /* route front PCM to HP */
9315 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
9316 /* port-B for mic-in (rear panel) with vref */
9317 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9318 /* port-C for line-in (rear panel) */
9319 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9320 /* port-D for Front */
9321 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9322 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
9323 /* port-E for HP out (front panel) */
9324 /* this has to be set to VREF80 */
9325 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9326 /* route front PCM to HP */
9327 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
9328 /* port-F for mic-in (front panel) with vref */
9329 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
9330 /* port-G for CLFE (rear panel) */
9331 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9332 /* port-H for side (rear panel) */
9333 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
9334 /* CD-in */
9335 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
9336 /* route front mic to ADC1*/
9337 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9338 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9339 /* Unmute DAC0~3 & spdif out*/
9340 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9341 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9342 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9343 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9344 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9345 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9346 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9347 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9348 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9349 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9350
9351 /* Unmute Stereo Mixer 15 */
9352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9355 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
9356
9357 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9358 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9359 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9360 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9361 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9362 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9363 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9364 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9365 /* hp used DAC 3 (Front) */
9366 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9367 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9368 { }
9369 };
9370
9371 /* additional init verbs for ASUS laptops */
9372 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
9373 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
9374 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
9375 { }
9376 };
9377
9378 /*
9379 * generic initialization of ADC, input mixers and output mixers
9380 */
9381 static struct hda_verb alc861_auto_init_verbs[] = {
9382 /*
9383 * Unmute ADC0 and set the default input to mic-in
9384 */
9385 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
9386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9387
9388 /* Unmute DAC0~3 & spdif out*/
9389 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9390 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9391 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9392 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9394
9395 /* Unmute Mixer 14 (mic) 1c (Line in)*/
9396 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9397 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9398 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9399 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9400
9401 /* Unmute Stereo Mixer 15 */
9402 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9403 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9404 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9405 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
9406
9407 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9408 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9409 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9410 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9412 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9413 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9414 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9415
9416 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9417 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9418 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9419 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9420 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9421 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9422 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
9423 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
9424
9425 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
9426
9427 { }
9428 };
9429
9430 static struct hda_verb alc861_toshiba_init_verbs[] = {
9431 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9432
9433 { }
9434 };
9435
9436 /* toggle speaker-output according to the hp-jack state */
9437 static void alc861_toshiba_automute(struct hda_codec *codec)
9438 {
9439 unsigned int present;
9440
9441 present = snd_hda_codec_read(codec, 0x0f, 0,
9442 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9443 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
9444 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9445 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
9446 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
9447 }
9448
9449 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
9450 unsigned int res)
9451 {
9452 if ((res >> 26) == ALC880_HP_EVENT)
9453 alc861_toshiba_automute(codec);
9454 }
9455
9456 /* pcm configuration: identiacal with ALC880 */
9457 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
9458 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
9459 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
9460 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
9461
9462
9463 #define ALC861_DIGOUT_NID 0x07
9464
9465 static struct hda_channel_mode alc861_8ch_modes[1] = {
9466 { 8, NULL }
9467 };
9468
9469 static hda_nid_t alc861_dac_nids[4] = {
9470 /* front, surround, clfe, side */
9471 0x03, 0x06, 0x05, 0x04
9472 };
9473
9474 static hda_nid_t alc660_dac_nids[3] = {
9475 /* front, clfe, surround */
9476 0x03, 0x05, 0x06
9477 };
9478
9479 static hda_nid_t alc861_adc_nids[1] = {
9480 /* ADC0-2 */
9481 0x08,
9482 };
9483
9484 static struct hda_input_mux alc861_capture_source = {
9485 .num_items = 5,
9486 .items = {
9487 { "Mic", 0x0 },
9488 { "Front Mic", 0x3 },
9489 { "Line", 0x1 },
9490 { "CD", 0x4 },
9491 { "Mixer", 0x5 },
9492 },
9493 };
9494
9495 /* fill in the dac_nids table from the parsed pin configuration */
9496 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
9497 const struct auto_pin_cfg *cfg)
9498 {
9499 int i;
9500 hda_nid_t nid;
9501
9502 spec->multiout.dac_nids = spec->private_dac_nids;
9503 for (i = 0; i < cfg->line_outs; i++) {
9504 nid = cfg->line_out_pins[i];
9505 if (nid) {
9506 if (i >= ARRAY_SIZE(alc861_dac_nids))
9507 continue;
9508 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
9509 }
9510 }
9511 spec->multiout.num_dacs = cfg->line_outs;
9512 return 0;
9513 }
9514
9515 /* add playback controls from the parsed DAC table */
9516 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
9517 const struct auto_pin_cfg *cfg)
9518 {
9519 char name[32];
9520 static const char *chname[4] = {
9521 "Front", "Surround", NULL /*CLFE*/, "Side"
9522 };
9523 hda_nid_t nid;
9524 int i, idx, err;
9525
9526 for (i = 0; i < cfg->line_outs; i++) {
9527 nid = spec->multiout.dac_nids[i];
9528 if (!nid)
9529 continue;
9530 if (nid == 0x05) {
9531 /* Center/LFE */
9532 err = add_control(spec, ALC_CTL_BIND_MUTE,
9533 "Center Playback Switch",
9534 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
9535 HDA_OUTPUT));
9536 if (err < 0)
9537 return err;
9538 err = add_control(spec, ALC_CTL_BIND_MUTE,
9539 "LFE Playback Switch",
9540 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9541 HDA_OUTPUT));
9542 if (err < 0)
9543 return err;
9544 } else {
9545 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
9546 idx++)
9547 if (nid == alc861_dac_nids[idx])
9548 break;
9549 sprintf(name, "%s Playback Switch", chname[idx]);
9550 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
9551 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9552 HDA_OUTPUT));
9553 if (err < 0)
9554 return err;
9555 }
9556 }
9557 return 0;
9558 }
9559
9560 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
9561 {
9562 int err;
9563 hda_nid_t nid;
9564
9565 if (!pin)
9566 return 0;
9567
9568 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
9569 nid = 0x03;
9570 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9571 "Headphone Playback Switch",
9572 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9573 if (err < 0)
9574 return err;
9575 spec->multiout.hp_nid = nid;
9576 }
9577 return 0;
9578 }
9579
9580 /* create playback/capture controls for input pins */
9581 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
9582 const struct auto_pin_cfg *cfg)
9583 {
9584 struct hda_input_mux *imux = &spec->private_imux;
9585 int i, err, idx, idx1;
9586
9587 for (i = 0; i < AUTO_PIN_LAST; i++) {
9588 switch (cfg->input_pins[i]) {
9589 case 0x0c:
9590 idx1 = 1;
9591 idx = 2; /* Line In */
9592 break;
9593 case 0x0f:
9594 idx1 = 2;
9595 idx = 2; /* Line In */
9596 break;
9597 case 0x0d:
9598 idx1 = 0;
9599 idx = 1; /* Mic In */
9600 break;
9601 case 0x10:
9602 idx1 = 3;
9603 idx = 1; /* Mic In */
9604 break;
9605 case 0x11:
9606 idx1 = 4;
9607 idx = 0; /* CD */
9608 break;
9609 default:
9610 continue;
9611 }
9612
9613 err = new_analog_input(spec, cfg->input_pins[i],
9614 auto_pin_cfg_labels[i], idx, 0x15);
9615 if (err < 0)
9616 return err;
9617
9618 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9619 imux->items[imux->num_items].index = idx1;
9620 imux->num_items++;
9621 }
9622 return 0;
9623 }
9624
9625 static struct snd_kcontrol_new alc861_capture_mixer[] = {
9626 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
9627 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
9628
9629 {
9630 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9631 /* The multiple "Capture Source" controls confuse alsamixer
9632 * So call somewhat different..
9633 *FIXME: the controls appear in the "playback" view!
9634 */
9635 /* .name = "Capture Source", */
9636 .name = "Input Source",
9637 .count = 1,
9638 .info = alc_mux_enum_info,
9639 .get = alc_mux_enum_get,
9640 .put = alc_mux_enum_put,
9641 },
9642 { } /* end */
9643 };
9644
9645 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
9646 hda_nid_t nid,
9647 int pin_type, int dac_idx)
9648 {
9649 /* set as output */
9650
9651 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
9652 pin_type);
9653 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
9654 AMP_OUT_UNMUTE);
9655
9656 }
9657
9658 static void alc861_auto_init_multi_out(struct hda_codec *codec)
9659 {
9660 struct alc_spec *spec = codec->spec;
9661 int i;
9662
9663 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
9664 for (i = 0; i < spec->autocfg.line_outs; i++) {
9665 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9666 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9667 if (nid)
9668 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
9669 spec->multiout.dac_nids[i]);
9670 }
9671 }
9672
9673 static void alc861_auto_init_hp_out(struct hda_codec *codec)
9674 {
9675 struct alc_spec *spec = codec->spec;
9676 hda_nid_t pin;
9677
9678 pin = spec->autocfg.hp_pins[0];
9679 if (pin) /* connect to front */
9680 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
9681 spec->multiout.dac_nids[0]);
9682 }
9683
9684 static void alc861_auto_init_analog_input(struct hda_codec *codec)
9685 {
9686 struct alc_spec *spec = codec->spec;
9687 int i;
9688
9689 for (i = 0; i < AUTO_PIN_LAST; i++) {
9690 hda_nid_t nid = spec->autocfg.input_pins[i];
9691 if (nid >= 0x0c && nid <= 0x11) {
9692 snd_hda_codec_write(codec, nid, 0,
9693 AC_VERB_SET_PIN_WIDGET_CONTROL,
9694 i <= AUTO_PIN_FRONT_MIC ?
9695 PIN_VREF80 : PIN_IN);
9696 }
9697 }
9698 }
9699
9700 /* parse the BIOS configuration and set up the alc_spec */
9701 /* return 1 if successful, 0 if the proper config is not found,
9702 * or a negative error code
9703 */
9704 static int alc861_parse_auto_config(struct hda_codec *codec)
9705 {
9706 struct alc_spec *spec = codec->spec;
9707 int err;
9708 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
9709
9710 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9711 alc861_ignore);
9712 if (err < 0)
9713 return err;
9714 if (!spec->autocfg.line_outs)
9715 return 0; /* can't find valid BIOS pin config */
9716
9717 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
9718 if (err < 0)
9719 return err;
9720 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
9721 if (err < 0)
9722 return err;
9723 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
9724 if (err < 0)
9725 return err;
9726 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
9727 if (err < 0)
9728 return err;
9729
9730 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9731
9732 if (spec->autocfg.dig_out_pin)
9733 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
9734
9735 if (spec->kctl_alloc)
9736 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9737
9738 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
9739
9740 spec->num_mux_defs = 1;
9741 spec->input_mux = &spec->private_imux;
9742
9743 spec->adc_nids = alc861_adc_nids;
9744 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
9745 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
9746 spec->num_mixers++;
9747
9748 return 1;
9749 }
9750
9751 /* additional initialization for auto-configuration model */
9752 static void alc861_auto_init(struct hda_codec *codec)
9753 {
9754 alc861_auto_init_multi_out(codec);
9755 alc861_auto_init_hp_out(codec);
9756 alc861_auto_init_analog_input(codec);
9757 }
9758
9759 #ifdef CONFIG_SND_HDA_POWER_SAVE
9760 static struct hda_amp_list alc861_loopbacks[] = {
9761 { 0x15, HDA_INPUT, 0 },
9762 { 0x15, HDA_INPUT, 1 },
9763 { 0x15, HDA_INPUT, 2 },
9764 { 0x15, HDA_INPUT, 3 },
9765 { } /* end */
9766 };
9767 #endif
9768
9769
9770 /*
9771 * configuration and preset
9772 */
9773 static const char *alc861_models[ALC861_MODEL_LAST] = {
9774 [ALC861_3ST] = "3stack",
9775 [ALC660_3ST] = "3stack-660",
9776 [ALC861_3ST_DIG] = "3stack-dig",
9777 [ALC861_6ST_DIG] = "6stack-dig",
9778 [ALC861_UNIWILL_M31] = "uniwill-m31",
9779 [ALC861_TOSHIBA] = "toshiba",
9780 [ALC861_ASUS] = "asus",
9781 [ALC861_ASUS_LAPTOP] = "asus-laptop",
9782 [ALC861_AUTO] = "auto",
9783 };
9784
9785 static struct snd_pci_quirk alc861_cfg_tbl[] = {
9786 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
9787 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9788 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
9789 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
9790 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
9791 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
9792 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
9793 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
9794 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
9795 * Any other models that need this preset?
9796 */
9797 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
9798 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
9799 SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
9800 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
9801 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
9802 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
9803 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
9804 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
9805 {}
9806 };
9807
9808 static struct alc_config_preset alc861_presets[] = {
9809 [ALC861_3ST] = {
9810 .mixers = { alc861_3ST_mixer },
9811 .init_verbs = { alc861_threestack_init_verbs },
9812 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9813 .dac_nids = alc861_dac_nids,
9814 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9815 .channel_mode = alc861_threestack_modes,
9816 .need_dac_fix = 1,
9817 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9818 .adc_nids = alc861_adc_nids,
9819 .input_mux = &alc861_capture_source,
9820 },
9821 [ALC861_3ST_DIG] = {
9822 .mixers = { alc861_base_mixer },
9823 .init_verbs = { alc861_threestack_init_verbs },
9824 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9825 .dac_nids = alc861_dac_nids,
9826 .dig_out_nid = ALC861_DIGOUT_NID,
9827 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9828 .channel_mode = alc861_threestack_modes,
9829 .need_dac_fix = 1,
9830 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9831 .adc_nids = alc861_adc_nids,
9832 .input_mux = &alc861_capture_source,
9833 },
9834 [ALC861_6ST_DIG] = {
9835 .mixers = { alc861_base_mixer },
9836 .init_verbs = { alc861_base_init_verbs },
9837 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9838 .dac_nids = alc861_dac_nids,
9839 .dig_out_nid = ALC861_DIGOUT_NID,
9840 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
9841 .channel_mode = alc861_8ch_modes,
9842 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9843 .adc_nids = alc861_adc_nids,
9844 .input_mux = &alc861_capture_source,
9845 },
9846 [ALC660_3ST] = {
9847 .mixers = { alc861_3ST_mixer },
9848 .init_verbs = { alc861_threestack_init_verbs },
9849 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
9850 .dac_nids = alc660_dac_nids,
9851 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
9852 .channel_mode = alc861_threestack_modes,
9853 .need_dac_fix = 1,
9854 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9855 .adc_nids = alc861_adc_nids,
9856 .input_mux = &alc861_capture_source,
9857 },
9858 [ALC861_UNIWILL_M31] = {
9859 .mixers = { alc861_uniwill_m31_mixer },
9860 .init_verbs = { alc861_uniwill_m31_init_verbs },
9861 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9862 .dac_nids = alc861_dac_nids,
9863 .dig_out_nid = ALC861_DIGOUT_NID,
9864 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
9865 .channel_mode = alc861_uniwill_m31_modes,
9866 .need_dac_fix = 1,
9867 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9868 .adc_nids = alc861_adc_nids,
9869 .input_mux = &alc861_capture_source,
9870 },
9871 [ALC861_TOSHIBA] = {
9872 .mixers = { alc861_toshiba_mixer },
9873 .init_verbs = { alc861_base_init_verbs,
9874 alc861_toshiba_init_verbs },
9875 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9876 .dac_nids = alc861_dac_nids,
9877 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9878 .channel_mode = alc883_3ST_2ch_modes,
9879 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9880 .adc_nids = alc861_adc_nids,
9881 .input_mux = &alc861_capture_source,
9882 .unsol_event = alc861_toshiba_unsol_event,
9883 .init_hook = alc861_toshiba_automute,
9884 },
9885 [ALC861_ASUS] = {
9886 .mixers = { alc861_asus_mixer },
9887 .init_verbs = { alc861_asus_init_verbs },
9888 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9889 .dac_nids = alc861_dac_nids,
9890 .dig_out_nid = ALC861_DIGOUT_NID,
9891 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
9892 .channel_mode = alc861_asus_modes,
9893 .need_dac_fix = 1,
9894 .hp_nid = 0x06,
9895 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9896 .adc_nids = alc861_adc_nids,
9897 .input_mux = &alc861_capture_source,
9898 },
9899 [ALC861_ASUS_LAPTOP] = {
9900 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
9901 .init_verbs = { alc861_asus_init_verbs,
9902 alc861_asus_laptop_init_verbs },
9903 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
9904 .dac_nids = alc861_dac_nids,
9905 .dig_out_nid = ALC861_DIGOUT_NID,
9906 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9907 .channel_mode = alc883_3ST_2ch_modes,
9908 .need_dac_fix = 1,
9909 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
9910 .adc_nids = alc861_adc_nids,
9911 .input_mux = &alc861_capture_source,
9912 },
9913 };
9914
9915
9916 static int patch_alc861(struct hda_codec *codec)
9917 {
9918 struct alc_spec *spec;
9919 int board_config;
9920 int err;
9921
9922 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9923 if (spec == NULL)
9924 return -ENOMEM;
9925
9926 codec->spec = spec;
9927
9928 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
9929 alc861_models,
9930 alc861_cfg_tbl);
9931
9932 if (board_config < 0) {
9933 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
9934 "trying auto-probe from BIOS...\n");
9935 board_config = ALC861_AUTO;
9936 }
9937
9938 if (board_config == ALC861_AUTO) {
9939 /* automatic parse from the BIOS config */
9940 err = alc861_parse_auto_config(codec);
9941 if (err < 0) {
9942 alc_free(codec);
9943 return err;
9944 } else if (!err) {
9945 printk(KERN_INFO
9946 "hda_codec: Cannot set up configuration "
9947 "from BIOS. Using base mode...\n");
9948 board_config = ALC861_3ST_DIG;
9949 }
9950 }
9951
9952 if (board_config != ALC861_AUTO)
9953 setup_preset(spec, &alc861_presets[board_config]);
9954
9955 spec->stream_name_analog = "ALC861 Analog";
9956 spec->stream_analog_playback = &alc861_pcm_analog_playback;
9957 spec->stream_analog_capture = &alc861_pcm_analog_capture;
9958
9959 spec->stream_name_digital = "ALC861 Digital";
9960 spec->stream_digital_playback = &alc861_pcm_digital_playback;
9961 spec->stream_digital_capture = &alc861_pcm_digital_capture;
9962
9963 codec->patch_ops = alc_patch_ops;
9964 if (board_config == ALC861_AUTO)
9965 spec->init_hook = alc861_auto_init;
9966 #ifdef CONFIG_SND_HDA_POWER_SAVE
9967 if (!spec->loopback.amplist)
9968 spec->loopback.amplist = alc861_loopbacks;
9969 #endif
9970
9971 return 0;
9972 }
9973
9974 /*
9975 * ALC861-VD support
9976 *
9977 * Based on ALC882
9978 *
9979 * In addition, an independent DAC
9980 */
9981 #define ALC861VD_DIGOUT_NID 0x06
9982
9983 static hda_nid_t alc861vd_dac_nids[4] = {
9984 /* front, surr, clfe, side surr */
9985 0x02, 0x03, 0x04, 0x05
9986 };
9987
9988 /* dac_nids for ALC660vd are in a different order - according to
9989 * Realtek's driver.
9990 * This should probably tesult in a different mixer for 6stack models
9991 * of ALC660vd codecs, but for now there is only 3stack mixer
9992 * - and it is the same as in 861vd.
9993 * adc_nids in ALC660vd are (is) the same as in 861vd
9994 */
9995 static hda_nid_t alc660vd_dac_nids[3] = {
9996 /* front, rear, clfe, rear_surr */
9997 0x02, 0x04, 0x03
9998 };
9999
10000 static hda_nid_t alc861vd_adc_nids[1] = {
10001 /* ADC0 */
10002 0x09,
10003 };
10004
10005 /* input MUX */
10006 /* FIXME: should be a matrix-type input source selection */
10007 static struct hda_input_mux alc861vd_capture_source = {
10008 .num_items = 4,
10009 .items = {
10010 { "Mic", 0x0 },
10011 { "Front Mic", 0x1 },
10012 { "Line", 0x2 },
10013 { "CD", 0x4 },
10014 },
10015 };
10016
10017 static struct hda_input_mux alc861vd_dallas_capture_source = {
10018 .num_items = 3,
10019 .items = {
10020 { "Front Mic", 0x0 },
10021 { "ATAPI Mic", 0x1 },
10022 { "Line In", 0x5 },
10023 },
10024 };
10025
10026 static struct hda_input_mux alc861vd_hp_capture_source = {
10027 .num_items = 2,
10028 .items = {
10029 { "Front Mic", 0x0 },
10030 { "ATAPI Mic", 0x1 },
10031 },
10032 };
10033
10034 #define alc861vd_mux_enum_info alc_mux_enum_info
10035 #define alc861vd_mux_enum_get alc_mux_enum_get
10036
10037 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
10038 struct snd_ctl_elem_value *ucontrol)
10039 {
10040 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10041 struct alc_spec *spec = codec->spec;
10042 const struct hda_input_mux *imux = spec->input_mux;
10043 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
10044 static hda_nid_t capture_mixers[1] = { 0x22 };
10045 hda_nid_t nid = capture_mixers[adc_idx];
10046 unsigned int *cur_val = &spec->cur_mux[adc_idx];
10047 unsigned int i, idx;
10048
10049 idx = ucontrol->value.enumerated.item[0];
10050 if (idx >= imux->num_items)
10051 idx = imux->num_items - 1;
10052 if (*cur_val == idx)
10053 return 0;
10054 for (i = 0; i < imux->num_items; i++) {
10055 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
10056 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
10057 imux->items[i].index,
10058 HDA_AMP_MUTE, v);
10059 }
10060 *cur_val = idx;
10061 return 1;
10062 }
10063
10064 /*
10065 * 2ch mode
10066 */
10067 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
10068 { 2, NULL }
10069 };
10070
10071 /*
10072 * 6ch mode
10073 */
10074 static struct hda_verb alc861vd_6stack_ch6_init[] = {
10075 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10076 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10077 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10078 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10079 { } /* end */
10080 };
10081
10082 /*
10083 * 8ch mode
10084 */
10085 static struct hda_verb alc861vd_6stack_ch8_init[] = {
10086 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10087 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10088 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10089 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10090 { } /* end */
10091 };
10092
10093 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
10094 { 6, alc861vd_6stack_ch6_init },
10095 { 8, alc861vd_6stack_ch8_init },
10096 };
10097
10098 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
10099 {
10100 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10101 .name = "Channel Mode",
10102 .info = alc_ch_mode_info,
10103 .get = alc_ch_mode_get,
10104 .put = alc_ch_mode_put,
10105 },
10106 { } /* end */
10107 };
10108
10109 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
10110 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
10111 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
10112
10113 {
10114 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10115 /* The multiple "Capture Source" controls confuse alsamixer
10116 * So call somewhat different..
10117 *FIXME: the controls appear in the "playback" view!
10118 */
10119 /* .name = "Capture Source", */
10120 .name = "Input Source",
10121 .count = 1,
10122 .info = alc861vd_mux_enum_info,
10123 .get = alc861vd_mux_enum_get,
10124 .put = alc861vd_mux_enum_put,
10125 },
10126 { } /* end */
10127 };
10128
10129 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
10130 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
10131 */
10132 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
10133 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10134 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10135
10136 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10137 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
10138
10139 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
10140 HDA_OUTPUT),
10141 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
10142 HDA_OUTPUT),
10143 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10144 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
10145
10146 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
10147 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
10148
10149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10150
10151 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10153 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10154
10155 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10156 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10157 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10158
10159 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10160 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10161
10162 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10163 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10164
10165 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10166 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10167
10168 { } /* end */
10169 };
10170
10171 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
10172 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10173 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10174
10175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10176
10177 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10180
10181 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10182 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10183 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10184
10185 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10186 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10187
10188 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10189 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10190
10191 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
10192 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
10193
10194 { } /* end */
10195 };
10196
10197 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
10198 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10199 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
10200 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10201
10202 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10203
10204 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10207
10208 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10209 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10210 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10211
10212 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10213 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10214
10215 { } /* end */
10216 };
10217
10218 /* Pin assignment: Front=0x14, HP = 0x15,
10219 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
10220 */
10221 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
10222 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10223 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10224 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10225 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10228 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10229 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10230 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
10231 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
10232 { } /* end */
10233 };
10234
10235 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
10236 * Front Mic=0x18, ATAPI Mic = 0x19,
10237 */
10238 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
10239 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10240 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
10241 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10242 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
10243 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10244 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10245 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10246 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10247
10248 { } /* end */
10249 };
10250
10251 /*
10252 * generic initialization of ADC, input mixers and output mixers
10253 */
10254 static struct hda_verb alc861vd_volume_init_verbs[] = {
10255 /*
10256 * Unmute ADC0 and set the default input to mic-in
10257 */
10258 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10259 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10260
10261 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
10262 * the analog-loopback mixer widget
10263 */
10264 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10269 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10270
10271 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
10272 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10274 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10275 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
10276
10277 /*
10278 * Set up output mixers (0x02 - 0x05)
10279 */
10280 /* set vol=0 to output mixers */
10281 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10282 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10283 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10284 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10285
10286 /* set up input amps for analog loopback */
10287 /* Amp Indices: DAC = 0, mixer = 1 */
10288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10290 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10291 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10292 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10293 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10294 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10295 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10296
10297 { }
10298 };
10299
10300 /*
10301 * 3-stack pin configuration:
10302 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
10303 */
10304 static struct hda_verb alc861vd_3stack_init_verbs[] = {
10305 /*
10306 * Set pin mode and muting
10307 */
10308 /* set front pin widgets 0x14 for output */
10309 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10310 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10311 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10312
10313 /* Mic (rear) pin: input vref at 80% */
10314 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10316 /* Front Mic pin: input vref at 80% */
10317 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10318 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10319 /* Line In pin: input */
10320 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10321 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10322 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10323 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10324 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10325 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10326 /* CD pin widget for input */
10327 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10328
10329 { }
10330 };
10331
10332 /*
10333 * 6-stack pin configuration:
10334 */
10335 static struct hda_verb alc861vd_6stack_init_verbs[] = {
10336 /*
10337 * Set pin mode and muting
10338 */
10339 /* set front pin widgets 0x14 for output */
10340 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10341 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10342 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10343
10344 /* Rear Pin: output 1 (0x0d) */
10345 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10346 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10347 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10348 /* CLFE Pin: output 2 (0x0e) */
10349 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10350 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10351 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
10352 /* Side Pin: output 3 (0x0f) */
10353 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10354 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10355 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
10356
10357 /* Mic (rear) pin: input vref at 80% */
10358 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10359 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10360 /* Front Mic pin: input vref at 80% */
10361 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10362 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10363 /* Line In pin: input */
10364 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10365 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10366 /* Line-2 In: Headphone output (output 0 - 0x0c) */
10367 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10368 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10369 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10370 /* CD pin widget for input */
10371 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10372
10373 { }
10374 };
10375
10376 static struct hda_verb alc861vd_eapd_verbs[] = {
10377 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10378 { }
10379 };
10380
10381 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
10382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10384 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10385 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10386 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10387 {}
10388 };
10389
10390 /* toggle speaker-output according to the hp-jack state */
10391 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
10392 {
10393 unsigned int present;
10394 unsigned char bits;
10395
10396 present = snd_hda_codec_read(codec, 0x1b, 0,
10397 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10398 bits = present ? HDA_AMP_MUTE : 0;
10399 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10400 HDA_AMP_MUTE, bits);
10401 }
10402
10403 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
10404 {
10405 unsigned int present;
10406 unsigned char bits;
10407
10408 present = snd_hda_codec_read(codec, 0x18, 0,
10409 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10410 bits = present ? HDA_AMP_MUTE : 0;
10411 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
10412 HDA_AMP_MUTE, bits);
10413 }
10414
10415 static void alc861vd_lenovo_automute(struct hda_codec *codec)
10416 {
10417 alc861vd_lenovo_hp_automute(codec);
10418 alc861vd_lenovo_mic_automute(codec);
10419 }
10420
10421 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
10422 unsigned int res)
10423 {
10424 switch (res >> 26) {
10425 case ALC880_HP_EVENT:
10426 alc861vd_lenovo_hp_automute(codec);
10427 break;
10428 case ALC880_MIC_EVENT:
10429 alc861vd_lenovo_mic_automute(codec);
10430 break;
10431 }
10432 }
10433
10434 static struct hda_verb alc861vd_dallas_verbs[] = {
10435 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10436 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10437 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10438 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10439
10440 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10441 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10442 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10443 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10444 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10445 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10446 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10447 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10448
10449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10450 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10453 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10454 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10455 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10456 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10457
10458 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10459 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10460 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
10461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10462 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10463 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10464 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10465 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10466
10467 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10471
10472 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10473 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10474 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10475
10476 { } /* end */
10477 };
10478
10479 /* toggle speaker-output according to the hp-jack state */
10480 static void alc861vd_dallas_automute(struct hda_codec *codec)
10481 {
10482 unsigned int present;
10483
10484 present = snd_hda_codec_read(codec, 0x15, 0,
10485 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10486 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10487 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
10488 }
10489
10490 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
10491 {
10492 if ((res >> 26) == ALC880_HP_EVENT)
10493 alc861vd_dallas_automute(codec);
10494 }
10495
10496 #ifdef CONFIG_SND_HDA_POWER_SAVE
10497 #define alc861vd_loopbacks alc880_loopbacks
10498 #endif
10499
10500 /* pcm configuration: identiacal with ALC880 */
10501 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
10502 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
10503 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
10504 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
10505
10506 /*
10507 * configuration and preset
10508 */
10509 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
10510 [ALC660VD_3ST] = "3stack-660",
10511 [ALC660VD_3ST_DIG] = "3stack-660-digout",
10512 [ALC861VD_3ST] = "3stack",
10513 [ALC861VD_3ST_DIG] = "3stack-digout",
10514 [ALC861VD_6ST_DIG] = "6stack-digout",
10515 [ALC861VD_LENOVO] = "lenovo",
10516 [ALC861VD_DALLAS] = "dallas",
10517 [ALC861VD_HP] = "hp",
10518 [ALC861VD_AUTO] = "auto",
10519 };
10520
10521 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
10522 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
10523 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
10524 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
10525 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
10526 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
10527
10528 SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
10529 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
10530 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
10531 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
10532 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
10533 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
10534 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
10535 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
10536 {}
10537 };
10538
10539 static struct alc_config_preset alc861vd_presets[] = {
10540 [ALC660VD_3ST] = {
10541 .mixers = { alc861vd_3st_mixer },
10542 .init_verbs = { alc861vd_volume_init_verbs,
10543 alc861vd_3stack_init_verbs },
10544 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10545 .dac_nids = alc660vd_dac_nids,
10546 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10547 .adc_nids = alc861vd_adc_nids,
10548 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10549 .channel_mode = alc861vd_3stack_2ch_modes,
10550 .input_mux = &alc861vd_capture_source,
10551 },
10552 [ALC660VD_3ST_DIG] = {
10553 .mixers = { alc861vd_3st_mixer },
10554 .init_verbs = { alc861vd_volume_init_verbs,
10555 alc861vd_3stack_init_verbs },
10556 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10557 .dac_nids = alc660vd_dac_nids,
10558 .dig_out_nid = ALC861VD_DIGOUT_NID,
10559 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10560 .adc_nids = alc861vd_adc_nids,
10561 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10562 .channel_mode = alc861vd_3stack_2ch_modes,
10563 .input_mux = &alc861vd_capture_source,
10564 },
10565 [ALC861VD_3ST] = {
10566 .mixers = { alc861vd_3st_mixer },
10567 .init_verbs = { alc861vd_volume_init_verbs,
10568 alc861vd_3stack_init_verbs },
10569 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10570 .dac_nids = alc861vd_dac_nids,
10571 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10572 .channel_mode = alc861vd_3stack_2ch_modes,
10573 .input_mux = &alc861vd_capture_source,
10574 },
10575 [ALC861VD_3ST_DIG] = {
10576 .mixers = { alc861vd_3st_mixer },
10577 .init_verbs = { alc861vd_volume_init_verbs,
10578 alc861vd_3stack_init_verbs },
10579 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10580 .dac_nids = alc861vd_dac_nids,
10581 .dig_out_nid = ALC861VD_DIGOUT_NID,
10582 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10583 .channel_mode = alc861vd_3stack_2ch_modes,
10584 .input_mux = &alc861vd_capture_source,
10585 },
10586 [ALC861VD_6ST_DIG] = {
10587 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
10588 .init_verbs = { alc861vd_volume_init_verbs,
10589 alc861vd_6stack_init_verbs },
10590 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10591 .dac_nids = alc861vd_dac_nids,
10592 .dig_out_nid = ALC861VD_DIGOUT_NID,
10593 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
10594 .channel_mode = alc861vd_6stack_modes,
10595 .input_mux = &alc861vd_capture_source,
10596 },
10597 [ALC861VD_LENOVO] = {
10598 .mixers = { alc861vd_lenovo_mixer },
10599 .init_verbs = { alc861vd_volume_init_verbs,
10600 alc861vd_3stack_init_verbs,
10601 alc861vd_eapd_verbs,
10602 alc861vd_lenovo_unsol_verbs },
10603 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
10604 .dac_nids = alc660vd_dac_nids,
10605 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10606 .adc_nids = alc861vd_adc_nids,
10607 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10608 .channel_mode = alc861vd_3stack_2ch_modes,
10609 .input_mux = &alc861vd_capture_source,
10610 .unsol_event = alc861vd_lenovo_unsol_event,
10611 .init_hook = alc861vd_lenovo_automute,
10612 },
10613 [ALC861VD_DALLAS] = {
10614 .mixers = { alc861vd_dallas_mixer },
10615 .init_verbs = { alc861vd_dallas_verbs },
10616 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10617 .dac_nids = alc861vd_dac_nids,
10618 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10619 .adc_nids = alc861vd_adc_nids,
10620 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10621 .channel_mode = alc861vd_3stack_2ch_modes,
10622 .input_mux = &alc861vd_dallas_capture_source,
10623 .unsol_event = alc861vd_dallas_unsol_event,
10624 .init_hook = alc861vd_dallas_automute,
10625 },
10626 [ALC861VD_HP] = {
10627 .mixers = { alc861vd_hp_mixer },
10628 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
10629 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
10630 .dac_nids = alc861vd_dac_nids,
10631 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
10632 .dig_out_nid = ALC861VD_DIGOUT_NID,
10633 .adc_nids = alc861vd_adc_nids,
10634 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
10635 .channel_mode = alc861vd_3stack_2ch_modes,
10636 .input_mux = &alc861vd_hp_capture_source,
10637 .unsol_event = alc861vd_dallas_unsol_event,
10638 .init_hook = alc861vd_dallas_automute,
10639 },
10640 };
10641
10642 /*
10643 * BIOS auto configuration
10644 */
10645 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
10646 hda_nid_t nid, int pin_type, int dac_idx)
10647 {
10648 /* set as output */
10649 snd_hda_codec_write(codec, nid, 0,
10650 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
10651 snd_hda_codec_write(codec, nid, 0,
10652 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
10653 }
10654
10655 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
10656 {
10657 struct alc_spec *spec = codec->spec;
10658 int i;
10659
10660 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
10661 for (i = 0; i <= HDA_SIDE; i++) {
10662 hda_nid_t nid = spec->autocfg.line_out_pins[i];
10663 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10664 if (nid)
10665 alc861vd_auto_set_output_and_unmute(codec, nid,
10666 pin_type, i);
10667 }
10668 }
10669
10670
10671 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
10672 {
10673 struct alc_spec *spec = codec->spec;
10674 hda_nid_t pin;
10675
10676 pin = spec->autocfg.hp_pins[0];
10677 if (pin) /* connect to front and use dac 0 */
10678 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
10679 }
10680
10681 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
10682 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
10683
10684 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
10685 {
10686 struct alc_spec *spec = codec->spec;
10687 int i;
10688
10689 for (i = 0; i < AUTO_PIN_LAST; i++) {
10690 hda_nid_t nid = spec->autocfg.input_pins[i];
10691 if (alc861vd_is_input_pin(nid)) {
10692 snd_hda_codec_write(codec, nid, 0,
10693 AC_VERB_SET_PIN_WIDGET_CONTROL,
10694 i <= AUTO_PIN_FRONT_MIC ?
10695 PIN_VREF80 : PIN_IN);
10696 if (nid != ALC861VD_PIN_CD_NID)
10697 snd_hda_codec_write(codec, nid, 0,
10698 AC_VERB_SET_AMP_GAIN_MUTE,
10699 AMP_OUT_MUTE);
10700 }
10701 }
10702 }
10703
10704 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
10705 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
10706
10707 /* add playback controls from the parsed DAC table */
10708 /* Based on ALC880 version. But ALC861VD has separate,
10709 * different NIDs for mute/unmute switch and volume control */
10710 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
10711 const struct auto_pin_cfg *cfg)
10712 {
10713 char name[32];
10714 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
10715 hda_nid_t nid_v, nid_s;
10716 int i, err;
10717
10718 for (i = 0; i < cfg->line_outs; i++) {
10719 if (!spec->multiout.dac_nids[i])
10720 continue;
10721 nid_v = alc861vd_idx_to_mixer_vol(
10722 alc880_dac_to_idx(
10723 spec->multiout.dac_nids[i]));
10724 nid_s = alc861vd_idx_to_mixer_switch(
10725 alc880_dac_to_idx(
10726 spec->multiout.dac_nids[i]));
10727
10728 if (i == 2) {
10729 /* Center/LFE */
10730 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10731 "Center Playback Volume",
10732 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
10733 HDA_OUTPUT));
10734 if (err < 0)
10735 return err;
10736 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10737 "LFE Playback Volume",
10738 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
10739 HDA_OUTPUT));
10740 if (err < 0)
10741 return err;
10742 err = add_control(spec, ALC_CTL_BIND_MUTE,
10743 "Center Playback Switch",
10744 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
10745 HDA_INPUT));
10746 if (err < 0)
10747 return err;
10748 err = add_control(spec, ALC_CTL_BIND_MUTE,
10749 "LFE Playback Switch",
10750 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
10751 HDA_INPUT));
10752 if (err < 0)
10753 return err;
10754 } else {
10755 sprintf(name, "%s Playback Volume", chname[i]);
10756 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10757 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
10758 HDA_OUTPUT));
10759 if (err < 0)
10760 return err;
10761 sprintf(name, "%s Playback Switch", chname[i]);
10762 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10763 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
10764 HDA_INPUT));
10765 if (err < 0)
10766 return err;
10767 }
10768 }
10769 return 0;
10770 }
10771
10772 /* add playback controls for speaker and HP outputs */
10773 /* Based on ALC880 version. But ALC861VD has separate,
10774 * different NIDs for mute/unmute switch and volume control */
10775 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
10776 hda_nid_t pin, const char *pfx)
10777 {
10778 hda_nid_t nid_v, nid_s;
10779 int err;
10780 char name[32];
10781
10782 if (!pin)
10783 return 0;
10784
10785 if (alc880_is_fixed_pin(pin)) {
10786 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
10787 /* specify the DAC as the extra output */
10788 if (!spec->multiout.hp_nid)
10789 spec->multiout.hp_nid = nid_v;
10790 else
10791 spec->multiout.extra_out_nid[0] = nid_v;
10792 /* control HP volume/switch on the output mixer amp */
10793 nid_v = alc861vd_idx_to_mixer_vol(
10794 alc880_fixed_pin_idx(pin));
10795 nid_s = alc861vd_idx_to_mixer_switch(
10796 alc880_fixed_pin_idx(pin));
10797
10798 sprintf(name, "%s Playback Volume", pfx);
10799 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10800 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
10801 if (err < 0)
10802 return err;
10803 sprintf(name, "%s Playback Switch", pfx);
10804 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
10805 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
10806 if (err < 0)
10807 return err;
10808 } else if (alc880_is_multi_pin(pin)) {
10809 /* set manual connection */
10810 /* we have only a switch on HP-out PIN */
10811 sprintf(name, "%s Playback Switch", pfx);
10812 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10813 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
10814 if (err < 0)
10815 return err;
10816 }
10817 return 0;
10818 }
10819
10820 /* parse the BIOS configuration and set up the alc_spec
10821 * return 1 if successful, 0 if the proper config is not found,
10822 * or a negative error code
10823 * Based on ALC880 version - had to change it to override
10824 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
10825 static int alc861vd_parse_auto_config(struct hda_codec *codec)
10826 {
10827 struct alc_spec *spec = codec->spec;
10828 int err;
10829 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
10830
10831 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10832 alc861vd_ignore);
10833 if (err < 0)
10834 return err;
10835 if (!spec->autocfg.line_outs)
10836 return 0; /* can't find valid BIOS pin config */
10837
10838 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10839 if (err < 0)
10840 return err;
10841 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
10842 if (err < 0)
10843 return err;
10844 err = alc861vd_auto_create_extra_out(spec,
10845 spec->autocfg.speaker_pins[0],
10846 "Speaker");
10847 if (err < 0)
10848 return err;
10849 err = alc861vd_auto_create_extra_out(spec,
10850 spec->autocfg.hp_pins[0],
10851 "Headphone");
10852 if (err < 0)
10853 return err;
10854 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
10855 if (err < 0)
10856 return err;
10857
10858 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10859
10860 if (spec->autocfg.dig_out_pin)
10861 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
10862
10863 if (spec->kctl_alloc)
10864 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10865
10866 spec->init_verbs[spec->num_init_verbs++]
10867 = alc861vd_volume_init_verbs;
10868
10869 spec->num_mux_defs = 1;
10870 spec->input_mux = &spec->private_imux;
10871
10872 return 1;
10873 }
10874
10875 /* additional initialization for auto-configuration model */
10876 static void alc861vd_auto_init(struct hda_codec *codec)
10877 {
10878 alc861vd_auto_init_multi_out(codec);
10879 alc861vd_auto_init_hp_out(codec);
10880 alc861vd_auto_init_analog_input(codec);
10881 }
10882
10883 static int patch_alc861vd(struct hda_codec *codec)
10884 {
10885 struct alc_spec *spec;
10886 int err, board_config;
10887
10888 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10889 if (spec == NULL)
10890 return -ENOMEM;
10891
10892 codec->spec = spec;
10893
10894 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
10895 alc861vd_models,
10896 alc861vd_cfg_tbl);
10897
10898 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
10899 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
10900 "ALC861VD, trying auto-probe from BIOS...\n");
10901 board_config = ALC861VD_AUTO;
10902 }
10903
10904 if (board_config == ALC861VD_AUTO) {
10905 /* automatic parse from the BIOS config */
10906 err = alc861vd_parse_auto_config(codec);
10907 if (err < 0) {
10908 alc_free(codec);
10909 return err;
10910 } else if (!err) {
10911 printk(KERN_INFO
10912 "hda_codec: Cannot set up configuration "
10913 "from BIOS. Using base mode...\n");
10914 board_config = ALC861VD_3ST;
10915 }
10916 }
10917
10918 if (board_config != ALC861VD_AUTO)
10919 setup_preset(spec, &alc861vd_presets[board_config]);
10920
10921 spec->stream_name_analog = "ALC861VD Analog";
10922 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
10923 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
10924
10925 spec->stream_name_digital = "ALC861VD Digital";
10926 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
10927 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
10928
10929 spec->adc_nids = alc861vd_adc_nids;
10930 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
10931
10932 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
10933 spec->num_mixers++;
10934
10935 codec->patch_ops = alc_patch_ops;
10936
10937 if (board_config == ALC861VD_AUTO)
10938 spec->init_hook = alc861vd_auto_init;
10939 #ifdef CONFIG_SND_HDA_POWER_SAVE
10940 if (!spec->loopback.amplist)
10941 spec->loopback.amplist = alc861vd_loopbacks;
10942 #endif
10943
10944 return 0;
10945 }
10946
10947 /*
10948 * ALC662 support
10949 *
10950 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
10951 * configuration. Each pin widget can choose any input DACs and a mixer.
10952 * Each ADC is connected from a mixer of all inputs. This makes possible
10953 * 6-channel independent captures.
10954 *
10955 * In addition, an independent DAC for the multi-playback (not used in this
10956 * driver yet).
10957 */
10958 #define ALC662_DIGOUT_NID 0x06
10959 #define ALC662_DIGIN_NID 0x0a
10960
10961 static hda_nid_t alc662_dac_nids[4] = {
10962 /* front, rear, clfe, rear_surr */
10963 0x02, 0x03, 0x04
10964 };
10965
10966 static hda_nid_t alc662_adc_nids[1] = {
10967 /* ADC1-2 */
10968 0x09,
10969 };
10970 /* input MUX */
10971 /* FIXME: should be a matrix-type input source selection */
10972
10973 static struct hda_input_mux alc662_capture_source = {
10974 .num_items = 4,
10975 .items = {
10976 { "Mic", 0x0 },
10977 { "Front Mic", 0x1 },
10978 { "Line", 0x2 },
10979 { "CD", 0x4 },
10980 },
10981 };
10982
10983 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
10984 .num_items = 2,
10985 .items = {
10986 { "Mic", 0x1 },
10987 { "Line", 0x2 },
10988 },
10989 };
10990 #define alc662_mux_enum_info alc_mux_enum_info
10991 #define alc662_mux_enum_get alc_mux_enum_get
10992
10993 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
10994 struct snd_ctl_elem_value *ucontrol)
10995 {
10996 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10997 struct alc_spec *spec = codec->spec;
10998 const struct hda_input_mux *imux = spec->input_mux;
10999 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11000 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
11001 hda_nid_t nid = capture_mixers[adc_idx];
11002 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11003 unsigned int i, idx;
11004
11005 idx = ucontrol->value.enumerated.item[0];
11006 if (idx >= imux->num_items)
11007 idx = imux->num_items - 1;
11008 if (*cur_val == idx)
11009 return 0;
11010 for (i = 0; i < imux->num_items; i++) {
11011 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11012 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11013 imux->items[i].index,
11014 HDA_AMP_MUTE, v);
11015 }
11016 *cur_val = idx;
11017 return 1;
11018 }
11019 /*
11020 * 2ch mode
11021 */
11022 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
11023 { 2, NULL }
11024 };
11025
11026 /*
11027 * 2ch mode
11028 */
11029 static struct hda_verb alc662_3ST_ch2_init[] = {
11030 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
11031 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11032 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
11033 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
11034 { } /* end */
11035 };
11036
11037 /*
11038 * 6ch mode
11039 */
11040 static struct hda_verb alc662_3ST_ch6_init[] = {
11041 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11042 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11043 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
11044 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11045 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11046 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
11047 { } /* end */
11048 };
11049
11050 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
11051 { 2, alc662_3ST_ch2_init },
11052 { 6, alc662_3ST_ch6_init },
11053 };
11054
11055 /*
11056 * 2ch mode
11057 */
11058 static struct hda_verb alc662_sixstack_ch6_init[] = {
11059 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11060 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11061 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11062 { } /* end */
11063 };
11064
11065 /*
11066 * 6ch mode
11067 */
11068 static struct hda_verb alc662_sixstack_ch8_init[] = {
11069 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11070 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11071 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11072 { } /* end */
11073 };
11074
11075 static struct hda_channel_mode alc662_5stack_modes[2] = {
11076 { 2, alc662_sixstack_ch6_init },
11077 { 6, alc662_sixstack_ch8_init },
11078 };
11079
11080 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11081 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11082 */
11083
11084 static struct snd_kcontrol_new alc662_base_mixer[] = {
11085 /* output mixer control */
11086 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11087 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
11088 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11089 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11090 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11091 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11092 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11093 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11095
11096 /*Input mixer control */
11097 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
11098 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
11099 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
11100 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
11101 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
11102 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
11103 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
11104 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
11105
11106 /* Capture mixer control */
11107 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11108 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11109 {
11110 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11111 .name = "Capture Source",
11112 .count = 1,
11113 .info = alc_mux_enum_info,
11114 .get = alc_mux_enum_get,
11115 .put = alc_mux_enum_put,
11116 },
11117 { } /* end */
11118 };
11119
11120 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
11121 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11122 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11123 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11124 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11125 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11126 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11127 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11128 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11129 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11130 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11131 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11132 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11133 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11134 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11135 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11136 {
11137 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11138 /* .name = "Capture Source", */
11139 .name = "Input Source",
11140 .count = 1,
11141 .info = alc662_mux_enum_info,
11142 .get = alc662_mux_enum_get,
11143 .put = alc662_mux_enum_put,
11144 },
11145 { } /* end */
11146 };
11147
11148 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
11149 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11150 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11151 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11152 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
11153 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
11154 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
11155 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
11156 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
11157 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11158 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11159 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11160 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11161 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11163 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11164 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11165 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11166 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11167 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11168 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11169 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11170 {
11171 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11172 /* .name = "Capture Source", */
11173 .name = "Input Source",
11174 .count = 1,
11175 .info = alc662_mux_enum_info,
11176 .get = alc662_mux_enum_get,
11177 .put = alc662_mux_enum_put,
11178 },
11179 { } /* end */
11180 };
11181
11182 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
11183 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11184 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
11185 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11186 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
11187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11188 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11189 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11192 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11193 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11194 {
11195 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11196 /* .name = "Capture Source", */
11197 .name = "Input Source",
11198 .count = 1,
11199 .info = alc662_mux_enum_info,
11200 .get = alc662_mux_enum_get,
11201 .put = alc662_mux_enum_put,
11202 },
11203 { } /* end */
11204 };
11205
11206 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
11207 {
11208 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11209 .name = "Channel Mode",
11210 .info = alc_ch_mode_info,
11211 .get = alc_ch_mode_get,
11212 .put = alc_ch_mode_put,
11213 },
11214 { } /* end */
11215 };
11216
11217 static struct hda_verb alc662_init_verbs[] = {
11218 /* ADC: mute amp left and right */
11219 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11220 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11221 /* Front mixer: unmute input/output amp left and right (volume = 0) */
11222
11223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11224 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11225 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11226 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11228
11229 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11230 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11231 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11232 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11233 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11234 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11235
11236 /* Front Pin: output 0 (0x0c) */
11237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11239
11240 /* Rear Pin: output 1 (0x0d) */
11241 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11242 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11243
11244 /* CLFE Pin: output 2 (0x0e) */
11245 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11246 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11247
11248 /* Mic (rear) pin: input vref at 80% */
11249 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11250 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11251 /* Front Mic pin: input vref at 80% */
11252 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11253 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11254 /* Line In pin: input */
11255 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11256 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11257 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11258 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11259 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11260 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11261 /* CD pin widget for input */
11262 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11263
11264 /* FIXME: use matrix-type input source selection */
11265 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11266 /* Input mixer */
11267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11270 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11271 { }
11272 };
11273
11274 static struct hda_verb alc662_sue_init_verbs[] = {
11275 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
11276 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
11277 {}
11278 };
11279
11280 /*
11281 * generic initialization of ADC, input mixers and output mixers
11282 */
11283 static struct hda_verb alc662_auto_init_verbs[] = {
11284 /*
11285 * Unmute ADC and set the default input to mic-in
11286 */
11287 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11288 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11289
11290 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11291 * mixer widget
11292 * Note: PASD motherboards uses the Line In 2 as the input for front
11293 * panel mic (mic 2)
11294 */
11295 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11300 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11301
11302 /*
11303 * Set up output mixers (0x0c - 0x0f)
11304 */
11305 /* set vol=0 to output mixers */
11306 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11307 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11308 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11309
11310 /* set up input amps for analog loopback */
11311 /* Amp Indices: DAC = 0, mixer = 1 */
11312 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11313 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11314 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11315 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11316 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11317 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11318
11319
11320 /* FIXME: use matrix-type input source selection */
11321 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11322 /* Input mixer */
11323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11325 { }
11326 };
11327
11328 /* capture mixer elements */
11329 static struct snd_kcontrol_new alc662_capture_mixer[] = {
11330 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11331 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11332 {
11333 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11334 /* The multiple "Capture Source" controls confuse alsamixer
11335 * So call somewhat different..
11336 * FIXME: the controls appear in the "playback" view!
11337 */
11338 /* .name = "Capture Source", */
11339 .name = "Input Source",
11340 .count = 1,
11341 .info = alc882_mux_enum_info,
11342 .get = alc882_mux_enum_get,
11343 .put = alc882_mux_enum_put,
11344 },
11345 { } /* end */
11346 };
11347
11348 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
11349 {
11350 unsigned int present;
11351 unsigned char bits;
11352
11353 present = snd_hda_codec_read(codec, 0x14, 0,
11354 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11355 bits = present ? HDA_AMP_MUTE : 0;
11356 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11357 HDA_AMP_MUTE, bits);
11358 }
11359
11360 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
11361 {
11362 unsigned int present;
11363 unsigned char bits;
11364
11365 present = snd_hda_codec_read(codec, 0x1b, 0,
11366 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11367 bits = present ? HDA_AMP_MUTE : 0;
11368 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11369 HDA_AMP_MUTE, bits);
11370 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11371 HDA_AMP_MUTE, bits);
11372 }
11373
11374 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
11375 unsigned int res)
11376 {
11377 if ((res >> 26) == ALC880_HP_EVENT)
11378 alc662_lenovo_101e_all_automute(codec);
11379 if ((res >> 26) == ALC880_FRONT_EVENT)
11380 alc662_lenovo_101e_ispeaker_automute(codec);
11381 }
11382
11383 #ifdef CONFIG_SND_HDA_POWER_SAVE
11384 #define alc662_loopbacks alc880_loopbacks
11385 #endif
11386
11387
11388 /* pcm configuration: identiacal with ALC880 */
11389 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
11390 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
11391 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
11392 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
11393
11394 /*
11395 * configuration and preset
11396 */
11397 static const char *alc662_models[ALC662_MODEL_LAST] = {
11398 [ALC662_3ST_2ch_DIG] = "3stack-dig",
11399 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
11400 [ALC662_3ST_6ch] = "3stack-6ch",
11401 [ALC662_5ST_DIG] = "6stack-dig",
11402 [ALC662_LENOVO_101E] = "lenovo-101e",
11403 [ALC662_AUTO] = "auto",
11404 };
11405
11406 static struct snd_pci_quirk alc662_cfg_tbl[] = {
11407 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
11408 {}
11409 };
11410
11411 static struct alc_config_preset alc662_presets[] = {
11412 [ALC662_3ST_2ch_DIG] = {
11413 .mixers = { alc662_3ST_2ch_mixer },
11414 .init_verbs = { alc662_init_verbs },
11415 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11416 .dac_nids = alc662_dac_nids,
11417 .dig_out_nid = ALC662_DIGOUT_NID,
11418 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11419 .adc_nids = alc662_adc_nids,
11420 .dig_in_nid = ALC662_DIGIN_NID,
11421 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11422 .channel_mode = alc662_3ST_2ch_modes,
11423 .input_mux = &alc662_capture_source,
11424 },
11425 [ALC662_3ST_6ch_DIG] = {
11426 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11427 .init_verbs = { alc662_init_verbs },
11428 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11429 .dac_nids = alc662_dac_nids,
11430 .dig_out_nid = ALC662_DIGOUT_NID,
11431 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11432 .adc_nids = alc662_adc_nids,
11433 .dig_in_nid = ALC662_DIGIN_NID,
11434 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11435 .channel_mode = alc662_3ST_6ch_modes,
11436 .need_dac_fix = 1,
11437 .input_mux = &alc662_capture_source,
11438 },
11439 [ALC662_3ST_6ch] = {
11440 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
11441 .init_verbs = { alc662_init_verbs },
11442 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11443 .dac_nids = alc662_dac_nids,
11444 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11445 .adc_nids = alc662_adc_nids,
11446 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
11447 .channel_mode = alc662_3ST_6ch_modes,
11448 .need_dac_fix = 1,
11449 .input_mux = &alc662_capture_source,
11450 },
11451 [ALC662_5ST_DIG] = {
11452 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
11453 .init_verbs = { alc662_init_verbs },
11454 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11455 .dac_nids = alc662_dac_nids,
11456 .dig_out_nid = ALC662_DIGOUT_NID,
11457 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11458 .adc_nids = alc662_adc_nids,
11459 .dig_in_nid = ALC662_DIGIN_NID,
11460 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
11461 .channel_mode = alc662_5stack_modes,
11462 .input_mux = &alc662_capture_source,
11463 },
11464 [ALC662_LENOVO_101E] = {
11465 .mixers = { alc662_lenovo_101e_mixer },
11466 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
11467 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
11468 .dac_nids = alc662_dac_nids,
11469 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
11470 .adc_nids = alc662_adc_nids,
11471 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
11472 .channel_mode = alc662_3ST_2ch_modes,
11473 .input_mux = &alc662_lenovo_101e_capture_source,
11474 .unsol_event = alc662_lenovo_101e_unsol_event,
11475 .init_hook = alc662_lenovo_101e_all_automute,
11476 },
11477
11478 };
11479
11480
11481 /*
11482 * BIOS auto configuration
11483 */
11484
11485 /* add playback controls from the parsed DAC table */
11486 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
11487 const struct auto_pin_cfg *cfg)
11488 {
11489 char name[32];
11490 static const char *chname[4] = {
11491 "Front", "Surround", NULL /*CLFE*/, "Side"
11492 };
11493 hda_nid_t nid;
11494 int i, err;
11495
11496 for (i = 0; i < cfg->line_outs; i++) {
11497 if (!spec->multiout.dac_nids[i])
11498 continue;
11499 nid = alc880_idx_to_mixer(i);
11500 if (i == 2) {
11501 /* Center/LFE */
11502 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11503 "Center Playback Volume",
11504 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11505 HDA_OUTPUT));
11506 if (err < 0)
11507 return err;
11508 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11509 "LFE Playback Volume",
11510 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11511 HDA_OUTPUT));
11512 if (err < 0)
11513 return err;
11514 err = add_control(spec, ALC_CTL_BIND_MUTE,
11515 "Center Playback Switch",
11516 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
11517 HDA_INPUT));
11518 if (err < 0)
11519 return err;
11520 err = add_control(spec, ALC_CTL_BIND_MUTE,
11521 "LFE Playback Switch",
11522 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
11523 HDA_INPUT));
11524 if (err < 0)
11525 return err;
11526 } else {
11527 sprintf(name, "%s Playback Volume", chname[i]);
11528 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11529 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11530 HDA_OUTPUT));
11531 if (err < 0)
11532 return err;
11533 sprintf(name, "%s Playback Switch", chname[i]);
11534 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11535 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
11536 HDA_INPUT));
11537 if (err < 0)
11538 return err;
11539 }
11540 }
11541 return 0;
11542 }
11543
11544 /* add playback controls for speaker and HP outputs */
11545 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
11546 const char *pfx)
11547 {
11548 hda_nid_t nid;
11549 int err;
11550 char name[32];
11551
11552 if (!pin)
11553 return 0;
11554
11555 if (alc880_is_fixed_pin(pin)) {
11556 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11557 /* printk("DAC nid=%x\n",nid); */
11558 /* specify the DAC as the extra output */
11559 if (!spec->multiout.hp_nid)
11560 spec->multiout.hp_nid = nid;
11561 else
11562 spec->multiout.extra_out_nid[0] = nid;
11563 /* control HP volume/switch on the output mixer amp */
11564 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
11565 sprintf(name, "%s Playback Volume", pfx);
11566 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11567 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11568 if (err < 0)
11569 return err;
11570 sprintf(name, "%s Playback Switch", pfx);
11571 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11572 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
11573 if (err < 0)
11574 return err;
11575 } else if (alc880_is_multi_pin(pin)) {
11576 /* set manual connection */
11577 /* we have only a switch on HP-out PIN */
11578 sprintf(name, "%s Playback Switch", pfx);
11579 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11580 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
11581 if (err < 0)
11582 return err;
11583 }
11584 return 0;
11585 }
11586
11587 /* create playback/capture controls for input pins */
11588 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
11589 const struct auto_pin_cfg *cfg)
11590 {
11591 struct hda_input_mux *imux = &spec->private_imux;
11592 int i, err, idx;
11593
11594 for (i = 0; i < AUTO_PIN_LAST; i++) {
11595 if (alc880_is_input_pin(cfg->input_pins[i])) {
11596 idx = alc880_input_pin_idx(cfg->input_pins[i]);
11597 err = new_analog_input(spec, cfg->input_pins[i],
11598 auto_pin_cfg_labels[i],
11599 idx, 0x0b);
11600 if (err < 0)
11601 return err;
11602 imux->items[imux->num_items].label =
11603 auto_pin_cfg_labels[i];
11604 imux->items[imux->num_items].index =
11605 alc880_input_pin_idx(cfg->input_pins[i]);
11606 imux->num_items++;
11607 }
11608 }
11609 return 0;
11610 }
11611
11612 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
11613 hda_nid_t nid, int pin_type,
11614 int dac_idx)
11615 {
11616 /* set as output */
11617 snd_hda_codec_write(codec, nid, 0,
11618 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
11619 snd_hda_codec_write(codec, nid, 0,
11620 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
11621 /* need the manual connection? */
11622 if (alc880_is_multi_pin(nid)) {
11623 struct alc_spec *spec = codec->spec;
11624 int idx = alc880_multi_pin_idx(nid);
11625 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
11626 AC_VERB_SET_CONNECT_SEL,
11627 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
11628 }
11629 }
11630
11631 static void alc662_auto_init_multi_out(struct hda_codec *codec)
11632 {
11633 struct alc_spec *spec = codec->spec;
11634 int i;
11635
11636 for (i = 0; i <= HDA_SIDE; i++) {
11637 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11638 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11639 if (nid)
11640 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
11641 i);
11642 }
11643 }
11644
11645 static void alc662_auto_init_hp_out(struct hda_codec *codec)
11646 {
11647 struct alc_spec *spec = codec->spec;
11648 hda_nid_t pin;
11649
11650 pin = spec->autocfg.hp_pins[0];
11651 if (pin) /* connect to front */
11652 /* use dac 0 */
11653 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
11654 }
11655
11656 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
11657 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
11658
11659 static void alc662_auto_init_analog_input(struct hda_codec *codec)
11660 {
11661 struct alc_spec *spec = codec->spec;
11662 int i;
11663
11664 for (i = 0; i < AUTO_PIN_LAST; i++) {
11665 hda_nid_t nid = spec->autocfg.input_pins[i];
11666 if (alc662_is_input_pin(nid)) {
11667 snd_hda_codec_write(codec, nid, 0,
11668 AC_VERB_SET_PIN_WIDGET_CONTROL,
11669 (i <= AUTO_PIN_FRONT_MIC ?
11670 PIN_VREF80 : PIN_IN));
11671 if (nid != ALC662_PIN_CD_NID)
11672 snd_hda_codec_write(codec, nid, 0,
11673 AC_VERB_SET_AMP_GAIN_MUTE,
11674 AMP_OUT_MUTE);
11675 }
11676 }
11677 }
11678
11679 static int alc662_parse_auto_config(struct hda_codec *codec)
11680 {
11681 struct alc_spec *spec = codec->spec;
11682 int err;
11683 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
11684
11685 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11686 alc662_ignore);
11687 if (err < 0)
11688 return err;
11689 if (!spec->autocfg.line_outs)
11690 return 0; /* can't find valid BIOS pin config */
11691
11692 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
11693 if (err < 0)
11694 return err;
11695 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
11696 if (err < 0)
11697 return err;
11698 err = alc662_auto_create_extra_out(spec,
11699 spec->autocfg.speaker_pins[0],
11700 "Speaker");
11701 if (err < 0)
11702 return err;
11703 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
11704 "Headphone");
11705 if (err < 0)
11706 return err;
11707 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
11708 if (err < 0)
11709 return err;
11710
11711 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11712
11713 if (spec->autocfg.dig_out_pin)
11714 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
11715
11716 if (spec->kctl_alloc)
11717 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11718
11719 spec->num_mux_defs = 1;
11720 spec->input_mux = &spec->private_imux;
11721
11722 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
11723 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
11724 spec->num_mixers++;
11725 return 1;
11726 }
11727
11728 /* additional initialization for auto-configuration model */
11729 static void alc662_auto_init(struct hda_codec *codec)
11730 {
11731 alc662_auto_init_multi_out(codec);
11732 alc662_auto_init_hp_out(codec);
11733 alc662_auto_init_analog_input(codec);
11734 }
11735
11736 static int patch_alc662(struct hda_codec *codec)
11737 {
11738 struct alc_spec *spec;
11739 int err, board_config;
11740
11741 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11742 if (!spec)
11743 return -ENOMEM;
11744
11745 codec->spec = spec;
11746
11747 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
11748 alc662_models,
11749 alc662_cfg_tbl);
11750 if (board_config < 0) {
11751 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
11752 "trying auto-probe from BIOS...\n");
11753 board_config = ALC662_AUTO;
11754 }
11755
11756 if (board_config == ALC662_AUTO) {
11757 /* automatic parse from the BIOS config */
11758 err = alc662_parse_auto_config(codec);
11759 if (err < 0) {
11760 alc_free(codec);
11761 return err;
11762 } else if (!err) {
11763 printk(KERN_INFO
11764 "hda_codec: Cannot set up configuration "
11765 "from BIOS. Using base mode...\n");
11766 board_config = ALC662_3ST_2ch_DIG;
11767 }
11768 }
11769
11770 if (board_config != ALC662_AUTO)
11771 setup_preset(spec, &alc662_presets[board_config]);
11772
11773 spec->stream_name_analog = "ALC662 Analog";
11774 spec->stream_analog_playback = &alc662_pcm_analog_playback;
11775 spec->stream_analog_capture = &alc662_pcm_analog_capture;
11776
11777 spec->stream_name_digital = "ALC662 Digital";
11778 spec->stream_digital_playback = &alc662_pcm_digital_playback;
11779 spec->stream_digital_capture = &alc662_pcm_digital_capture;
11780
11781 if (!spec->adc_nids && spec->input_mux) {
11782 spec->adc_nids = alc662_adc_nids;
11783 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
11784 }
11785
11786 codec->patch_ops = alc_patch_ops;
11787 if (board_config == ALC662_AUTO)
11788 spec->init_hook = alc662_auto_init;
11789 #ifdef CONFIG_SND_HDA_POWER_SAVE
11790 if (!spec->loopback.amplist)
11791 spec->loopback.amplist = alc662_loopbacks;
11792 #endif
11793
11794 return 0;
11795 }
11796
11797 /*
11798 * patch entries
11799 */
11800 struct hda_codec_preset snd_hda_preset_realtek[] = {
11801 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
11802 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
11803 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
11804 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
11805 .patch = patch_alc861 },
11806 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
11807 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
11808 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
11809 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
11810 .patch = patch_alc883 },
11811 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
11812 .patch = patch_alc662 },
11813 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
11814 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
11815 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
11816 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
11817 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
11818 {} /* terminator */
11819 };