]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - sound/pci/hda/patch_realtek.c
[ALSA] hda-codec - Add model for Acer Aspire 5310
[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 <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <sound/core.h>
31 #include "hda_codec.h"
32 #include "hda_local.h"
33
34 #define ALC880_FRONT_EVENT 0x01
35 #define ALC880_DCVOL_EVENT 0x02
36 #define ALC880_HP_EVENT 0x04
37 #define ALC880_MIC_EVENT 0x08
38
39 /* ALC880 board config type */
40 enum {
41 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
46 ALC880_Z71V,
47 ALC880_6ST,
48 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
53 ALC880_ASUS_DIG2,
54 ALC880_FUJITSU,
55 ALC880_UNIWILL_DIG,
56 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
58 ALC880_CLEVO,
59 ALC880_TCL_S700,
60 ALC880_LG,
61 ALC880_LG_LW,
62 #ifdef CONFIG_SND_DEBUG
63 ALC880_TEST,
64 #endif
65 ALC880_AUTO,
66 ALC880_MODEL_LAST /* last tag */
67 };
68
69 /* ALC260 models */
70 enum {
71 ALC260_BASIC,
72 ALC260_HP,
73 ALC260_HP_3013,
74 ALC260_FUJITSU_S702X,
75 ALC260_ACER,
76 ALC260_WILL,
77 ALC260_REPLACER_672V,
78 #ifdef CONFIG_SND_DEBUG
79 ALC260_TEST,
80 #endif
81 ALC260_AUTO,
82 ALC260_MODEL_LAST /* last tag */
83 };
84
85 /* ALC262 models */
86 enum {
87 ALC262_BASIC,
88 ALC262_HIPPO,
89 ALC262_HIPPO_1,
90 ALC262_FUJITSU,
91 ALC262_HP_BPC,
92 ALC262_HP_BPC_D7000_WL,
93 ALC262_HP_BPC_D7000_WF,
94 ALC262_HP_TC_T5735,
95 ALC262_HP_RP5700,
96 ALC262_BENQ_ED8,
97 ALC262_SONY_ASSAMD,
98 ALC262_BENQ_T31,
99 ALC262_ULTRA,
100 ALC262_AUTO,
101 ALC262_MODEL_LAST /* last tag */
102 };
103
104 /* ALC268 models */
105 enum {
106 ALC268_3ST,
107 ALC268_TOSHIBA,
108 ALC268_ACER,
109 ALC268_DELL,
110 #ifdef CONFIG_SND_DEBUG
111 ALC268_TEST,
112 #endif
113 ALC268_AUTO,
114 ALC268_MODEL_LAST /* last tag */
115 };
116
117 /* ALC269 models */
118 enum {
119 ALC269_BASIC,
120 ALC269_AUTO,
121 ALC269_MODEL_LAST /* last tag */
122 };
123
124 /* ALC861 models */
125 enum {
126 ALC861_3ST,
127 ALC660_3ST,
128 ALC861_3ST_DIG,
129 ALC861_6ST_DIG,
130 ALC861_UNIWILL_M31,
131 ALC861_TOSHIBA,
132 ALC861_ASUS,
133 ALC861_ASUS_LAPTOP,
134 ALC861_AUTO,
135 ALC861_MODEL_LAST,
136 };
137
138 /* ALC861-VD models */
139 enum {
140 ALC660VD_3ST,
141 ALC660VD_3ST_DIG,
142 ALC861VD_3ST,
143 ALC861VD_3ST_DIG,
144 ALC861VD_6ST_DIG,
145 ALC861VD_LENOVO,
146 ALC861VD_DALLAS,
147 ALC861VD_HP,
148 ALC861VD_AUTO,
149 ALC861VD_MODEL_LAST,
150 };
151
152 /* ALC662 models */
153 enum {
154 ALC662_3ST_2ch_DIG,
155 ALC662_3ST_6ch_DIG,
156 ALC662_3ST_6ch,
157 ALC662_5ST_DIG,
158 ALC662_LENOVO_101E,
159 ALC662_ASUS_EEEPC_P701,
160 ALC662_ASUS_EEEPC_EP20,
161 ALC662_AUTO,
162 ALC662_MODEL_LAST,
163 };
164
165 /* ALC882 models */
166 enum {
167 ALC882_3ST_DIG,
168 ALC882_6ST_DIG,
169 ALC882_ARIMA,
170 ALC882_W2JC,
171 ALC882_TARGA,
172 ALC882_ASUS_A7J,
173 ALC882_ASUS_A7M,
174 ALC885_MACPRO,
175 ALC885_MBP3,
176 ALC885_IMAC24,
177 ALC882_AUTO,
178 ALC882_MODEL_LAST,
179 };
180
181 /* ALC883 models */
182 enum {
183 ALC883_3ST_2ch_DIG,
184 ALC883_3ST_6ch_DIG,
185 ALC883_3ST_6ch,
186 ALC883_6ST_DIG,
187 ALC883_TARGA_DIG,
188 ALC883_TARGA_2ch_DIG,
189 ALC883_ACER,
190 ALC883_ACER_ASPIRE,
191 ALC883_MEDION,
192 ALC883_MEDION_MD2,
193 ALC883_LAPTOP_EAPD,
194 ALC883_LENOVO_101E_2ch,
195 ALC883_LENOVO_NB0763,
196 ALC888_LENOVO_MS7195_DIG,
197 ALC883_HAIER_W66,
198 ALC888_6ST_HP,
199 ALC888_3ST_HP,
200 ALC888_6ST_DELL,
201 ALC883_MITAC,
202 ALC883_AUTO,
203 ALC883_MODEL_LAST,
204 };
205
206 /* for GPIO Poll */
207 #define GPIO_MASK 0x03
208
209 struct alc_spec {
210 /* codec parameterization */
211 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
212 unsigned int num_mixers;
213
214 const struct hda_verb *init_verbs[5]; /* initialization verbs
215 * don't forget NULL
216 * termination!
217 */
218 unsigned int num_init_verbs;
219
220 char *stream_name_analog; /* analog PCM stream */
221 struct hda_pcm_stream *stream_analog_playback;
222 struct hda_pcm_stream *stream_analog_capture;
223 struct hda_pcm_stream *stream_analog_alt_playback;
224 struct hda_pcm_stream *stream_analog_alt_capture;
225
226 char *stream_name_digital; /* digital PCM stream */
227 struct hda_pcm_stream *stream_digital_playback;
228 struct hda_pcm_stream *stream_digital_capture;
229
230 /* playback */
231 struct hda_multi_out multiout; /* playback set-up
232 * max_channels, dacs must be set
233 * dig_out_nid and hp_nid are optional
234 */
235 hda_nid_t alt_dac_nid;
236
237 /* capture */
238 unsigned int num_adc_nids;
239 hda_nid_t *adc_nids;
240 hda_nid_t dig_in_nid; /* digital-in NID; optional */
241
242 /* capture source */
243 unsigned int num_mux_defs;
244 const struct hda_input_mux *input_mux;
245 unsigned int cur_mux[3];
246
247 /* channel model */
248 const struct hda_channel_mode *channel_mode;
249 int num_channel_mode;
250 int need_dac_fix;
251
252 /* PCM information */
253 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
254
255 /* dynamic controls, init_verbs and input_mux */
256 struct auto_pin_cfg autocfg;
257 unsigned int num_kctl_alloc, num_kctl_used;
258 struct snd_kcontrol_new *kctl_alloc;
259 struct hda_input_mux private_imux;
260 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
261
262 /* hooks */
263 void (*init_hook)(struct hda_codec *codec);
264 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
265
266 /* for pin sensing */
267 unsigned int sense_updated: 1;
268 unsigned int jack_present: 1;
269
270 /* for virtual master */
271 hda_nid_t vmaster_nid;
272 u32 vmaster_tlv[4];
273 #ifdef CONFIG_SND_HDA_POWER_SAVE
274 struct hda_loopback_check loopback;
275 #endif
276 };
277
278 /*
279 * configuration template - to be copied to the spec instance
280 */
281 struct alc_config_preset {
282 struct snd_kcontrol_new *mixers[5]; /* should be identical size
283 * with spec
284 */
285 const struct hda_verb *init_verbs[5];
286 unsigned int num_dacs;
287 hda_nid_t *dac_nids;
288 hda_nid_t dig_out_nid; /* optional */
289 hda_nid_t hp_nid; /* optional */
290 unsigned int num_adc_nids;
291 hda_nid_t *adc_nids;
292 hda_nid_t dig_in_nid;
293 unsigned int num_channel_mode;
294 const struct hda_channel_mode *channel_mode;
295 int need_dac_fix;
296 unsigned int num_mux_defs;
297 const struct hda_input_mux *input_mux;
298 void (*unsol_event)(struct hda_codec *, unsigned int);
299 void (*init_hook)(struct hda_codec *);
300 #ifdef CONFIG_SND_HDA_POWER_SAVE
301 struct hda_amp_list *loopbacks;
302 #endif
303 };
304
305
306 /*
307 * input MUX handling
308 */
309 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
310 struct snd_ctl_elem_info *uinfo)
311 {
312 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
313 struct alc_spec *spec = codec->spec;
314 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
315 if (mux_idx >= spec->num_mux_defs)
316 mux_idx = 0;
317 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
318 }
319
320 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
321 struct snd_ctl_elem_value *ucontrol)
322 {
323 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
324 struct alc_spec *spec = codec->spec;
325 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
326
327 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
328 return 0;
329 }
330
331 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
332 struct snd_ctl_elem_value *ucontrol)
333 {
334 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
335 struct alc_spec *spec = codec->spec;
336 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
337 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
338 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
339 spec->adc_nids[adc_idx],
340 &spec->cur_mux[adc_idx]);
341 }
342
343
344 /*
345 * channel mode setting
346 */
347 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
348 struct snd_ctl_elem_info *uinfo)
349 {
350 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
351 struct alc_spec *spec = codec->spec;
352 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
353 spec->num_channel_mode);
354 }
355
356 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
357 struct snd_ctl_elem_value *ucontrol)
358 {
359 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
360 struct alc_spec *spec = codec->spec;
361 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
362 spec->num_channel_mode,
363 spec->multiout.max_channels);
364 }
365
366 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
367 struct snd_ctl_elem_value *ucontrol)
368 {
369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
370 struct alc_spec *spec = codec->spec;
371 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
372 spec->num_channel_mode,
373 &spec->multiout.max_channels);
374 if (err >= 0 && spec->need_dac_fix)
375 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
376 return err;
377 }
378
379 /*
380 * Control the mode of pin widget settings via the mixer. "pc" is used
381 * instead of "%" to avoid consequences of accidently treating the % as
382 * being part of a format specifier. Maximum allowed length of a value is
383 * 63 characters plus NULL terminator.
384 *
385 * Note: some retasking pin complexes seem to ignore requests for input
386 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
387 * are requested. Therefore order this list so that this behaviour will not
388 * cause problems when mixer clients move through the enum sequentially.
389 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
390 * March 2006.
391 */
392 static char *alc_pin_mode_names[] = {
393 "Mic 50pc bias", "Mic 80pc bias",
394 "Line in", "Line out", "Headphone out",
395 };
396 static unsigned char alc_pin_mode_values[] = {
397 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
398 };
399 /* The control can present all 5 options, or it can limit the options based
400 * in the pin being assumed to be exclusively an input or an output pin. In
401 * addition, "input" pins may or may not process the mic bias option
402 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
403 * accept requests for bias as of chip versions up to March 2006) and/or
404 * wiring in the computer.
405 */
406 #define ALC_PIN_DIR_IN 0x00
407 #define ALC_PIN_DIR_OUT 0x01
408 #define ALC_PIN_DIR_INOUT 0x02
409 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
410 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
411
412 /* Info about the pin modes supported by the different pin direction modes.
413 * For each direction the minimum and maximum values are given.
414 */
415 static signed char alc_pin_mode_dir_info[5][2] = {
416 { 0, 2 }, /* ALC_PIN_DIR_IN */
417 { 3, 4 }, /* ALC_PIN_DIR_OUT */
418 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
419 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
420 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
421 };
422 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
423 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
424 #define alc_pin_mode_n_items(_dir) \
425 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
426
427 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
428 struct snd_ctl_elem_info *uinfo)
429 {
430 unsigned int item_num = uinfo->value.enumerated.item;
431 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
432
433 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
434 uinfo->count = 1;
435 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
436
437 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
438 item_num = alc_pin_mode_min(dir);
439 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
440 return 0;
441 }
442
443 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
445 {
446 unsigned int i;
447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
448 hda_nid_t nid = kcontrol->private_value & 0xffff;
449 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
450 long *valp = ucontrol->value.integer.value;
451 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
452 AC_VERB_GET_PIN_WIDGET_CONTROL,
453 0x00);
454
455 /* Find enumerated value for current pinctl setting */
456 i = alc_pin_mode_min(dir);
457 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
458 i++;
459 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
460 return 0;
461 }
462
463 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
464 struct snd_ctl_elem_value *ucontrol)
465 {
466 signed int change;
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 hda_nid_t nid = kcontrol->private_value & 0xffff;
469 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
470 long val = *ucontrol->value.integer.value;
471 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
472 AC_VERB_GET_PIN_WIDGET_CONTROL,
473 0x00);
474
475 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
476 val = alc_pin_mode_min(dir);
477
478 change = pinctl != alc_pin_mode_values[val];
479 if (change) {
480 /* Set pin mode to that requested */
481 snd_hda_codec_write_cache(codec, nid, 0,
482 AC_VERB_SET_PIN_WIDGET_CONTROL,
483 alc_pin_mode_values[val]);
484
485 /* Also enable the retasking pin's input/output as required
486 * for the requested pin mode. Enum values of 2 or less are
487 * input modes.
488 *
489 * Dynamically switching the input/output buffers probably
490 * reduces noise slightly (particularly on input) so we'll
491 * do it. However, having both input and output buffers
492 * enabled simultaneously doesn't seem to be problematic if
493 * this turns out to be necessary in the future.
494 */
495 if (val <= 2) {
496 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
497 HDA_AMP_MUTE, HDA_AMP_MUTE);
498 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
499 HDA_AMP_MUTE, 0);
500 } else {
501 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
502 HDA_AMP_MUTE, HDA_AMP_MUTE);
503 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
504 HDA_AMP_MUTE, 0);
505 }
506 }
507 return change;
508 }
509
510 #define ALC_PIN_MODE(xname, nid, dir) \
511 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
512 .info = alc_pin_mode_info, \
513 .get = alc_pin_mode_get, \
514 .put = alc_pin_mode_put, \
515 .private_value = nid | (dir<<16) }
516
517 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
518 * together using a mask with more than one bit set. This control is
519 * currently used only by the ALC260 test model. At this stage they are not
520 * needed for any "production" models.
521 */
522 #ifdef CONFIG_SND_DEBUG
523 #define alc_gpio_data_info snd_ctl_boolean_mono_info
524
525 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
527 {
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 hda_nid_t nid = kcontrol->private_value & 0xffff;
530 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
531 long *valp = ucontrol->value.integer.value;
532 unsigned int val = snd_hda_codec_read(codec, nid, 0,
533 AC_VERB_GET_GPIO_DATA, 0x00);
534
535 *valp = (val & mask) != 0;
536 return 0;
537 }
538 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_value *ucontrol)
540 {
541 signed int change;
542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
543 hda_nid_t nid = kcontrol->private_value & 0xffff;
544 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
545 long val = *ucontrol->value.integer.value;
546 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
547 AC_VERB_GET_GPIO_DATA,
548 0x00);
549
550 /* Set/unset the masked GPIO bit(s) as needed */
551 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
552 if (val == 0)
553 gpio_data &= ~mask;
554 else
555 gpio_data |= mask;
556 snd_hda_codec_write_cache(codec, nid, 0,
557 AC_VERB_SET_GPIO_DATA, gpio_data);
558
559 return change;
560 }
561 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
562 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
563 .info = alc_gpio_data_info, \
564 .get = alc_gpio_data_get, \
565 .put = alc_gpio_data_put, \
566 .private_value = nid | (mask<<16) }
567 #endif /* CONFIG_SND_DEBUG */
568
569 /* A switch control to allow the enabling of the digital IO pins on the
570 * ALC260. This is incredibly simplistic; the intention of this control is
571 * to provide something in the test model allowing digital outputs to be
572 * identified if present. If models are found which can utilise these
573 * outputs a more complete mixer control can be devised for those models if
574 * necessary.
575 */
576 #ifdef CONFIG_SND_DEBUG
577 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
578
579 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
580 struct snd_ctl_elem_value *ucontrol)
581 {
582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
583 hda_nid_t nid = kcontrol->private_value & 0xffff;
584 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
585 long *valp = ucontrol->value.integer.value;
586 unsigned int val = snd_hda_codec_read(codec, nid, 0,
587 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
588
589 *valp = (val & mask) != 0;
590 return 0;
591 }
592 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
593 struct snd_ctl_elem_value *ucontrol)
594 {
595 signed int change;
596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
597 hda_nid_t nid = kcontrol->private_value & 0xffff;
598 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
599 long val = *ucontrol->value.integer.value;
600 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
601 AC_VERB_GET_DIGI_CONVERT_1,
602 0x00);
603
604 /* Set/unset the masked control bit(s) as needed */
605 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
606 if (val==0)
607 ctrl_data &= ~mask;
608 else
609 ctrl_data |= mask;
610 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
611 ctrl_data);
612
613 return change;
614 }
615 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
616 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
617 .info = alc_spdif_ctrl_info, \
618 .get = alc_spdif_ctrl_get, \
619 .put = alc_spdif_ctrl_put, \
620 .private_value = nid | (mask<<16) }
621 #endif /* CONFIG_SND_DEBUG */
622
623 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
624 * Again, this is only used in the ALC26x test models to help identify when
625 * the EAPD line must be asserted for features to work.
626 */
627 #ifdef CONFIG_SND_DEBUG
628 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
629
630 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
632 {
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 hda_nid_t nid = kcontrol->private_value & 0xffff;
635 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
636 long *valp = ucontrol->value.integer.value;
637 unsigned int val = snd_hda_codec_read(codec, nid, 0,
638 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
639
640 *valp = (val & mask) != 0;
641 return 0;
642 }
643
644 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_value *ucontrol)
646 {
647 int change;
648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
649 hda_nid_t nid = kcontrol->private_value & 0xffff;
650 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
651 long val = *ucontrol->value.integer.value;
652 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
653 AC_VERB_GET_EAPD_BTLENABLE,
654 0x00);
655
656 /* Set/unset the masked control bit(s) as needed */
657 change = (!val ? 0 : mask) != (ctrl_data & mask);
658 if (!val)
659 ctrl_data &= ~mask;
660 else
661 ctrl_data |= mask;
662 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
663 ctrl_data);
664
665 return change;
666 }
667
668 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
669 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
670 .info = alc_eapd_ctrl_info, \
671 .get = alc_eapd_ctrl_get, \
672 .put = alc_eapd_ctrl_put, \
673 .private_value = nid | (mask<<16) }
674 #endif /* CONFIG_SND_DEBUG */
675
676 /*
677 * set up from the preset table
678 */
679 static void setup_preset(struct alc_spec *spec,
680 const struct alc_config_preset *preset)
681 {
682 int i;
683
684 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
685 spec->mixers[spec->num_mixers++] = preset->mixers[i];
686 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
687 i++)
688 spec->init_verbs[spec->num_init_verbs++] =
689 preset->init_verbs[i];
690
691 spec->channel_mode = preset->channel_mode;
692 spec->num_channel_mode = preset->num_channel_mode;
693 spec->need_dac_fix = preset->need_dac_fix;
694
695 spec->multiout.max_channels = spec->channel_mode[0].channels;
696
697 spec->multiout.num_dacs = preset->num_dacs;
698 spec->multiout.dac_nids = preset->dac_nids;
699 spec->multiout.dig_out_nid = preset->dig_out_nid;
700 spec->multiout.hp_nid = preset->hp_nid;
701
702 spec->num_mux_defs = preset->num_mux_defs;
703 if (!spec->num_mux_defs)
704 spec->num_mux_defs = 1;
705 spec->input_mux = preset->input_mux;
706
707 spec->num_adc_nids = preset->num_adc_nids;
708 spec->adc_nids = preset->adc_nids;
709 spec->dig_in_nid = preset->dig_in_nid;
710
711 spec->unsol_event = preset->unsol_event;
712 spec->init_hook = preset->init_hook;
713 #ifdef CONFIG_SND_HDA_POWER_SAVE
714 spec->loopback.amplist = preset->loopbacks;
715 #endif
716 }
717
718 /* Enable GPIO mask and set output */
719 static struct hda_verb alc_gpio1_init_verbs[] = {
720 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
721 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
722 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
723 { }
724 };
725
726 static struct hda_verb alc_gpio2_init_verbs[] = {
727 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
728 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
729 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
730 { }
731 };
732
733 static struct hda_verb alc_gpio3_init_verbs[] = {
734 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
735 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
736 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
737 { }
738 };
739
740 static void alc_sku_automute(struct hda_codec *codec)
741 {
742 struct alc_spec *spec = codec->spec;
743 unsigned int mute;
744 unsigned int present;
745 unsigned int hp_nid = spec->autocfg.hp_pins[0];
746 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
747
748 /* need to execute and sync at first */
749 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
750 present = snd_hda_codec_read(codec, hp_nid, 0,
751 AC_VERB_GET_PIN_SENSE, 0);
752 spec->jack_present = (present & 0x80000000) != 0;
753 if (spec->jack_present) {
754 /* mute internal speaker */
755 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
756 HDA_AMP_MUTE, HDA_AMP_MUTE);
757 } else {
758 /* unmute internal speaker if necessary */
759 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
760 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
761 HDA_AMP_MUTE, mute);
762 }
763 }
764
765 /* unsolicited event for HP jack sensing */
766 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
767 {
768 if (codec->vendor_id == 0x10ec0880)
769 res >>= 28;
770 else
771 res >>= 26;
772 if (res != ALC880_HP_EVENT)
773 return;
774
775 alc_sku_automute(codec);
776 }
777
778 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
779 * 31 ~ 16 : Manufacture ID
780 * 15 ~ 8 : SKU ID
781 * 7 ~ 0 : Assembly ID
782 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
783 */
784 static void alc_subsystem_id(struct hda_codec *codec,
785 unsigned int porta, unsigned int porte,
786 unsigned int portd)
787 {
788 unsigned int ass, tmp, i;
789 unsigned nid;
790 struct alc_spec *spec = codec->spec;
791
792 ass = codec->subsystem_id & 0xffff;
793 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
794 goto do_sku;
795
796 /*
797 * 31~30 : port conetcivity
798 * 29~21 : reserve
799 * 20 : PCBEEP input
800 * 19~16 : Check sum (15:1)
801 * 15~1 : Custom
802 * 0 : override
803 */
804 nid = 0x1d;
805 if (codec->vendor_id == 0x10ec0260)
806 nid = 0x17;
807 ass = snd_hda_codec_read(codec, nid, 0,
808 AC_VERB_GET_CONFIG_DEFAULT, 0);
809 if (!(ass & 1) && !(ass & 0x100000))
810 return;
811 if ((ass >> 30) != 1) /* no physical connection */
812 return;
813
814 /* check sum */
815 tmp = 0;
816 for (i = 1; i < 16; i++) {
817 if ((ass >> i) & 1)
818 tmp++;
819 }
820 if (((ass >> 16) & 0xf) != tmp)
821 return;
822 do_sku:
823 /*
824 * 0 : override
825 * 1 : Swap Jack
826 * 2 : 0 --> Desktop, 1 --> Laptop
827 * 3~5 : External Amplifier control
828 * 7~6 : Reserved
829 */
830 tmp = (ass & 0x38) >> 3; /* external Amp control */
831 switch (tmp) {
832 case 1:
833 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
834 break;
835 case 3:
836 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
837 break;
838 case 7:
839 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
840 break;
841 case 5: /* set EAPD output high */
842 switch (codec->vendor_id) {
843 case 0x10ec0260:
844 snd_hda_codec_write(codec, 0x0f, 0,
845 AC_VERB_SET_EAPD_BTLENABLE, 2);
846 snd_hda_codec_write(codec, 0x10, 0,
847 AC_VERB_SET_EAPD_BTLENABLE, 2);
848 break;
849 case 0x10ec0262:
850 case 0x10ec0267:
851 case 0x10ec0268:
852 case 0x10ec0269:
853 case 0x10ec0862:
854 case 0x10ec0662:
855 snd_hda_codec_write(codec, 0x14, 0,
856 AC_VERB_SET_EAPD_BTLENABLE, 2);
857 snd_hda_codec_write(codec, 0x15, 0,
858 AC_VERB_SET_EAPD_BTLENABLE, 2);
859 break;
860 }
861 switch (codec->vendor_id) {
862 case 0x10ec0260:
863 snd_hda_codec_write(codec, 0x1a, 0,
864 AC_VERB_SET_COEF_INDEX, 7);
865 tmp = snd_hda_codec_read(codec, 0x1a, 0,
866 AC_VERB_GET_PROC_COEF, 0);
867 snd_hda_codec_write(codec, 0x1a, 0,
868 AC_VERB_SET_COEF_INDEX, 7);
869 snd_hda_codec_write(codec, 0x1a, 0,
870 AC_VERB_SET_PROC_COEF,
871 tmp | 0x2010);
872 break;
873 case 0x10ec0262:
874 case 0x10ec0880:
875 case 0x10ec0882:
876 case 0x10ec0883:
877 case 0x10ec0885:
878 case 0x10ec0888:
879 snd_hda_codec_write(codec, 0x20, 0,
880 AC_VERB_SET_COEF_INDEX, 7);
881 tmp = snd_hda_codec_read(codec, 0x20, 0,
882 AC_VERB_GET_PROC_COEF, 0);
883 snd_hda_codec_write(codec, 0x20, 0,
884 AC_VERB_SET_COEF_INDEX, 7);
885 snd_hda_codec_write(codec, 0x20, 0,
886 AC_VERB_SET_PROC_COEF,
887 tmp | 0x2010);
888 break;
889 case 0x10ec0267:
890 case 0x10ec0268:
891 snd_hda_codec_write(codec, 0x20, 0,
892 AC_VERB_SET_COEF_INDEX, 7);
893 tmp = snd_hda_codec_read(codec, 0x20, 0,
894 AC_VERB_GET_PROC_COEF, 0);
895 snd_hda_codec_write(codec, 0x20, 0,
896 AC_VERB_SET_COEF_INDEX, 7);
897 snd_hda_codec_write(codec, 0x20, 0,
898 AC_VERB_SET_PROC_COEF,
899 tmp | 0x3000);
900 break;
901 }
902 default:
903 break;
904 }
905
906 /* is laptop or Desktop and enable the function "Mute internal speaker
907 * when the external headphone out jack is plugged"
908 */
909 if (!(ass & 0x8000))
910 return;
911 /*
912 * 10~8 : Jack location
913 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
914 * 14~13: Resvered
915 * 15 : 1 --> enable the function "Mute internal speaker
916 * when the external headphone out jack is plugged"
917 */
918 if (!spec->autocfg.speaker_pins[0]) {
919 if (spec->autocfg.line_out_pins[0])
920 spec->autocfg.speaker_pins[0] =
921 spec->autocfg.line_out_pins[0];
922 else
923 return;
924 }
925
926 if (!spec->autocfg.hp_pins[0]) {
927 tmp = (ass >> 11) & 0x3; /* HP to chassis */
928 if (tmp == 0)
929 spec->autocfg.hp_pins[0] = porta;
930 else if (tmp == 1)
931 spec->autocfg.hp_pins[0] = porte;
932 else if (tmp == 2)
933 spec->autocfg.hp_pins[0] = portd;
934 else
935 return;
936 }
937
938 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
939 AC_VERB_SET_UNSOLICITED_ENABLE,
940 AC_USRSP_EN | ALC880_HP_EVENT);
941 spec->unsol_event = alc_sku_unsol_event;
942 spec->init_hook = alc_sku_automute;
943 }
944
945 /*
946 * Fix-up pin default configurations
947 */
948
949 struct alc_pincfg {
950 hda_nid_t nid;
951 u32 val;
952 };
953
954 static void alc_fix_pincfg(struct hda_codec *codec,
955 const struct snd_pci_quirk *quirk,
956 const struct alc_pincfg **pinfix)
957 {
958 const struct alc_pincfg *cfg;
959
960 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
961 if (!quirk)
962 return;
963
964 cfg = pinfix[quirk->value];
965 for (; cfg->nid; cfg++) {
966 int i;
967 u32 val = cfg->val;
968 for (i = 0; i < 4; i++) {
969 snd_hda_codec_write(codec, cfg->nid, 0,
970 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
971 val & 0xff);
972 val >>= 8;
973 }
974 }
975 }
976
977 /*
978 * ALC880 3-stack model
979 *
980 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
981 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
982 * F-Mic = 0x1b, HP = 0x19
983 */
984
985 static hda_nid_t alc880_dac_nids[4] = {
986 /* front, rear, clfe, rear_surr */
987 0x02, 0x05, 0x04, 0x03
988 };
989
990 static hda_nid_t alc880_adc_nids[3] = {
991 /* ADC0-2 */
992 0x07, 0x08, 0x09,
993 };
994
995 /* The datasheet says the node 0x07 is connected from inputs,
996 * but it shows zero connection in the real implementation on some devices.
997 * Note: this is a 915GAV bug, fixed on 915GLV
998 */
999 static hda_nid_t alc880_adc_nids_alt[2] = {
1000 /* ADC1-2 */
1001 0x08, 0x09,
1002 };
1003
1004 #define ALC880_DIGOUT_NID 0x06
1005 #define ALC880_DIGIN_NID 0x0a
1006
1007 static struct hda_input_mux alc880_capture_source = {
1008 .num_items = 4,
1009 .items = {
1010 { "Mic", 0x0 },
1011 { "Front Mic", 0x3 },
1012 { "Line", 0x2 },
1013 { "CD", 0x4 },
1014 },
1015 };
1016
1017 /* channel source setting (2/6 channel selection for 3-stack) */
1018 /* 2ch mode */
1019 static struct hda_verb alc880_threestack_ch2_init[] = {
1020 /* set line-in to input, mute it */
1021 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1022 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1023 /* set mic-in to input vref 80%, mute it */
1024 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1025 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1026 { } /* end */
1027 };
1028
1029 /* 6ch mode */
1030 static struct hda_verb alc880_threestack_ch6_init[] = {
1031 /* set line-in to output, unmute it */
1032 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1033 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1034 /* set mic-in to output, unmute it */
1035 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1036 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1037 { } /* end */
1038 };
1039
1040 static struct hda_channel_mode alc880_threestack_modes[2] = {
1041 { 2, alc880_threestack_ch2_init },
1042 { 6, alc880_threestack_ch6_init },
1043 };
1044
1045 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1046 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1047 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1048 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1049 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1050 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1052 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1053 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1060 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1061 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1062 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1063 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1064 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1065 {
1066 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1067 .name = "Channel Mode",
1068 .info = alc_ch_mode_info,
1069 .get = alc_ch_mode_get,
1070 .put = alc_ch_mode_put,
1071 },
1072 { } /* end */
1073 };
1074
1075 /* capture mixer elements */
1076 static struct snd_kcontrol_new alc880_capture_mixer[] = {
1077 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1078 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1079 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1080 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1081 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1083 {
1084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1085 /* The multiple "Capture Source" controls confuse alsamixer
1086 * So call somewhat different..
1087 */
1088 /* .name = "Capture Source", */
1089 .name = "Input Source",
1090 .count = 3,
1091 .info = alc_mux_enum_info,
1092 .get = alc_mux_enum_get,
1093 .put = alc_mux_enum_put,
1094 },
1095 { } /* end */
1096 };
1097
1098 /* capture mixer elements (in case NID 0x07 not available) */
1099 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
1100 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1101 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1102 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1103 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1104 {
1105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1106 /* The multiple "Capture Source" controls confuse alsamixer
1107 * So call somewhat different..
1108 */
1109 /* .name = "Capture Source", */
1110 .name = "Input Source",
1111 .count = 2,
1112 .info = alc_mux_enum_info,
1113 .get = alc_mux_enum_get,
1114 .put = alc_mux_enum_put,
1115 },
1116 { } /* end */
1117 };
1118
1119
1120
1121 /*
1122 * ALC880 5-stack model
1123 *
1124 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1125 * Side = 0x02 (0xd)
1126 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1127 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1128 */
1129
1130 /* additional mixers to alc880_three_stack_mixer */
1131 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1132 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1133 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1134 { } /* end */
1135 };
1136
1137 /* channel source setting (6/8 channel selection for 5-stack) */
1138 /* 6ch mode */
1139 static struct hda_verb alc880_fivestack_ch6_init[] = {
1140 /* set line-in to input, mute it */
1141 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1142 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1143 { } /* end */
1144 };
1145
1146 /* 8ch mode */
1147 static struct hda_verb alc880_fivestack_ch8_init[] = {
1148 /* set line-in to output, unmute it */
1149 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1150 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1151 { } /* end */
1152 };
1153
1154 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1155 { 6, alc880_fivestack_ch6_init },
1156 { 8, alc880_fivestack_ch8_init },
1157 };
1158
1159
1160 /*
1161 * ALC880 6-stack model
1162 *
1163 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1164 * Side = 0x05 (0x0f)
1165 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1166 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1167 */
1168
1169 static hda_nid_t alc880_6st_dac_nids[4] = {
1170 /* front, rear, clfe, rear_surr */
1171 0x02, 0x03, 0x04, 0x05
1172 };
1173
1174 static struct hda_input_mux alc880_6stack_capture_source = {
1175 .num_items = 4,
1176 .items = {
1177 { "Mic", 0x0 },
1178 { "Front Mic", 0x1 },
1179 { "Line", 0x2 },
1180 { "CD", 0x4 },
1181 },
1182 };
1183
1184 /* fixed 8-channels */
1185 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1186 { 8, NULL },
1187 };
1188
1189 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1190 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1191 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1192 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1193 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1194 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1195 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1196 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1197 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1198 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1199 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1200 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1201 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1202 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1203 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1205 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1206 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1207 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1208 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1209 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1210 {
1211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1212 .name = "Channel Mode",
1213 .info = alc_ch_mode_info,
1214 .get = alc_ch_mode_get,
1215 .put = alc_ch_mode_put,
1216 },
1217 { } /* end */
1218 };
1219
1220
1221 /*
1222 * ALC880 W810 model
1223 *
1224 * W810 has rear IO for:
1225 * Front (DAC 02)
1226 * Surround (DAC 03)
1227 * Center/LFE (DAC 04)
1228 * Digital out (06)
1229 *
1230 * The system also has a pair of internal speakers, and a headphone jack.
1231 * These are both connected to Line2 on the codec, hence to DAC 02.
1232 *
1233 * There is a variable resistor to control the speaker or headphone
1234 * volume. This is a hardware-only device without a software API.
1235 *
1236 * Plugging headphones in will disable the internal speakers. This is
1237 * implemented in hardware, not via the driver using jack sense. In
1238 * a similar fashion, plugging into the rear socket marked "front" will
1239 * disable both the speakers and headphones.
1240 *
1241 * For input, there's a microphone jack, and an "audio in" jack.
1242 * These may not do anything useful with this driver yet, because I
1243 * haven't setup any initialization verbs for these yet...
1244 */
1245
1246 static hda_nid_t alc880_w810_dac_nids[3] = {
1247 /* front, rear/surround, clfe */
1248 0x02, 0x03, 0x04
1249 };
1250
1251 /* fixed 6 channels */
1252 static struct hda_channel_mode alc880_w810_modes[1] = {
1253 { 6, NULL }
1254 };
1255
1256 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1257 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1258 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1259 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1260 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1261 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1262 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1263 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1264 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1265 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1266 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1267 { } /* end */
1268 };
1269
1270
1271 /*
1272 * Z710V model
1273 *
1274 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1275 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1276 * Line = 0x1a
1277 */
1278
1279 static hda_nid_t alc880_z71v_dac_nids[1] = {
1280 0x02
1281 };
1282 #define ALC880_Z71V_HP_DAC 0x03
1283
1284 /* fixed 2 channels */
1285 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1286 { 2, NULL }
1287 };
1288
1289 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1290 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1291 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1292 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1293 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1294 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1295 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1298 { } /* end */
1299 };
1300
1301
1302 /*
1303 * ALC880 F1734 model
1304 *
1305 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1306 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1307 */
1308
1309 static hda_nid_t alc880_f1734_dac_nids[1] = {
1310 0x03
1311 };
1312 #define ALC880_F1734_HP_DAC 0x02
1313
1314 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1315 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1316 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1317 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1318 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1319 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1320 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1321 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1322 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1323 { } /* end */
1324 };
1325
1326
1327 /*
1328 * ALC880 ASUS model
1329 *
1330 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1331 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1332 * Mic = 0x18, Line = 0x1a
1333 */
1334
1335 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1336 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1337
1338 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1339 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1340 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1341 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1342 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1343 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1344 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1345 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1346 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1348 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1353 {
1354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1355 .name = "Channel Mode",
1356 .info = alc_ch_mode_info,
1357 .get = alc_ch_mode_get,
1358 .put = alc_ch_mode_put,
1359 },
1360 { } /* end */
1361 };
1362
1363 /*
1364 * ALC880 ASUS W1V model
1365 *
1366 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1367 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1368 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1369 */
1370
1371 /* additional mixers to alc880_asus_mixer */
1372 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1373 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1374 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1375 { } /* end */
1376 };
1377
1378 /* additional mixers to alc880_asus_mixer */
1379 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1380 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1381 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1382 { } /* end */
1383 };
1384
1385 /* TCL S700 */
1386 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1387 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1388 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1389 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1390 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1391 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1395 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1396 {
1397 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1398 /* The multiple "Capture Source" controls confuse alsamixer
1399 * So call somewhat different..
1400 */
1401 /* .name = "Capture Source", */
1402 .name = "Input Source",
1403 .count = 1,
1404 .info = alc_mux_enum_info,
1405 .get = alc_mux_enum_get,
1406 .put = alc_mux_enum_put,
1407 },
1408 { } /* end */
1409 };
1410
1411 /* Uniwill */
1412 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1413 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1414 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1415 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1416 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1417 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1418 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1419 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1420 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1421 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1422 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1423 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1424 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1425 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1426 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1427 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1428 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1429 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1430 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1431 {
1432 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1433 .name = "Channel Mode",
1434 .info = alc_ch_mode_info,
1435 .get = alc_ch_mode_get,
1436 .put = alc_ch_mode_put,
1437 },
1438 { } /* end */
1439 };
1440
1441 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1442 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1443 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1444 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1445 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1446 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1447 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1448 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1449 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1450 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1451 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1452 { } /* end */
1453 };
1454
1455 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1456 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1457 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1458 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1459 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1462 { } /* end */
1463 };
1464
1465 /*
1466 * virtual master controls
1467 */
1468
1469 /*
1470 * slave controls for virtual master
1471 */
1472 static const char *alc_slave_vols[] = {
1473 "Front Playback Volume",
1474 "Surround Playback Volume",
1475 "Center Playback Volume",
1476 "LFE Playback Volume",
1477 "Side Playback Volume",
1478 "Headphone Playback Volume",
1479 "Speaker Playback Volume",
1480 "Mono Playback Volume",
1481 "iSpeaker Playback Volume",
1482 "Line-Out Playback Volume",
1483 NULL,
1484 };
1485
1486 static const char *alc_slave_sws[] = {
1487 "Front Playback Switch",
1488 "Surround Playback Switch",
1489 "Center Playback Switch",
1490 "LFE Playback Switch",
1491 "Side Playback Switch",
1492 "Headphone Playback Switch",
1493 "Speaker Playback Switch",
1494 "Mono Playback Switch",
1495 "iSpeaker Playback Switch",
1496 NULL,
1497 };
1498
1499 /*
1500 * build control elements
1501 */
1502 static int alc_build_controls(struct hda_codec *codec)
1503 {
1504 struct alc_spec *spec = codec->spec;
1505 int err;
1506 int i;
1507
1508 for (i = 0; i < spec->num_mixers; i++) {
1509 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1510 if (err < 0)
1511 return err;
1512 }
1513
1514 if (spec->multiout.dig_out_nid) {
1515 err = snd_hda_create_spdif_out_ctls(codec,
1516 spec->multiout.dig_out_nid);
1517 if (err < 0)
1518 return err;
1519 }
1520 if (spec->dig_in_nid) {
1521 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1522 if (err < 0)
1523 return err;
1524 }
1525
1526 /* if we have no master control, let's create it */
1527 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1528 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1529 HDA_OUTPUT, spec->vmaster_tlv);
1530 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1531 spec->vmaster_tlv, alc_slave_vols);
1532 if (err < 0)
1533 return err;
1534 }
1535 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1536 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1537 NULL, alc_slave_sws);
1538 if (err < 0)
1539 return err;
1540 }
1541
1542 return 0;
1543 }
1544
1545
1546 /*
1547 * initialize the codec volumes, etc
1548 */
1549
1550 /*
1551 * generic initialization of ADC, input mixers and output mixers
1552 */
1553 static struct hda_verb alc880_volume_init_verbs[] = {
1554 /*
1555 * Unmute ADC0-2 and set the default input to mic-in
1556 */
1557 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1559 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1560 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1561 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1562 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1563
1564 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1565 * mixer widget
1566 * Note: PASD motherboards uses the Line In 2 as the input for front
1567 * panel mic (mic 2)
1568 */
1569 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1576 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1577
1578 /*
1579 * Set up output mixers (0x0c - 0x0f)
1580 */
1581 /* set vol=0 to output mixers */
1582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1584 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1585 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1586 /* set up input amps for analog loopback */
1587 /* Amp Indices: DAC = 0, mixer = 1 */
1588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1592 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1595 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1596
1597 { }
1598 };
1599
1600 /*
1601 * 3-stack pin configuration:
1602 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1603 */
1604 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1605 /*
1606 * preset connection lists of input pins
1607 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1608 */
1609 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1610 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1611 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1612
1613 /*
1614 * Set pin mode and muting
1615 */
1616 /* set front pin widgets 0x14 for output */
1617 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1618 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1619 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1622 /* Mic2 (as headphone out) for HP output */
1623 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1624 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625 /* Line In pin widget for input */
1626 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1628 /* Line2 (as front mic) pin widget for input and vref at 80% */
1629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1631 /* CD pin widget for input */
1632 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1633
1634 { }
1635 };
1636
1637 /*
1638 * 5-stack pin configuration:
1639 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1640 * line-in/side = 0x1a, f-mic = 0x1b
1641 */
1642 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1643 /*
1644 * preset connection lists of input pins
1645 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1646 */
1647 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1648 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1649
1650 /*
1651 * Set pin mode and muting
1652 */
1653 /* set pin widgets 0x14-0x17 for output */
1654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1656 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1657 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1658 /* unmute pins for output (no gain on this amp) */
1659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1662 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1663
1664 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1666 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1667 /* Mic2 (as headphone out) for HP output */
1668 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1669 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1670 /* Line In pin widget for input */
1671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1673 /* Line2 (as front mic) pin widget for input and vref at 80% */
1674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1675 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1676 /* CD pin widget for input */
1677 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1678
1679 { }
1680 };
1681
1682 /*
1683 * W810 pin configuration:
1684 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1685 */
1686 static struct hda_verb alc880_pin_w810_init_verbs[] = {
1687 /* hphone/speaker input selector: front DAC */
1688 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1689
1690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1695 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1696
1697 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1699
1700 { }
1701 };
1702
1703 /*
1704 * Z71V pin configuration:
1705 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1706 */
1707 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1708 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1712
1713 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1716 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1717
1718 { }
1719 };
1720
1721 /*
1722 * 6-stack pin configuration:
1723 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1724 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1725 */
1726 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1727 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1728
1729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1730 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1733 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1734 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1735 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1736 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1737
1738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1744 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1745 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1746 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1747
1748 { }
1749 };
1750
1751 /*
1752 * Uniwill pin configuration:
1753 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1754 * line = 0x1a
1755 */
1756 static struct hda_verb alc880_uniwill_init_verbs[] = {
1757 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1758
1759 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1763 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1764 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1765 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1766 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1771 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1773
1774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1776 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1780 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1781 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1782 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1783
1784 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1785 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1786
1787 { }
1788 };
1789
1790 /*
1791 * Uniwill P53
1792 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1793 */
1794 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1795 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1796
1797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1798 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1801 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1803 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1805 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1808 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1809
1810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1814 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1815 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1816
1817 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1818 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1819
1820 { }
1821 };
1822
1823 static struct hda_verb alc880_beep_init_verbs[] = {
1824 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1825 { }
1826 };
1827
1828 /* toggle speaker-output according to the hp-jack state */
1829 static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1830 {
1831 unsigned int present;
1832 unsigned char bits;
1833
1834 present = snd_hda_codec_read(codec, 0x14, 0,
1835 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1836 bits = present ? HDA_AMP_MUTE : 0;
1837 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1838 HDA_AMP_MUTE, bits);
1839 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1840 HDA_AMP_MUTE, bits);
1841 }
1842
1843 /* auto-toggle front mic */
1844 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1845 {
1846 unsigned int present;
1847 unsigned char bits;
1848
1849 present = snd_hda_codec_read(codec, 0x18, 0,
1850 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1851 bits = present ? HDA_AMP_MUTE : 0;
1852 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1853 }
1854
1855 static void alc880_uniwill_automute(struct hda_codec *codec)
1856 {
1857 alc880_uniwill_hp_automute(codec);
1858 alc880_uniwill_mic_automute(codec);
1859 }
1860
1861 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1862 unsigned int res)
1863 {
1864 /* Looks like the unsol event is incompatible with the standard
1865 * definition. 4bit tag is placed at 28 bit!
1866 */
1867 switch (res >> 28) {
1868 case ALC880_HP_EVENT:
1869 alc880_uniwill_hp_automute(codec);
1870 break;
1871 case ALC880_MIC_EVENT:
1872 alc880_uniwill_mic_automute(codec);
1873 break;
1874 }
1875 }
1876
1877 static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1878 {
1879 unsigned int present;
1880 unsigned char bits;
1881
1882 present = snd_hda_codec_read(codec, 0x14, 0,
1883 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1884 bits = present ? HDA_AMP_MUTE : 0;
1885 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
1886 }
1887
1888 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1889 {
1890 unsigned int present;
1891
1892 present = snd_hda_codec_read(codec, 0x21, 0,
1893 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1894 present &= HDA_AMP_VOLMASK;
1895 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1896 HDA_AMP_VOLMASK, present);
1897 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1898 HDA_AMP_VOLMASK, present);
1899 }
1900
1901 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1902 unsigned int res)
1903 {
1904 /* Looks like the unsol event is incompatible with the standard
1905 * definition. 4bit tag is placed at 28 bit!
1906 */
1907 if ((res >> 28) == ALC880_HP_EVENT)
1908 alc880_uniwill_p53_hp_automute(codec);
1909 if ((res >> 28) == ALC880_DCVOL_EVENT)
1910 alc880_uniwill_p53_dcvol_automute(codec);
1911 }
1912
1913 /*
1914 * F1734 pin configuration:
1915 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1916 */
1917 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1918 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1919 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1920 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1921 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1922
1923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1924 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1927
1928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1935 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1937
1938 { }
1939 };
1940
1941 /*
1942 * ASUS pin configuration:
1943 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1944 */
1945 static struct hda_verb alc880_pin_asus_init_verbs[] = {
1946 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1947 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1948 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1949 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1950
1951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1952 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1953 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1956 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1957 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1958 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1959
1960 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1962 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1964 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1969
1970 { }
1971 };
1972
1973 /* Enable GPIO mask and set output */
1974 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1975 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1976
1977 /* Clevo m520g init */
1978 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1979 /* headphone output */
1980 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1981 /* line-out */
1982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1984 /* Line-in */
1985 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1986 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1987 /* CD */
1988 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1989 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1990 /* Mic1 (rear panel) */
1991 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1993 /* Mic2 (front panel) */
1994 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1995 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1996 /* headphone */
1997 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1998 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1999 /* change to EAPD mode */
2000 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2001 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2002
2003 { }
2004 };
2005
2006 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2007 /* change to EAPD mode */
2008 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2009 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2010
2011 /* Headphone output */
2012 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2013 /* Front output*/
2014 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2015 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2016
2017 /* Line In pin widget for input */
2018 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2019 /* CD pin widget for input */
2020 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2021 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2022 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2023
2024 /* change to EAPD mode */
2025 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2026 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2027
2028 { }
2029 };
2030
2031 /*
2032 * LG m1 express dual
2033 *
2034 * Pin assignment:
2035 * Rear Line-In/Out (blue): 0x14
2036 * Build-in Mic-In: 0x15
2037 * Speaker-out: 0x17
2038 * HP-Out (green): 0x1b
2039 * Mic-In/Out (red): 0x19
2040 * SPDIF-Out: 0x1e
2041 */
2042
2043 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2044 static hda_nid_t alc880_lg_dac_nids[3] = {
2045 0x05, 0x02, 0x03
2046 };
2047
2048 /* seems analog CD is not working */
2049 static struct hda_input_mux alc880_lg_capture_source = {
2050 .num_items = 3,
2051 .items = {
2052 { "Mic", 0x1 },
2053 { "Line", 0x5 },
2054 { "Internal Mic", 0x6 },
2055 },
2056 };
2057
2058 /* 2,4,6 channel modes */
2059 static struct hda_verb alc880_lg_ch2_init[] = {
2060 /* set line-in and mic-in to input */
2061 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2062 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2063 { }
2064 };
2065
2066 static struct hda_verb alc880_lg_ch4_init[] = {
2067 /* set line-in to out and mic-in to input */
2068 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2069 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2070 { }
2071 };
2072
2073 static struct hda_verb alc880_lg_ch6_init[] = {
2074 /* set line-in and mic-in to output */
2075 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2076 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2077 { }
2078 };
2079
2080 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2081 { 2, alc880_lg_ch2_init },
2082 { 4, alc880_lg_ch4_init },
2083 { 6, alc880_lg_ch6_init },
2084 };
2085
2086 static struct snd_kcontrol_new alc880_lg_mixer[] = {
2087 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2088 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2089 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2090 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2091 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2092 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2093 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2094 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2096 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2099 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2100 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2101 {
2102 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2103 .name = "Channel Mode",
2104 .info = alc_ch_mode_info,
2105 .get = alc_ch_mode_get,
2106 .put = alc_ch_mode_put,
2107 },
2108 { } /* end */
2109 };
2110
2111 static struct hda_verb alc880_lg_init_verbs[] = {
2112 /* set capture source to mic-in */
2113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2115 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2116 /* mute all amp mixer inputs */
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2120 /* line-in to input */
2121 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2122 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2123 /* built-in mic */
2124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2126 /* speaker-out */
2127 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2128 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2129 /* mic-in to input */
2130 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2132 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2133 /* HP-out */
2134 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2135 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2136 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2137 /* jack sense */
2138 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2139 { }
2140 };
2141
2142 /* toggle speaker-output according to the hp-jack state */
2143 static void alc880_lg_automute(struct hda_codec *codec)
2144 {
2145 unsigned int present;
2146 unsigned char bits;
2147
2148 present = snd_hda_codec_read(codec, 0x1b, 0,
2149 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2150 bits = present ? HDA_AMP_MUTE : 0;
2151 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2152 HDA_AMP_MUTE, bits);
2153 }
2154
2155 static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2156 {
2157 /* Looks like the unsol event is incompatible with the standard
2158 * definition. 4bit tag is placed at 28 bit!
2159 */
2160 if ((res >> 28) == 0x01)
2161 alc880_lg_automute(codec);
2162 }
2163
2164 /*
2165 * LG LW20
2166 *
2167 * Pin assignment:
2168 * Speaker-out: 0x14
2169 * Mic-In: 0x18
2170 * Built-in Mic-In: 0x19
2171 * Line-In: 0x1b
2172 * HP-Out: 0x1a
2173 * SPDIF-Out: 0x1e
2174 */
2175
2176 static struct hda_input_mux alc880_lg_lw_capture_source = {
2177 .num_items = 3,
2178 .items = {
2179 { "Mic", 0x0 },
2180 { "Internal Mic", 0x1 },
2181 { "Line In", 0x2 },
2182 },
2183 };
2184
2185 #define alc880_lg_lw_modes alc880_threestack_modes
2186
2187 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2188 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2190 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2191 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2192 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2193 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2194 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2195 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2196 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2197 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2201 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2202 {
2203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2204 .name = "Channel Mode",
2205 .info = alc_ch_mode_info,
2206 .get = alc_ch_mode_get,
2207 .put = alc_ch_mode_put,
2208 },
2209 { } /* end */
2210 };
2211
2212 static struct hda_verb alc880_lg_lw_init_verbs[] = {
2213 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2214 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2215 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2216
2217 /* set capture source to mic-in */
2218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2219 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2220 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2222 /* speaker-out */
2223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2224 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2225 /* HP-out */
2226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2227 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2228 /* mic-in to input */
2229 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2231 /* built-in mic */
2232 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2234 /* jack sense */
2235 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2236 { }
2237 };
2238
2239 /* toggle speaker-output according to the hp-jack state */
2240 static void alc880_lg_lw_automute(struct hda_codec *codec)
2241 {
2242 unsigned int present;
2243 unsigned char bits;
2244
2245 present = snd_hda_codec_read(codec, 0x1b, 0,
2246 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2247 bits = present ? HDA_AMP_MUTE : 0;
2248 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2249 HDA_AMP_MUTE, bits);
2250 }
2251
2252 static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2253 {
2254 /* Looks like the unsol event is incompatible with the standard
2255 * definition. 4bit tag is placed at 28 bit!
2256 */
2257 if ((res >> 28) == 0x01)
2258 alc880_lg_lw_automute(codec);
2259 }
2260
2261 #ifdef CONFIG_SND_HDA_POWER_SAVE
2262 static struct hda_amp_list alc880_loopbacks[] = {
2263 { 0x0b, HDA_INPUT, 0 },
2264 { 0x0b, HDA_INPUT, 1 },
2265 { 0x0b, HDA_INPUT, 2 },
2266 { 0x0b, HDA_INPUT, 3 },
2267 { 0x0b, HDA_INPUT, 4 },
2268 { } /* end */
2269 };
2270
2271 static struct hda_amp_list alc880_lg_loopbacks[] = {
2272 { 0x0b, HDA_INPUT, 1 },
2273 { 0x0b, HDA_INPUT, 6 },
2274 { 0x0b, HDA_INPUT, 7 },
2275 { } /* end */
2276 };
2277 #endif
2278
2279 /*
2280 * Common callbacks
2281 */
2282
2283 static int alc_init(struct hda_codec *codec)
2284 {
2285 struct alc_spec *spec = codec->spec;
2286 unsigned int i;
2287
2288 for (i = 0; i < spec->num_init_verbs; i++)
2289 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2290
2291 if (spec->init_hook)
2292 spec->init_hook(codec);
2293
2294 return 0;
2295 }
2296
2297 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2298 {
2299 struct alc_spec *spec = codec->spec;
2300
2301 if (spec->unsol_event)
2302 spec->unsol_event(codec, res);
2303 }
2304
2305 #ifdef CONFIG_SND_HDA_POWER_SAVE
2306 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2307 {
2308 struct alc_spec *spec = codec->spec;
2309 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2310 }
2311 #endif
2312
2313 /*
2314 * Analog playback callbacks
2315 */
2316 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2317 struct hda_codec *codec,
2318 struct snd_pcm_substream *substream)
2319 {
2320 struct alc_spec *spec = codec->spec;
2321 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2322 }
2323
2324 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2325 struct hda_codec *codec,
2326 unsigned int stream_tag,
2327 unsigned int format,
2328 struct snd_pcm_substream *substream)
2329 {
2330 struct alc_spec *spec = codec->spec;
2331 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2332 stream_tag, format, substream);
2333 }
2334
2335 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2336 struct hda_codec *codec,
2337 struct snd_pcm_substream *substream)
2338 {
2339 struct alc_spec *spec = codec->spec;
2340 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2341 }
2342
2343 /*
2344 * Digital out
2345 */
2346 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2347 struct hda_codec *codec,
2348 struct snd_pcm_substream *substream)
2349 {
2350 struct alc_spec *spec = codec->spec;
2351 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2352 }
2353
2354 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2355 struct hda_codec *codec,
2356 unsigned int stream_tag,
2357 unsigned int format,
2358 struct snd_pcm_substream *substream)
2359 {
2360 struct alc_spec *spec = codec->spec;
2361 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2362 stream_tag, format, substream);
2363 }
2364
2365 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2366 struct hda_codec *codec,
2367 struct snd_pcm_substream *substream)
2368 {
2369 struct alc_spec *spec = codec->spec;
2370 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2371 }
2372
2373 /*
2374 * Analog capture
2375 */
2376 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2377 struct hda_codec *codec,
2378 unsigned int stream_tag,
2379 unsigned int format,
2380 struct snd_pcm_substream *substream)
2381 {
2382 struct alc_spec *spec = codec->spec;
2383
2384 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2385 stream_tag, 0, format);
2386 return 0;
2387 }
2388
2389 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2390 struct hda_codec *codec,
2391 struct snd_pcm_substream *substream)
2392 {
2393 struct alc_spec *spec = codec->spec;
2394
2395 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2396 0, 0, 0);
2397 return 0;
2398 }
2399
2400
2401 /*
2402 */
2403 static struct hda_pcm_stream alc880_pcm_analog_playback = {
2404 .substreams = 1,
2405 .channels_min = 2,
2406 .channels_max = 8,
2407 /* NID is set in alc_build_pcms */
2408 .ops = {
2409 .open = alc880_playback_pcm_open,
2410 .prepare = alc880_playback_pcm_prepare,
2411 .cleanup = alc880_playback_pcm_cleanup
2412 },
2413 };
2414
2415 static struct hda_pcm_stream alc880_pcm_analog_capture = {
2416 .substreams = 1,
2417 .channels_min = 2,
2418 .channels_max = 2,
2419 /* NID is set in alc_build_pcms */
2420 };
2421
2422 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2423 .substreams = 1,
2424 .channels_min = 2,
2425 .channels_max = 2,
2426 /* NID is set in alc_build_pcms */
2427 };
2428
2429 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2430 .substreams = 2, /* can be overridden */
2431 .channels_min = 2,
2432 .channels_max = 2,
2433 /* NID is set in alc_build_pcms */
2434 .ops = {
2435 .prepare = alc880_alt_capture_pcm_prepare,
2436 .cleanup = alc880_alt_capture_pcm_cleanup
2437 },
2438 };
2439
2440 static struct hda_pcm_stream alc880_pcm_digital_playback = {
2441 .substreams = 1,
2442 .channels_min = 2,
2443 .channels_max = 2,
2444 /* NID is set in alc_build_pcms */
2445 .ops = {
2446 .open = alc880_dig_playback_pcm_open,
2447 .close = alc880_dig_playback_pcm_close,
2448 .prepare = alc880_dig_playback_pcm_prepare
2449 },
2450 };
2451
2452 static struct hda_pcm_stream alc880_pcm_digital_capture = {
2453 .substreams = 1,
2454 .channels_min = 2,
2455 .channels_max = 2,
2456 /* NID is set in alc_build_pcms */
2457 };
2458
2459 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
2460 static struct hda_pcm_stream alc_pcm_null_stream = {
2461 .substreams = 0,
2462 .channels_min = 0,
2463 .channels_max = 0,
2464 };
2465
2466 static int alc_build_pcms(struct hda_codec *codec)
2467 {
2468 struct alc_spec *spec = codec->spec;
2469 struct hda_pcm *info = spec->pcm_rec;
2470 int i;
2471
2472 codec->num_pcms = 1;
2473 codec->pcm_info = info;
2474
2475 info->name = spec->stream_name_analog;
2476 if (spec->stream_analog_playback) {
2477 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2478 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2479 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2480 }
2481 if (spec->stream_analog_capture) {
2482 snd_assert(spec->adc_nids, return -EINVAL);
2483 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2484 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2485 }
2486
2487 if (spec->channel_mode) {
2488 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2489 for (i = 0; i < spec->num_channel_mode; i++) {
2490 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2491 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2492 }
2493 }
2494 }
2495
2496 /* SPDIF for stream index #1 */
2497 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2498 codec->num_pcms = 2;
2499 info = spec->pcm_rec + 1;
2500 info->name = spec->stream_name_digital;
2501 if (spec->multiout.dig_out_nid &&
2502 spec->stream_digital_playback) {
2503 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2505 }
2506 if (spec->dig_in_nid &&
2507 spec->stream_digital_capture) {
2508 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2509 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2510 }
2511 }
2512
2513 /* If the use of more than one ADC is requested for the current
2514 * model, configure a second analog capture-only PCM.
2515 */
2516 /* Additional Analaog capture for index #2 */
2517 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2518 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
2519 codec->num_pcms = 3;
2520 info = spec->pcm_rec + 2;
2521 info->name = spec->stream_name_analog;
2522 if (spec->alt_dac_nid) {
2523 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2524 *spec->stream_analog_alt_playback;
2525 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2526 spec->alt_dac_nid;
2527 } else {
2528 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2529 alc_pcm_null_stream;
2530 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2531 }
2532 if (spec->num_adc_nids > 1) {
2533 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2534 *spec->stream_analog_alt_capture;
2535 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2536 spec->adc_nids[1];
2537 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2538 spec->num_adc_nids - 1;
2539 } else {
2540 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2541 alc_pcm_null_stream;
2542 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2543 }
2544 }
2545
2546 return 0;
2547 }
2548
2549 static void alc_free(struct hda_codec *codec)
2550 {
2551 struct alc_spec *spec = codec->spec;
2552 unsigned int i;
2553
2554 if (!spec)
2555 return;
2556
2557 if (spec->kctl_alloc) {
2558 for (i = 0; i < spec->num_kctl_used; i++)
2559 kfree(spec->kctl_alloc[i].name);
2560 kfree(spec->kctl_alloc);
2561 }
2562 kfree(spec);
2563 }
2564
2565 /*
2566 */
2567 static struct hda_codec_ops alc_patch_ops = {
2568 .build_controls = alc_build_controls,
2569 .build_pcms = alc_build_pcms,
2570 .init = alc_init,
2571 .free = alc_free,
2572 .unsol_event = alc_unsol_event,
2573 #ifdef CONFIG_SND_HDA_POWER_SAVE
2574 .check_power_status = alc_check_power_status,
2575 #endif
2576 };
2577
2578
2579 /*
2580 * Test configuration for debugging
2581 *
2582 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2583 * enum controls.
2584 */
2585 #ifdef CONFIG_SND_DEBUG
2586 static hda_nid_t alc880_test_dac_nids[4] = {
2587 0x02, 0x03, 0x04, 0x05
2588 };
2589
2590 static struct hda_input_mux alc880_test_capture_source = {
2591 .num_items = 7,
2592 .items = {
2593 { "In-1", 0x0 },
2594 { "In-2", 0x1 },
2595 { "In-3", 0x2 },
2596 { "In-4", 0x3 },
2597 { "CD", 0x4 },
2598 { "Front", 0x5 },
2599 { "Surround", 0x6 },
2600 },
2601 };
2602
2603 static struct hda_channel_mode alc880_test_modes[4] = {
2604 { 2, NULL },
2605 { 4, NULL },
2606 { 6, NULL },
2607 { 8, NULL },
2608 };
2609
2610 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2611 struct snd_ctl_elem_info *uinfo)
2612 {
2613 static char *texts[] = {
2614 "N/A", "Line Out", "HP Out",
2615 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2616 };
2617 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2618 uinfo->count = 1;
2619 uinfo->value.enumerated.items = 8;
2620 if (uinfo->value.enumerated.item >= 8)
2621 uinfo->value.enumerated.item = 7;
2622 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2623 return 0;
2624 }
2625
2626 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2627 struct snd_ctl_elem_value *ucontrol)
2628 {
2629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2630 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2631 unsigned int pin_ctl, item = 0;
2632
2633 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2634 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2635 if (pin_ctl & AC_PINCTL_OUT_EN) {
2636 if (pin_ctl & AC_PINCTL_HP_EN)
2637 item = 2;
2638 else
2639 item = 1;
2640 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2641 switch (pin_ctl & AC_PINCTL_VREFEN) {
2642 case AC_PINCTL_VREF_HIZ: item = 3; break;
2643 case AC_PINCTL_VREF_50: item = 4; break;
2644 case AC_PINCTL_VREF_GRD: item = 5; break;
2645 case AC_PINCTL_VREF_80: item = 6; break;
2646 case AC_PINCTL_VREF_100: item = 7; break;
2647 }
2648 }
2649 ucontrol->value.enumerated.item[0] = item;
2650 return 0;
2651 }
2652
2653 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2654 struct snd_ctl_elem_value *ucontrol)
2655 {
2656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2657 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2658 static unsigned int ctls[] = {
2659 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2660 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2661 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2662 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2663 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2664 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2665 };
2666 unsigned int old_ctl, new_ctl;
2667
2668 old_ctl = snd_hda_codec_read(codec, nid, 0,
2669 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2670 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2671 if (old_ctl != new_ctl) {
2672 int val;
2673 snd_hda_codec_write_cache(codec, nid, 0,
2674 AC_VERB_SET_PIN_WIDGET_CONTROL,
2675 new_ctl);
2676 val = ucontrol->value.enumerated.item[0] >= 3 ?
2677 HDA_AMP_MUTE : 0;
2678 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2679 HDA_AMP_MUTE, val);
2680 return 1;
2681 }
2682 return 0;
2683 }
2684
2685 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2686 struct snd_ctl_elem_info *uinfo)
2687 {
2688 static char *texts[] = {
2689 "Front", "Surround", "CLFE", "Side"
2690 };
2691 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2692 uinfo->count = 1;
2693 uinfo->value.enumerated.items = 4;
2694 if (uinfo->value.enumerated.item >= 4)
2695 uinfo->value.enumerated.item = 3;
2696 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2697 return 0;
2698 }
2699
2700 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2701 struct snd_ctl_elem_value *ucontrol)
2702 {
2703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2704 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2705 unsigned int sel;
2706
2707 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2708 ucontrol->value.enumerated.item[0] = sel & 3;
2709 return 0;
2710 }
2711
2712 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2713 struct snd_ctl_elem_value *ucontrol)
2714 {
2715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2716 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2717 unsigned int sel;
2718
2719 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2720 if (ucontrol->value.enumerated.item[0] != sel) {
2721 sel = ucontrol->value.enumerated.item[0] & 3;
2722 snd_hda_codec_write_cache(codec, nid, 0,
2723 AC_VERB_SET_CONNECT_SEL, sel);
2724 return 1;
2725 }
2726 return 0;
2727 }
2728
2729 #define PIN_CTL_TEST(xname,nid) { \
2730 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2731 .name = xname, \
2732 .info = alc_test_pin_ctl_info, \
2733 .get = alc_test_pin_ctl_get, \
2734 .put = alc_test_pin_ctl_put, \
2735 .private_value = nid \
2736 }
2737
2738 #define PIN_SRC_TEST(xname,nid) { \
2739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2740 .name = xname, \
2741 .info = alc_test_pin_src_info, \
2742 .get = alc_test_pin_src_get, \
2743 .put = alc_test_pin_src_put, \
2744 .private_value = nid \
2745 }
2746
2747 static struct snd_kcontrol_new alc880_test_mixer[] = {
2748 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2749 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2750 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2751 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2752 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2753 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2754 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2755 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2756 PIN_CTL_TEST("Front Pin Mode", 0x14),
2757 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2758 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2759 PIN_CTL_TEST("Side Pin Mode", 0x17),
2760 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2761 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2762 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2763 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2764 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2765 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2766 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2767 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2768 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2769 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2770 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2771 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2772 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2773 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2774 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2775 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2776 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2777 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2778 {
2779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2780 .name = "Channel Mode",
2781 .info = alc_ch_mode_info,
2782 .get = alc_ch_mode_get,
2783 .put = alc_ch_mode_put,
2784 },
2785 { } /* end */
2786 };
2787
2788 static struct hda_verb alc880_test_init_verbs[] = {
2789 /* Unmute inputs of 0x0c - 0x0f */
2790 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2792 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2794 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2795 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2796 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2797 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2798 /* Vol output for 0x0c-0x0f */
2799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2800 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2801 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2802 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2803 /* Set output pins 0x14-0x17 */
2804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2806 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2807 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2808 /* Unmute output pins 0x14-0x17 */
2809 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2811 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2812 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2813 /* Set input pins 0x18-0x1c */
2814 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2815 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2816 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2817 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2818 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2819 /* Mute input pins 0x18-0x1b */
2820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2821 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2824 /* ADC set up */
2825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2826 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2827 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2828 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2829 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2830 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2831 /* Analog input/passthru */
2832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2837 { }
2838 };
2839 #endif
2840
2841 /*
2842 */
2843
2844 static const char *alc880_models[ALC880_MODEL_LAST] = {
2845 [ALC880_3ST] = "3stack",
2846 [ALC880_TCL_S700] = "tcl",
2847 [ALC880_3ST_DIG] = "3stack-digout",
2848 [ALC880_CLEVO] = "clevo",
2849 [ALC880_5ST] = "5stack",
2850 [ALC880_5ST_DIG] = "5stack-digout",
2851 [ALC880_W810] = "w810",
2852 [ALC880_Z71V] = "z71v",
2853 [ALC880_6ST] = "6stack",
2854 [ALC880_6ST_DIG] = "6stack-digout",
2855 [ALC880_ASUS] = "asus",
2856 [ALC880_ASUS_W1V] = "asus-w1v",
2857 [ALC880_ASUS_DIG] = "asus-dig",
2858 [ALC880_ASUS_DIG2] = "asus-dig2",
2859 [ALC880_UNIWILL_DIG] = "uniwill",
2860 [ALC880_UNIWILL_P53] = "uniwill-p53",
2861 [ALC880_FUJITSU] = "fujitsu",
2862 [ALC880_F1734] = "F1734",
2863 [ALC880_LG] = "lg",
2864 [ALC880_LG_LW] = "lg-lw",
2865 #ifdef CONFIG_SND_DEBUG
2866 [ALC880_TEST] = "test",
2867 #endif
2868 [ALC880_AUTO] = "auto",
2869 };
2870
2871 static struct snd_pci_quirk alc880_cfg_tbl[] = {
2872 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2873 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2874 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2875 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2876 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2877 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2878 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2879 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2880 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2881 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2882 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2883 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2884 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2885 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2886 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2887 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2888 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2889 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2890 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2891 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2892 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2893 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2894 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2895 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2896 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2897 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
2898 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2899 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2900 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2901 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2902 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2903 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2904 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2905 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2906 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2907 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2908 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2909 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2910 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2911 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2912 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2913 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2914 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2915 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2916 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2917 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2918 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2919 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2920 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2921 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2922 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2923 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2924 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2925 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2926 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2927 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2928 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2929 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2930 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2931 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2932 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2933 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2934 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2935 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2936 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2937 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2938 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2939 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2940 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2941 {}
2942 };
2943
2944 /*
2945 * ALC880 codec presets
2946 */
2947 static struct alc_config_preset alc880_presets[] = {
2948 [ALC880_3ST] = {
2949 .mixers = { alc880_three_stack_mixer },
2950 .init_verbs = { alc880_volume_init_verbs,
2951 alc880_pin_3stack_init_verbs },
2952 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2953 .dac_nids = alc880_dac_nids,
2954 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2955 .channel_mode = alc880_threestack_modes,
2956 .need_dac_fix = 1,
2957 .input_mux = &alc880_capture_source,
2958 },
2959 [ALC880_3ST_DIG] = {
2960 .mixers = { alc880_three_stack_mixer },
2961 .init_verbs = { alc880_volume_init_verbs,
2962 alc880_pin_3stack_init_verbs },
2963 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2964 .dac_nids = alc880_dac_nids,
2965 .dig_out_nid = ALC880_DIGOUT_NID,
2966 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2967 .channel_mode = alc880_threestack_modes,
2968 .need_dac_fix = 1,
2969 .input_mux = &alc880_capture_source,
2970 },
2971 [ALC880_TCL_S700] = {
2972 .mixers = { alc880_tcl_s700_mixer },
2973 .init_verbs = { alc880_volume_init_verbs,
2974 alc880_pin_tcl_S700_init_verbs,
2975 alc880_gpio2_init_verbs },
2976 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2977 .dac_nids = alc880_dac_nids,
2978 .hp_nid = 0x03,
2979 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2980 .channel_mode = alc880_2_jack_modes,
2981 .input_mux = &alc880_capture_source,
2982 },
2983 [ALC880_5ST] = {
2984 .mixers = { alc880_three_stack_mixer,
2985 alc880_five_stack_mixer},
2986 .init_verbs = { alc880_volume_init_verbs,
2987 alc880_pin_5stack_init_verbs },
2988 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2989 .dac_nids = alc880_dac_nids,
2990 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2991 .channel_mode = alc880_fivestack_modes,
2992 .input_mux = &alc880_capture_source,
2993 },
2994 [ALC880_5ST_DIG] = {
2995 .mixers = { alc880_three_stack_mixer,
2996 alc880_five_stack_mixer },
2997 .init_verbs = { alc880_volume_init_verbs,
2998 alc880_pin_5stack_init_verbs },
2999 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3000 .dac_nids = alc880_dac_nids,
3001 .dig_out_nid = ALC880_DIGOUT_NID,
3002 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3003 .channel_mode = alc880_fivestack_modes,
3004 .input_mux = &alc880_capture_source,
3005 },
3006 [ALC880_6ST] = {
3007 .mixers = { alc880_six_stack_mixer },
3008 .init_verbs = { alc880_volume_init_verbs,
3009 alc880_pin_6stack_init_verbs },
3010 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3011 .dac_nids = alc880_6st_dac_nids,
3012 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3013 .channel_mode = alc880_sixstack_modes,
3014 .input_mux = &alc880_6stack_capture_source,
3015 },
3016 [ALC880_6ST_DIG] = {
3017 .mixers = { alc880_six_stack_mixer },
3018 .init_verbs = { alc880_volume_init_verbs,
3019 alc880_pin_6stack_init_verbs },
3020 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3021 .dac_nids = alc880_6st_dac_nids,
3022 .dig_out_nid = ALC880_DIGOUT_NID,
3023 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3024 .channel_mode = alc880_sixstack_modes,
3025 .input_mux = &alc880_6stack_capture_source,
3026 },
3027 [ALC880_W810] = {
3028 .mixers = { alc880_w810_base_mixer },
3029 .init_verbs = { alc880_volume_init_verbs,
3030 alc880_pin_w810_init_verbs,
3031 alc880_gpio2_init_verbs },
3032 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3033 .dac_nids = alc880_w810_dac_nids,
3034 .dig_out_nid = ALC880_DIGOUT_NID,
3035 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3036 .channel_mode = alc880_w810_modes,
3037 .input_mux = &alc880_capture_source,
3038 },
3039 [ALC880_Z71V] = {
3040 .mixers = { alc880_z71v_mixer },
3041 .init_verbs = { alc880_volume_init_verbs,
3042 alc880_pin_z71v_init_verbs },
3043 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3044 .dac_nids = alc880_z71v_dac_nids,
3045 .dig_out_nid = ALC880_DIGOUT_NID,
3046 .hp_nid = 0x03,
3047 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3048 .channel_mode = alc880_2_jack_modes,
3049 .input_mux = &alc880_capture_source,
3050 },
3051 [ALC880_F1734] = {
3052 .mixers = { alc880_f1734_mixer },
3053 .init_verbs = { alc880_volume_init_verbs,
3054 alc880_pin_f1734_init_verbs },
3055 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3056 .dac_nids = alc880_f1734_dac_nids,
3057 .hp_nid = 0x02,
3058 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3059 .channel_mode = alc880_2_jack_modes,
3060 .input_mux = &alc880_capture_source,
3061 },
3062 [ALC880_ASUS] = {
3063 .mixers = { alc880_asus_mixer },
3064 .init_verbs = { alc880_volume_init_verbs,
3065 alc880_pin_asus_init_verbs,
3066 alc880_gpio1_init_verbs },
3067 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3068 .dac_nids = alc880_asus_dac_nids,
3069 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3070 .channel_mode = alc880_asus_modes,
3071 .need_dac_fix = 1,
3072 .input_mux = &alc880_capture_source,
3073 },
3074 [ALC880_ASUS_DIG] = {
3075 .mixers = { alc880_asus_mixer },
3076 .init_verbs = { alc880_volume_init_verbs,
3077 alc880_pin_asus_init_verbs,
3078 alc880_gpio1_init_verbs },
3079 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3080 .dac_nids = alc880_asus_dac_nids,
3081 .dig_out_nid = ALC880_DIGOUT_NID,
3082 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3083 .channel_mode = alc880_asus_modes,
3084 .need_dac_fix = 1,
3085 .input_mux = &alc880_capture_source,
3086 },
3087 [ALC880_ASUS_DIG2] = {
3088 .mixers = { alc880_asus_mixer },
3089 .init_verbs = { alc880_volume_init_verbs,
3090 alc880_pin_asus_init_verbs,
3091 alc880_gpio2_init_verbs }, /* use GPIO2 */
3092 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3093 .dac_nids = alc880_asus_dac_nids,
3094 .dig_out_nid = ALC880_DIGOUT_NID,
3095 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3096 .channel_mode = alc880_asus_modes,
3097 .need_dac_fix = 1,
3098 .input_mux = &alc880_capture_source,
3099 },
3100 [ALC880_ASUS_W1V] = {
3101 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
3102 .init_verbs = { alc880_volume_init_verbs,
3103 alc880_pin_asus_init_verbs,
3104 alc880_gpio1_init_verbs },
3105 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3106 .dac_nids = alc880_asus_dac_nids,
3107 .dig_out_nid = ALC880_DIGOUT_NID,
3108 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3109 .channel_mode = alc880_asus_modes,
3110 .need_dac_fix = 1,
3111 .input_mux = &alc880_capture_source,
3112 },
3113 [ALC880_UNIWILL_DIG] = {
3114 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
3115 .init_verbs = { alc880_volume_init_verbs,
3116 alc880_pin_asus_init_verbs },
3117 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3118 .dac_nids = alc880_asus_dac_nids,
3119 .dig_out_nid = ALC880_DIGOUT_NID,
3120 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3121 .channel_mode = alc880_asus_modes,
3122 .need_dac_fix = 1,
3123 .input_mux = &alc880_capture_source,
3124 },
3125 [ALC880_UNIWILL] = {
3126 .mixers = { alc880_uniwill_mixer },
3127 .init_verbs = { alc880_volume_init_verbs,
3128 alc880_uniwill_init_verbs },
3129 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3130 .dac_nids = alc880_asus_dac_nids,
3131 .dig_out_nid = ALC880_DIGOUT_NID,
3132 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3133 .channel_mode = alc880_threestack_modes,
3134 .need_dac_fix = 1,
3135 .input_mux = &alc880_capture_source,
3136 .unsol_event = alc880_uniwill_unsol_event,
3137 .init_hook = alc880_uniwill_automute,
3138 },
3139 [ALC880_UNIWILL_P53] = {
3140 .mixers = { alc880_uniwill_p53_mixer },
3141 .init_verbs = { alc880_volume_init_verbs,
3142 alc880_uniwill_p53_init_verbs },
3143 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3144 .dac_nids = alc880_asus_dac_nids,
3145 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3146 .channel_mode = alc880_threestack_modes,
3147 .input_mux = &alc880_capture_source,
3148 .unsol_event = alc880_uniwill_p53_unsol_event,
3149 .init_hook = alc880_uniwill_p53_hp_automute,
3150 },
3151 [ALC880_FUJITSU] = {
3152 .mixers = { alc880_fujitsu_mixer,
3153 alc880_pcbeep_mixer, },
3154 .init_verbs = { alc880_volume_init_verbs,
3155 alc880_uniwill_p53_init_verbs,
3156 alc880_beep_init_verbs },
3157 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3158 .dac_nids = alc880_dac_nids,
3159 .dig_out_nid = ALC880_DIGOUT_NID,
3160 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3161 .channel_mode = alc880_2_jack_modes,
3162 .input_mux = &alc880_capture_source,
3163 .unsol_event = alc880_uniwill_p53_unsol_event,
3164 .init_hook = alc880_uniwill_p53_hp_automute,
3165 },
3166 [ALC880_CLEVO] = {
3167 .mixers = { alc880_three_stack_mixer },
3168 .init_verbs = { alc880_volume_init_verbs,
3169 alc880_pin_clevo_init_verbs },
3170 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3171 .dac_nids = alc880_dac_nids,
3172 .hp_nid = 0x03,
3173 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3174 .channel_mode = alc880_threestack_modes,
3175 .need_dac_fix = 1,
3176 .input_mux = &alc880_capture_source,
3177 },
3178 [ALC880_LG] = {
3179 .mixers = { alc880_lg_mixer },
3180 .init_verbs = { alc880_volume_init_verbs,
3181 alc880_lg_init_verbs },
3182 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3183 .dac_nids = alc880_lg_dac_nids,
3184 .dig_out_nid = ALC880_DIGOUT_NID,
3185 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3186 .channel_mode = alc880_lg_ch_modes,
3187 .need_dac_fix = 1,
3188 .input_mux = &alc880_lg_capture_source,
3189 .unsol_event = alc880_lg_unsol_event,
3190 .init_hook = alc880_lg_automute,
3191 #ifdef CONFIG_SND_HDA_POWER_SAVE
3192 .loopbacks = alc880_lg_loopbacks,
3193 #endif
3194 },
3195 [ALC880_LG_LW] = {
3196 .mixers = { alc880_lg_lw_mixer },
3197 .init_verbs = { alc880_volume_init_verbs,
3198 alc880_lg_lw_init_verbs },
3199 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3200 .dac_nids = alc880_dac_nids,
3201 .dig_out_nid = ALC880_DIGOUT_NID,
3202 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3203 .channel_mode = alc880_lg_lw_modes,
3204 .input_mux = &alc880_lg_lw_capture_source,
3205 .unsol_event = alc880_lg_lw_unsol_event,
3206 .init_hook = alc880_lg_lw_automute,
3207 },
3208 #ifdef CONFIG_SND_DEBUG
3209 [ALC880_TEST] = {
3210 .mixers = { alc880_test_mixer },
3211 .init_verbs = { alc880_test_init_verbs },
3212 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3213 .dac_nids = alc880_test_dac_nids,
3214 .dig_out_nid = ALC880_DIGOUT_NID,
3215 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3216 .channel_mode = alc880_test_modes,
3217 .input_mux = &alc880_test_capture_source,
3218 },
3219 #endif
3220 };
3221
3222 /*
3223 * Automatic parse of I/O pins from the BIOS configuration
3224 */
3225
3226 #define NUM_CONTROL_ALLOC 32
3227 #define NUM_VERB_ALLOC 32
3228
3229 enum {
3230 ALC_CTL_WIDGET_VOL,
3231 ALC_CTL_WIDGET_MUTE,
3232 ALC_CTL_BIND_MUTE,
3233 };
3234 static struct snd_kcontrol_new alc880_control_templates[] = {
3235 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3236 HDA_CODEC_MUTE(NULL, 0, 0, 0),
3237 HDA_BIND_MUTE(NULL, 0, 0, 0),
3238 };
3239
3240 /* add dynamic controls */
3241 static int add_control(struct alc_spec *spec, int type, const char *name,
3242 unsigned long val)
3243 {
3244 struct snd_kcontrol_new *knew;
3245
3246 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3247 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3248
3249 /* array + terminator */
3250 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3251 if (!knew)
3252 return -ENOMEM;
3253 if (spec->kctl_alloc) {
3254 memcpy(knew, spec->kctl_alloc,
3255 sizeof(*knew) * spec->num_kctl_alloc);
3256 kfree(spec->kctl_alloc);
3257 }
3258 spec->kctl_alloc = knew;
3259 spec->num_kctl_alloc = num;
3260 }
3261
3262 knew = &spec->kctl_alloc[spec->num_kctl_used];
3263 *knew = alc880_control_templates[type];
3264 knew->name = kstrdup(name, GFP_KERNEL);
3265 if (!knew->name)
3266 return -ENOMEM;
3267 knew->private_value = val;
3268 spec->num_kctl_used++;
3269 return 0;
3270 }
3271
3272 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3273 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3274 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3275 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3276 #define alc880_is_input_pin(nid) ((nid) >= 0x18)
3277 #define alc880_input_pin_idx(nid) ((nid) - 0x18)
3278 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
3279 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
3280 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3281 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
3282 #define ALC880_PIN_CD_NID 0x1c
3283
3284 /* fill in the dac_nids table from the parsed pin configuration */
3285 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3286 const struct auto_pin_cfg *cfg)
3287 {
3288 hda_nid_t nid;
3289 int assigned[4];
3290 int i, j;
3291
3292 memset(assigned, 0, sizeof(assigned));
3293 spec->multiout.dac_nids = spec->private_dac_nids;
3294
3295 /* check the pins hardwired to audio widget */
3296 for (i = 0; i < cfg->line_outs; i++) {
3297 nid = cfg->line_out_pins[i];
3298 if (alc880_is_fixed_pin(nid)) {
3299 int idx = alc880_fixed_pin_idx(nid);
3300 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3301 assigned[idx] = 1;
3302 }
3303 }
3304 /* left pins can be connect to any audio widget */
3305 for (i = 0; i < cfg->line_outs; i++) {
3306 nid = cfg->line_out_pins[i];
3307 if (alc880_is_fixed_pin(nid))
3308 continue;
3309 /* search for an empty channel */
3310 for (j = 0; j < cfg->line_outs; j++) {
3311 if (!assigned[j]) {
3312 spec->multiout.dac_nids[i] =
3313 alc880_idx_to_dac(j);
3314 assigned[j] = 1;
3315 break;
3316 }
3317 }
3318 }
3319 spec->multiout.num_dacs = cfg->line_outs;
3320 return 0;
3321 }
3322
3323 /* add playback controls from the parsed DAC table */
3324 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3325 const struct auto_pin_cfg *cfg)
3326 {
3327 char name[32];
3328 static const char *chname[4] = {
3329 "Front", "Surround", NULL /*CLFE*/, "Side"
3330 };
3331 hda_nid_t nid;
3332 int i, err;
3333
3334 for (i = 0; i < cfg->line_outs; i++) {
3335 if (!spec->multiout.dac_nids[i])
3336 continue;
3337 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3338 if (i == 2) {
3339 /* Center/LFE */
3340 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3341 "Center Playback Volume",
3342 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3343 HDA_OUTPUT));
3344 if (err < 0)
3345 return err;
3346 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3347 "LFE Playback Volume",
3348 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3349 HDA_OUTPUT));
3350 if (err < 0)
3351 return err;
3352 err = add_control(spec, ALC_CTL_BIND_MUTE,
3353 "Center Playback Switch",
3354 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3355 HDA_INPUT));
3356 if (err < 0)
3357 return err;
3358 err = add_control(spec, ALC_CTL_BIND_MUTE,
3359 "LFE Playback Switch",
3360 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3361 HDA_INPUT));
3362 if (err < 0)
3363 return err;
3364 } else {
3365 sprintf(name, "%s Playback Volume", chname[i]);
3366 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3367 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3368 HDA_OUTPUT));
3369 if (err < 0)
3370 return err;
3371 sprintf(name, "%s Playback Switch", chname[i]);
3372 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3373 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3374 HDA_INPUT));
3375 if (err < 0)
3376 return err;
3377 }
3378 }
3379 return 0;
3380 }
3381
3382 /* add playback controls for speaker and HP outputs */
3383 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3384 const char *pfx)
3385 {
3386 hda_nid_t nid;
3387 int err;
3388 char name[32];
3389
3390 if (!pin)
3391 return 0;
3392
3393 if (alc880_is_fixed_pin(pin)) {
3394 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3395 /* specify the DAC as the extra output */
3396 if (!spec->multiout.hp_nid)
3397 spec->multiout.hp_nid = nid;
3398 else
3399 spec->multiout.extra_out_nid[0] = nid;
3400 /* control HP volume/switch on the output mixer amp */
3401 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3402 sprintf(name, "%s Playback Volume", pfx);
3403 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3404 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3405 if (err < 0)
3406 return err;
3407 sprintf(name, "%s Playback Switch", pfx);
3408 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3409 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3410 if (err < 0)
3411 return err;
3412 } else if (alc880_is_multi_pin(pin)) {
3413 /* set manual connection */
3414 /* we have only a switch on HP-out PIN */
3415 sprintf(name, "%s Playback Switch", pfx);
3416 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3417 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3418 if (err < 0)
3419 return err;
3420 }
3421 return 0;
3422 }
3423
3424 /* create input playback/capture controls for the given pin */
3425 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3426 const char *ctlname,
3427 int idx, hda_nid_t mix_nid)
3428 {
3429 char name[32];
3430 int err;
3431
3432 sprintf(name, "%s Playback Volume", ctlname);
3433 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3434 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3435 if (err < 0)
3436 return err;
3437 sprintf(name, "%s Playback Switch", ctlname);
3438 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3439 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3440 if (err < 0)
3441 return err;
3442 return 0;
3443 }
3444
3445 /* create playback/capture controls for input pins */
3446 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3447 const struct auto_pin_cfg *cfg)
3448 {
3449 struct hda_input_mux *imux = &spec->private_imux;
3450 int i, err, idx;
3451
3452 for (i = 0; i < AUTO_PIN_LAST; i++) {
3453 if (alc880_is_input_pin(cfg->input_pins[i])) {
3454 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3455 err = new_analog_input(spec, cfg->input_pins[i],
3456 auto_pin_cfg_labels[i],
3457 idx, 0x0b);
3458 if (err < 0)
3459 return err;
3460 imux->items[imux->num_items].label =
3461 auto_pin_cfg_labels[i];
3462 imux->items[imux->num_items].index =
3463 alc880_input_pin_idx(cfg->input_pins[i]);
3464 imux->num_items++;
3465 }
3466 }
3467 return 0;
3468 }
3469
3470 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3471 hda_nid_t nid, int pin_type,
3472 int dac_idx)
3473 {
3474 /* set as output */
3475 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3476 pin_type);
3477 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3478 AMP_OUT_UNMUTE);
3479 /* need the manual connection? */
3480 if (alc880_is_multi_pin(nid)) {
3481 struct alc_spec *spec = codec->spec;
3482 int idx = alc880_multi_pin_idx(nid);
3483 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3484 AC_VERB_SET_CONNECT_SEL,
3485 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3486 }
3487 }
3488
3489 static int get_pin_type(int line_out_type)
3490 {
3491 if (line_out_type == AUTO_PIN_HP_OUT)
3492 return PIN_HP;
3493 else
3494 return PIN_OUT;
3495 }
3496
3497 static void alc880_auto_init_multi_out(struct hda_codec *codec)
3498 {
3499 struct alc_spec *spec = codec->spec;
3500 int i;
3501
3502 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3503 for (i = 0; i < spec->autocfg.line_outs; i++) {
3504 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3505 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3506 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3507 }
3508 }
3509
3510 static void alc880_auto_init_extra_out(struct hda_codec *codec)
3511 {
3512 struct alc_spec *spec = codec->spec;
3513 hda_nid_t pin;
3514
3515 pin = spec->autocfg.speaker_pins[0];
3516 if (pin) /* connect to front */
3517 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3518 pin = spec->autocfg.hp_pins[0];
3519 if (pin) /* connect to front */
3520 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3521 }
3522
3523 static void alc880_auto_init_analog_input(struct hda_codec *codec)
3524 {
3525 struct alc_spec *spec = codec->spec;
3526 int i;
3527
3528 for (i = 0; i < AUTO_PIN_LAST; i++) {
3529 hda_nid_t nid = spec->autocfg.input_pins[i];
3530 if (alc880_is_input_pin(nid)) {
3531 snd_hda_codec_write(codec, nid, 0,
3532 AC_VERB_SET_PIN_WIDGET_CONTROL,
3533 i <= AUTO_PIN_FRONT_MIC ?
3534 PIN_VREF80 : PIN_IN);
3535 if (nid != ALC880_PIN_CD_NID)
3536 snd_hda_codec_write(codec, nid, 0,
3537 AC_VERB_SET_AMP_GAIN_MUTE,
3538 AMP_OUT_MUTE);
3539 }
3540 }
3541 }
3542
3543 /* parse the BIOS configuration and set up the alc_spec */
3544 /* return 1 if successful, 0 if the proper config is not found,
3545 * or a negative error code
3546 */
3547 static int alc880_parse_auto_config(struct hda_codec *codec)
3548 {
3549 struct alc_spec *spec = codec->spec;
3550 int err;
3551 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3552
3553 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3554 alc880_ignore);
3555 if (err < 0)
3556 return err;
3557 if (!spec->autocfg.line_outs)
3558 return 0; /* can't find valid BIOS pin config */
3559
3560 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3561 if (err < 0)
3562 return err;
3563 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3564 if (err < 0)
3565 return err;
3566 err = alc880_auto_create_extra_out(spec,
3567 spec->autocfg.speaker_pins[0],
3568 "Speaker");
3569 if (err < 0)
3570 return err;
3571 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3572 "Headphone");
3573 if (err < 0)
3574 return err;
3575 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3576 if (err < 0)
3577 return err;
3578
3579 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3580
3581 if (spec->autocfg.dig_out_pin)
3582 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3583 if (spec->autocfg.dig_in_pin)
3584 spec->dig_in_nid = ALC880_DIGIN_NID;
3585
3586 if (spec->kctl_alloc)
3587 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3588
3589 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3590
3591 spec->num_mux_defs = 1;
3592 spec->input_mux = &spec->private_imux;
3593
3594 return 1;
3595 }
3596
3597 /* additional initialization for auto-configuration model */
3598 static void alc880_auto_init(struct hda_codec *codec)
3599 {
3600 alc880_auto_init_multi_out(codec);
3601 alc880_auto_init_extra_out(codec);
3602 alc880_auto_init_analog_input(codec);
3603 }
3604
3605 /*
3606 * OK, here we have finally the patch for ALC880
3607 */
3608
3609 static int patch_alc880(struct hda_codec *codec)
3610 {
3611 struct alc_spec *spec;
3612 int board_config;
3613 int err;
3614
3615 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3616 if (spec == NULL)
3617 return -ENOMEM;
3618
3619 codec->spec = spec;
3620
3621 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3622 alc880_models,
3623 alc880_cfg_tbl);
3624 if (board_config < 0) {
3625 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3626 "trying auto-probe from BIOS...\n");
3627 board_config = ALC880_AUTO;
3628 }
3629
3630 if (board_config == ALC880_AUTO) {
3631 /* automatic parse from the BIOS config */
3632 err = alc880_parse_auto_config(codec);
3633 if (err < 0) {
3634 alc_free(codec);
3635 return err;
3636 } else if (!err) {
3637 printk(KERN_INFO
3638 "hda_codec: Cannot set up configuration "
3639 "from BIOS. Using 3-stack mode...\n");
3640 board_config = ALC880_3ST;
3641 }
3642 }
3643
3644 if (board_config != ALC880_AUTO)
3645 setup_preset(spec, &alc880_presets[board_config]);
3646
3647 spec->stream_name_analog = "ALC880 Analog";
3648 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3649 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3650 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
3651
3652 spec->stream_name_digital = "ALC880 Digital";
3653 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3654 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3655
3656 if (!spec->adc_nids && spec->input_mux) {
3657 /* check whether NID 0x07 is valid */
3658 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3659 /* get type */
3660 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3661 if (wcap != AC_WID_AUD_IN) {
3662 spec->adc_nids = alc880_adc_nids_alt;
3663 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3664 spec->mixers[spec->num_mixers] =
3665 alc880_capture_alt_mixer;
3666 spec->num_mixers++;
3667 } else {
3668 spec->adc_nids = alc880_adc_nids;
3669 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3670 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3671 spec->num_mixers++;
3672 }
3673 }
3674
3675 spec->vmaster_nid = 0x0c;
3676
3677 codec->patch_ops = alc_patch_ops;
3678 if (board_config == ALC880_AUTO)
3679 spec->init_hook = alc880_auto_init;
3680 #ifdef CONFIG_SND_HDA_POWER_SAVE
3681 if (!spec->loopback.amplist)
3682 spec->loopback.amplist = alc880_loopbacks;
3683 #endif
3684
3685 return 0;
3686 }
3687
3688
3689 /*
3690 * ALC260 support
3691 */
3692
3693 static hda_nid_t alc260_dac_nids[1] = {
3694 /* front */
3695 0x02,
3696 };
3697
3698 static hda_nid_t alc260_adc_nids[1] = {
3699 /* ADC0 */
3700 0x04,
3701 };
3702
3703 static hda_nid_t alc260_adc_nids_alt[1] = {
3704 /* ADC1 */
3705 0x05,
3706 };
3707
3708 static hda_nid_t alc260_hp_adc_nids[2] = {
3709 /* ADC1, 0 */
3710 0x05, 0x04
3711 };
3712
3713 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
3714 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3715 */
3716 static hda_nid_t alc260_dual_adc_nids[2] = {
3717 /* ADC0, ADC1 */
3718 0x04, 0x05
3719 };
3720
3721 #define ALC260_DIGOUT_NID 0x03
3722 #define ALC260_DIGIN_NID 0x06
3723
3724 static struct hda_input_mux alc260_capture_source = {
3725 .num_items = 4,
3726 .items = {
3727 { "Mic", 0x0 },
3728 { "Front Mic", 0x1 },
3729 { "Line", 0x2 },
3730 { "CD", 0x4 },
3731 },
3732 };
3733
3734 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3735 * headphone jack and the internal CD lines since these are the only pins at
3736 * which audio can appear. For flexibility, also allow the option of
3737 * recording the mixer output on the second ADC (ADC0 doesn't have a
3738 * connection to the mixer output).
3739 */
3740 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3741 {
3742 .num_items = 3,
3743 .items = {
3744 { "Mic/Line", 0x0 },
3745 { "CD", 0x4 },
3746 { "Headphone", 0x2 },
3747 },
3748 },
3749 {
3750 .num_items = 4,
3751 .items = {
3752 { "Mic/Line", 0x0 },
3753 { "CD", 0x4 },
3754 { "Headphone", 0x2 },
3755 { "Mixer", 0x5 },
3756 },
3757 },
3758
3759 };
3760
3761 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3762 * the Fujitsu S702x, but jacks are marked differently.
3763 */
3764 static struct hda_input_mux alc260_acer_capture_sources[2] = {
3765 {
3766 .num_items = 4,
3767 .items = {
3768 { "Mic", 0x0 },
3769 { "Line", 0x2 },
3770 { "CD", 0x4 },
3771 { "Headphone", 0x5 },
3772 },
3773 },
3774 {
3775 .num_items = 5,
3776 .items = {
3777 { "Mic", 0x0 },
3778 { "Line", 0x2 },
3779 { "CD", 0x4 },
3780 { "Headphone", 0x6 },
3781 { "Mixer", 0x5 },
3782 },
3783 },
3784 };
3785 /*
3786 * This is just place-holder, so there's something for alc_build_pcms to look
3787 * at when it calculates the maximum number of channels. ALC260 has no mixer
3788 * element which allows changing the channel mode, so the verb list is
3789 * never used.
3790 */
3791 static struct hda_channel_mode alc260_modes[1] = {
3792 { 2, NULL },
3793 };
3794
3795
3796 /* Mixer combinations
3797 *
3798 * basic: base_output + input + pc_beep + capture
3799 * HP: base_output + input + capture_alt
3800 * HP_3013: hp_3013 + input + capture
3801 * fujitsu: fujitsu + capture
3802 * acer: acer + capture
3803 */
3804
3805 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3806 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3807 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3808 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3809 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3810 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3811 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3812 { } /* end */
3813 };
3814
3815 static struct snd_kcontrol_new alc260_input_mixer[] = {
3816 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3817 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3818 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3819 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3821 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3824 { } /* end */
3825 };
3826
3827 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3828 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3829 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3830 { } /* end */
3831 };
3832
3833 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3834 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3835 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3836 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3837 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3838 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3839 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3840 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3841 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3842 { } /* end */
3843 };
3844
3845 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3846 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3847 */
3848 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3849 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3850 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3851 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3852 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3853 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3854 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3855 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3856 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3857 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3858 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3859 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3860 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3861 { } /* end */
3862 };
3863
3864 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3865 * versions of the ALC260 don't act on requests to enable mic bias from NID
3866 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3867 * datasheet doesn't mention this restriction. At this stage it's not clear
3868 * whether this behaviour is intentional or is a hardware bug in chip
3869 * revisions available in early 2006. Therefore for now allow the
3870 * "Headphone Jack Mode" control to span all choices, but if it turns out
3871 * that the lack of mic bias for this NID is intentional we could change the
3872 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3873 *
3874 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3875 * don't appear to make the mic bias available from the "line" jack, even
3876 * though the NID used for this jack (0x14) can supply it. The theory is
3877 * that perhaps Acer have included blocking capacitors between the ALC260
3878 * and the output jack. If this turns out to be the case for all such
3879 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3880 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3881 *
3882 * The C20x Tablet series have a mono internal speaker which is controlled
3883 * via the chip's Mono sum widget and pin complex, so include the necessary
3884 * controls for such models. On models without a "mono speaker" the control
3885 * won't do anything.
3886 */
3887 static struct snd_kcontrol_new alc260_acer_mixer[] = {
3888 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3889 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3890 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3891 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3892 HDA_OUTPUT),
3893 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3894 HDA_INPUT),
3895 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3896 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3898 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3899 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3900 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3901 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3902 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3903 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3904 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3905 { } /* end */
3906 };
3907
3908 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3909 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3910 */
3911 static struct snd_kcontrol_new alc260_will_mixer[] = {
3912 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3913 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3915 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3916 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3917 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3918 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3919 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3920 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3921 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3922 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3923 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3924 { } /* end */
3925 };
3926
3927 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3928 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3929 */
3930 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3931 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3932 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3934 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3935 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3936 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3937 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3938 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3939 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3940 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3941 { } /* end */
3942 };
3943
3944 /* capture mixer elements */
3945 static struct snd_kcontrol_new alc260_capture_mixer[] = {
3946 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3947 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3948 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3949 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3950 {
3951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3952 /* The multiple "Capture Source" controls confuse alsamixer
3953 * So call somewhat different..
3954 */
3955 /* .name = "Capture Source", */
3956 .name = "Input Source",
3957 .count = 2,
3958 .info = alc_mux_enum_info,
3959 .get = alc_mux_enum_get,
3960 .put = alc_mux_enum_put,
3961 },
3962 { } /* end */
3963 };
3964
3965 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3966 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3967 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3968 {
3969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3970 /* The multiple "Capture Source" controls confuse alsamixer
3971 * So call somewhat different..
3972 */
3973 /* .name = "Capture Source", */
3974 .name = "Input Source",
3975 .count = 1,
3976 .info = alc_mux_enum_info,
3977 .get = alc_mux_enum_get,
3978 .put = alc_mux_enum_put,
3979 },
3980 { } /* end */
3981 };
3982
3983 /*
3984 * initialization verbs
3985 */
3986 static struct hda_verb alc260_init_verbs[] = {
3987 /* Line In pin widget for input */
3988 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3989 /* CD pin widget for input */
3990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3991 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3992 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3993 /* Mic2 (front panel) pin widget for input and vref at 80% */
3994 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3995 /* LINE-2 is used for line-out in rear */
3996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3997 /* select line-out */
3998 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3999 /* LINE-OUT pin */
4000 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4001 /* enable HP */
4002 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4003 /* enable Mono */
4004 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4005 /* mute capture amp left and right */
4006 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4007 /* set connection select to line in (default select for this ADC) */
4008 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4009 /* mute capture amp left and right */
4010 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4011 /* set connection select to line in (default select for this ADC) */
4012 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
4013 /* set vol=0 Line-Out mixer amp left and right */
4014 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4015 /* unmute pin widget amp left and right (no gain on this amp) */
4016 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4017 /* set vol=0 HP mixer amp left and right */
4018 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4019 /* unmute pin widget amp left and right (no gain on this amp) */
4020 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4021 /* set vol=0 Mono mixer amp left and right */
4022 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4023 /* unmute pin widget amp left and right (no gain on this amp) */
4024 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4025 /* unmute LINE-2 out pin */
4026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4027 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4028 * Line In 2 = 0x03
4029 */
4030 /* mute analog inputs */
4031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4036 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4037 /* mute Front out path */
4038 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4040 /* mute Headphone out path */
4041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4043 /* mute Mono out path */
4044 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4045 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4046 { }
4047 };
4048
4049 #if 0 /* should be identical with alc260_init_verbs? */
4050 static struct hda_verb alc260_hp_init_verbs[] = {
4051 /* Headphone and output */
4052 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4053 /* mono output */
4054 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4055 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4056 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4057 /* Mic2 (front panel) pin widget for input and vref at 80% */
4058 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4059 /* Line In pin widget for input */
4060 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4061 /* Line-2 pin widget for output */
4062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4063 /* CD pin widget for input */
4064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4065 /* unmute amp left and right */
4066 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4067 /* set connection select to line in (default select for this ADC) */
4068 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4069 /* unmute Line-Out mixer amp left and right (volume = 0) */
4070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4071 /* mute pin widget amp left and right (no gain on this amp) */
4072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4073 /* unmute HP mixer amp left and right (volume = 0) */
4074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4075 /* mute pin widget amp left and right (no gain on this amp) */
4076 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4077 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4078 * Line In 2 = 0x03
4079 */
4080 /* mute analog inputs */
4081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4086 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4087 /* Unmute Front out path */
4088 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4089 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4090 /* Unmute Headphone out path */
4091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4092 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4093 /* Unmute Mono out path */
4094 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4095 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4096 { }
4097 };
4098 #endif
4099
4100 static struct hda_verb alc260_hp_3013_init_verbs[] = {
4101 /* Line out and output */
4102 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4103 /* mono output */
4104 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4105 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4106 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4107 /* Mic2 (front panel) pin widget for input and vref at 80% */
4108 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4109 /* Line In pin widget for input */
4110 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4111 /* Headphone pin widget for output */
4112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4113 /* CD pin widget for input */
4114 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4115 /* unmute amp left and right */
4116 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4117 /* set connection select to line in (default select for this ADC) */
4118 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4119 /* unmute Line-Out mixer amp left and right (volume = 0) */
4120 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4121 /* mute pin widget amp left and right (no gain on this amp) */
4122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4123 /* unmute HP mixer amp left and right (volume = 0) */
4124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4125 /* mute pin widget amp left and right (no gain on this amp) */
4126 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4127 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4128 * Line In 2 = 0x03
4129 */
4130 /* mute analog inputs */
4131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4134 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4136 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4137 /* Unmute Front out path */
4138 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4139 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4140 /* Unmute Headphone out path */
4141 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4142 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4143 /* Unmute Mono out path */
4144 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4145 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4146 { }
4147 };
4148
4149 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
4150 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4151 * audio = 0x16, internal speaker = 0x10.
4152 */
4153 static struct hda_verb alc260_fujitsu_init_verbs[] = {
4154 /* Disable all GPIOs */
4155 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4156 /* Internal speaker is connected to headphone pin */
4157 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4158 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4159 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4160 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4161 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4162 /* Ensure all other unused pins are disabled and muted. */
4163 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4164 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4165 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4166 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4167 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4168 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4170 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4171
4172 /* Disable digital (SPDIF) pins */
4173 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4174 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4175
4176 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4177 * when acting as an output.
4178 */
4179 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4180
4181 /* Start with output sum widgets muted and their output gains at min */
4182 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4183 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4184 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4185 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4186 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4187 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4188 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4189 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4190 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4191
4192 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4193 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4194 /* Unmute Line1 pin widget output buffer since it starts as an output.
4195 * If the pin mode is changed by the user the pin mode control will
4196 * take care of enabling the pin's input/output buffers as needed.
4197 * Therefore there's no need to enable the input buffer at this
4198 * stage.
4199 */
4200 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4201 /* Unmute input buffer of pin widget used for Line-in (no equiv
4202 * mixer ctrl)
4203 */
4204 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4205
4206 /* Mute capture amp left and right */
4207 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4208 /* Set ADC connection select to match default mixer setting - line
4209 * in (on mic1 pin)
4210 */
4211 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4212
4213 /* Do the same for the second ADC: mute capture input amp and
4214 * set ADC connection to line in (on mic1 pin)
4215 */
4216 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4217 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4218
4219 /* Mute all inputs to mixer widget (even unconnected ones) */
4220 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4222 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4224 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4228
4229 { }
4230 };
4231
4232 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4233 * similar laptops (adapted from Fujitsu init verbs).
4234 */
4235 static struct hda_verb alc260_acer_init_verbs[] = {
4236 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4237 * the headphone jack. Turn this on and rely on the standard mute
4238 * methods whenever the user wants to turn these outputs off.
4239 */
4240 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4241 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4242 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4243 /* Internal speaker/Headphone jack is connected to Line-out pin */
4244 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4245 /* Internal microphone/Mic jack is connected to Mic1 pin */
4246 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4247 /* Line In jack is connected to Line1 pin */
4248 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4249 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4250 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4251 /* Ensure all other unused pins are disabled and muted. */
4252 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4253 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4254 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4255 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4258 /* Disable digital (SPDIF) pins */
4259 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4260 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4261
4262 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4263 * bus when acting as outputs.
4264 */
4265 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4266 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4267
4268 /* Start with output sum widgets muted and their output gains at min */
4269 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4270 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4271 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4272 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4273 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4275 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4276 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4277 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4278
4279 /* Unmute Line-out pin widget amp left and right
4280 * (no equiv mixer ctrl)
4281 */
4282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4283 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4284 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4285 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4286 * inputs. If the pin mode is changed by the user the pin mode control
4287 * will take care of enabling the pin's input/output buffers as needed.
4288 * Therefore there's no need to enable the input buffer at this
4289 * stage.
4290 */
4291 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4293
4294 /* Mute capture amp left and right */
4295 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4296 /* Set ADC connection select to match default mixer setting - mic
4297 * (on mic1 pin)
4298 */
4299 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4300
4301 /* Do similar with the second ADC: mute capture input amp and
4302 * set ADC connection to mic to match ALSA's default state.
4303 */
4304 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4305 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4306
4307 /* Mute all inputs to mixer widget (even unconnected ones) */
4308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4316
4317 { }
4318 };
4319
4320 static struct hda_verb alc260_will_verbs[] = {
4321 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4322 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4323 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4324 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4325 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4326 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4327 {}
4328 };
4329
4330 static struct hda_verb alc260_replacer_672v_verbs[] = {
4331 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4332 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4333 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4334
4335 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4336 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4337 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4338
4339 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4340 {}
4341 };
4342
4343 /* toggle speaker-output according to the hp-jack state */
4344 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4345 {
4346 unsigned int present;
4347
4348 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4349 present = snd_hda_codec_read(codec, 0x0f, 0,
4350 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4351 if (present) {
4352 snd_hda_codec_write_cache(codec, 0x01, 0,
4353 AC_VERB_SET_GPIO_DATA, 1);
4354 snd_hda_codec_write_cache(codec, 0x0f, 0,
4355 AC_VERB_SET_PIN_WIDGET_CONTROL,
4356 PIN_HP);
4357 } else {
4358 snd_hda_codec_write_cache(codec, 0x01, 0,
4359 AC_VERB_SET_GPIO_DATA, 0);
4360 snd_hda_codec_write_cache(codec, 0x0f, 0,
4361 AC_VERB_SET_PIN_WIDGET_CONTROL,
4362 PIN_OUT);
4363 }
4364 }
4365
4366 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4367 unsigned int res)
4368 {
4369 if ((res >> 26) == ALC880_HP_EVENT)
4370 alc260_replacer_672v_automute(codec);
4371 }
4372
4373 /* Test configuration for debugging, modelled after the ALC880 test
4374 * configuration.
4375 */
4376 #ifdef CONFIG_SND_DEBUG
4377 static hda_nid_t alc260_test_dac_nids[1] = {
4378 0x02,
4379 };
4380 static hda_nid_t alc260_test_adc_nids[2] = {
4381 0x04, 0x05,
4382 };
4383 /* For testing the ALC260, each input MUX needs its own definition since
4384 * the signal assignments are different. This assumes that the first ADC
4385 * is NID 0x04.
4386 */
4387 static struct hda_input_mux alc260_test_capture_sources[2] = {
4388 {
4389 .num_items = 7,
4390 .items = {
4391 { "MIC1 pin", 0x0 },
4392 { "MIC2 pin", 0x1 },
4393 { "LINE1 pin", 0x2 },
4394 { "LINE2 pin", 0x3 },
4395 { "CD pin", 0x4 },
4396 { "LINE-OUT pin", 0x5 },
4397 { "HP-OUT pin", 0x6 },
4398 },
4399 },
4400 {
4401 .num_items = 8,
4402 .items = {
4403 { "MIC1 pin", 0x0 },
4404 { "MIC2 pin", 0x1 },
4405 { "LINE1 pin", 0x2 },
4406 { "LINE2 pin", 0x3 },
4407 { "CD pin", 0x4 },
4408 { "Mixer", 0x5 },
4409 { "LINE-OUT pin", 0x6 },
4410 { "HP-OUT pin", 0x7 },
4411 },
4412 },
4413 };
4414 static struct snd_kcontrol_new alc260_test_mixer[] = {
4415 /* Output driver widgets */
4416 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4417 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4418 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4419 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4420 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4421 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4422
4423 /* Modes for retasking pin widgets
4424 * Note: the ALC260 doesn't seem to act on requests to enable mic
4425 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4426 * mention this restriction. At this stage it's not clear whether
4427 * this behaviour is intentional or is a hardware bug in chip
4428 * revisions available at least up until early 2006. Therefore for
4429 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4430 * choices, but if it turns out that the lack of mic bias for these
4431 * NIDs is intentional we could change their modes from
4432 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4433 */
4434 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4435 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4436 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4437 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4438 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4439 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4440
4441 /* Loopback mixer controls */
4442 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4443 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4444 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4445 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4446 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4447 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4448 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4449 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4450 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4451 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4452 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4453 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4454 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4455 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4456 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4457 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4458
4459 /* Controls for GPIO pins, assuming they are configured as outputs */
4460 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4461 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4462 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4463 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4464
4465 /* Switches to allow the digital IO pins to be enabled. The datasheet
4466 * is ambigious as to which NID is which; testing on laptops which
4467 * make this output available should provide clarification.
4468 */
4469 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4470 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4471
4472 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4473 * this output to turn on an external amplifier.
4474 */
4475 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4476 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4477
4478 { } /* end */
4479 };
4480 static struct hda_verb alc260_test_init_verbs[] = {
4481 /* Enable all GPIOs as outputs with an initial value of 0 */
4482 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4483 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4484 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4485
4486 /* Enable retasking pins as output, initially without power amp */
4487 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4488 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4490 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4491 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4492 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4493
4494 /* Disable digital (SPDIF) pins initially, but users can enable
4495 * them via a mixer switch. In the case of SPDIF-out, this initverb
4496 * payload also sets the generation to 0, output to be in "consumer"
4497 * PCM format, copyright asserted, no pre-emphasis and no validity
4498 * control.
4499 */
4500 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4501 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4502
4503 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4504 * OUT1 sum bus when acting as an output.
4505 */
4506 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4507 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4508 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4509 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4510
4511 /* Start with output sum widgets muted and their output gains at min */
4512 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4513 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4514 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4515 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4516 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4518 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4519 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4520 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4521
4522 /* Unmute retasking pin widget output buffers since the default
4523 * state appears to be output. As the pin mode is changed by the
4524 * user the pin mode control will take care of enabling the pin's
4525 * input/output buffers as needed.
4526 */
4527 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4528 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4530 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4531 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4532 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4533 /* Also unmute the mono-out pin widget */
4534 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4535
4536 /* Mute capture amp left and right */
4537 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4538 /* Set ADC connection select to match default mixer setting (mic1
4539 * pin)
4540 */
4541 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4542
4543 /* Do the same for the second ADC: mute capture input amp and
4544 * set ADC connection to mic1 pin
4545 */
4546 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4547 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4548
4549 /* Mute all inputs to mixer widget (even unconnected ones) */
4550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4558
4559 { }
4560 };
4561 #endif
4562
4563 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4564 #define alc260_pcm_analog_capture alc880_pcm_analog_capture
4565
4566 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4567 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4568
4569 /*
4570 * for BIOS auto-configuration
4571 */
4572
4573 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4574 const char *pfx)
4575 {
4576 hda_nid_t nid_vol;
4577 unsigned long vol_val, sw_val;
4578 char name[32];
4579 int err;
4580
4581 if (nid >= 0x0f && nid < 0x11) {
4582 nid_vol = nid - 0x7;
4583 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4584 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4585 } else if (nid == 0x11) {
4586 nid_vol = nid - 0x7;
4587 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4588 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4589 } else if (nid >= 0x12 && nid <= 0x15) {
4590 nid_vol = 0x08;
4591 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4592 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4593 } else
4594 return 0; /* N/A */
4595
4596 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4597 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4598 if (err < 0)
4599 return err;
4600 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4601 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4602 if (err < 0)
4603 return err;
4604 return 1;
4605 }
4606
4607 /* add playback controls from the parsed DAC table */
4608 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4609 const struct auto_pin_cfg *cfg)
4610 {
4611 hda_nid_t nid;
4612 int err;
4613
4614 spec->multiout.num_dacs = 1;
4615 spec->multiout.dac_nids = spec->private_dac_nids;
4616 spec->multiout.dac_nids[0] = 0x02;
4617
4618 nid = cfg->line_out_pins[0];
4619 if (nid) {
4620 err = alc260_add_playback_controls(spec, nid, "Front");
4621 if (err < 0)
4622 return err;
4623 }
4624
4625 nid = cfg->speaker_pins[0];
4626 if (nid) {
4627 err = alc260_add_playback_controls(spec, nid, "Speaker");
4628 if (err < 0)
4629 return err;
4630 }
4631
4632 nid = cfg->hp_pins[0];
4633 if (nid) {
4634 err = alc260_add_playback_controls(spec, nid, "Headphone");
4635 if (err < 0)
4636 return err;
4637 }
4638 return 0;
4639 }
4640
4641 /* create playback/capture controls for input pins */
4642 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4643 const struct auto_pin_cfg *cfg)
4644 {
4645 struct hda_input_mux *imux = &spec->private_imux;
4646 int i, err, idx;
4647
4648 for (i = 0; i < AUTO_PIN_LAST; i++) {
4649 if (cfg->input_pins[i] >= 0x12) {
4650 idx = cfg->input_pins[i] - 0x12;
4651 err = new_analog_input(spec, cfg->input_pins[i],
4652 auto_pin_cfg_labels[i], idx,
4653 0x07);
4654 if (err < 0)
4655 return err;
4656 imux->items[imux->num_items].label =
4657 auto_pin_cfg_labels[i];
4658 imux->items[imux->num_items].index = idx;
4659 imux->num_items++;
4660 }
4661 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4662 idx = cfg->input_pins[i] - 0x09;
4663 err = new_analog_input(spec, cfg->input_pins[i],
4664 auto_pin_cfg_labels[i], idx,
4665 0x07);
4666 if (err < 0)
4667 return err;
4668 imux->items[imux->num_items].label =
4669 auto_pin_cfg_labels[i];
4670 imux->items[imux->num_items].index = idx;
4671 imux->num_items++;
4672 }
4673 }
4674 return 0;
4675 }
4676
4677 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4678 hda_nid_t nid, int pin_type,
4679 int sel_idx)
4680 {
4681 /* set as output */
4682 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4683 pin_type);
4684 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4685 AMP_OUT_UNMUTE);
4686 /* need the manual connection? */
4687 if (nid >= 0x12) {
4688 int idx = nid - 0x12;
4689 snd_hda_codec_write(codec, idx + 0x0b, 0,
4690 AC_VERB_SET_CONNECT_SEL, sel_idx);
4691 }
4692 }
4693
4694 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4695 {
4696 struct alc_spec *spec = codec->spec;
4697 hda_nid_t nid;
4698
4699 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4700 nid = spec->autocfg.line_out_pins[0];
4701 if (nid) {
4702 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4703 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4704 }
4705
4706 nid = spec->autocfg.speaker_pins[0];
4707 if (nid)
4708 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4709
4710 nid = spec->autocfg.hp_pins[0];
4711 if (nid)
4712 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4713 }
4714
4715 #define ALC260_PIN_CD_NID 0x16
4716 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4717 {
4718 struct alc_spec *spec = codec->spec;
4719 int i;
4720
4721 for (i = 0; i < AUTO_PIN_LAST; i++) {
4722 hda_nid_t nid = spec->autocfg.input_pins[i];
4723 if (nid >= 0x12) {
4724 snd_hda_codec_write(codec, nid, 0,
4725 AC_VERB_SET_PIN_WIDGET_CONTROL,
4726 i <= AUTO_PIN_FRONT_MIC ?
4727 PIN_VREF80 : PIN_IN);
4728 if (nid != ALC260_PIN_CD_NID)
4729 snd_hda_codec_write(codec, nid, 0,
4730 AC_VERB_SET_AMP_GAIN_MUTE,
4731 AMP_OUT_MUTE);
4732 }
4733 }
4734 }
4735
4736 /*
4737 * generic initialization of ADC, input mixers and output mixers
4738 */
4739 static struct hda_verb alc260_volume_init_verbs[] = {
4740 /*
4741 * Unmute ADC0-1 and set the default input to mic-in
4742 */
4743 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4744 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4745 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4746 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4747
4748 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4749 * mixer widget
4750 * Note: PASD motherboards uses the Line In 2 as the input for
4751 * front panel mic (mic 2)
4752 */
4753 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4754 /* mute analog inputs */
4755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4757 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4760
4761 /*
4762 * Set up output mixers (0x08 - 0x0a)
4763 */
4764 /* set vol=0 to output mixers */
4765 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4766 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4767 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4768 /* set up input amps for analog loopback */
4769 /* Amp Indices: DAC = 0, mixer = 1 */
4770 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4771 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4772 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4773 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4774 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4775 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4776
4777 { }
4778 };
4779
4780 static int alc260_parse_auto_config(struct hda_codec *codec)
4781 {
4782 struct alc_spec *spec = codec->spec;
4783 unsigned int wcap;
4784 int err;
4785 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4786
4787 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4788 alc260_ignore);
4789 if (err < 0)
4790 return err;
4791 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4792 if (err < 0)
4793 return err;
4794 if (!spec->kctl_alloc)
4795 return 0; /* can't find valid BIOS pin config */
4796 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4797 if (err < 0)
4798 return err;
4799
4800 spec->multiout.max_channels = 2;
4801
4802 if (spec->autocfg.dig_out_pin)
4803 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4804 if (spec->kctl_alloc)
4805 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4806
4807 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4808
4809 spec->num_mux_defs = 1;
4810 spec->input_mux = &spec->private_imux;
4811
4812 /* check whether NID 0x04 is valid */
4813 wcap = get_wcaps(codec, 0x04);
4814 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4815 if (wcap != AC_WID_AUD_IN) {
4816 spec->adc_nids = alc260_adc_nids_alt;
4817 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4818 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4819 } else {
4820 spec->adc_nids = alc260_adc_nids;
4821 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4822 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4823 }
4824 spec->num_mixers++;
4825
4826 return 1;
4827 }
4828
4829 /* additional initialization for auto-configuration model */
4830 static void alc260_auto_init(struct hda_codec *codec)
4831 {
4832 alc260_auto_init_multi_out(codec);
4833 alc260_auto_init_analog_input(codec);
4834 }
4835
4836 #ifdef CONFIG_SND_HDA_POWER_SAVE
4837 static struct hda_amp_list alc260_loopbacks[] = {
4838 { 0x07, HDA_INPUT, 0 },
4839 { 0x07, HDA_INPUT, 1 },
4840 { 0x07, HDA_INPUT, 2 },
4841 { 0x07, HDA_INPUT, 3 },
4842 { 0x07, HDA_INPUT, 4 },
4843 { } /* end */
4844 };
4845 #endif
4846
4847 /*
4848 * ALC260 configurations
4849 */
4850 static const char *alc260_models[ALC260_MODEL_LAST] = {
4851 [ALC260_BASIC] = "basic",
4852 [ALC260_HP] = "hp",
4853 [ALC260_HP_3013] = "hp-3013",
4854 [ALC260_FUJITSU_S702X] = "fujitsu",
4855 [ALC260_ACER] = "acer",
4856 [ALC260_WILL] = "will",
4857 [ALC260_REPLACER_672V] = "replacer",
4858 #ifdef CONFIG_SND_DEBUG
4859 [ALC260_TEST] = "test",
4860 #endif
4861 [ALC260_AUTO] = "auto",
4862 };
4863
4864 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4865 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4866 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4867 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4868 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4869 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4870 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4871 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4872 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4873 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4874 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4875 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4876 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4877 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4878 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4879 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4880 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4881 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4882 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4883 {}
4884 };
4885
4886 static struct alc_config_preset alc260_presets[] = {
4887 [ALC260_BASIC] = {
4888 .mixers = { alc260_base_output_mixer,
4889 alc260_input_mixer,
4890 alc260_pc_beep_mixer,
4891 alc260_capture_mixer },
4892 .init_verbs = { alc260_init_verbs },
4893 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4894 .dac_nids = alc260_dac_nids,
4895 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4896 .adc_nids = alc260_adc_nids,
4897 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4898 .channel_mode = alc260_modes,
4899 .input_mux = &alc260_capture_source,
4900 },
4901 [ALC260_HP] = {
4902 .mixers = { alc260_base_output_mixer,
4903 alc260_input_mixer,
4904 alc260_capture_alt_mixer },
4905 .init_verbs = { alc260_init_verbs },
4906 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4907 .dac_nids = alc260_dac_nids,
4908 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4909 .adc_nids = alc260_hp_adc_nids,
4910 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4911 .channel_mode = alc260_modes,
4912 .input_mux = &alc260_capture_source,
4913 },
4914 [ALC260_HP_3013] = {
4915 .mixers = { alc260_hp_3013_mixer,
4916 alc260_input_mixer,
4917 alc260_capture_alt_mixer },
4918 .init_verbs = { alc260_hp_3013_init_verbs },
4919 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4920 .dac_nids = alc260_dac_nids,
4921 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4922 .adc_nids = alc260_hp_adc_nids,
4923 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4924 .channel_mode = alc260_modes,
4925 .input_mux = &alc260_capture_source,
4926 },
4927 [ALC260_FUJITSU_S702X] = {
4928 .mixers = { alc260_fujitsu_mixer,
4929 alc260_capture_mixer },
4930 .init_verbs = { alc260_fujitsu_init_verbs },
4931 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4932 .dac_nids = alc260_dac_nids,
4933 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4934 .adc_nids = alc260_dual_adc_nids,
4935 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4936 .channel_mode = alc260_modes,
4937 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4938 .input_mux = alc260_fujitsu_capture_sources,
4939 },
4940 [ALC260_ACER] = {
4941 .mixers = { alc260_acer_mixer,
4942 alc260_capture_mixer },
4943 .init_verbs = { alc260_acer_init_verbs },
4944 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4945 .dac_nids = alc260_dac_nids,
4946 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4947 .adc_nids = alc260_dual_adc_nids,
4948 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4949 .channel_mode = alc260_modes,
4950 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4951 .input_mux = alc260_acer_capture_sources,
4952 },
4953 [ALC260_WILL] = {
4954 .mixers = { alc260_will_mixer,
4955 alc260_capture_mixer },
4956 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4957 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4958 .dac_nids = alc260_dac_nids,
4959 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4960 .adc_nids = alc260_adc_nids,
4961 .dig_out_nid = ALC260_DIGOUT_NID,
4962 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4963 .channel_mode = alc260_modes,
4964 .input_mux = &alc260_capture_source,
4965 },
4966 [ALC260_REPLACER_672V] = {
4967 .mixers = { alc260_replacer_672v_mixer,
4968 alc260_capture_mixer },
4969 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4970 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4971 .dac_nids = alc260_dac_nids,
4972 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4973 .adc_nids = alc260_adc_nids,
4974 .dig_out_nid = ALC260_DIGOUT_NID,
4975 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4976 .channel_mode = alc260_modes,
4977 .input_mux = &alc260_capture_source,
4978 .unsol_event = alc260_replacer_672v_unsol_event,
4979 .init_hook = alc260_replacer_672v_automute,
4980 },
4981 #ifdef CONFIG_SND_DEBUG
4982 [ALC260_TEST] = {
4983 .mixers = { alc260_test_mixer,
4984 alc260_capture_mixer },
4985 .init_verbs = { alc260_test_init_verbs },
4986 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4987 .dac_nids = alc260_test_dac_nids,
4988 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4989 .adc_nids = alc260_test_adc_nids,
4990 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4991 .channel_mode = alc260_modes,
4992 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4993 .input_mux = alc260_test_capture_sources,
4994 },
4995 #endif
4996 };
4997
4998 static int patch_alc260(struct hda_codec *codec)
4999 {
5000 struct alc_spec *spec;
5001 int err, board_config;
5002
5003 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5004 if (spec == NULL)
5005 return -ENOMEM;
5006
5007 codec->spec = spec;
5008
5009 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5010 alc260_models,
5011 alc260_cfg_tbl);
5012 if (board_config < 0) {
5013 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5014 "trying auto-probe from BIOS...\n");
5015 board_config = ALC260_AUTO;
5016 }
5017
5018 if (board_config == ALC260_AUTO) {
5019 /* automatic parse from the BIOS config */
5020 err = alc260_parse_auto_config(codec);
5021 if (err < 0) {
5022 alc_free(codec);
5023 return err;
5024 } else if (!err) {
5025 printk(KERN_INFO
5026 "hda_codec: Cannot set up configuration "
5027 "from BIOS. Using base mode...\n");
5028 board_config = ALC260_BASIC;
5029 }
5030 }
5031
5032 if (board_config != ALC260_AUTO)
5033 setup_preset(spec, &alc260_presets[board_config]);
5034
5035 spec->stream_name_analog = "ALC260 Analog";
5036 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5037 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5038
5039 spec->stream_name_digital = "ALC260 Digital";
5040 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5041 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5042
5043 spec->vmaster_nid = 0x08;
5044
5045 codec->patch_ops = alc_patch_ops;
5046 if (board_config == ALC260_AUTO)
5047 spec->init_hook = alc260_auto_init;
5048 #ifdef CONFIG_SND_HDA_POWER_SAVE
5049 if (!spec->loopback.amplist)
5050 spec->loopback.amplist = alc260_loopbacks;
5051 #endif
5052
5053 return 0;
5054 }
5055
5056
5057 /*
5058 * ALC882 support
5059 *
5060 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5061 * configuration. Each pin widget can choose any input DACs and a mixer.
5062 * Each ADC is connected from a mixer of all inputs. This makes possible
5063 * 6-channel independent captures.
5064 *
5065 * In addition, an independent DAC for the multi-playback (not used in this
5066 * driver yet).
5067 */
5068 #define ALC882_DIGOUT_NID 0x06
5069 #define ALC882_DIGIN_NID 0x0a
5070
5071 static struct hda_channel_mode alc882_ch_modes[1] = {
5072 { 8, NULL }
5073 };
5074
5075 static hda_nid_t alc882_dac_nids[4] = {
5076 /* front, rear, clfe, rear_surr */
5077 0x02, 0x03, 0x04, 0x05
5078 };
5079
5080 /* identical with ALC880 */
5081 #define alc882_adc_nids alc880_adc_nids
5082 #define alc882_adc_nids_alt alc880_adc_nids_alt
5083
5084 /* input MUX */
5085 /* FIXME: should be a matrix-type input source selection */
5086
5087 static struct hda_input_mux alc882_capture_source = {
5088 .num_items = 4,
5089 .items = {
5090 { "Mic", 0x0 },
5091 { "Front Mic", 0x1 },
5092 { "Line", 0x2 },
5093 { "CD", 0x4 },
5094 },
5095 };
5096 #define alc882_mux_enum_info alc_mux_enum_info
5097 #define alc882_mux_enum_get alc_mux_enum_get
5098
5099 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5100 struct snd_ctl_elem_value *ucontrol)
5101 {
5102 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5103 struct alc_spec *spec = codec->spec;
5104 const struct hda_input_mux *imux = spec->input_mux;
5105 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5106 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5107 hda_nid_t nid = capture_mixers[adc_idx];
5108 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5109 unsigned int i, idx;
5110
5111 idx = ucontrol->value.enumerated.item[0];
5112 if (idx >= imux->num_items)
5113 idx = imux->num_items - 1;
5114 if (*cur_val == idx)
5115 return 0;
5116 for (i = 0; i < imux->num_items; i++) {
5117 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5118 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
5119 imux->items[i].index,
5120 HDA_AMP_MUTE, v);
5121 }
5122 *cur_val = idx;
5123 return 1;
5124 }
5125
5126 /*
5127 * 2ch mode
5128 */
5129 static struct hda_verb alc882_3ST_ch2_init[] = {
5130 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5131 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5132 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5133 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5134 { } /* end */
5135 };
5136
5137 /*
5138 * 6ch mode
5139 */
5140 static struct hda_verb alc882_3ST_ch6_init[] = {
5141 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5142 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5143 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5144 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5145 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5146 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5147 { } /* end */
5148 };
5149
5150 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5151 { 2, alc882_3ST_ch2_init },
5152 { 6, alc882_3ST_ch6_init },
5153 };
5154
5155 /*
5156 * 6ch mode
5157 */
5158 static struct hda_verb alc882_sixstack_ch6_init[] = {
5159 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5160 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5161 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5162 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5163 { } /* end */
5164 };
5165
5166 /*
5167 * 8ch mode
5168 */
5169 static struct hda_verb alc882_sixstack_ch8_init[] = {
5170 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5171 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5172 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5173 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5174 { } /* end */
5175 };
5176
5177 static struct hda_channel_mode alc882_sixstack_modes[2] = {
5178 { 6, alc882_sixstack_ch6_init },
5179 { 8, alc882_sixstack_ch8_init },
5180 };
5181
5182 /*
5183 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5184 */
5185
5186 /*
5187 * 2ch mode
5188 */
5189 static struct hda_verb alc885_mbp_ch2_init[] = {
5190 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5191 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5192 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5193 { } /* end */
5194 };
5195
5196 /*
5197 * 6ch mode
5198 */
5199 static struct hda_verb alc885_mbp_ch6_init[] = {
5200 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5201 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5202 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5203 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5204 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5205 { } /* end */
5206 };
5207
5208 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5209 { 2, alc885_mbp_ch2_init },
5210 { 6, alc885_mbp_ch6_init },
5211 };
5212
5213
5214 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5215 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5216 */
5217 static struct snd_kcontrol_new alc882_base_mixer[] = {
5218 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5219 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5220 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5221 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5222 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5223 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5224 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5225 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5226 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5227 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5229 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5230 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5231 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5232 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5234 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5236 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5237 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5238 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5239 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5240 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5241 { } /* end */
5242 };
5243
5244 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
5245 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5246 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5247 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5248 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5249 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5250 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5252 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
5253 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
5254 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5255 { } /* end */
5256 };
5257 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5258 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5259 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5260 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5261 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5262 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5263 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5266 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5267 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5268 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5269 { } /* end */
5270 };
5271
5272 static struct snd_kcontrol_new alc882_targa_mixer[] = {
5273 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5274 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5278 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5279 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5282 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5283 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5284 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5285 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5286 { } /* end */
5287 };
5288
5289 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5290 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5291 */
5292 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5293 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5294 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5295 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5296 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5297 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5298 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5299 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5300 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5301 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5302 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5304 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5305 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5306 { } /* end */
5307 };
5308
5309 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5310 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5311 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5318 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5320 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5321 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5322 { } /* end */
5323 };
5324
5325 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5326 {
5327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5328 .name = "Channel Mode",
5329 .info = alc_ch_mode_info,
5330 .get = alc_ch_mode_get,
5331 .put = alc_ch_mode_put,
5332 },
5333 { } /* end */
5334 };
5335
5336 static struct hda_verb alc882_init_verbs[] = {
5337 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5341 /* Rear mixer */
5342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5344 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5345 /* CLFE mixer */
5346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5349 /* Side mixer */
5350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5353
5354 /* Front Pin: output 0 (0x0c) */
5355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5356 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5357 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5358 /* Rear Pin: output 1 (0x0d) */
5359 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5361 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5362 /* CLFE Pin: output 2 (0x0e) */
5363 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5364 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5365 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5366 /* Side Pin: output 3 (0x0f) */
5367 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5368 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5369 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5370 /* Mic (rear) pin: input vref at 80% */
5371 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5372 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5373 /* Front Mic pin: input vref at 80% */
5374 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5376 /* Line In pin: input */
5377 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5379 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5380 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5381 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5382 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5383 /* CD pin widget for input */
5384 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5385
5386 /* FIXME: use matrix-type input source selection */
5387 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5388 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5391 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5393 /* Input mixer2 */
5394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5396 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5398 /* Input mixer3 */
5399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5403 /* ADC1: mute amp left and right */
5404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5405 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5406 /* ADC2: mute amp left and right */
5407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5408 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5409 /* ADC3: mute amp left and right */
5410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5411 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5412
5413 { }
5414 };
5415
5416 static struct hda_verb alc882_eapd_verbs[] = {
5417 /* change to EAPD mode */
5418 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5419 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5420 { }
5421 };
5422
5423 /* Mac Pro test */
5424 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5425 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5426 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5430 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5431 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5432 { } /* end */
5433 };
5434
5435 static struct hda_verb alc882_macpro_init_verbs[] = {
5436 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5438 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5439 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5440 /* Front Pin: output 0 (0x0c) */
5441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5443 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5444 /* Front Mic pin: input vref at 80% */
5445 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5446 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5447 /* Speaker: output */
5448 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5449 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5450 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5451 /* Headphone output (output 0 - 0x0c) */
5452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5453 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5454 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5455
5456 /* FIXME: use matrix-type input source selection */
5457 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5458 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5461 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5462 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5463 /* Input mixer2 */
5464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5465 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5466 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5467 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5468 /* Input mixer3 */
5469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5471 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5473 /* ADC1: mute amp left and right */
5474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5475 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5476 /* ADC2: mute amp left and right */
5477 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5478 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5479 /* ADC3: mute amp left and right */
5480 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5481 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5482
5483 { }
5484 };
5485
5486 /* Macbook Pro rev3 */
5487 static struct hda_verb alc885_mbp3_init_verbs[] = {
5488 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5492 /* Rear mixer */
5493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5494 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5495 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5496 /* Front Pin: output 0 (0x0c) */
5497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5499 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5500 /* HP Pin: output 0 (0x0d) */
5501 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5503 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5504 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5505 /* Mic (rear) pin: input vref at 80% */
5506 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5507 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5508 /* Front Mic pin: input vref at 80% */
5509 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5511 /* Line In pin: use output 1 when in LineOut mode */
5512 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5513 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5514 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5515
5516 /* FIXME: use matrix-type input source selection */
5517 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5518 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5521 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5523 /* Input mixer2 */
5524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5527 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5528 /* Input mixer3 */
5529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5533 /* ADC1: mute amp left and right */
5534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5535 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5536 /* ADC2: mute amp left and right */
5537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5538 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5539 /* ADC3: mute amp left and right */
5540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5541 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5542
5543 { }
5544 };
5545
5546 /* iMac 24 mixer. */
5547 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5548 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5549 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5550 { } /* end */
5551 };
5552
5553 /* iMac 24 init verbs. */
5554 static struct hda_verb alc885_imac24_init_verbs[] = {
5555 /* Internal speakers: output 0 (0x0c) */
5556 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5557 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5558 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5559 /* Internal speakers: output 0 (0x0c) */
5560 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5561 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5562 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5563 /* Headphone: output 0 (0x0c) */
5564 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5565 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5566 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5567 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5568 /* Front Mic: input vref at 80% */
5569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5571 { }
5572 };
5573
5574 /* Toggle speaker-output according to the hp-jack state */
5575 static void alc885_imac24_automute(struct hda_codec *codec)
5576 {
5577 unsigned int present;
5578
5579 present = snd_hda_codec_read(codec, 0x14, 0,
5580 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5581 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5582 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5583 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5584 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5585 }
5586
5587 /* Processes unsolicited events. */
5588 static void alc885_imac24_unsol_event(struct hda_codec *codec,
5589 unsigned int res)
5590 {
5591 /* Headphone insertion or removal. */
5592 if ((res >> 26) == ALC880_HP_EVENT)
5593 alc885_imac24_automute(codec);
5594 }
5595
5596 static void alc885_mbp3_automute(struct hda_codec *codec)
5597 {
5598 unsigned int present;
5599
5600 present = snd_hda_codec_read(codec, 0x15, 0,
5601 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5602 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5603 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5604 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5605 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5606
5607 }
5608 static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5609 unsigned int res)
5610 {
5611 /* Headphone insertion or removal. */
5612 if ((res >> 26) == ALC880_HP_EVENT)
5613 alc885_mbp3_automute(codec);
5614 }
5615
5616
5617 static struct hda_verb alc882_targa_verbs[] = {
5618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5619 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5620
5621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5623
5624 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5625 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5626 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5627
5628 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5629 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5630 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5631 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5632 { } /* end */
5633 };
5634
5635 /* toggle speaker-output according to the hp-jack state */
5636 static void alc882_targa_automute(struct hda_codec *codec)
5637 {
5638 unsigned int present;
5639
5640 present = snd_hda_codec_read(codec, 0x14, 0,
5641 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5642 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5643 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5644 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5645 present ? 1 : 3);
5646 }
5647
5648 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5649 {
5650 /* Looks like the unsol event is incompatible with the standard
5651 * definition. 4bit tag is placed at 26 bit!
5652 */
5653 if (((res >> 26) == ALC880_HP_EVENT)) {
5654 alc882_targa_automute(codec);
5655 }
5656 }
5657
5658 static struct hda_verb alc882_asus_a7j_verbs[] = {
5659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5661
5662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5665
5666 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5668 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5669
5670 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5671 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5672 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5673 { } /* end */
5674 };
5675
5676 static struct hda_verb alc882_asus_a7m_verbs[] = {
5677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5679
5680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5682 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5683
5684 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5686 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5687
5688 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5689 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5690 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5691 { } /* end */
5692 };
5693
5694 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5695 {
5696 unsigned int gpiostate, gpiomask, gpiodir;
5697
5698 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5699 AC_VERB_GET_GPIO_DATA, 0);
5700
5701 if (!muted)
5702 gpiostate |= (1 << pin);
5703 else
5704 gpiostate &= ~(1 << pin);
5705
5706 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5707 AC_VERB_GET_GPIO_MASK, 0);
5708 gpiomask |= (1 << pin);
5709
5710 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5711 AC_VERB_GET_GPIO_DIRECTION, 0);
5712 gpiodir |= (1 << pin);
5713
5714
5715 snd_hda_codec_write(codec, codec->afg, 0,
5716 AC_VERB_SET_GPIO_MASK, gpiomask);
5717 snd_hda_codec_write(codec, codec->afg, 0,
5718 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5719
5720 msleep(1);
5721
5722 snd_hda_codec_write(codec, codec->afg, 0,
5723 AC_VERB_SET_GPIO_DATA, gpiostate);
5724 }
5725
5726 /* set up GPIO at initialization */
5727 static void alc885_macpro_init_hook(struct hda_codec *codec)
5728 {
5729 alc882_gpio_mute(codec, 0, 0);
5730 alc882_gpio_mute(codec, 1, 0);
5731 }
5732
5733 /* set up GPIO and update auto-muting at initialization */
5734 static void alc885_imac24_init_hook(struct hda_codec *codec)
5735 {
5736 alc885_macpro_init_hook(codec);
5737 alc885_imac24_automute(codec);
5738 }
5739
5740 /*
5741 * generic initialization of ADC, input mixers and output mixers
5742 */
5743 static struct hda_verb alc882_auto_init_verbs[] = {
5744 /*
5745 * Unmute ADC0-2 and set the default input to mic-in
5746 */
5747 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5749 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5751 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5752 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5753
5754 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5755 * mixer widget
5756 * Note: PASD motherboards uses the Line In 2 as the input for
5757 * front panel mic (mic 2)
5758 */
5759 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5765
5766 /*
5767 * Set up output mixers (0x0c - 0x0f)
5768 */
5769 /* set vol=0 to output mixers */
5770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5771 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5773 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5774 /* set up input amps for analog loopback */
5775 /* Amp Indices: DAC = 0, mixer = 1 */
5776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5777 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5779 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5781 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5782 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5783 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5784 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5785 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5786
5787 /* FIXME: use matrix-type input source selection */
5788 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5789 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5792 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5793 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5794 /* Input mixer2 */
5795 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5798 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5799 /* Input mixer3 */
5800 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5804
5805 { }
5806 };
5807
5808 /* capture mixer elements */
5809 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5810 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5811 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5812 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5813 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5814 {
5815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5816 /* The multiple "Capture Source" controls confuse alsamixer
5817 * So call somewhat different..
5818 */
5819 /* .name = "Capture Source", */
5820 .name = "Input Source",
5821 .count = 2,
5822 .info = alc882_mux_enum_info,
5823 .get = alc882_mux_enum_get,
5824 .put = alc882_mux_enum_put,
5825 },
5826 { } /* end */
5827 };
5828
5829 static struct snd_kcontrol_new alc882_capture_mixer[] = {
5830 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5831 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5832 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5833 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5834 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5835 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5836 {
5837 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5838 /* The multiple "Capture Source" controls confuse alsamixer
5839 * So call somewhat different..
5840 */
5841 /* .name = "Capture Source", */
5842 .name = "Input Source",
5843 .count = 3,
5844 .info = alc882_mux_enum_info,
5845 .get = alc882_mux_enum_get,
5846 .put = alc882_mux_enum_put,
5847 },
5848 { } /* end */
5849 };
5850
5851 #ifdef CONFIG_SND_HDA_POWER_SAVE
5852 #define alc882_loopbacks alc880_loopbacks
5853 #endif
5854
5855 /* pcm configuration: identiacal with ALC880 */
5856 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
5857 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
5858 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
5859 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
5860
5861 /*
5862 * configuration and preset
5863 */
5864 static const char *alc882_models[ALC882_MODEL_LAST] = {
5865 [ALC882_3ST_DIG] = "3stack-dig",
5866 [ALC882_6ST_DIG] = "6stack-dig",
5867 [ALC882_ARIMA] = "arima",
5868 [ALC882_W2JC] = "w2jc",
5869 [ALC882_TARGA] = "targa",
5870 [ALC882_ASUS_A7J] = "asus-a7j",
5871 [ALC882_ASUS_A7M] = "asus-a7m",
5872 [ALC885_MACPRO] = "macpro",
5873 [ALC885_MBP3] = "mbp3",
5874 [ALC885_IMAC24] = "imac24",
5875 [ALC882_AUTO] = "auto",
5876 };
5877
5878 static struct snd_pci_quirk alc882_cfg_tbl[] = {
5879 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5880 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5881 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
5882 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
5883 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
5884 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
5885 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5886 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5887 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5888 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5889 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5890 {}
5891 };
5892
5893 static struct alc_config_preset alc882_presets[] = {
5894 [ALC882_3ST_DIG] = {
5895 .mixers = { alc882_base_mixer },
5896 .init_verbs = { alc882_init_verbs },
5897 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5898 .dac_nids = alc882_dac_nids,
5899 .dig_out_nid = ALC882_DIGOUT_NID,
5900 .dig_in_nid = ALC882_DIGIN_NID,
5901 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5902 .channel_mode = alc882_ch_modes,
5903 .need_dac_fix = 1,
5904 .input_mux = &alc882_capture_source,
5905 },
5906 [ALC882_6ST_DIG] = {
5907 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5908 .init_verbs = { alc882_init_verbs },
5909 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5910 .dac_nids = alc882_dac_nids,
5911 .dig_out_nid = ALC882_DIGOUT_NID,
5912 .dig_in_nid = ALC882_DIGIN_NID,
5913 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5914 .channel_mode = alc882_sixstack_modes,
5915 .input_mux = &alc882_capture_source,
5916 },
5917 [ALC882_ARIMA] = {
5918 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5919 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5920 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5921 .dac_nids = alc882_dac_nids,
5922 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5923 .channel_mode = alc882_sixstack_modes,
5924 .input_mux = &alc882_capture_source,
5925 },
5926 [ALC882_W2JC] = {
5927 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5928 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5929 alc880_gpio1_init_verbs },
5930 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5931 .dac_nids = alc882_dac_nids,
5932 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5933 .channel_mode = alc880_threestack_modes,
5934 .need_dac_fix = 1,
5935 .input_mux = &alc882_capture_source,
5936 .dig_out_nid = ALC882_DIGOUT_NID,
5937 },
5938 [ALC885_MBP3] = {
5939 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5940 .init_verbs = { alc885_mbp3_init_verbs,
5941 alc880_gpio1_init_verbs },
5942 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5943 .dac_nids = alc882_dac_nids,
5944 .channel_mode = alc885_mbp_6ch_modes,
5945 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5946 .input_mux = &alc882_capture_source,
5947 .dig_out_nid = ALC882_DIGOUT_NID,
5948 .dig_in_nid = ALC882_DIGIN_NID,
5949 .unsol_event = alc885_mbp3_unsol_event,
5950 .init_hook = alc885_mbp3_automute,
5951 },
5952 [ALC885_MACPRO] = {
5953 .mixers = { alc882_macpro_mixer },
5954 .init_verbs = { alc882_macpro_init_verbs },
5955 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5956 .dac_nids = alc882_dac_nids,
5957 .dig_out_nid = ALC882_DIGOUT_NID,
5958 .dig_in_nid = ALC882_DIGIN_NID,
5959 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5960 .channel_mode = alc882_ch_modes,
5961 .input_mux = &alc882_capture_source,
5962 .init_hook = alc885_macpro_init_hook,
5963 },
5964 [ALC885_IMAC24] = {
5965 .mixers = { alc885_imac24_mixer },
5966 .init_verbs = { alc885_imac24_init_verbs },
5967 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5968 .dac_nids = alc882_dac_nids,
5969 .dig_out_nid = ALC882_DIGOUT_NID,
5970 .dig_in_nid = ALC882_DIGIN_NID,
5971 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5972 .channel_mode = alc882_ch_modes,
5973 .input_mux = &alc882_capture_source,
5974 .unsol_event = alc885_imac24_unsol_event,
5975 .init_hook = alc885_imac24_init_hook,
5976 },
5977 [ALC882_TARGA] = {
5978 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5979 alc882_capture_mixer },
5980 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5981 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5982 .dac_nids = alc882_dac_nids,
5983 .dig_out_nid = ALC882_DIGOUT_NID,
5984 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5985 .adc_nids = alc882_adc_nids,
5986 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5987 .channel_mode = alc882_3ST_6ch_modes,
5988 .need_dac_fix = 1,
5989 .input_mux = &alc882_capture_source,
5990 .unsol_event = alc882_targa_unsol_event,
5991 .init_hook = alc882_targa_automute,
5992 },
5993 [ALC882_ASUS_A7J] = {
5994 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5995 alc882_capture_mixer },
5996 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5997 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5998 .dac_nids = alc882_dac_nids,
5999 .dig_out_nid = ALC882_DIGOUT_NID,
6000 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6001 .adc_nids = alc882_adc_nids,
6002 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6003 .channel_mode = alc882_3ST_6ch_modes,
6004 .need_dac_fix = 1,
6005 .input_mux = &alc882_capture_source,
6006 },
6007 [ALC882_ASUS_A7M] = {
6008 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6009 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6010 alc880_gpio1_init_verbs,
6011 alc882_asus_a7m_verbs },
6012 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6013 .dac_nids = alc882_dac_nids,
6014 .dig_out_nid = ALC882_DIGOUT_NID,
6015 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6016 .channel_mode = alc880_threestack_modes,
6017 .need_dac_fix = 1,
6018 .input_mux = &alc882_capture_source,
6019 },
6020 };
6021
6022
6023 /*
6024 * Pin config fixes
6025 */
6026 enum {
6027 PINFIX_ABIT_AW9D_MAX
6028 };
6029
6030 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6031 { 0x15, 0x01080104 }, /* side */
6032 { 0x16, 0x01011012 }, /* rear */
6033 { 0x17, 0x01016011 }, /* clfe */
6034 { }
6035 };
6036
6037 static const struct alc_pincfg *alc882_pin_fixes[] = {
6038 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6039 };
6040
6041 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6042 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6043 {}
6044 };
6045
6046 /*
6047 * BIOS auto configuration
6048 */
6049 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6050 hda_nid_t nid, int pin_type,
6051 int dac_idx)
6052 {
6053 /* set as output */
6054 struct alc_spec *spec = codec->spec;
6055 int idx;
6056
6057 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6058 idx = 4;
6059 else
6060 idx = spec->multiout.dac_nids[dac_idx] - 2;
6061
6062 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6063 pin_type);
6064 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6065 AMP_OUT_UNMUTE);
6066 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6067
6068 }
6069
6070 static void alc882_auto_init_multi_out(struct hda_codec *codec)
6071 {
6072 struct alc_spec *spec = codec->spec;
6073 int i;
6074
6075 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6076 for (i = 0; i <= HDA_SIDE; i++) {
6077 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6078 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6079 if (nid)
6080 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
6081 i);
6082 }
6083 }
6084
6085 static void alc882_auto_init_hp_out(struct hda_codec *codec)
6086 {
6087 struct alc_spec *spec = codec->spec;
6088 hda_nid_t pin;
6089
6090 pin = spec->autocfg.hp_pins[0];
6091 if (pin) /* connect to front */
6092 /* use dac 0 */
6093 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6094 }
6095
6096 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6097 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6098
6099 static void alc882_auto_init_analog_input(struct hda_codec *codec)
6100 {
6101 struct alc_spec *spec = codec->spec;
6102 int i;
6103
6104 for (i = 0; i < AUTO_PIN_LAST; i++) {
6105 hda_nid_t nid = spec->autocfg.input_pins[i];
6106 if (alc882_is_input_pin(nid)) {
6107 snd_hda_codec_write(codec, nid, 0,
6108 AC_VERB_SET_PIN_WIDGET_CONTROL,
6109 i <= AUTO_PIN_FRONT_MIC ?
6110 PIN_VREF80 : PIN_IN);
6111 if (nid != ALC882_PIN_CD_NID)
6112 snd_hda_codec_write(codec, nid, 0,
6113 AC_VERB_SET_AMP_GAIN_MUTE,
6114 AMP_OUT_MUTE);
6115 }
6116 }
6117 }
6118
6119 /* add mic boosts if needed */
6120 static int alc_auto_add_mic_boost(struct hda_codec *codec)
6121 {
6122 struct alc_spec *spec = codec->spec;
6123 int err;
6124 hda_nid_t nid;
6125
6126 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
6127 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6128 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6129 "Mic Boost",
6130 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6131 if (err < 0)
6132 return err;
6133 }
6134 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
6135 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6136 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6137 "Front Mic Boost",
6138 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6139 if (err < 0)
6140 return err;
6141 }
6142 return 0;
6143 }
6144
6145 /* almost identical with ALC880 parser... */
6146 static int alc882_parse_auto_config(struct hda_codec *codec)
6147 {
6148 struct alc_spec *spec = codec->spec;
6149 int err = alc880_parse_auto_config(codec);
6150
6151 if (err < 0)
6152 return err;
6153 else if (!err)
6154 return 0; /* no config found */
6155
6156 err = alc_auto_add_mic_boost(codec);
6157 if (err < 0)
6158 return err;
6159
6160 /* hack - override the init verbs */
6161 spec->init_verbs[0] = alc882_auto_init_verbs;
6162
6163 return 1; /* config found */
6164 }
6165
6166 /* additional initialization for auto-configuration model */
6167 static void alc882_auto_init(struct hda_codec *codec)
6168 {
6169 alc882_auto_init_multi_out(codec);
6170 alc882_auto_init_hp_out(codec);
6171 alc882_auto_init_analog_input(codec);
6172 }
6173
6174 static int patch_alc882(struct hda_codec *codec)
6175 {
6176 struct alc_spec *spec;
6177 int err, board_config;
6178
6179 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6180 if (spec == NULL)
6181 return -ENOMEM;
6182
6183 codec->spec = spec;
6184
6185 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6186 alc882_models,
6187 alc882_cfg_tbl);
6188
6189 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
6190 /* Pick up systems that don't supply PCI SSID */
6191 switch (codec->subsystem_id) {
6192 case 0x106b0c00: /* Mac Pro */
6193 board_config = ALC885_MACPRO;
6194 break;
6195 case 0x106b1000: /* iMac 24 */
6196 board_config = ALC885_IMAC24;
6197 break;
6198 case 0x106b00a1: /* Macbook */
6199 case 0x106b2c00: /* Macbook Pro rev3 */
6200 board_config = ALC885_MBP3;
6201 break;
6202 default:
6203 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6204 "trying auto-probe from BIOS...\n");
6205 board_config = ALC882_AUTO;
6206 }
6207 }
6208
6209 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6210
6211 if (board_config == ALC882_AUTO) {
6212 /* automatic parse from the BIOS config */
6213 err = alc882_parse_auto_config(codec);
6214 if (err < 0) {
6215 alc_free(codec);
6216 return err;
6217 } else if (!err) {
6218 printk(KERN_INFO
6219 "hda_codec: Cannot set up configuration "
6220 "from BIOS. Using base mode...\n");
6221 board_config = ALC882_3ST_DIG;
6222 }
6223 }
6224
6225 if (board_config != ALC882_AUTO)
6226 setup_preset(spec, &alc882_presets[board_config]);
6227
6228 spec->stream_name_analog = "ALC882 Analog";
6229 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6230 spec->stream_analog_capture = &alc882_pcm_analog_capture;
6231 /* FIXME: setup DAC5 */
6232 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6233 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
6234
6235 spec->stream_name_digital = "ALC882 Digital";
6236 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6237 spec->stream_digital_capture = &alc882_pcm_digital_capture;
6238
6239 if (!spec->adc_nids && spec->input_mux) {
6240 /* check whether NID 0x07 is valid */
6241 unsigned int wcap = get_wcaps(codec, 0x07);
6242 /* get type */
6243 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6244 if (wcap != AC_WID_AUD_IN) {
6245 spec->adc_nids = alc882_adc_nids_alt;
6246 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
6247 spec->mixers[spec->num_mixers] =
6248 alc882_capture_alt_mixer;
6249 spec->num_mixers++;
6250 } else {
6251 spec->adc_nids = alc882_adc_nids;
6252 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6253 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6254 spec->num_mixers++;
6255 }
6256 }
6257
6258 spec->vmaster_nid = 0x0c;
6259
6260 codec->patch_ops = alc_patch_ops;
6261 if (board_config == ALC882_AUTO)
6262 spec->init_hook = alc882_auto_init;
6263 #ifdef CONFIG_SND_HDA_POWER_SAVE
6264 if (!spec->loopback.amplist)
6265 spec->loopback.amplist = alc882_loopbacks;
6266 #endif
6267
6268 return 0;
6269 }
6270
6271 /*
6272 * ALC883 support
6273 *
6274 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6275 * configuration. Each pin widget can choose any input DACs and a mixer.
6276 * Each ADC is connected from a mixer of all inputs. This makes possible
6277 * 6-channel independent captures.
6278 *
6279 * In addition, an independent DAC for the multi-playback (not used in this
6280 * driver yet).
6281 */
6282 #define ALC883_DIGOUT_NID 0x06
6283 #define ALC883_DIGIN_NID 0x0a
6284
6285 static hda_nid_t alc883_dac_nids[4] = {
6286 /* front, rear, clfe, rear_surr */
6287 0x02, 0x04, 0x03, 0x05
6288 };
6289
6290 static hda_nid_t alc883_adc_nids[2] = {
6291 /* ADC1-2 */
6292 0x08, 0x09,
6293 };
6294
6295 /* input MUX */
6296 /* FIXME: should be a matrix-type input source selection */
6297
6298 static struct hda_input_mux alc883_capture_source = {
6299 .num_items = 4,
6300 .items = {
6301 { "Mic", 0x0 },
6302 { "Front Mic", 0x1 },
6303 { "Line", 0x2 },
6304 { "CD", 0x4 },
6305 },
6306 };
6307
6308 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6309 .num_items = 2,
6310 .items = {
6311 { "Mic", 0x1 },
6312 { "Line", 0x2 },
6313 },
6314 };
6315
6316 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6317 .num_items = 4,
6318 .items = {
6319 { "Mic", 0x0 },
6320 { "iMic", 0x1 },
6321 { "Line", 0x2 },
6322 { "CD", 0x4 },
6323 },
6324 };
6325
6326 #define alc883_mux_enum_info alc_mux_enum_info
6327 #define alc883_mux_enum_get alc_mux_enum_get
6328
6329 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6330 struct snd_ctl_elem_value *ucontrol)
6331 {
6332 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6333 struct alc_spec *spec = codec->spec;
6334 const struct hda_input_mux *imux = spec->input_mux;
6335 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6336 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6337 hda_nid_t nid = capture_mixers[adc_idx];
6338 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6339 unsigned int i, idx;
6340
6341 idx = ucontrol->value.enumerated.item[0];
6342 if (idx >= imux->num_items)
6343 idx = imux->num_items - 1;
6344 if (*cur_val == idx)
6345 return 0;
6346 for (i = 0; i < imux->num_items; i++) {
6347 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6348 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
6349 imux->items[i].index,
6350 HDA_AMP_MUTE, v);
6351 }
6352 *cur_val = idx;
6353 return 1;
6354 }
6355
6356 /*
6357 * 2ch mode
6358 */
6359 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6360 { 2, NULL }
6361 };
6362
6363 /*
6364 * 2ch mode
6365 */
6366 static struct hda_verb alc883_3ST_ch2_init[] = {
6367 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6368 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6369 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6370 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6371 { } /* end */
6372 };
6373
6374 /*
6375 * 4ch mode
6376 */
6377 static struct hda_verb alc883_3ST_ch4_init[] = {
6378 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6379 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6380 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6381 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6382 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6383 { } /* end */
6384 };
6385
6386 /*
6387 * 6ch mode
6388 */
6389 static struct hda_verb alc883_3ST_ch6_init[] = {
6390 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6391 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6392 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6393 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6394 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6395 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6396 { } /* end */
6397 };
6398
6399 static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
6400 { 2, alc883_3ST_ch2_init },
6401 { 4, alc883_3ST_ch4_init },
6402 { 6, alc883_3ST_ch6_init },
6403 };
6404
6405 /*
6406 * 6ch mode
6407 */
6408 static struct hda_verb alc883_sixstack_ch6_init[] = {
6409 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6410 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6411 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6412 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6413 { } /* end */
6414 };
6415
6416 /*
6417 * 8ch mode
6418 */
6419 static struct hda_verb alc883_sixstack_ch8_init[] = {
6420 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6421 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6422 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6423 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6424 { } /* end */
6425 };
6426
6427 static struct hda_channel_mode alc883_sixstack_modes[2] = {
6428 { 6, alc883_sixstack_ch6_init },
6429 { 8, alc883_sixstack_ch8_init },
6430 };
6431
6432 static struct hda_verb alc883_medion_eapd_verbs[] = {
6433 /* eanable EAPD on medion laptop */
6434 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6435 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6436 { }
6437 };
6438
6439 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6440 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6441 */
6442
6443 static struct snd_kcontrol_new alc883_base_mixer[] = {
6444 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6445 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6446 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6447 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6448 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6449 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6450 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6451 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6452 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6453 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6455 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6456 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6457 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6458 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6460 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6462 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6463 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6464 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6465 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6466 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6467 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6468 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6469 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6470 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6471 {
6472 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6473 /* .name = "Capture Source", */
6474 .name = "Input Source",
6475 .count = 2,
6476 .info = alc883_mux_enum_info,
6477 .get = alc883_mux_enum_get,
6478 .put = alc883_mux_enum_put,
6479 },
6480 { } /* end */
6481 };
6482
6483 static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6484 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6485 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6486 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6487 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6488 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6489 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6490 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6492 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6493 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6494 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6495 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6496 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6497 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6498 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6499 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6500 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6501 {
6502 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6503 /* .name = "Capture Source", */
6504 .name = "Input Source",
6505 .count = 2,
6506 .info = alc883_mux_enum_info,
6507 .get = alc883_mux_enum_get,
6508 .put = alc883_mux_enum_put,
6509 },
6510 { } /* end */
6511 };
6512
6513 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6514 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6515 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6516 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6517 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6518 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6519 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6520 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6521 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6522 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6523 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6524 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6525 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6526 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6527 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6528 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6529 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6530 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6531 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6532 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6533 {
6534 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6535 /* .name = "Capture Source", */
6536 .name = "Input Source",
6537 .count = 2,
6538 .info = alc883_mux_enum_info,
6539 .get = alc883_mux_enum_get,
6540 .put = alc883_mux_enum_put,
6541 },
6542 { } /* end */
6543 };
6544
6545 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6546 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6547 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6548 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6549 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6550 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6551 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6552 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6553 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6555 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6556 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6557 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6558 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6560 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6561 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6562 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6563 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6564 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6565 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6566 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6567 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6568 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6569 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6570 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6571 {
6572 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6573 /* .name = "Capture Source", */
6574 .name = "Input Source",
6575 .count = 2,
6576 .info = alc883_mux_enum_info,
6577 .get = alc883_mux_enum_get,
6578 .put = alc883_mux_enum_put,
6579 },
6580 { } /* end */
6581 };
6582
6583 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
6584 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6585 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6586 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6587 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6588 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6589 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6590 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6591 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6592 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6593 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6594 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6595 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6596 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6598 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6599 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6600 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6601 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6602 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6603 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6604 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6605 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6606 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6607
6608 {
6609 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6610 /* .name = "Capture Source", */
6611 .name = "Input Source",
6612 .count = 1,
6613 .info = alc883_mux_enum_info,
6614 .get = alc883_mux_enum_get,
6615 .put = alc883_mux_enum_put,
6616 },
6617 { } /* end */
6618 };
6619
6620 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6621 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6622 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6623 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6624 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6625 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6626 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6627 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6628 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6629 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6630 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6631 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6632 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6633 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6635 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6637 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6638 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6639 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6640 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6641 {
6642 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6643 /* .name = "Capture Source", */
6644 .name = "Input Source",
6645 .count = 2,
6646 .info = alc883_mux_enum_info,
6647 .get = alc883_mux_enum_get,
6648 .put = alc883_mux_enum_put,
6649 },
6650 { } /* end */
6651 };
6652
6653 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6654 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6656 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6657 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6658 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6660 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6662 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6663 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6664 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6665 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6666 {
6667 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6668 /* .name = "Capture Source", */
6669 .name = "Input Source",
6670 .count = 2,
6671 .info = alc883_mux_enum_info,
6672 .get = alc883_mux_enum_get,
6673 .put = alc883_mux_enum_put,
6674 },
6675 { } /* end */
6676 };
6677
6678 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6679 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6680 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6681 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6682 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6684 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6685 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6686 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6687 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6688 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6689 {
6690 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6691 /* .name = "Capture Source", */
6692 .name = "Input Source",
6693 .count = 1,
6694 .info = alc883_mux_enum_info,
6695 .get = alc883_mux_enum_get,
6696 .put = alc883_mux_enum_put,
6697 },
6698 { } /* end */
6699 };
6700
6701 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6702 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6703 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6704 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6705 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6706 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6709 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6710 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6711 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6712 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6713 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6714 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6715 {
6716 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6717 /* .name = "Capture Source", */
6718 .name = "Input Source",
6719 .count = 2,
6720 .info = alc883_mux_enum_info,
6721 .get = alc883_mux_enum_get,
6722 .put = alc883_mux_enum_put,
6723 },
6724 { } /* end */
6725 };
6726
6727 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6728 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6729 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6730 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6731 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6732 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6733 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6734 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6735 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6736 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6737 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6738 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6739 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6740 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6741 {
6742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6743 /* .name = "Capture Source", */
6744 .name = "Input Source",
6745 .count = 2,
6746 .info = alc883_mux_enum_info,
6747 .get = alc883_mux_enum_get,
6748 .put = alc883_mux_enum_put,
6749 },
6750 { } /* end */
6751 };
6752
6753 static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6754 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6755 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6756 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6757 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6758 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6759 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6760 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6761 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6762 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6763 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6764 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6765 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6766 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6767 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6768 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6769 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6770 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6771 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6772 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6773 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6774 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6775 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6776 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6777 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6778 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6779 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6780 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6781 {
6782 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6783 /* .name = "Capture Source", */
6784 .name = "Input Source",
6785 .count = 2,
6786 .info = alc883_mux_enum_info,
6787 .get = alc883_mux_enum_get,
6788 .put = alc883_mux_enum_put,
6789 },
6790 { } /* end */
6791 };
6792
6793 static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6794 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6795 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6796 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6797 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6798 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6799 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6800 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6801 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6802 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6803 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6804 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6805 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6806 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6808 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6810 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6811 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6812 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6813 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6814 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6815 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6816 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6817 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6818 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6819 {
6820 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6821 /* .name = "Capture Source", */
6822 .name = "Input Source",
6823 .count = 2,
6824 .info = alc883_mux_enum_info,
6825 .get = alc883_mux_enum_get,
6826 .put = alc883_mux_enum_put,
6827 },
6828 { } /* end */
6829 };
6830
6831 static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6832 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6833 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6834 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6835 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6836 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6837 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6838 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6839 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6840 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6841 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6848 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6849 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6850 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6851 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6852 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6853 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6854 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6855 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6856 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6857 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6858 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6859 {
6860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6861 /* .name = "Capture Source", */
6862 .name = "Input Source",
6863 .count = 2,
6864 .info = alc883_mux_enum_info,
6865 .get = alc883_mux_enum_get,
6866 .put = alc883_mux_enum_put,
6867 },
6868 { } /* end */
6869 };
6870
6871 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
6872 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6873 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6874 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6875 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6876 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6878 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6880 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6881 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6882 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6883 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6884 {
6885 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6886 /* .name = "Capture Source", */
6887 .name = "Input Source",
6888 .count = 2,
6889 .info = alc883_mux_enum_info,
6890 .get = alc883_mux_enum_get,
6891 .put = alc883_mux_enum_put,
6892 },
6893 { } /* end */
6894 };
6895
6896 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6897 {
6898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6899 .name = "Channel Mode",
6900 .info = alc_ch_mode_info,
6901 .get = alc_ch_mode_get,
6902 .put = alc_ch_mode_put,
6903 },
6904 { } /* end */
6905 };
6906
6907 static struct hda_verb alc883_init_verbs[] = {
6908 /* ADC1: mute amp left and right */
6909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6910 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6911 /* ADC2: mute amp left and right */
6912 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6913 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6914 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6918 /* Rear mixer */
6919 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6920 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6922 /* CLFE mixer */
6923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6926 /* Side mixer */
6927 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6930
6931 /* mute analog input loopbacks */
6932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6937
6938 /* Front Pin: output 0 (0x0c) */
6939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6940 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6941 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6942 /* Rear Pin: output 1 (0x0d) */
6943 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6944 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6945 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6946 /* CLFE Pin: output 2 (0x0e) */
6947 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6948 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6949 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6950 /* Side Pin: output 3 (0x0f) */
6951 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6952 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6953 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6954 /* Mic (rear) pin: input vref at 80% */
6955 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6956 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6957 /* Front Mic pin: input vref at 80% */
6958 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6959 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6960 /* Line In pin: input */
6961 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6963 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6964 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6965 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6966 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6967 /* CD pin widget for input */
6968 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6969
6970 /* FIXME: use matrix-type input source selection */
6971 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6972 /* Input mixer2 */
6973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6974 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6977 /* Input mixer3 */
6978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6982 { }
6983 };
6984
6985 /* toggle speaker-output according to the hp-jack state */
6986 static void alc883_mitac_hp_automute(struct hda_codec *codec)
6987 {
6988 unsigned int present;
6989
6990 present = snd_hda_codec_read(codec, 0x15, 0,
6991 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6992 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6993 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6994 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
6995 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6996 }
6997
6998 /* auto-toggle front mic */
6999 /*
7000 static void alc883_mitac_mic_automute(struct hda_codec *codec)
7001 {
7002 unsigned int present;
7003 unsigned char bits;
7004
7005 present = snd_hda_codec_read(codec, 0x18, 0,
7006 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7007 bits = present ? HDA_AMP_MUTE : 0;
7008 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7009 }
7010 */
7011
7012 static void alc883_mitac_automute(struct hda_codec *codec)
7013 {
7014 alc883_mitac_hp_automute(codec);
7015 /* alc883_mitac_mic_automute(codec); */
7016 }
7017
7018 static void alc883_mitac_unsol_event(struct hda_codec *codec,
7019 unsigned int res)
7020 {
7021 switch (res >> 26) {
7022 case ALC880_HP_EVENT:
7023 alc883_mitac_hp_automute(codec);
7024 break;
7025 case ALC880_MIC_EVENT:
7026 /* alc883_mitac_mic_automute(codec); */
7027 break;
7028 }
7029 }
7030
7031 static struct hda_verb alc883_mitac_verbs[] = {
7032 /* HP */
7033 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7034 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7035 /* Subwoofer */
7036 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7037 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7038
7039 /* enable unsolicited event */
7040 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7041 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7042
7043 { } /* end */
7044 };
7045
7046 static struct hda_verb alc883_tagra_verbs[] = {
7047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7048 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7049
7050 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7052
7053 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7054 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7055 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7056
7057 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7058 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7059 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7060 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
7061
7062 { } /* end */
7063 };
7064
7065 static struct hda_verb alc883_lenovo_101e_verbs[] = {
7066 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7067 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7068 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7069 { } /* end */
7070 };
7071
7072 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7074 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7075 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7076 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7077 { } /* end */
7078 };
7079
7080 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7082 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7083 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7084 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7085 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7086 { } /* end */
7087 };
7088
7089 static struct hda_verb alc883_haier_w66_verbs[] = {
7090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7092
7093 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7094
7095 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7096 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7097 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7099 { } /* end */
7100 };
7101
7102 static struct hda_verb alc888_6st_hp_verbs[] = {
7103 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7104 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7105 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7106 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7107 { }
7108 };
7109
7110 static struct hda_verb alc888_3st_hp_verbs[] = {
7111 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7112 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7113 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7114 { }
7115 };
7116
7117 static struct hda_verb alc888_6st_dell_verbs[] = {
7118 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7119 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7120 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7121 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7122 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7123 { }
7124 };
7125
7126 static struct hda_verb alc888_3st_hp_2ch_init[] = {
7127 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7128 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7129 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7130 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7131 { }
7132 };
7133
7134 static struct hda_verb alc888_3st_hp_6ch_init[] = {
7135 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7136 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7137 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7138 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7139 { }
7140 };
7141
7142 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7143 { 2, alc888_3st_hp_2ch_init },
7144 { 6, alc888_3st_hp_6ch_init },
7145 };
7146
7147 /* toggle front-jack and RCA according to the hp-jack state */
7148 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7149 {
7150 unsigned int present;
7151
7152 present = snd_hda_codec_read(codec, 0x1b, 0,
7153 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7154 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7155 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7156 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7157 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7158 }
7159
7160 /* toggle RCA according to the front-jack state */
7161 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7162 {
7163 unsigned int present;
7164
7165 present = snd_hda_codec_read(codec, 0x14, 0,
7166 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7167 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7168 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7169 }
7170
7171 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7172 unsigned int res)
7173 {
7174 if ((res >> 26) == ALC880_HP_EVENT)
7175 alc888_lenovo_ms7195_front_automute(codec);
7176 if ((res >> 26) == ALC880_FRONT_EVENT)
7177 alc888_lenovo_ms7195_rca_automute(codec);
7178 }
7179
7180 static struct hda_verb alc883_medion_md2_verbs[] = {
7181 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7182 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7183
7184 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7185
7186 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7187 { } /* end */
7188 };
7189
7190 /* toggle speaker-output according to the hp-jack state */
7191 static void alc883_medion_md2_automute(struct hda_codec *codec)
7192 {
7193 unsigned int present;
7194
7195 present = snd_hda_codec_read(codec, 0x14, 0,
7196 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7197 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7198 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7199 }
7200
7201 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7202 unsigned int res)
7203 {
7204 if ((res >> 26) == ALC880_HP_EVENT)
7205 alc883_medion_md2_automute(codec);
7206 }
7207
7208 /* toggle speaker-output according to the hp-jack state */
7209 static void alc883_tagra_automute(struct hda_codec *codec)
7210 {
7211 unsigned int present;
7212 unsigned char bits;
7213
7214 present = snd_hda_codec_read(codec, 0x14, 0,
7215 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7216 bits = present ? HDA_AMP_MUTE : 0;
7217 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7218 HDA_AMP_MUTE, bits);
7219 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7220 present ? 1 : 3);
7221 }
7222
7223 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7224 {
7225 if ((res >> 26) == ALC880_HP_EVENT)
7226 alc883_tagra_automute(codec);
7227 }
7228
7229 static void alc883_haier_w66_automute(struct hda_codec *codec)
7230 {
7231 unsigned int present;
7232 unsigned char bits;
7233
7234 present = snd_hda_codec_read(codec, 0x1b, 0,
7235 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7236 bits = present ? 0x80 : 0;
7237 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7238 0x80, bits);
7239 }
7240
7241 static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7242 unsigned int res)
7243 {
7244 if ((res >> 26) == ALC880_HP_EVENT)
7245 alc883_haier_w66_automute(codec);
7246 }
7247
7248 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7249 {
7250 unsigned int present;
7251 unsigned char bits;
7252
7253 present = snd_hda_codec_read(codec, 0x14, 0,
7254 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7255 bits = present ? HDA_AMP_MUTE : 0;
7256 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7257 HDA_AMP_MUTE, bits);
7258 }
7259
7260 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7261 {
7262 unsigned int present;
7263 unsigned char bits;
7264
7265 present = snd_hda_codec_read(codec, 0x1b, 0,
7266 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7267 bits = present ? HDA_AMP_MUTE : 0;
7268 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7269 HDA_AMP_MUTE, bits);
7270 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7271 HDA_AMP_MUTE, bits);
7272 }
7273
7274 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7275 unsigned int res)
7276 {
7277 if ((res >> 26) == ALC880_HP_EVENT)
7278 alc883_lenovo_101e_all_automute(codec);
7279 if ((res >> 26) == ALC880_FRONT_EVENT)
7280 alc883_lenovo_101e_ispeaker_automute(codec);
7281 }
7282
7283 /* toggle speaker-output according to the hp-jack state */
7284 static void alc883_acer_aspire_automute(struct hda_codec *codec)
7285 {
7286 unsigned int present;
7287
7288 present = snd_hda_codec_read(codec, 0x14, 0,
7289 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7290 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7291 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7292 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7293 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7294 }
7295
7296 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7297 unsigned int res)
7298 {
7299 if ((res >> 26) == ALC880_HP_EVENT)
7300 alc883_acer_aspire_automute(codec);
7301 }
7302
7303 static struct hda_verb alc883_acer_eapd_verbs[] = {
7304 /* HP Pin: output 0 (0x0c) */
7305 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7306 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7307 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7308 /* Front Pin: output 0 (0x0c) */
7309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7310 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7311 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7312 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7313 /* eanable EAPD on medion laptop */
7314 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7315 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7316 /* enable unsolicited event */
7317 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7318 { }
7319 };
7320
7321 static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7322 {
7323 unsigned int present;
7324
7325 present = snd_hda_codec_read(codec, 0x1b, 0,
7326 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7327 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7328 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7329 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7330 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7331 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7332 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7333 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7334 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7335 }
7336
7337 static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7338 unsigned int res)
7339 {
7340 switch (res >> 26) {
7341 case ALC880_HP_EVENT:
7342 printk("hp_event\n");
7343 alc888_6st_dell_front_automute(codec);
7344 break;
7345 }
7346 }
7347
7348 /*
7349 * generic initialization of ADC, input mixers and output mixers
7350 */
7351 static struct hda_verb alc883_auto_init_verbs[] = {
7352 /*
7353 * Unmute ADC0-2 and set the default input to mic-in
7354 */
7355 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7357 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7358 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7359
7360 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7361 * mixer widget
7362 * Note: PASD motherboards uses the Line In 2 as the input for
7363 * front panel mic (mic 2)
7364 */
7365 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7366 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7371
7372 /*
7373 * Set up output mixers (0x0c - 0x0f)
7374 */
7375 /* set vol=0 to output mixers */
7376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7377 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7378 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7379 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7380 /* set up input amps for analog loopback */
7381 /* Amp Indices: DAC = 0, mixer = 1 */
7382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7385 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7388 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7390 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7391 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7392
7393 /* FIXME: use matrix-type input source selection */
7394 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7395 /* Input mixer1 */
7396 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7398 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7399 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7400 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7401 /* Input mixer2 */
7402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7403 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7404 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7405 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7406 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7407
7408 { }
7409 };
7410
7411 /* capture mixer elements */
7412 static struct snd_kcontrol_new alc883_capture_mixer[] = {
7413 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7414 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7415 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7416 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7417 {
7418 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7419 /* The multiple "Capture Source" controls confuse alsamixer
7420 * So call somewhat different..
7421 */
7422 /* .name = "Capture Source", */
7423 .name = "Input Source",
7424 .count = 2,
7425 .info = alc882_mux_enum_info,
7426 .get = alc882_mux_enum_get,
7427 .put = alc882_mux_enum_put,
7428 },
7429 { } /* end */
7430 };
7431
7432 #ifdef CONFIG_SND_HDA_POWER_SAVE
7433 #define alc883_loopbacks alc880_loopbacks
7434 #endif
7435
7436 /* pcm configuration: identiacal with ALC880 */
7437 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
7438 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
7439 #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
7440 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
7441 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
7442
7443 /*
7444 * configuration and preset
7445 */
7446 static const char *alc883_models[ALC883_MODEL_LAST] = {
7447 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7448 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7449 [ALC883_3ST_6ch] = "3stack-6ch",
7450 [ALC883_6ST_DIG] = "6stack-dig",
7451 [ALC883_TARGA_DIG] = "targa-dig",
7452 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
7453 [ALC883_ACER] = "acer",
7454 [ALC883_ACER_ASPIRE] = "acer-aspire",
7455 [ALC883_MEDION] = "medion",
7456 [ALC883_MEDION_MD2] = "medion-md2",
7457 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
7458 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
7459 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7460 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
7461 [ALC883_HAIER_W66] = "haier-w66",
7462 [ALC888_6ST_HP] = "6stack-hp",
7463 [ALC888_3ST_HP] = "3stack-hp",
7464 [ALC888_6ST_DELL] = "6stack-dell",
7465 [ALC883_MITAC] = "mitac",
7466 [ALC883_AUTO] = "auto",
7467 };
7468
7469 static struct snd_pci_quirk alc883_cfg_tbl[] = {
7470 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
7471 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7472 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7473 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7474 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
7475 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
7476 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
7477 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7478 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7479 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7480 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7481 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
7482 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7483 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7484 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
7485 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
7486 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7487 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7488 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7489 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7490 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7491 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7492 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7493 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7494 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7495 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7496 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7497 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7498 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
7499 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7500 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7501 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7502 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7503 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7504 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
7505 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7506 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7507 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
7508 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7509 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7510 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7511 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7512 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7513 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
7514 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
7515 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
7516 {}
7517 };
7518
7519 static struct alc_config_preset alc883_presets[] = {
7520 [ALC883_3ST_2ch_DIG] = {
7521 .mixers = { alc883_3ST_2ch_mixer },
7522 .init_verbs = { alc883_init_verbs },
7523 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7524 .dac_nids = alc883_dac_nids,
7525 .dig_out_nid = ALC883_DIGOUT_NID,
7526 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7527 .adc_nids = alc883_adc_nids,
7528 .dig_in_nid = ALC883_DIGIN_NID,
7529 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7530 .channel_mode = alc883_3ST_2ch_modes,
7531 .input_mux = &alc883_capture_source,
7532 },
7533 [ALC883_3ST_6ch_DIG] = {
7534 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7535 .init_verbs = { alc883_init_verbs },
7536 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7537 .dac_nids = alc883_dac_nids,
7538 .dig_out_nid = ALC883_DIGOUT_NID,
7539 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7540 .adc_nids = alc883_adc_nids,
7541 .dig_in_nid = ALC883_DIGIN_NID,
7542 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7543 .channel_mode = alc883_3ST_6ch_modes,
7544 .need_dac_fix = 1,
7545 .input_mux = &alc883_capture_source,
7546 },
7547 [ALC883_3ST_6ch] = {
7548 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7549 .init_verbs = { alc883_init_verbs },
7550 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7551 .dac_nids = alc883_dac_nids,
7552 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7553 .adc_nids = alc883_adc_nids,
7554 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7555 .channel_mode = alc883_3ST_6ch_modes,
7556 .need_dac_fix = 1,
7557 .input_mux = &alc883_capture_source,
7558 },
7559 [ALC883_6ST_DIG] = {
7560 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7561 .init_verbs = { alc883_init_verbs },
7562 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7563 .dac_nids = alc883_dac_nids,
7564 .dig_out_nid = ALC883_DIGOUT_NID,
7565 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7566 .adc_nids = alc883_adc_nids,
7567 .dig_in_nid = ALC883_DIGIN_NID,
7568 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7569 .channel_mode = alc883_sixstack_modes,
7570 .input_mux = &alc883_capture_source,
7571 },
7572 [ALC883_TARGA_DIG] = {
7573 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7574 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7575 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7576 .dac_nids = alc883_dac_nids,
7577 .dig_out_nid = ALC883_DIGOUT_NID,
7578 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7579 .adc_nids = alc883_adc_nids,
7580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7581 .channel_mode = alc883_3ST_6ch_modes,
7582 .need_dac_fix = 1,
7583 .input_mux = &alc883_capture_source,
7584 .unsol_event = alc883_tagra_unsol_event,
7585 .init_hook = alc883_tagra_automute,
7586 },
7587 [ALC883_TARGA_2ch_DIG] = {
7588 .mixers = { alc883_tagra_2ch_mixer},
7589 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7590 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7591 .dac_nids = alc883_dac_nids,
7592 .dig_out_nid = ALC883_DIGOUT_NID,
7593 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7594 .adc_nids = alc883_adc_nids,
7595 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7596 .channel_mode = alc883_3ST_2ch_modes,
7597 .input_mux = &alc883_capture_source,
7598 .unsol_event = alc883_tagra_unsol_event,
7599 .init_hook = alc883_tagra_automute,
7600 },
7601 [ALC883_ACER] = {
7602 .mixers = { alc883_base_mixer },
7603 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7604 * and the headphone jack. Turn this on and rely on the
7605 * standard mute methods whenever the user wants to turn
7606 * these outputs off.
7607 */
7608 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7609 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7610 .dac_nids = alc883_dac_nids,
7611 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7612 .adc_nids = alc883_adc_nids,
7613 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7614 .channel_mode = alc883_3ST_2ch_modes,
7615 .input_mux = &alc883_capture_source,
7616 },
7617 [ALC883_ACER_ASPIRE] = {
7618 .mixers = { alc883_acer_aspire_mixer },
7619 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
7620 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7621 .dac_nids = alc883_dac_nids,
7622 .dig_out_nid = ALC883_DIGOUT_NID,
7623 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7624 .adc_nids = alc883_adc_nids,
7625 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7626 .channel_mode = alc883_3ST_2ch_modes,
7627 .input_mux = &alc883_capture_source,
7628 .unsol_event = alc883_acer_aspire_unsol_event,
7629 .init_hook = alc883_acer_aspire_automute,
7630 },
7631 [ALC883_MEDION] = {
7632 .mixers = { alc883_fivestack_mixer,
7633 alc883_chmode_mixer },
7634 .init_verbs = { alc883_init_verbs,
7635 alc883_medion_eapd_verbs },
7636 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7637 .dac_nids = alc883_dac_nids,
7638 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7639 .adc_nids = alc883_adc_nids,
7640 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7641 .channel_mode = alc883_sixstack_modes,
7642 .input_mux = &alc883_capture_source,
7643 },
7644 [ALC883_MEDION_MD2] = {
7645 .mixers = { alc883_medion_md2_mixer},
7646 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7647 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7648 .dac_nids = alc883_dac_nids,
7649 .dig_out_nid = ALC883_DIGOUT_NID,
7650 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7651 .adc_nids = alc883_adc_nids,
7652 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7653 .channel_mode = alc883_3ST_2ch_modes,
7654 .input_mux = &alc883_capture_source,
7655 .unsol_event = alc883_medion_md2_unsol_event,
7656 .init_hook = alc883_medion_md2_automute,
7657 },
7658 [ALC883_LAPTOP_EAPD] = {
7659 .mixers = { alc883_base_mixer },
7660 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7661 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7662 .dac_nids = alc883_dac_nids,
7663 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7664 .adc_nids = alc883_adc_nids,
7665 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7666 .channel_mode = alc883_3ST_2ch_modes,
7667 .input_mux = &alc883_capture_source,
7668 },
7669 [ALC883_LENOVO_101E_2ch] = {
7670 .mixers = { alc883_lenovo_101e_2ch_mixer},
7671 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7672 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7673 .dac_nids = alc883_dac_nids,
7674 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7675 .adc_nids = alc883_adc_nids,
7676 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7677 .channel_mode = alc883_3ST_2ch_modes,
7678 .input_mux = &alc883_lenovo_101e_capture_source,
7679 .unsol_event = alc883_lenovo_101e_unsol_event,
7680 .init_hook = alc883_lenovo_101e_all_automute,
7681 },
7682 [ALC883_LENOVO_NB0763] = {
7683 .mixers = { alc883_lenovo_nb0763_mixer },
7684 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7685 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7686 .dac_nids = alc883_dac_nids,
7687 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7688 .adc_nids = alc883_adc_nids,
7689 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7690 .channel_mode = alc883_3ST_2ch_modes,
7691 .need_dac_fix = 1,
7692 .input_mux = &alc883_lenovo_nb0763_capture_source,
7693 .unsol_event = alc883_medion_md2_unsol_event,
7694 .init_hook = alc883_medion_md2_automute,
7695 },
7696 [ALC888_LENOVO_MS7195_DIG] = {
7697 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7698 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7699 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7700 .dac_nids = alc883_dac_nids,
7701 .dig_out_nid = ALC883_DIGOUT_NID,
7702 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7703 .adc_nids = alc883_adc_nids,
7704 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7705 .channel_mode = alc883_3ST_6ch_modes,
7706 .need_dac_fix = 1,
7707 .input_mux = &alc883_capture_source,
7708 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7709 .init_hook = alc888_lenovo_ms7195_front_automute,
7710 },
7711 [ALC883_HAIER_W66] = {
7712 .mixers = { alc883_tagra_2ch_mixer},
7713 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7714 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7715 .dac_nids = alc883_dac_nids,
7716 .dig_out_nid = ALC883_DIGOUT_NID,
7717 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7718 .adc_nids = alc883_adc_nids,
7719 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7720 .channel_mode = alc883_3ST_2ch_modes,
7721 .input_mux = &alc883_capture_source,
7722 .unsol_event = alc883_haier_w66_unsol_event,
7723 .init_hook = alc883_haier_w66_automute,
7724 },
7725 [ALC888_6ST_HP] = {
7726 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7727 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
7728 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7729 .dac_nids = alc883_dac_nids,
7730 .dig_out_nid = ALC883_DIGOUT_NID,
7731 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7732 .adc_nids = alc883_adc_nids,
7733 .dig_in_nid = ALC883_DIGIN_NID,
7734 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7735 .channel_mode = alc883_sixstack_modes,
7736 .input_mux = &alc883_capture_source,
7737 },
7738 [ALC888_3ST_HP] = {
7739 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7740 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
7741 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7742 .dac_nids = alc883_dac_nids,
7743 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7744 .adc_nids = alc883_adc_nids,
7745 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7746 .channel_mode = alc888_3st_hp_modes,
7747 .need_dac_fix = 1,
7748 .input_mux = &alc883_capture_source,
7749 },
7750 [ALC888_6ST_DELL] = {
7751 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7752 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7753 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7754 .dac_nids = alc883_dac_nids,
7755 .dig_out_nid = ALC883_DIGOUT_NID,
7756 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7757 .adc_nids = alc883_adc_nids,
7758 .dig_in_nid = ALC883_DIGIN_NID,
7759 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7760 .channel_mode = alc883_sixstack_modes,
7761 .input_mux = &alc883_capture_source,
7762 .unsol_event = alc888_6st_dell_unsol_event,
7763 .init_hook = alc888_6st_dell_front_automute,
7764 },
7765 [ALC883_MITAC] = {
7766 .mixers = { alc883_mitac_mixer },
7767 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7768 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7769 .dac_nids = alc883_dac_nids,
7770 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7771 .adc_nids = alc883_adc_nids,
7772 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7773 .channel_mode = alc883_3ST_2ch_modes,
7774 .input_mux = &alc883_capture_source,
7775 .unsol_event = alc883_mitac_unsol_event,
7776 .init_hook = alc883_mitac_automute,
7777 },
7778 };
7779
7780
7781 /*
7782 * BIOS auto configuration
7783 */
7784 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7785 hda_nid_t nid, int pin_type,
7786 int dac_idx)
7787 {
7788 /* set as output */
7789 struct alc_spec *spec = codec->spec;
7790 int idx;
7791
7792 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7793 idx = 4;
7794 else
7795 idx = spec->multiout.dac_nids[dac_idx] - 2;
7796
7797 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7798 pin_type);
7799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7800 AMP_OUT_UNMUTE);
7801 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7802
7803 }
7804
7805 static void alc883_auto_init_multi_out(struct hda_codec *codec)
7806 {
7807 struct alc_spec *spec = codec->spec;
7808 int i;
7809
7810 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
7811 for (i = 0; i <= HDA_SIDE; i++) {
7812 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7813 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7814 if (nid)
7815 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
7816 i);
7817 }
7818 }
7819
7820 static void alc883_auto_init_hp_out(struct hda_codec *codec)
7821 {
7822 struct alc_spec *spec = codec->spec;
7823 hda_nid_t pin;
7824
7825 pin = spec->autocfg.hp_pins[0];
7826 if (pin) /* connect to front */
7827 /* use dac 0 */
7828 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7829 }
7830
7831 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7832 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7833
7834 static void alc883_auto_init_analog_input(struct hda_codec *codec)
7835 {
7836 struct alc_spec *spec = codec->spec;
7837 int i;
7838
7839 for (i = 0; i < AUTO_PIN_LAST; i++) {
7840 hda_nid_t nid = spec->autocfg.input_pins[i];
7841 if (alc883_is_input_pin(nid)) {
7842 snd_hda_codec_write(codec, nid, 0,
7843 AC_VERB_SET_PIN_WIDGET_CONTROL,
7844 (i <= AUTO_PIN_FRONT_MIC ?
7845 PIN_VREF80 : PIN_IN));
7846 if (nid != ALC883_PIN_CD_NID)
7847 snd_hda_codec_write(codec, nid, 0,
7848 AC_VERB_SET_AMP_GAIN_MUTE,
7849 AMP_OUT_MUTE);
7850 }
7851 }
7852 }
7853
7854 /* almost identical with ALC880 parser... */
7855 static int alc883_parse_auto_config(struct hda_codec *codec)
7856 {
7857 struct alc_spec *spec = codec->spec;
7858 int err = alc880_parse_auto_config(codec);
7859
7860 if (err < 0)
7861 return err;
7862 else if (!err)
7863 return 0; /* no config found */
7864
7865 err = alc_auto_add_mic_boost(codec);
7866 if (err < 0)
7867 return err;
7868
7869 /* hack - override the init verbs */
7870 spec->init_verbs[0] = alc883_auto_init_verbs;
7871 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7872 spec->num_mixers++;
7873
7874 return 1; /* config found */
7875 }
7876
7877 /* additional initialization for auto-configuration model */
7878 static void alc883_auto_init(struct hda_codec *codec)
7879 {
7880 alc883_auto_init_multi_out(codec);
7881 alc883_auto_init_hp_out(codec);
7882 alc883_auto_init_analog_input(codec);
7883 }
7884
7885 static int patch_alc883(struct hda_codec *codec)
7886 {
7887 struct alc_spec *spec;
7888 int err, board_config;
7889
7890 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7891 if (spec == NULL)
7892 return -ENOMEM;
7893
7894 codec->spec = spec;
7895
7896 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7897 alc883_models,
7898 alc883_cfg_tbl);
7899 if (board_config < 0) {
7900 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7901 "trying auto-probe from BIOS...\n");
7902 board_config = ALC883_AUTO;
7903 }
7904
7905 if (board_config == ALC883_AUTO) {
7906 /* automatic parse from the BIOS config */
7907 err = alc883_parse_auto_config(codec);
7908 if (err < 0) {
7909 alc_free(codec);
7910 return err;
7911 } else if (!err) {
7912 printk(KERN_INFO
7913 "hda_codec: Cannot set up configuration "
7914 "from BIOS. Using base mode...\n");
7915 board_config = ALC883_3ST_2ch_DIG;
7916 }
7917 }
7918
7919 if (board_config != ALC883_AUTO)
7920 setup_preset(spec, &alc883_presets[board_config]);
7921
7922 spec->stream_name_analog = "ALC883 Analog";
7923 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7924 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7925 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
7926
7927 spec->stream_name_digital = "ALC883 Digital";
7928 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7929 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7930
7931 if (!spec->adc_nids && spec->input_mux) {
7932 spec->adc_nids = alc883_adc_nids;
7933 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7934 }
7935
7936 spec->vmaster_nid = 0x0c;
7937
7938 codec->patch_ops = alc_patch_ops;
7939 if (board_config == ALC883_AUTO)
7940 spec->init_hook = alc883_auto_init;
7941 #ifdef CONFIG_SND_HDA_POWER_SAVE
7942 if (!spec->loopback.amplist)
7943 spec->loopback.amplist = alc883_loopbacks;
7944 #endif
7945
7946 return 0;
7947 }
7948
7949 /*
7950 * ALC262 support
7951 */
7952
7953 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7954 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
7955
7956 #define alc262_dac_nids alc260_dac_nids
7957 #define alc262_adc_nids alc882_adc_nids
7958 #define alc262_adc_nids_alt alc882_adc_nids_alt
7959
7960 #define alc262_modes alc260_modes
7961 #define alc262_capture_source alc882_capture_source
7962
7963 static struct snd_kcontrol_new alc262_base_mixer[] = {
7964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7965 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7966 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7967 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7968 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7969 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7972 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7973 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7974 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7975 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7976 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7977 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7978 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7979 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7980 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7981 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7982 { } /* end */
7983 };
7984
7985 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7986 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7987 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7994 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7997 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7998 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7999 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8000 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8001 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8002 { } /* end */
8003 };
8004
8005 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
8006 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8009 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8010 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8011
8012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8013 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8014 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8016 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8017 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8018 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8019 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8022 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8023 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8024 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8025 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8026 { } /* end */
8027 };
8028
8029 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8031 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8032 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8033 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8034 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8035 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8036 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8037 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
8038 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
8039 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8040 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8041 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8042 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8043 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8044 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8045 { } /* end */
8046 };
8047
8048 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8049 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8050 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8051 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
8052 { } /* end */
8053 };
8054
8055 static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
8056 .ops = &snd_hda_bind_vol,
8057 .values = {
8058 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8059 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8060 0
8061 },
8062 };
8063
8064 static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
8065 .ops = &snd_hda_bind_sw,
8066 .values = {
8067 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8068 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8069 0
8070 },
8071 };
8072
8073 /* mute/unmute internal speaker according to the hp jack and mute state */
8074 static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8075 {
8076 struct alc_spec *spec = codec->spec;
8077 unsigned int mute;
8078
8079 if (force || !spec->sense_updated) {
8080 unsigned int present;
8081 present = snd_hda_codec_read(codec, 0x15, 0,
8082 AC_VERB_GET_PIN_SENSE, 0);
8083 spec->jack_present = (present & 0x80000000) != 0;
8084 spec->sense_updated = 1;
8085 }
8086 if (spec->jack_present)
8087 mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
8088 else /* unmute internal speaker if necessary */
8089 mute = (0x7000 | ((0)<<8));
8090 snd_hda_codec_write(codec, 0x0c, 0,
8091 AC_VERB_SET_AMP_GAIN_MUTE, mute );
8092 }
8093
8094 static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8095 unsigned int res)
8096 {
8097 if ((res >> 26) != ALC880_HP_EVENT)
8098 return;
8099 alc262_hp_t5735_automute(codec, 1);
8100 }
8101
8102 static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8103 {
8104 alc262_hp_t5735_automute(codec, 1);
8105 }
8106
8107 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
8108 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
8109 HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
8110 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8111 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8112 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8113 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8114 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8117 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8118 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8119 { } /* end */
8120 };
8121
8122 static struct hda_verb alc262_hp_t5735_verbs[] = {
8123 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8125
8126 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8127 { }
8128 };
8129
8130 static struct hda_bind_ctls alc262_hp_rp5700_bind_front_vol = {
8131 .ops = &snd_hda_bind_vol,
8132 .values = {
8133 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8134 HDA_COMPOSE_AMP_VAL(0x0e, 3, 0, HDA_OUTPUT),
8135 0
8136 },
8137 };
8138
8139 static struct hda_bind_ctls alc262_hp_rp5700_bind_front_sw = {
8140 .ops = &snd_hda_bind_sw,
8141 .values = {
8142 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
8143 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
8144 0
8145 },
8146 };
8147
8148 static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
8149 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_rp5700_bind_front_vol),
8150 HDA_BIND_SW("PCM Playback Switch", &alc262_hp_rp5700_bind_front_sw),
8151 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8152 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8153 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8154 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8155 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8156 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8157 { } /* end */
8158 };
8159
8160 static struct hda_verb alc262_hp_rp5700_verbs[] = {
8161 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8162 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8163 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8164 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8165 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8166 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8167 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8169 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8171 {}
8172 };
8173
8174 static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8175 .num_items = 1,
8176 .items = {
8177 { "Line", 0x1 },
8178 },
8179 };
8180
8181 /* bind hp and internal speaker mute (with plug check) */
8182 static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8183 struct snd_ctl_elem_value *ucontrol)
8184 {
8185 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8186 long *valp = ucontrol->value.integer.value;
8187 int change;
8188
8189 /* change hp mute */
8190 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8191 HDA_AMP_MUTE,
8192 valp[0] ? 0 : HDA_AMP_MUTE);
8193 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8194 HDA_AMP_MUTE,
8195 valp[1] ? 0 : HDA_AMP_MUTE);
8196 if (change) {
8197 /* change speaker according to HP jack state */
8198 struct alc_spec *spec = codec->spec;
8199 unsigned int mute;
8200 if (spec->jack_present)
8201 mute = HDA_AMP_MUTE;
8202 else
8203 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8204 HDA_OUTPUT, 0);
8205 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8206 HDA_AMP_MUTE, mute);
8207 }
8208 return change;
8209 }
8210
8211 static struct snd_kcontrol_new alc262_sony_mixer[] = {
8212 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8213 {
8214 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8215 .name = "Master Playback Switch",
8216 .info = snd_hda_mixer_amp_switch_info,
8217 .get = snd_hda_mixer_amp_switch_get,
8218 .put = alc262_sony_master_sw_put,
8219 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8220 },
8221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8222 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8223 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8224 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8225 { } /* end */
8226 };
8227
8228 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8229 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8230 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8231 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8232 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8233 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8234 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8235 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8236 { } /* end */
8237 };
8238
8239 #define alc262_capture_mixer alc882_capture_mixer
8240 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
8241
8242 /*
8243 * generic initialization of ADC, input mixers and output mixers
8244 */
8245 static struct hda_verb alc262_init_verbs[] = {
8246 /*
8247 * Unmute ADC0-2 and set the default input to mic-in
8248 */
8249 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8251 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8252 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8253 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8254 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255
8256 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8257 * mixer widget
8258 * Note: PASD motherboards uses the Line In 2 as the input for
8259 * front panel mic (mic 2)
8260 */
8261 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8267
8268 /*
8269 * Set up output mixers (0x0c - 0x0e)
8270 */
8271 /* set vol=0 to output mixers */
8272 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8273 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8274 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8275 /* set up input amps for analog loopback */
8276 /* Amp Indices: DAC = 0, mixer = 1 */
8277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8279 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8281 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8283
8284 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8285 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8286 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8287 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8288 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8289 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8290
8291 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8292 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8293 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8294 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8295 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8296
8297 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8299
8300 /* FIXME: use matrix-type input source selection */
8301 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8302 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8305 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8307 /* Input mixer2 */
8308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8312 /* Input mixer3 */
8313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8317
8318 { }
8319 };
8320
8321 static struct hda_verb alc262_hippo_unsol_verbs[] = {
8322 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8324 {}
8325 };
8326
8327 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8328 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8329 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8330 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8331
8332 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8333 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8334 {}
8335 };
8336
8337 static struct hda_verb alc262_sony_unsol_verbs[] = {
8338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8339 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8340 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8341
8342 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8344 };
8345
8346 /* mute/unmute internal speaker according to the hp jack and mute state */
8347 static void alc262_hippo_automute(struct hda_codec *codec)
8348 {
8349 struct alc_spec *spec = codec->spec;
8350 unsigned int mute;
8351 unsigned int present;
8352
8353 /* need to execute and sync at first */
8354 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8355 present = snd_hda_codec_read(codec, 0x15, 0,
8356 AC_VERB_GET_PIN_SENSE, 0);
8357 spec->jack_present = (present & 0x80000000) != 0;
8358 if (spec->jack_present) {
8359 /* mute internal speaker */
8360 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8361 HDA_AMP_MUTE, HDA_AMP_MUTE);
8362 } else {
8363 /* unmute internal speaker if necessary */
8364 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8365 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8366 HDA_AMP_MUTE, mute);
8367 }
8368 }
8369
8370 /* unsolicited event for HP jack sensing */
8371 static void alc262_hippo_unsol_event(struct hda_codec *codec,
8372 unsigned int res)
8373 {
8374 if ((res >> 26) != ALC880_HP_EVENT)
8375 return;
8376 alc262_hippo_automute(codec);
8377 }
8378
8379 static void alc262_hippo1_automute(struct hda_codec *codec)
8380 {
8381 unsigned int mute;
8382 unsigned int present;
8383
8384 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8385 present = snd_hda_codec_read(codec, 0x1b, 0,
8386 AC_VERB_GET_PIN_SENSE, 0);
8387 present = (present & 0x80000000) != 0;
8388 if (present) {
8389 /* mute internal speaker */
8390 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8391 HDA_AMP_MUTE, HDA_AMP_MUTE);
8392 } else {
8393 /* unmute internal speaker if necessary */
8394 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8395 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8396 HDA_AMP_MUTE, mute);
8397 }
8398 }
8399
8400 /* unsolicited event for HP jack sensing */
8401 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8402 unsigned int res)
8403 {
8404 if ((res >> 26) != ALC880_HP_EVENT)
8405 return;
8406 alc262_hippo1_automute(codec);
8407 }
8408
8409 /*
8410 * fujitsu model
8411 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8412 */
8413
8414 #define ALC_HP_EVENT 0x37
8415
8416 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8417 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8419 {}
8420 };
8421
8422 static struct hda_input_mux alc262_fujitsu_capture_source = {
8423 .num_items = 3,
8424 .items = {
8425 { "Mic", 0x0 },
8426 { "Int Mic", 0x1 },
8427 { "CD", 0x4 },
8428 },
8429 };
8430
8431 static struct hda_input_mux alc262_HP_capture_source = {
8432 .num_items = 5,
8433 .items = {
8434 { "Mic", 0x0 },
8435 { "Front Mic", 0x1 },
8436 { "Line", 0x2 },
8437 { "CD", 0x4 },
8438 { "AUX IN", 0x6 },
8439 },
8440 };
8441
8442 static struct hda_input_mux alc262_HP_D7000_capture_source = {
8443 .num_items = 4,
8444 .items = {
8445 { "Mic", 0x0 },
8446 { "Front Mic", 0x2 },
8447 { "Line", 0x1 },
8448 { "CD", 0x4 },
8449 },
8450 };
8451
8452 /* mute/unmute internal speaker according to the hp jack and mute state */
8453 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8454 {
8455 struct alc_spec *spec = codec->spec;
8456 unsigned int mute;
8457
8458 if (force || !spec->sense_updated) {
8459 unsigned int present;
8460 /* need to execute and sync at first */
8461 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8462 present = snd_hda_codec_read(codec, 0x14, 0,
8463 AC_VERB_GET_PIN_SENSE, 0);
8464 spec->jack_present = (present & 0x80000000) != 0;
8465 spec->sense_updated = 1;
8466 }
8467 if (spec->jack_present) {
8468 /* mute internal speaker */
8469 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8470 HDA_AMP_MUTE, HDA_AMP_MUTE);
8471 } else {
8472 /* unmute internal speaker if necessary */
8473 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
8474 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8475 HDA_AMP_MUTE, mute);
8476 }
8477 }
8478
8479 /* unsolicited event for HP jack sensing */
8480 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8481 unsigned int res)
8482 {
8483 if ((res >> 26) != ALC_HP_EVENT)
8484 return;
8485 alc262_fujitsu_automute(codec, 1);
8486 }
8487
8488 /* bind volumes of both NID 0x0c and 0x0d */
8489 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8490 .ops = &snd_hda_bind_vol,
8491 .values = {
8492 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8493 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8494 0
8495 },
8496 };
8497
8498 /* bind hp and internal speaker mute (with plug check) */
8499 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8500 struct snd_ctl_elem_value *ucontrol)
8501 {
8502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8503 long *valp = ucontrol->value.integer.value;
8504 int change;
8505
8506 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
8507 HDA_AMP_MUTE,
8508 valp[0] ? 0 : HDA_AMP_MUTE);
8509 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
8510 HDA_AMP_MUTE,
8511 valp[1] ? 0 : HDA_AMP_MUTE);
8512 if (change)
8513 alc262_fujitsu_automute(codec, 0);
8514 return change;
8515 }
8516
8517 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
8518 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
8519 {
8520 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8521 .name = "Master Playback Switch",
8522 .info = snd_hda_mixer_amp_switch_info,
8523 .get = snd_hda_mixer_amp_switch_get,
8524 .put = alc262_fujitsu_master_sw_put,
8525 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8526 },
8527 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8528 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8529 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8530 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8531 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8532 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8533 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8534 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8535 { } /* end */
8536 };
8537
8538 /* additional init verbs for Benq laptops */
8539 static struct hda_verb alc262_EAPD_verbs[] = {
8540 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8541 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8542 {}
8543 };
8544
8545 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8546 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8547 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8548
8549 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8550 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8551 {}
8552 };
8553
8554 /* Samsung Q1 Ultra Vista model setup */
8555 static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8556 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8557 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8558 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8560 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8561 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8562 { } /* end */
8563 };
8564
8565 static struct hda_verb alc262_ultra_verbs[] = {
8566 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8567 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8568 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8569 /* Mic is on Node 0x19 */
8570 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8571 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8573 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8574 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8575 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8576 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8577 {}
8578 };
8579
8580 static struct hda_input_mux alc262_ultra_capture_source = {
8581 .num_items = 1,
8582 .items = {
8583 { "Mic", 0x1 },
8584 },
8585 };
8586
8587 /* mute/unmute internal speaker according to the hp jack and mute state */
8588 static void alc262_ultra_automute(struct hda_codec *codec)
8589 {
8590 struct alc_spec *spec = codec->spec;
8591 unsigned int mute;
8592 unsigned int present;
8593
8594 /* need to execute and sync at first */
8595 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8596 present = snd_hda_codec_read(codec, 0x15, 0,
8597 AC_VERB_GET_PIN_SENSE, 0);
8598 spec->jack_present = (present & 0x80000000) != 0;
8599 if (spec->jack_present) {
8600 /* mute internal speaker */
8601 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8602 HDA_AMP_MUTE, HDA_AMP_MUTE);
8603 } else {
8604 /* unmute internal speaker if necessary */
8605 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8606 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8607 HDA_AMP_MUTE, mute);
8608 }
8609 }
8610
8611 /* unsolicited event for HP jack sensing */
8612 static void alc262_ultra_unsol_event(struct hda_codec *codec,
8613 unsigned int res)
8614 {
8615 if ((res >> 26) != ALC880_HP_EVENT)
8616 return;
8617 alc262_ultra_automute(codec);
8618 }
8619
8620 /* add playback controls from the parsed DAC table */
8621 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8622 const struct auto_pin_cfg *cfg)
8623 {
8624 hda_nid_t nid;
8625 int err;
8626
8627 spec->multiout.num_dacs = 1; /* only use one dac */
8628 spec->multiout.dac_nids = spec->private_dac_nids;
8629 spec->multiout.dac_nids[0] = 2;
8630
8631 nid = cfg->line_out_pins[0];
8632 if (nid) {
8633 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8634 "Front Playback Volume",
8635 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8636 if (err < 0)
8637 return err;
8638 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8639 "Front Playback Switch",
8640 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8641 if (err < 0)
8642 return err;
8643 }
8644
8645 nid = cfg->speaker_pins[0];
8646 if (nid) {
8647 if (nid == 0x16) {
8648 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8649 "Speaker Playback Volume",
8650 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8651 HDA_OUTPUT));
8652 if (err < 0)
8653 return err;
8654 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8655 "Speaker Playback Switch",
8656 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8657 HDA_OUTPUT));
8658 if (err < 0)
8659 return err;
8660 } else {
8661 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8662 "Speaker Playback Switch",
8663 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8664 HDA_OUTPUT));
8665 if (err < 0)
8666 return err;
8667 }
8668 }
8669 nid = cfg->hp_pins[0];
8670 if (nid) {
8671 /* spec->multiout.hp_nid = 2; */
8672 if (nid == 0x16) {
8673 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8674 "Headphone Playback Volume",
8675 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8676 HDA_OUTPUT));
8677 if (err < 0)
8678 return err;
8679 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8680 "Headphone Playback Switch",
8681 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8682 HDA_OUTPUT));
8683 if (err < 0)
8684 return err;
8685 } else {
8686 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8687 "Headphone Playback Switch",
8688 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8689 HDA_OUTPUT));
8690 if (err < 0)
8691 return err;
8692 }
8693 }
8694 return 0;
8695 }
8696
8697 /* identical with ALC880 */
8698 #define alc262_auto_create_analog_input_ctls \
8699 alc880_auto_create_analog_input_ctls
8700
8701 /*
8702 * generic initialization of ADC, input mixers and output mixers
8703 */
8704 static struct hda_verb alc262_volume_init_verbs[] = {
8705 /*
8706 * Unmute ADC0-2 and set the default input to mic-in
8707 */
8708 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8709 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8710 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8711 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8712 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8713 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8714
8715 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8716 * mixer widget
8717 * Note: PASD motherboards uses the Line In 2 as the input for
8718 * front panel mic (mic 2)
8719 */
8720 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8726
8727 /*
8728 * Set up output mixers (0x0c - 0x0f)
8729 */
8730 /* set vol=0 to output mixers */
8731 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8732 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8733 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8734
8735 /* set up input amps for analog loopback */
8736 /* Amp Indices: DAC = 0, mixer = 1 */
8737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8739 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8741 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8743
8744 /* FIXME: use matrix-type input source selection */
8745 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8746 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8747 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8750 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8751 /* Input mixer2 */
8752 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8754 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8755 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8756 /* Input mixer3 */
8757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8760 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8761
8762 { }
8763 };
8764
8765 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8766 /*
8767 * Unmute ADC0-2 and set the default input to mic-in
8768 */
8769 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8770 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8771 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8772 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8773 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8774 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8775
8776 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8777 * mixer widget
8778 * Note: PASD motherboards uses the Line In 2 as the input for
8779 * front panel mic (mic 2)
8780 */
8781 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8782 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8783 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8784 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8785 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8786 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8787 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8788 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8789
8790 /*
8791 * Set up output mixers (0x0c - 0x0e)
8792 */
8793 /* set vol=0 to output mixers */
8794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8795 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8796 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8797
8798 /* set up input amps for analog loopback */
8799 /* Amp Indices: DAC = 0, mixer = 1 */
8800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8804 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8805 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8806
8807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8808 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8809 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8810
8811 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8812 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8813
8814 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8815 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8816
8817 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8818 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8819 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8820 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8821 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8822
8823 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8824 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8825 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8826 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8827 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8828 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8829
8830
8831 /* FIXME: use matrix-type input source selection */
8832 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8833 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8834 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8835 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8836 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8837 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8838 /* Input mixer2 */
8839 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8840 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8841 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8842 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8843 /* Input mixer3 */
8844 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8848
8849 { }
8850 };
8851
8852 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8853 /*
8854 * Unmute ADC0-2 and set the default input to mic-in
8855 */
8856 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8858 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8860 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8862
8863 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8864 * mixer widget
8865 * Note: PASD motherboards uses the Line In 2 as the input for front
8866 * panel mic (mic 2)
8867 */
8868 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8869 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
8877 /*
8878 * Set up output mixers (0x0c - 0x0e)
8879 */
8880 /* set vol=0 to output mixers */
8881 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8882 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8883 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8884
8885 /* set up input amps for analog loopback */
8886 /* Amp Indices: DAC = 0, mixer = 1 */
8887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8891 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8893
8894
8895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8896 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8897 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8898 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8899 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8900 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8901 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8902
8903 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8904 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8905
8906 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8907 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8908
8909 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8910 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8911 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8912 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8913 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8914 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8915
8916 /* FIXME: use matrix-type input source selection */
8917 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8918 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8923 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8924 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8925 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8926 /* Input mixer2 */
8927 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8929 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8930 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8931 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8932 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8933 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8934 /* Input mixer3 */
8935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8940 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8942
8943 { }
8944 };
8945
8946 #ifdef CONFIG_SND_HDA_POWER_SAVE
8947 #define alc262_loopbacks alc880_loopbacks
8948 #endif
8949
8950 /* pcm configuration: identiacal with ALC880 */
8951 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
8952 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
8953 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
8954 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
8955
8956 /*
8957 * BIOS auto configuration
8958 */
8959 static int alc262_parse_auto_config(struct hda_codec *codec)
8960 {
8961 struct alc_spec *spec = codec->spec;
8962 int err;
8963 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8964
8965 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8966 alc262_ignore);
8967 if (err < 0)
8968 return err;
8969 if (!spec->autocfg.line_outs)
8970 return 0; /* can't find valid BIOS pin config */
8971 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8972 if (err < 0)
8973 return err;
8974 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8975 if (err < 0)
8976 return err;
8977
8978 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8979
8980 if (spec->autocfg.dig_out_pin)
8981 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8982 if (spec->autocfg.dig_in_pin)
8983 spec->dig_in_nid = ALC262_DIGIN_NID;
8984
8985 if (spec->kctl_alloc)
8986 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8987
8988 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
8989 spec->num_mux_defs = 1;
8990 spec->input_mux = &spec->private_imux;
8991
8992 err = alc_auto_add_mic_boost(codec);
8993 if (err < 0)
8994 return err;
8995
8996 return 1;
8997 }
8998
8999 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
9000 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
9001 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
9002
9003
9004 /* init callback for auto-configuration model -- overriding the default init */
9005 static void alc262_auto_init(struct hda_codec *codec)
9006 {
9007 alc262_auto_init_multi_out(codec);
9008 alc262_auto_init_hp_out(codec);
9009 alc262_auto_init_analog_input(codec);
9010 }
9011
9012 /*
9013 * configuration and preset
9014 */
9015 static const char *alc262_models[ALC262_MODEL_LAST] = {
9016 [ALC262_BASIC] = "basic",
9017 [ALC262_HIPPO] = "hippo",
9018 [ALC262_HIPPO_1] = "hippo_1",
9019 [ALC262_FUJITSU] = "fujitsu",
9020 [ALC262_HP_BPC] = "hp-bpc",
9021 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
9022 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
9023 [ALC262_HP_RP5700] = "hp-rp5700",
9024 [ALC262_BENQ_ED8] = "benq",
9025 [ALC262_BENQ_T31] = "benq-t31",
9026 [ALC262_SONY_ASSAMD] = "sony-assamd",
9027 [ALC262_ULTRA] = "ultra",
9028 [ALC262_AUTO] = "auto",
9029 };
9030
9031 static struct snd_pci_quirk alc262_cfg_tbl[] = {
9032 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9033 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
9034 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
9035 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9036 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
9037 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
9038 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
9039 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
9040 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
9041 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
9042 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
9043 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
9044 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
9045 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
9046 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
9047 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
9048 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
9049 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9050 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9051 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
9052 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9053 ALC262_HP_TC_T5735),
9054 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
9055 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9056 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
9057 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9058 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9059 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
9060 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
9061 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
9062 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
9063 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
9064 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
9065 {}
9066 };
9067
9068 static struct alc_config_preset alc262_presets[] = {
9069 [ALC262_BASIC] = {
9070 .mixers = { alc262_base_mixer },
9071 .init_verbs = { alc262_init_verbs },
9072 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9073 .dac_nids = alc262_dac_nids,
9074 .hp_nid = 0x03,
9075 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9076 .channel_mode = alc262_modes,
9077 .input_mux = &alc262_capture_source,
9078 },
9079 [ALC262_HIPPO] = {
9080 .mixers = { alc262_base_mixer },
9081 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9082 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9083 .dac_nids = alc262_dac_nids,
9084 .hp_nid = 0x03,
9085 .dig_out_nid = ALC262_DIGOUT_NID,
9086 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9087 .channel_mode = alc262_modes,
9088 .input_mux = &alc262_capture_source,
9089 .unsol_event = alc262_hippo_unsol_event,
9090 .init_hook = alc262_hippo_automute,
9091 },
9092 [ALC262_HIPPO_1] = {
9093 .mixers = { alc262_hippo1_mixer },
9094 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9095 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9096 .dac_nids = alc262_dac_nids,
9097 .hp_nid = 0x02,
9098 .dig_out_nid = ALC262_DIGOUT_NID,
9099 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9100 .channel_mode = alc262_modes,
9101 .input_mux = &alc262_capture_source,
9102 .unsol_event = alc262_hippo1_unsol_event,
9103 .init_hook = alc262_hippo1_automute,
9104 },
9105 [ALC262_FUJITSU] = {
9106 .mixers = { alc262_fujitsu_mixer },
9107 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9108 alc262_fujitsu_unsol_verbs },
9109 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9110 .dac_nids = alc262_dac_nids,
9111 .hp_nid = 0x03,
9112 .dig_out_nid = ALC262_DIGOUT_NID,
9113 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9114 .channel_mode = alc262_modes,
9115 .input_mux = &alc262_fujitsu_capture_source,
9116 .unsol_event = alc262_fujitsu_unsol_event,
9117 },
9118 [ALC262_HP_BPC] = {
9119 .mixers = { alc262_HP_BPC_mixer },
9120 .init_verbs = { alc262_HP_BPC_init_verbs },
9121 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9122 .dac_nids = alc262_dac_nids,
9123 .hp_nid = 0x03,
9124 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9125 .channel_mode = alc262_modes,
9126 .input_mux = &alc262_HP_capture_source,
9127 },
9128 [ALC262_HP_BPC_D7000_WF] = {
9129 .mixers = { alc262_HP_BPC_WildWest_mixer },
9130 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9131 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9132 .dac_nids = alc262_dac_nids,
9133 .hp_nid = 0x03,
9134 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9135 .channel_mode = alc262_modes,
9136 .input_mux = &alc262_HP_D7000_capture_source,
9137 },
9138 [ALC262_HP_BPC_D7000_WL] = {
9139 .mixers = { alc262_HP_BPC_WildWest_mixer,
9140 alc262_HP_BPC_WildWest_option_mixer },
9141 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9142 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9143 .dac_nids = alc262_dac_nids,
9144 .hp_nid = 0x03,
9145 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9146 .channel_mode = alc262_modes,
9147 .input_mux = &alc262_HP_D7000_capture_source,
9148 },
9149 [ALC262_HP_TC_T5735] = {
9150 .mixers = { alc262_hp_t5735_mixer },
9151 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9152 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9153 .dac_nids = alc262_dac_nids,
9154 .hp_nid = 0x03,
9155 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9156 .channel_mode = alc262_modes,
9157 .input_mux = &alc262_capture_source,
9158 .unsol_event = alc262_hp_t5735_unsol_event,
9159 .init_hook = alc262_hp_t5735_init_hook,
9160 },
9161 [ALC262_HP_RP5700] = {
9162 .mixers = { alc262_hp_rp5700_mixer },
9163 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9164 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9165 .dac_nids = alc262_dac_nids,
9166 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9167 .channel_mode = alc262_modes,
9168 .input_mux = &alc262_hp_rp5700_capture_source,
9169 },
9170 [ALC262_BENQ_ED8] = {
9171 .mixers = { alc262_base_mixer },
9172 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9173 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9174 .dac_nids = alc262_dac_nids,
9175 .hp_nid = 0x03,
9176 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9177 .channel_mode = alc262_modes,
9178 .input_mux = &alc262_capture_source,
9179 },
9180 [ALC262_SONY_ASSAMD] = {
9181 .mixers = { alc262_sony_mixer },
9182 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9183 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9184 .dac_nids = alc262_dac_nids,
9185 .hp_nid = 0x02,
9186 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9187 .channel_mode = alc262_modes,
9188 .input_mux = &alc262_capture_source,
9189 .unsol_event = alc262_hippo_unsol_event,
9190 .init_hook = alc262_hippo_automute,
9191 },
9192 [ALC262_BENQ_T31] = {
9193 .mixers = { alc262_benq_t31_mixer },
9194 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9195 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9196 .dac_nids = alc262_dac_nids,
9197 .hp_nid = 0x03,
9198 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9199 .channel_mode = alc262_modes,
9200 .input_mux = &alc262_capture_source,
9201 .unsol_event = alc262_hippo_unsol_event,
9202 .init_hook = alc262_hippo_automute,
9203 },
9204 [ALC262_ULTRA] = {
9205 .mixers = { alc262_ultra_mixer },
9206 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9207 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9208 .dac_nids = alc262_dac_nids,
9209 .hp_nid = 0x03,
9210 .dig_out_nid = ALC262_DIGOUT_NID,
9211 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9212 .channel_mode = alc262_modes,
9213 .input_mux = &alc262_ultra_capture_source,
9214 .unsol_event = alc262_ultra_unsol_event,
9215 .init_hook = alc262_ultra_automute,
9216 },
9217 };
9218
9219 static int patch_alc262(struct hda_codec *codec)
9220 {
9221 struct alc_spec *spec;
9222 int board_config;
9223 int err;
9224
9225 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9226 if (spec == NULL)
9227 return -ENOMEM;
9228
9229 codec->spec = spec;
9230 #if 0
9231 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9232 * under-run
9233 */
9234 {
9235 int tmp;
9236 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9237 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9238 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9239 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9240 }
9241 #endif
9242
9243 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9244 alc262_models,
9245 alc262_cfg_tbl);
9246
9247 if (board_config < 0) {
9248 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9249 "trying auto-probe from BIOS...\n");
9250 board_config = ALC262_AUTO;
9251 }
9252
9253 if (board_config == ALC262_AUTO) {
9254 /* automatic parse from the BIOS config */
9255 err = alc262_parse_auto_config(codec);
9256 if (err < 0) {
9257 alc_free(codec);
9258 return err;
9259 } else if (!err) {
9260 printk(KERN_INFO
9261 "hda_codec: Cannot set up configuration "
9262 "from BIOS. Using base mode...\n");
9263 board_config = ALC262_BASIC;
9264 }
9265 }
9266
9267 if (board_config != ALC262_AUTO)
9268 setup_preset(spec, &alc262_presets[board_config]);
9269
9270 spec->stream_name_analog = "ALC262 Analog";
9271 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9272 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9273
9274 spec->stream_name_digital = "ALC262 Digital";
9275 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9276 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9277
9278 if (!spec->adc_nids && spec->input_mux) {
9279 /* check whether NID 0x07 is valid */
9280 unsigned int wcap = get_wcaps(codec, 0x07);
9281
9282 /* get type */
9283 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9284 if (wcap != AC_WID_AUD_IN) {
9285 spec->adc_nids = alc262_adc_nids_alt;
9286 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
9287 spec->mixers[spec->num_mixers] =
9288 alc262_capture_alt_mixer;
9289 spec->num_mixers++;
9290 } else {
9291 spec->adc_nids = alc262_adc_nids;
9292 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9293 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9294 spec->num_mixers++;
9295 }
9296 }
9297
9298 spec->vmaster_nid = 0x0c;
9299
9300 codec->patch_ops = alc_patch_ops;
9301 if (board_config == ALC262_AUTO)
9302 spec->init_hook = alc262_auto_init;
9303 #ifdef CONFIG_SND_HDA_POWER_SAVE
9304 if (!spec->loopback.amplist)
9305 spec->loopback.amplist = alc262_loopbacks;
9306 #endif
9307
9308 return 0;
9309 }
9310
9311 /*
9312 * ALC268 channel source setting (2 channel)
9313 */
9314 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9315 #define alc268_modes alc260_modes
9316
9317 static hda_nid_t alc268_dac_nids[2] = {
9318 /* front, hp */
9319 0x02, 0x03
9320 };
9321
9322 static hda_nid_t alc268_adc_nids[2] = {
9323 /* ADC0-1 */
9324 0x08, 0x07
9325 };
9326
9327 static hda_nid_t alc268_adc_nids_alt[1] = {
9328 /* ADC0 */
9329 0x08
9330 };
9331
9332 static struct snd_kcontrol_new alc268_base_mixer[] = {
9333 /* output mixer control */
9334 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9335 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9336 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9337 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9338 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9339 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9340 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
9341 { }
9342 };
9343
9344 static struct hda_verb alc268_eapd_verbs[] = {
9345 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9346 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9347 { }
9348 };
9349
9350 /* Toshiba specific */
9351 #define alc268_toshiba_automute alc262_hippo_automute
9352
9353 static struct hda_verb alc268_toshiba_verbs[] = {
9354 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9355 { } /* end */
9356 };
9357
9358 /* Acer specific */
9359 /* bind volumes of both NID 0x02 and 0x03 */
9360 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9361 .ops = &snd_hda_bind_vol,
9362 .values = {
9363 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9364 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9365 0
9366 },
9367 };
9368
9369 /* mute/unmute internal speaker according to the hp jack and mute state */
9370 static void alc268_acer_automute(struct hda_codec *codec, int force)
9371 {
9372 struct alc_spec *spec = codec->spec;
9373 unsigned int mute;
9374
9375 if (force || !spec->sense_updated) {
9376 unsigned int present;
9377 present = snd_hda_codec_read(codec, 0x14, 0,
9378 AC_VERB_GET_PIN_SENSE, 0);
9379 spec->jack_present = (present & 0x80000000) != 0;
9380 spec->sense_updated = 1;
9381 }
9382 if (spec->jack_present)
9383 mute = HDA_AMP_MUTE; /* mute internal speaker */
9384 else /* unmute internal speaker if necessary */
9385 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9386 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9387 HDA_AMP_MUTE, mute);
9388 }
9389
9390
9391 /* bind hp and internal speaker mute (with plug check) */
9392 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9393 struct snd_ctl_elem_value *ucontrol)
9394 {
9395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9396 long *valp = ucontrol->value.integer.value;
9397 int change;
9398
9399 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9400 HDA_AMP_MUTE,
9401 valp[0] ? 0 : HDA_AMP_MUTE);
9402 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9403 HDA_AMP_MUTE,
9404 valp[1] ? 0 : HDA_AMP_MUTE);
9405 if (change)
9406 alc268_acer_automute(codec, 0);
9407 return change;
9408 }
9409
9410 static struct snd_kcontrol_new alc268_acer_mixer[] = {
9411 /* output mixer control */
9412 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9413 {
9414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9415 .name = "Master Playback Switch",
9416 .info = snd_hda_mixer_amp_switch_info,
9417 .get = snd_hda_mixer_amp_switch_get,
9418 .put = alc268_acer_master_sw_put,
9419 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9420 },
9421 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9422 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9423 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
9424 { }
9425 };
9426
9427 static struct hda_verb alc268_acer_verbs[] = {
9428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9429 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9430
9431 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9432 { }
9433 };
9434
9435 /* unsolicited event for HP jack sensing */
9436 static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9437 unsigned int res)
9438 {
9439 if ((res >> 26) != ALC880_HP_EVENT)
9440 return;
9441 alc268_toshiba_automute(codec);
9442 }
9443
9444 static void alc268_acer_unsol_event(struct hda_codec *codec,
9445 unsigned int res)
9446 {
9447 if ((res >> 26) != ALC880_HP_EVENT)
9448 return;
9449 alc268_acer_automute(codec, 1);
9450 }
9451
9452 static void alc268_acer_init_hook(struct hda_codec *codec)
9453 {
9454 alc268_acer_automute(codec, 1);
9455 }
9456
9457 static struct snd_kcontrol_new alc268_dell_mixer[] = {
9458 /* output mixer control */
9459 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9460 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9461 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9462 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9463 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9464 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9465 { }
9466 };
9467
9468 static struct hda_verb alc268_dell_verbs[] = {
9469 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9471 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9472 { }
9473 };
9474
9475 /* mute/unmute internal speaker according to the hp jack and mute state */
9476 static void alc268_dell_automute(struct hda_codec *codec)
9477 {
9478 unsigned int present;
9479 unsigned int mute;
9480
9481 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9482 if (present & 0x80000000)
9483 mute = HDA_AMP_MUTE;
9484 else
9485 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9486 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9487 HDA_AMP_MUTE, mute);
9488 }
9489
9490 static void alc268_dell_unsol_event(struct hda_codec *codec,
9491 unsigned int res)
9492 {
9493 if ((res >> 26) != ALC880_HP_EVENT)
9494 return;
9495 alc268_dell_automute(codec);
9496 }
9497
9498 #define alc268_dell_init_hook alc268_dell_automute
9499
9500 /*
9501 * generic initialization of ADC, input mixers and output mixers
9502 */
9503 static struct hda_verb alc268_base_init_verbs[] = {
9504 /* Unmute DAC0-1 and set vol = 0 */
9505 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9506 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9507 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9508 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9509 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9510 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9511
9512 /*
9513 * Set up output mixers (0x0c - 0x0e)
9514 */
9515 /* set vol=0 to output mixers */
9516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9517 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9519 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9520
9521 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9522 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9523
9524 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9525 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9526 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9527 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9528 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9529 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9530 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9531 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9532
9533 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9535 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9536 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9537 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9538 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9539 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9540 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9541
9542 /* Unmute Selector 23h,24h and set the default input to mic-in */
9543
9544 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9546 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9547 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9548
9549 { }
9550 };
9551
9552 /*
9553 * generic initialization of ADC, input mixers and output mixers
9554 */
9555 static struct hda_verb alc268_volume_init_verbs[] = {
9556 /* set output DAC */
9557 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9558 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9559 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9560 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9561
9562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9563 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9564 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9565 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9566 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9567
9568 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9569 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9570 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9571 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9572 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9573
9574 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9575 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9577 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9578
9579 /* set PCBEEP vol = 0 */
9580 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9581
9582 { }
9583 };
9584
9585 #define alc268_mux_enum_info alc_mux_enum_info
9586 #define alc268_mux_enum_get alc_mux_enum_get
9587
9588 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9589 struct snd_ctl_elem_value *ucontrol)
9590 {
9591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9592 struct alc_spec *spec = codec->spec;
9593
9594 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9595 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9596 hda_nid_t nid = capture_mixers[adc_idx];
9597
9598 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9599 nid,
9600 &spec->cur_mux[adc_idx]);
9601 }
9602
9603 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9604 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9605 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9606 {
9607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9608 /* The multiple "Capture Source" controls confuse alsamixer
9609 * So call somewhat different..
9610 */
9611 /* .name = "Capture Source", */
9612 .name = "Input Source",
9613 .count = 1,
9614 .info = alc268_mux_enum_info,
9615 .get = alc268_mux_enum_get,
9616 .put = alc268_mux_enum_put,
9617 },
9618 { } /* end */
9619 };
9620
9621 static struct snd_kcontrol_new alc268_capture_mixer[] = {
9622 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9623 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9624 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9625 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9626 {
9627 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9628 /* The multiple "Capture Source" controls confuse alsamixer
9629 * So call somewhat different..
9630 */
9631 /* .name = "Capture Source", */
9632 .name = "Input Source",
9633 .count = 2,
9634 .info = alc268_mux_enum_info,
9635 .get = alc268_mux_enum_get,
9636 .put = alc268_mux_enum_put,
9637 },
9638 { } /* end */
9639 };
9640
9641 static struct hda_input_mux alc268_capture_source = {
9642 .num_items = 4,
9643 .items = {
9644 { "Mic", 0x0 },
9645 { "Front Mic", 0x1 },
9646 { "Line", 0x2 },
9647 { "CD", 0x3 },
9648 },
9649 };
9650
9651 #ifdef CONFIG_SND_DEBUG
9652 static struct snd_kcontrol_new alc268_test_mixer[] = {
9653 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9654 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9657
9658 /* Volume widgets */
9659 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9660 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9661 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9662 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9663 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9664 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9665 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9666 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9667 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9668 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9669 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9670 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9671 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
9672 /* The below appears problematic on some hardwares */
9673 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
9674 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9675 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9676 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9677 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9678
9679 /* Modes for retasking pin widgets */
9680 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9681 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9682 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9683 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9684
9685 /* Controls for GPIO pins, assuming they are configured as outputs */
9686 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9687 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9688 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9689 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9690
9691 /* Switches to allow the digital SPDIF output pin to be enabled.
9692 * The ALC268 does not have an SPDIF input.
9693 */
9694 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9695
9696 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9697 * this output to turn on an external amplifier.
9698 */
9699 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9700 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9701
9702 { } /* end */
9703 };
9704 #endif
9705
9706 /* create input playback/capture controls for the given pin */
9707 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9708 const char *ctlname, int idx)
9709 {
9710 char name[32];
9711 int err;
9712
9713 sprintf(name, "%s Playback Volume", ctlname);
9714 if (nid == 0x14) {
9715 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9716 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9717 HDA_OUTPUT));
9718 if (err < 0)
9719 return err;
9720 } else if (nid == 0x15) {
9721 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9722 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9723 HDA_OUTPUT));
9724 if (err < 0)
9725 return err;
9726 } else
9727 return -1;
9728 sprintf(name, "%s Playback Switch", ctlname);
9729 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9730 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9731 if (err < 0)
9732 return err;
9733 return 0;
9734 }
9735
9736 /* add playback controls from the parsed DAC table */
9737 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9738 const struct auto_pin_cfg *cfg)
9739 {
9740 hda_nid_t nid;
9741 int err;
9742
9743 spec->multiout.num_dacs = 2; /* only use one dac */
9744 spec->multiout.dac_nids = spec->private_dac_nids;
9745 spec->multiout.dac_nids[0] = 2;
9746 spec->multiout.dac_nids[1] = 3;
9747
9748 nid = cfg->line_out_pins[0];
9749 if (nid)
9750 alc268_new_analog_output(spec, nid, "Front", 0);
9751
9752 nid = cfg->speaker_pins[0];
9753 if (nid == 0x1d) {
9754 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9755 "Speaker Playback Volume",
9756 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9757 if (err < 0)
9758 return err;
9759 }
9760 nid = cfg->hp_pins[0];
9761 if (nid)
9762 alc268_new_analog_output(spec, nid, "Headphone", 0);
9763
9764 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9765 if (nid == 0x16) {
9766 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9767 "Mono Playback Switch",
9768 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9769 if (err < 0)
9770 return err;
9771 }
9772 return 0;
9773 }
9774
9775 /* create playback/capture controls for input pins */
9776 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9777 const struct auto_pin_cfg *cfg)
9778 {
9779 struct hda_input_mux *imux = &spec->private_imux;
9780 int i, idx1;
9781
9782 for (i = 0; i < AUTO_PIN_LAST; i++) {
9783 switch(cfg->input_pins[i]) {
9784 case 0x18:
9785 idx1 = 0; /* Mic 1 */
9786 break;
9787 case 0x19:
9788 idx1 = 1; /* Mic 2 */
9789 break;
9790 case 0x1a:
9791 idx1 = 2; /* Line In */
9792 break;
9793 case 0x1c:
9794 idx1 = 3; /* CD */
9795 break;
9796 default:
9797 continue;
9798 }
9799 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9800 imux->items[imux->num_items].index = idx1;
9801 imux->num_items++;
9802 }
9803 return 0;
9804 }
9805
9806 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9807 {
9808 struct alc_spec *spec = codec->spec;
9809 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9810 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9811 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9812 unsigned int dac_vol1, dac_vol2;
9813
9814 if (speaker_nid) {
9815 snd_hda_codec_write(codec, speaker_nid, 0,
9816 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9817 snd_hda_codec_write(codec, 0x0f, 0,
9818 AC_VERB_SET_AMP_GAIN_MUTE,
9819 AMP_IN_UNMUTE(1));
9820 snd_hda_codec_write(codec, 0x10, 0,
9821 AC_VERB_SET_AMP_GAIN_MUTE,
9822 AMP_IN_UNMUTE(1));
9823 } else {
9824 snd_hda_codec_write(codec, 0x0f, 0,
9825 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9826 snd_hda_codec_write(codec, 0x10, 0,
9827 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9828 }
9829
9830 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9831 if (line_nid == 0x14)
9832 dac_vol2 = AMP_OUT_ZERO;
9833 else if (line_nid == 0x15)
9834 dac_vol1 = AMP_OUT_ZERO;
9835 if (hp_nid == 0x14)
9836 dac_vol2 = AMP_OUT_ZERO;
9837 else if (hp_nid == 0x15)
9838 dac_vol1 = AMP_OUT_ZERO;
9839 if (line_nid != 0x16 || hp_nid != 0x16 ||
9840 spec->autocfg.line_out_pins[1] != 0x16 ||
9841 spec->autocfg.line_out_pins[2] != 0x16)
9842 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9843
9844 snd_hda_codec_write(codec, 0x02, 0,
9845 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9846 snd_hda_codec_write(codec, 0x03, 0,
9847 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9848 }
9849
9850 /* pcm configuration: identiacal with ALC880 */
9851 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
9852 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
9853 #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
9854 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
9855
9856 /*
9857 * BIOS auto configuration
9858 */
9859 static int alc268_parse_auto_config(struct hda_codec *codec)
9860 {
9861 struct alc_spec *spec = codec->spec;
9862 int err;
9863 static hda_nid_t alc268_ignore[] = { 0 };
9864
9865 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9866 alc268_ignore);
9867 if (err < 0)
9868 return err;
9869 if (!spec->autocfg.line_outs)
9870 return 0; /* can't find valid BIOS pin config */
9871
9872 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
9873 if (err < 0)
9874 return err;
9875 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
9876 if (err < 0)
9877 return err;
9878
9879 spec->multiout.max_channels = 2;
9880
9881 /* digital only support output */
9882 if (spec->autocfg.dig_out_pin)
9883 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
9884
9885 if (spec->kctl_alloc)
9886 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9887
9888 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
9889 spec->num_mux_defs = 1;
9890 spec->input_mux = &spec->private_imux;
9891
9892 err = alc_auto_add_mic_boost(codec);
9893 if (err < 0)
9894 return err;
9895
9896 return 1;
9897 }
9898
9899 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
9900 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
9901 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
9902
9903 /* init callback for auto-configuration model -- overriding the default init */
9904 static void alc268_auto_init(struct hda_codec *codec)
9905 {
9906 alc268_auto_init_multi_out(codec);
9907 alc268_auto_init_hp_out(codec);
9908 alc268_auto_init_mono_speaker_out(codec);
9909 alc268_auto_init_analog_input(codec);
9910 }
9911
9912 /*
9913 * configuration and preset
9914 */
9915 static const char *alc268_models[ALC268_MODEL_LAST] = {
9916 [ALC268_3ST] = "3stack",
9917 [ALC268_TOSHIBA] = "toshiba",
9918 [ALC268_ACER] = "acer",
9919 [ALC268_DELL] = "dell",
9920 #ifdef CONFIG_SND_DEBUG
9921 [ALC268_TEST] = "test",
9922 #endif
9923 [ALC268_AUTO] = "auto",
9924 };
9925
9926 static struct snd_pci_quirk alc268_cfg_tbl[] = {
9927 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
9928 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
9929 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
9930 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
9931 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
9932 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
9933 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
9934 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
9935 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
9936 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
9937 {}
9938 };
9939
9940 static struct alc_config_preset alc268_presets[] = {
9941 [ALC268_3ST] = {
9942 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9943 .init_verbs = { alc268_base_init_verbs },
9944 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9945 .dac_nids = alc268_dac_nids,
9946 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9947 .adc_nids = alc268_adc_nids_alt,
9948 .hp_nid = 0x03,
9949 .dig_out_nid = ALC268_DIGOUT_NID,
9950 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9951 .channel_mode = alc268_modes,
9952 .input_mux = &alc268_capture_source,
9953 },
9954 [ALC268_TOSHIBA] = {
9955 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9956 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9957 alc268_toshiba_verbs },
9958 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9959 .dac_nids = alc268_dac_nids,
9960 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9961 .adc_nids = alc268_adc_nids_alt,
9962 .hp_nid = 0x03,
9963 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9964 .channel_mode = alc268_modes,
9965 .input_mux = &alc268_capture_source,
9966 .unsol_event = alc268_toshiba_unsol_event,
9967 .init_hook = alc268_toshiba_automute,
9968 },
9969 [ALC268_ACER] = {
9970 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9971 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9972 alc268_acer_verbs },
9973 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9974 .dac_nids = alc268_dac_nids,
9975 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9976 .adc_nids = alc268_adc_nids_alt,
9977 .hp_nid = 0x02,
9978 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9979 .channel_mode = alc268_modes,
9980 .input_mux = &alc268_capture_source,
9981 .unsol_event = alc268_acer_unsol_event,
9982 .init_hook = alc268_acer_init_hook,
9983 },
9984 [ALC268_DELL] = {
9985 .mixers = { alc268_dell_mixer },
9986 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9987 alc268_dell_verbs },
9988 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9989 .dac_nids = alc268_dac_nids,
9990 .hp_nid = 0x02,
9991 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9992 .channel_mode = alc268_modes,
9993 .unsol_event = alc268_dell_unsol_event,
9994 .init_hook = alc268_dell_init_hook,
9995 .input_mux = &alc268_capture_source,
9996 },
9997 #ifdef CONFIG_SND_DEBUG
9998 [ALC268_TEST] = {
9999 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10000 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10001 alc268_volume_init_verbs },
10002 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10003 .dac_nids = alc268_dac_nids,
10004 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10005 .adc_nids = alc268_adc_nids_alt,
10006 .hp_nid = 0x03,
10007 .dig_out_nid = ALC268_DIGOUT_NID,
10008 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10009 .channel_mode = alc268_modes,
10010 .input_mux = &alc268_capture_source,
10011 },
10012 #endif
10013 };
10014
10015 static int patch_alc268(struct hda_codec *codec)
10016 {
10017 struct alc_spec *spec;
10018 int board_config;
10019 int err;
10020
10021 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10022 if (spec == NULL)
10023 return -ENOMEM;
10024
10025 codec->spec = spec;
10026
10027 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10028 alc268_models,
10029 alc268_cfg_tbl);
10030
10031 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10032 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10033 "trying auto-probe from BIOS...\n");
10034 board_config = ALC268_AUTO;
10035 }
10036
10037 if (board_config == ALC268_AUTO) {
10038 /* automatic parse from the BIOS config */
10039 err = alc268_parse_auto_config(codec);
10040 if (err < 0) {
10041 alc_free(codec);
10042 return err;
10043 } else if (!err) {
10044 printk(KERN_INFO
10045 "hda_codec: Cannot set up configuration "
10046 "from BIOS. Using base mode...\n");
10047 board_config = ALC268_3ST;
10048 }
10049 }
10050
10051 if (board_config != ALC268_AUTO)
10052 setup_preset(spec, &alc268_presets[board_config]);
10053
10054 spec->stream_name_analog = "ALC268 Analog";
10055 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10056 spec->stream_analog_capture = &alc268_pcm_analog_capture;
10057 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
10058
10059 spec->stream_name_digital = "ALC268 Digital";
10060 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10061
10062 if (!spec->adc_nids && spec->input_mux) {
10063 /* check whether NID 0x07 is valid */
10064 unsigned int wcap = get_wcaps(codec, 0x07);
10065
10066 /* get type */
10067 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10068 if (wcap != AC_WID_AUD_IN) {
10069 spec->adc_nids = alc268_adc_nids_alt;
10070 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10071 spec->mixers[spec->num_mixers] =
10072 alc268_capture_alt_mixer;
10073 spec->num_mixers++;
10074 } else {
10075 spec->adc_nids = alc268_adc_nids;
10076 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10077 spec->mixers[spec->num_mixers] =
10078 alc268_capture_mixer;
10079 spec->num_mixers++;
10080 }
10081 }
10082
10083 spec->vmaster_nid = 0x02;
10084
10085 codec->patch_ops = alc_patch_ops;
10086 if (board_config == ALC268_AUTO)
10087 spec->init_hook = alc268_auto_init;
10088
10089 return 0;
10090 }
10091
10092 /*
10093 * ALC269 channel source setting (2 channel)
10094 */
10095 #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10096
10097 #define alc269_dac_nids alc260_dac_nids
10098
10099 static hda_nid_t alc269_adc_nids[1] = {
10100 /* ADC1 */
10101 0x07,
10102 };
10103
10104 #define alc269_modes alc260_modes
10105 #define alc269_capture_source alc880_lg_lw_capture_source
10106
10107 static struct snd_kcontrol_new alc269_base_mixer[] = {
10108 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10109 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10114 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10115 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10116 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10117 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10119 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10120 { } /* end */
10121 };
10122
10123 /* capture mixer elements */
10124 static struct snd_kcontrol_new alc269_capture_mixer[] = {
10125 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10126 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10127 {
10128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10129 /* The multiple "Capture Source" controls confuse alsamixer
10130 * So call somewhat different..
10131 */
10132 /* .name = "Capture Source", */
10133 .name = "Input Source",
10134 .count = 1,
10135 .info = alc_mux_enum_info,
10136 .get = alc_mux_enum_get,
10137 .put = alc_mux_enum_put,
10138 },
10139 { } /* end */
10140 };
10141
10142 /*
10143 * generic initialization of ADC, input mixers and output mixers
10144 */
10145 static struct hda_verb alc269_init_verbs[] = {
10146 /*
10147 * Unmute ADC0 and set the default input to mic-in
10148 */
10149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10150
10151 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10152 * analog-loopback mixer widget
10153 * Note: PASD motherboards uses the Line In 2 as the input for
10154 * front panel mic (mic 2)
10155 */
10156 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10159 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10161 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10162
10163 /*
10164 * Set up output mixers (0x0c - 0x0e)
10165 */
10166 /* set vol=0 to output mixers */
10167 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10168 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10169
10170 /* set up input amps for analog loopback */
10171 /* Amp Indices: DAC = 0, mixer = 1 */
10172 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10174 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10175 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10176 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10177 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10178
10179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10180 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10181 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10182 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10183 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10184 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10185 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10186
10187 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10189 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10190 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10191 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10192 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10193 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10194
10195 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10196 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10197
10198 /* FIXME: use matrix-type input source selection */
10199 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10200 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10202 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10203 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10204 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10205
10206 /* set EAPD */
10207 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10208 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10209 { }
10210 };
10211
10212 /* add playback controls from the parsed DAC table */
10213 static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10214 const struct auto_pin_cfg *cfg)
10215 {
10216 hda_nid_t nid;
10217 int err;
10218
10219 spec->multiout.num_dacs = 1; /* only use one dac */
10220 spec->multiout.dac_nids = spec->private_dac_nids;
10221 spec->multiout.dac_nids[0] = 2;
10222
10223 nid = cfg->line_out_pins[0];
10224 if (nid) {
10225 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10226 "Front Playback Volume",
10227 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10228 if (err < 0)
10229 return err;
10230 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10231 "Front Playback Switch",
10232 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10233 if (err < 0)
10234 return err;
10235 }
10236
10237 nid = cfg->speaker_pins[0];
10238 if (nid) {
10239 if (!cfg->line_out_pins[0]) {
10240 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10241 "Speaker Playback Volume",
10242 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10243 HDA_OUTPUT));
10244 if (err < 0)
10245 return err;
10246 }
10247 if (nid == 0x16) {
10248 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10249 "Speaker Playback Switch",
10250 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10251 HDA_OUTPUT));
10252 if (err < 0)
10253 return err;
10254 } else {
10255 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10256 "Speaker Playback Switch",
10257 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10258 HDA_OUTPUT));
10259 if (err < 0)
10260 return err;
10261 }
10262 }
10263 nid = cfg->hp_pins[0];
10264 if (nid) {
10265 /* spec->multiout.hp_nid = 2; */
10266 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10267 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10268 "Headphone Playback Volume",
10269 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10270 HDA_OUTPUT));
10271 if (err < 0)
10272 return err;
10273 }
10274 if (nid == 0x16) {
10275 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10276 "Headphone Playback Switch",
10277 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10278 HDA_OUTPUT));
10279 if (err < 0)
10280 return err;
10281 } else {
10282 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10283 "Headphone Playback Switch",
10284 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10285 HDA_OUTPUT));
10286 if (err < 0)
10287 return err;
10288 }
10289 }
10290 return 0;
10291 }
10292
10293 #define alc269_auto_create_analog_input_ctls \
10294 alc880_auto_create_analog_input_ctls
10295
10296 #ifdef CONFIG_SND_HDA_POWER_SAVE
10297 #define alc269_loopbacks alc880_loopbacks
10298 #endif
10299
10300 /* pcm configuration: identiacal with ALC880 */
10301 #define alc269_pcm_analog_playback alc880_pcm_analog_playback
10302 #define alc269_pcm_analog_capture alc880_pcm_analog_capture
10303 #define alc269_pcm_digital_playback alc880_pcm_digital_playback
10304 #define alc269_pcm_digital_capture alc880_pcm_digital_capture
10305
10306 /*
10307 * BIOS auto configuration
10308 */
10309 static int alc269_parse_auto_config(struct hda_codec *codec)
10310 {
10311 struct alc_spec *spec = codec->spec;
10312 int err;
10313 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10314
10315 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10316 alc269_ignore);
10317 if (err < 0)
10318 return err;
10319
10320 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10321 if (err < 0)
10322 return err;
10323 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10324 if (err < 0)
10325 return err;
10326
10327 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10328
10329 if (spec->autocfg.dig_out_pin)
10330 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10331
10332 if (spec->kctl_alloc)
10333 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10334
10335 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10336 spec->num_mux_defs = 1;
10337 spec->input_mux = &spec->private_imux;
10338
10339 err = alc_auto_add_mic_boost(codec);
10340 if (err < 0)
10341 return err;
10342
10343 return 1;
10344 }
10345
10346 #define alc269_auto_init_multi_out alc882_auto_init_multi_out
10347 #define alc269_auto_init_hp_out alc882_auto_init_hp_out
10348 #define alc269_auto_init_analog_input alc882_auto_init_analog_input
10349
10350
10351 /* init callback for auto-configuration model -- overriding the default init */
10352 static void alc269_auto_init(struct hda_codec *codec)
10353 {
10354 alc269_auto_init_multi_out(codec);
10355 alc269_auto_init_hp_out(codec);
10356 alc269_auto_init_analog_input(codec);
10357 }
10358
10359 /*
10360 * configuration and preset
10361 */
10362 static const char *alc269_models[ALC269_MODEL_LAST] = {
10363 [ALC269_BASIC] = "basic",
10364 };
10365
10366 static struct snd_pci_quirk alc269_cfg_tbl[] = {
10367 {}
10368 };
10369
10370 static struct alc_config_preset alc269_presets[] = {
10371 [ALC269_BASIC] = {
10372 .mixers = { alc269_base_mixer },
10373 .init_verbs = { alc269_init_verbs },
10374 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10375 .dac_nids = alc269_dac_nids,
10376 .hp_nid = 0x03,
10377 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10378 .channel_mode = alc269_modes,
10379 .input_mux = &alc269_capture_source,
10380 },
10381 };
10382
10383 static int patch_alc269(struct hda_codec *codec)
10384 {
10385 struct alc_spec *spec;
10386 int board_config;
10387 int err;
10388
10389 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10390 if (spec == NULL)
10391 return -ENOMEM;
10392
10393 codec->spec = spec;
10394
10395 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10396 alc269_models,
10397 alc269_cfg_tbl);
10398
10399 if (board_config < 0) {
10400 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10401 "trying auto-probe from BIOS...\n");
10402 board_config = ALC269_AUTO;
10403 }
10404
10405 if (board_config == ALC269_AUTO) {
10406 /* automatic parse from the BIOS config */
10407 err = alc269_parse_auto_config(codec);
10408 if (err < 0) {
10409 alc_free(codec);
10410 return err;
10411 } else if (!err) {
10412 printk(KERN_INFO
10413 "hda_codec: Cannot set up configuration "
10414 "from BIOS. Using base mode...\n");
10415 board_config = ALC269_BASIC;
10416 }
10417 }
10418
10419 if (board_config != ALC269_AUTO)
10420 setup_preset(spec, &alc269_presets[board_config]);
10421
10422 spec->stream_name_analog = "ALC269 Analog";
10423 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10424 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10425
10426 spec->stream_name_digital = "ALC269 Digital";
10427 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10428 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10429
10430 spec->adc_nids = alc269_adc_nids;
10431 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10432 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10433 spec->num_mixers++;
10434
10435 codec->patch_ops = alc_patch_ops;
10436 if (board_config == ALC269_AUTO)
10437 spec->init_hook = alc269_auto_init;
10438 #ifdef CONFIG_SND_HDA_POWER_SAVE
10439 if (!spec->loopback.amplist)
10440 spec->loopback.amplist = alc269_loopbacks;
10441 #endif
10442
10443 return 0;
10444 }
10445
10446 /*
10447 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10448 */
10449
10450 /*
10451 * set the path ways for 2 channel output
10452 * need to set the codec line out and mic 1 pin widgets to inputs
10453 */
10454 static struct hda_verb alc861_threestack_ch2_init[] = {
10455 /* set pin widget 1Ah (line in) for input */
10456 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10457 /* set pin widget 18h (mic1/2) for input, for mic also enable
10458 * the vref
10459 */
10460 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10461
10462 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10463 #if 0
10464 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10465 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10466 #endif
10467 { } /* end */
10468 };
10469 /*
10470 * 6ch mode
10471 * need to set the codec line out and mic 1 pin widgets to outputs
10472 */
10473 static struct hda_verb alc861_threestack_ch6_init[] = {
10474 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10475 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10476 /* set pin widget 18h (mic1) for output (CLFE)*/
10477 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10478
10479 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10480 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10481
10482 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10483 #if 0
10484 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10485 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10486 #endif
10487 { } /* end */
10488 };
10489
10490 static struct hda_channel_mode alc861_threestack_modes[2] = {
10491 { 2, alc861_threestack_ch2_init },
10492 { 6, alc861_threestack_ch6_init },
10493 };
10494 /* Set mic1 as input and unmute the mixer */
10495 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10496 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10497 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10498 { } /* end */
10499 };
10500 /* Set mic1 as output and mute mixer */
10501 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10502 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10503 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10504 { } /* end */
10505 };
10506
10507 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10508 { 2, alc861_uniwill_m31_ch2_init },
10509 { 4, alc861_uniwill_m31_ch4_init },
10510 };
10511
10512 /* Set mic1 and line-in as input and unmute the mixer */
10513 static struct hda_verb alc861_asus_ch2_init[] = {
10514 /* set pin widget 1Ah (line in) for input */
10515 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10516 /* set pin widget 18h (mic1/2) for input, for mic also enable
10517 * the vref
10518 */
10519 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10520
10521 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10522 #if 0
10523 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10524 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10525 #endif
10526 { } /* end */
10527 };
10528 /* Set mic1 nad line-in as output and mute mixer */
10529 static struct hda_verb alc861_asus_ch6_init[] = {
10530 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10531 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10532 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10533 /* set pin widget 18h (mic1) for output (CLFE)*/
10534 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10535 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10536 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10537 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10538
10539 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10540 #if 0
10541 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10542 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10543 #endif
10544 { } /* end */
10545 };
10546
10547 static struct hda_channel_mode alc861_asus_modes[2] = {
10548 { 2, alc861_asus_ch2_init },
10549 { 6, alc861_asus_ch6_init },
10550 };
10551
10552 /* patch-ALC861 */
10553
10554 static struct snd_kcontrol_new alc861_base_mixer[] = {
10555 /* output mixer control */
10556 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10557 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10558 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10559 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10560 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10561
10562 /*Input mixer control */
10563 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10564 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10565 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10566 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10567 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10568 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10570 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10571 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10572 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10573
10574 /* Capture mixer control */
10575 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10576 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10577 {
10578 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10579 .name = "Capture Source",
10580 .count = 1,
10581 .info = alc_mux_enum_info,
10582 .get = alc_mux_enum_get,
10583 .put = alc_mux_enum_put,
10584 },
10585 { } /* end */
10586 };
10587
10588 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10589 /* output mixer control */
10590 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10591 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10592 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10593 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10594 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10595
10596 /* Input mixer control */
10597 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10598 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10599 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10600 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10601 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10602 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10604 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10605 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10606 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10607
10608 /* Capture mixer control */
10609 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10610 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10611 {
10612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10613 .name = "Capture Source",
10614 .count = 1,
10615 .info = alc_mux_enum_info,
10616 .get = alc_mux_enum_get,
10617 .put = alc_mux_enum_put,
10618 },
10619 {
10620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10621 .name = "Channel Mode",
10622 .info = alc_ch_mode_info,
10623 .get = alc_ch_mode_get,
10624 .put = alc_ch_mode_put,
10625 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10626 },
10627 { } /* end */
10628 };
10629
10630 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
10631 /* output mixer control */
10632 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10634 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10635
10636 /*Capture mixer control */
10637 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10638 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10639 {
10640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10641 .name = "Capture Source",
10642 .count = 1,
10643 .info = alc_mux_enum_info,
10644 .get = alc_mux_enum_get,
10645 .put = alc_mux_enum_put,
10646 },
10647
10648 { } /* end */
10649 };
10650
10651 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10652 /* output mixer control */
10653 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10654 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10655 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10656 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10657 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10658
10659 /* Input mixer control */
10660 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10661 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10662 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10663 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10664 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10665 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10667 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10668 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10669 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10670
10671 /* Capture mixer control */
10672 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10673 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10674 {
10675 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10676 .name = "Capture Source",
10677 .count = 1,
10678 .info = alc_mux_enum_info,
10679 .get = alc_mux_enum_get,
10680 .put = alc_mux_enum_put,
10681 },
10682 {
10683 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10684 .name = "Channel Mode",
10685 .info = alc_ch_mode_info,
10686 .get = alc_ch_mode_get,
10687 .put = alc_ch_mode_put,
10688 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10689 },
10690 { } /* end */
10691 };
10692
10693 static struct snd_kcontrol_new alc861_asus_mixer[] = {
10694 /* output mixer control */
10695 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10696 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10697 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10698 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10699 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10700
10701 /* Input mixer control */
10702 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10703 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10704 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10705 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10706 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10707 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10709 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10710 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10712
10713 /* Capture mixer control */
10714 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10715 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10716 {
10717 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10718 .name = "Capture Source",
10719 .count = 1,
10720 .info = alc_mux_enum_info,
10721 .get = alc_mux_enum_get,
10722 .put = alc_mux_enum_put,
10723 },
10724 {
10725 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10726 .name = "Channel Mode",
10727 .info = alc_ch_mode_info,
10728 .get = alc_ch_mode_get,
10729 .put = alc_ch_mode_put,
10730 .private_value = ARRAY_SIZE(alc861_asus_modes),
10731 },
10732 { }
10733 };
10734
10735 /* additional mixer */
10736 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
10737 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10738 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10739 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10740 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10741 { }
10742 };
10743
10744 /*
10745 * generic initialization of ADC, input mixers and output mixers
10746 */
10747 static struct hda_verb alc861_base_init_verbs[] = {
10748 /*
10749 * Unmute ADC0 and set the default input to mic-in
10750 */
10751 /* port-A for surround (rear panel) */
10752 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10753 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10754 /* port-B for mic-in (rear panel) with vref */
10755 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10756 /* port-C for line-in (rear panel) */
10757 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10758 /* port-D for Front */
10759 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10760 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10761 /* port-E for HP out (front panel) */
10762 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10763 /* route front PCM to HP */
10764 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10765 /* port-F for mic-in (front panel) with vref */
10766 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10767 /* port-G for CLFE (rear panel) */
10768 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10769 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10770 /* port-H for side (rear panel) */
10771 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10772 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10773 /* CD-in */
10774 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10775 /* route front mic to ADC1*/
10776 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10777 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10778
10779 /* Unmute DAC0~3 & spdif out*/
10780 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10781 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10782 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10783 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10785
10786 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10787 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10788 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10789 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10790 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10791
10792 /* Unmute Stereo Mixer 15 */
10793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10794 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10795 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
10797
10798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10799 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10800 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10801 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10802 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10803 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10804 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10805 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10806 /* hp used DAC 3 (Front) */
10807 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10808 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10809
10810 { }
10811 };
10812
10813 static struct hda_verb alc861_threestack_init_verbs[] = {
10814 /*
10815 * Unmute ADC0 and set the default input to mic-in
10816 */
10817 /* port-A for surround (rear panel) */
10818 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10819 /* port-B for mic-in (rear panel) with vref */
10820 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10821 /* port-C for line-in (rear panel) */
10822 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10823 /* port-D for Front */
10824 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10825 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10826 /* port-E for HP out (front panel) */
10827 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10828 /* route front PCM to HP */
10829 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10830 /* port-F for mic-in (front panel) with vref */
10831 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10832 /* port-G for CLFE (rear panel) */
10833 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10834 /* port-H for side (rear panel) */
10835 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10836 /* CD-in */
10837 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10838 /* route front mic to ADC1*/
10839 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10840 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10841 /* Unmute DAC0~3 & spdif out*/
10842 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10843 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10844 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10845 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10846 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10847
10848 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10849 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10850 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10851 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10852 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10853
10854 /* Unmute Stereo Mixer 15 */
10855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10857 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10858 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
10859
10860 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10861 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10862 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10863 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10864 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10865 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10866 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10867 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10868 /* hp used DAC 3 (Front) */
10869 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10870 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10871 { }
10872 };
10873
10874 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
10875 /*
10876 * Unmute ADC0 and set the default input to mic-in
10877 */
10878 /* port-A for surround (rear panel) */
10879 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10880 /* port-B for mic-in (rear panel) with vref */
10881 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10882 /* port-C for line-in (rear panel) */
10883 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10884 /* port-D for Front */
10885 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10886 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10887 /* port-E for HP out (front panel) */
10888 /* this has to be set to VREF80 */
10889 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10890 /* route front PCM to HP */
10891 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10892 /* port-F for mic-in (front panel) with vref */
10893 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10894 /* port-G for CLFE (rear panel) */
10895 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10896 /* port-H for side (rear panel) */
10897 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10898 /* CD-in */
10899 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10900 /* route front mic to ADC1*/
10901 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10903 /* Unmute DAC0~3 & spdif out*/
10904 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10905 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10906 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10907 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10908 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10909
10910 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10911 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10912 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10913 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10914 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10915
10916 /* Unmute Stereo Mixer 15 */
10917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10919 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
10921
10922 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10923 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10926 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10928 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10929 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10930 /* hp used DAC 3 (Front) */
10931 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10932 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10933 { }
10934 };
10935
10936 static struct hda_verb alc861_asus_init_verbs[] = {
10937 /*
10938 * Unmute ADC0 and set the default input to mic-in
10939 */
10940 /* port-A for surround (rear panel)
10941 * according to codec#0 this is the HP jack
10942 */
10943 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
10944 /* route front PCM to HP */
10945 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
10946 /* port-B for mic-in (rear panel) with vref */
10947 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10948 /* port-C for line-in (rear panel) */
10949 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10950 /* port-D for Front */
10951 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10952 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10953 /* port-E for HP out (front panel) */
10954 /* this has to be set to VREF80 */
10955 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10956 /* route front PCM to HP */
10957 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10958 /* port-F for mic-in (front panel) with vref */
10959 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10960 /* port-G for CLFE (rear panel) */
10961 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10962 /* port-H for side (rear panel) */
10963 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10964 /* CD-in */
10965 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10966 /* route front mic to ADC1*/
10967 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10968 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10969 /* Unmute DAC0~3 & spdif out*/
10970 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10971 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10972 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10973 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10974 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10975 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10976 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10977 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10978 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10979 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10980
10981 /* Unmute Stereo Mixer 15 */
10982 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10983 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10985 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
10986
10987 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10988 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10989 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10990 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10991 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10993 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10994 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10995 /* hp used DAC 3 (Front) */
10996 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10997 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10998 { }
10999 };
11000
11001 /* additional init verbs for ASUS laptops */
11002 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11003 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11004 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11005 { }
11006 };
11007
11008 /*
11009 * generic initialization of ADC, input mixers and output mixers
11010 */
11011 static struct hda_verb alc861_auto_init_verbs[] = {
11012 /*
11013 * Unmute ADC0 and set the default input to mic-in
11014 */
11015 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
11016 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11017
11018 /* Unmute DAC0~3 & spdif out*/
11019 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11020 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11021 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11022 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11023 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11024
11025 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11026 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11027 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11028 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11029 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11030
11031 /* Unmute Stereo Mixer 15 */
11032 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11033 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11036
11037 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11038 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11039 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11040 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11041 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11042 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11043 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11044 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11045
11046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11047 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11048 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11049 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11050 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11051 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11052 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11054
11055 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
11056
11057 { }
11058 };
11059
11060 static struct hda_verb alc861_toshiba_init_verbs[] = {
11061 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11062
11063 { }
11064 };
11065
11066 /* toggle speaker-output according to the hp-jack state */
11067 static void alc861_toshiba_automute(struct hda_codec *codec)
11068 {
11069 unsigned int present;
11070
11071 present = snd_hda_codec_read(codec, 0x0f, 0,
11072 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11073 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11074 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11075 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11076 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
11077 }
11078
11079 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11080 unsigned int res)
11081 {
11082 if ((res >> 26) == ALC880_HP_EVENT)
11083 alc861_toshiba_automute(codec);
11084 }
11085
11086 /* pcm configuration: identiacal with ALC880 */
11087 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
11088 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
11089 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
11090 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
11091
11092
11093 #define ALC861_DIGOUT_NID 0x07
11094
11095 static struct hda_channel_mode alc861_8ch_modes[1] = {
11096 { 8, NULL }
11097 };
11098
11099 static hda_nid_t alc861_dac_nids[4] = {
11100 /* front, surround, clfe, side */
11101 0x03, 0x06, 0x05, 0x04
11102 };
11103
11104 static hda_nid_t alc660_dac_nids[3] = {
11105 /* front, clfe, surround */
11106 0x03, 0x05, 0x06
11107 };
11108
11109 static hda_nid_t alc861_adc_nids[1] = {
11110 /* ADC0-2 */
11111 0x08,
11112 };
11113
11114 static struct hda_input_mux alc861_capture_source = {
11115 .num_items = 5,
11116 .items = {
11117 { "Mic", 0x0 },
11118 { "Front Mic", 0x3 },
11119 { "Line", 0x1 },
11120 { "CD", 0x4 },
11121 { "Mixer", 0x5 },
11122 },
11123 };
11124
11125 /* fill in the dac_nids table from the parsed pin configuration */
11126 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11127 const struct auto_pin_cfg *cfg)
11128 {
11129 int i;
11130 hda_nid_t nid;
11131
11132 spec->multiout.dac_nids = spec->private_dac_nids;
11133 for (i = 0; i < cfg->line_outs; i++) {
11134 nid = cfg->line_out_pins[i];
11135 if (nid) {
11136 if (i >= ARRAY_SIZE(alc861_dac_nids))
11137 continue;
11138 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11139 }
11140 }
11141 spec->multiout.num_dacs = cfg->line_outs;
11142 return 0;
11143 }
11144
11145 /* add playback controls from the parsed DAC table */
11146 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11147 const struct auto_pin_cfg *cfg)
11148 {
11149 char name[32];
11150 static const char *chname[4] = {
11151 "Front", "Surround", NULL /*CLFE*/, "Side"
11152 };
11153 hda_nid_t nid;
11154 int i, idx, err;
11155
11156 for (i = 0; i < cfg->line_outs; i++) {
11157 nid = spec->multiout.dac_nids[i];
11158 if (!nid)
11159 continue;
11160 if (nid == 0x05) {
11161 /* Center/LFE */
11162 err = add_control(spec, ALC_CTL_BIND_MUTE,
11163 "Center Playback Switch",
11164 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11165 HDA_OUTPUT));
11166 if (err < 0)
11167 return err;
11168 err = add_control(spec, ALC_CTL_BIND_MUTE,
11169 "LFE Playback Switch",
11170 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11171 HDA_OUTPUT));
11172 if (err < 0)
11173 return err;
11174 } else {
11175 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11176 idx++)
11177 if (nid == alc861_dac_nids[idx])
11178 break;
11179 sprintf(name, "%s Playback Switch", chname[idx]);
11180 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11181 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11182 HDA_OUTPUT));
11183 if (err < 0)
11184 return err;
11185 }
11186 }
11187 return 0;
11188 }
11189
11190 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11191 {
11192 int err;
11193 hda_nid_t nid;
11194
11195 if (!pin)
11196 return 0;
11197
11198 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11199 nid = 0x03;
11200 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11201 "Headphone Playback Switch",
11202 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11203 if (err < 0)
11204 return err;
11205 spec->multiout.hp_nid = nid;
11206 }
11207 return 0;
11208 }
11209
11210 /* create playback/capture controls for input pins */
11211 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11212 const struct auto_pin_cfg *cfg)
11213 {
11214 struct hda_input_mux *imux = &spec->private_imux;
11215 int i, err, idx, idx1;
11216
11217 for (i = 0; i < AUTO_PIN_LAST; i++) {
11218 switch (cfg->input_pins[i]) {
11219 case 0x0c:
11220 idx1 = 1;
11221 idx = 2; /* Line In */
11222 break;
11223 case 0x0f:
11224 idx1 = 2;
11225 idx = 2; /* Line In */
11226 break;
11227 case 0x0d:
11228 idx1 = 0;
11229 idx = 1; /* Mic In */
11230 break;
11231 case 0x10:
11232 idx1 = 3;
11233 idx = 1; /* Mic In */
11234 break;
11235 case 0x11:
11236 idx1 = 4;
11237 idx = 0; /* CD */
11238 break;
11239 default:
11240 continue;
11241 }
11242
11243 err = new_analog_input(spec, cfg->input_pins[i],
11244 auto_pin_cfg_labels[i], idx, 0x15);
11245 if (err < 0)
11246 return err;
11247
11248 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11249 imux->items[imux->num_items].index = idx1;
11250 imux->num_items++;
11251 }
11252 return 0;
11253 }
11254
11255 static struct snd_kcontrol_new alc861_capture_mixer[] = {
11256 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11257 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11258
11259 {
11260 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11261 /* The multiple "Capture Source" controls confuse alsamixer
11262 * So call somewhat different..
11263 */
11264 /* .name = "Capture Source", */
11265 .name = "Input Source",
11266 .count = 1,
11267 .info = alc_mux_enum_info,
11268 .get = alc_mux_enum_get,
11269 .put = alc_mux_enum_put,
11270 },
11271 { } /* end */
11272 };
11273
11274 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11275 hda_nid_t nid,
11276 int pin_type, int dac_idx)
11277 {
11278 /* set as output */
11279
11280 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11281 pin_type);
11282 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11283 AMP_OUT_UNMUTE);
11284
11285 }
11286
11287 static void alc861_auto_init_multi_out(struct hda_codec *codec)
11288 {
11289 struct alc_spec *spec = codec->spec;
11290 int i;
11291
11292 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
11293 for (i = 0; i < spec->autocfg.line_outs; i++) {
11294 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11295 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11296 if (nid)
11297 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
11298 spec->multiout.dac_nids[i]);
11299 }
11300 }
11301
11302 static void alc861_auto_init_hp_out(struct hda_codec *codec)
11303 {
11304 struct alc_spec *spec = codec->spec;
11305 hda_nid_t pin;
11306
11307 pin = spec->autocfg.hp_pins[0];
11308 if (pin) /* connect to front */
11309 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11310 spec->multiout.dac_nids[0]);
11311 }
11312
11313 static void alc861_auto_init_analog_input(struct hda_codec *codec)
11314 {
11315 struct alc_spec *spec = codec->spec;
11316 int i;
11317
11318 for (i = 0; i < AUTO_PIN_LAST; i++) {
11319 hda_nid_t nid = spec->autocfg.input_pins[i];
11320 if (nid >= 0x0c && nid <= 0x11) {
11321 snd_hda_codec_write(codec, nid, 0,
11322 AC_VERB_SET_PIN_WIDGET_CONTROL,
11323 i <= AUTO_PIN_FRONT_MIC ?
11324 PIN_VREF80 : PIN_IN);
11325 }
11326 }
11327 }
11328
11329 /* parse the BIOS configuration and set up the alc_spec */
11330 /* return 1 if successful, 0 if the proper config is not found,
11331 * or a negative error code
11332 */
11333 static int alc861_parse_auto_config(struct hda_codec *codec)
11334 {
11335 struct alc_spec *spec = codec->spec;
11336 int err;
11337 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11338
11339 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11340 alc861_ignore);
11341 if (err < 0)
11342 return err;
11343 if (!spec->autocfg.line_outs)
11344 return 0; /* can't find valid BIOS pin config */
11345
11346 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11347 if (err < 0)
11348 return err;
11349 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11350 if (err < 0)
11351 return err;
11352 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11353 if (err < 0)
11354 return err;
11355 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11356 if (err < 0)
11357 return err;
11358
11359 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11360
11361 if (spec->autocfg.dig_out_pin)
11362 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11363
11364 if (spec->kctl_alloc)
11365 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11366
11367 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11368
11369 spec->num_mux_defs = 1;
11370 spec->input_mux = &spec->private_imux;
11371
11372 spec->adc_nids = alc861_adc_nids;
11373 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11374 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11375 spec->num_mixers++;
11376
11377 return 1;
11378 }
11379
11380 /* additional initialization for auto-configuration model */
11381 static void alc861_auto_init(struct hda_codec *codec)
11382 {
11383 alc861_auto_init_multi_out(codec);
11384 alc861_auto_init_hp_out(codec);
11385 alc861_auto_init_analog_input(codec);
11386 }
11387
11388 #ifdef CONFIG_SND_HDA_POWER_SAVE
11389 static struct hda_amp_list alc861_loopbacks[] = {
11390 { 0x15, HDA_INPUT, 0 },
11391 { 0x15, HDA_INPUT, 1 },
11392 { 0x15, HDA_INPUT, 2 },
11393 { 0x15, HDA_INPUT, 3 },
11394 { } /* end */
11395 };
11396 #endif
11397
11398
11399 /*
11400 * configuration and preset
11401 */
11402 static const char *alc861_models[ALC861_MODEL_LAST] = {
11403 [ALC861_3ST] = "3stack",
11404 [ALC660_3ST] = "3stack-660",
11405 [ALC861_3ST_DIG] = "3stack-dig",
11406 [ALC861_6ST_DIG] = "6stack-dig",
11407 [ALC861_UNIWILL_M31] = "uniwill-m31",
11408 [ALC861_TOSHIBA] = "toshiba",
11409 [ALC861_ASUS] = "asus",
11410 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11411 [ALC861_AUTO] = "auto",
11412 };
11413
11414 static struct snd_pci_quirk alc861_cfg_tbl[] = {
11415 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
11416 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11417 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11418 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
11419 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
11420 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
11421 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
11422 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11423 * Any other models that need this preset?
11424 */
11425 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
11426 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11427 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
11428 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11429 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11430 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11431 /* FIXME: the below seems conflict */
11432 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11433 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11434 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
11435 {}
11436 };
11437
11438 static struct alc_config_preset alc861_presets[] = {
11439 [ALC861_3ST] = {
11440 .mixers = { alc861_3ST_mixer },
11441 .init_verbs = { alc861_threestack_init_verbs },
11442 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11443 .dac_nids = alc861_dac_nids,
11444 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11445 .channel_mode = alc861_threestack_modes,
11446 .need_dac_fix = 1,
11447 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11448 .adc_nids = alc861_adc_nids,
11449 .input_mux = &alc861_capture_source,
11450 },
11451 [ALC861_3ST_DIG] = {
11452 .mixers = { alc861_base_mixer },
11453 .init_verbs = { alc861_threestack_init_verbs },
11454 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11455 .dac_nids = alc861_dac_nids,
11456 .dig_out_nid = ALC861_DIGOUT_NID,
11457 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11458 .channel_mode = alc861_threestack_modes,
11459 .need_dac_fix = 1,
11460 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11461 .adc_nids = alc861_adc_nids,
11462 .input_mux = &alc861_capture_source,
11463 },
11464 [ALC861_6ST_DIG] = {
11465 .mixers = { alc861_base_mixer },
11466 .init_verbs = { alc861_base_init_verbs },
11467 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11468 .dac_nids = alc861_dac_nids,
11469 .dig_out_nid = ALC861_DIGOUT_NID,
11470 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11471 .channel_mode = alc861_8ch_modes,
11472 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11473 .adc_nids = alc861_adc_nids,
11474 .input_mux = &alc861_capture_source,
11475 },
11476 [ALC660_3ST] = {
11477 .mixers = { alc861_3ST_mixer },
11478 .init_verbs = { alc861_threestack_init_verbs },
11479 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11480 .dac_nids = alc660_dac_nids,
11481 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11482 .channel_mode = alc861_threestack_modes,
11483 .need_dac_fix = 1,
11484 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11485 .adc_nids = alc861_adc_nids,
11486 .input_mux = &alc861_capture_source,
11487 },
11488 [ALC861_UNIWILL_M31] = {
11489 .mixers = { alc861_uniwill_m31_mixer },
11490 .init_verbs = { alc861_uniwill_m31_init_verbs },
11491 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11492 .dac_nids = alc861_dac_nids,
11493 .dig_out_nid = ALC861_DIGOUT_NID,
11494 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11495 .channel_mode = alc861_uniwill_m31_modes,
11496 .need_dac_fix = 1,
11497 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11498 .adc_nids = alc861_adc_nids,
11499 .input_mux = &alc861_capture_source,
11500 },
11501 [ALC861_TOSHIBA] = {
11502 .mixers = { alc861_toshiba_mixer },
11503 .init_verbs = { alc861_base_init_verbs,
11504 alc861_toshiba_init_verbs },
11505 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11506 .dac_nids = alc861_dac_nids,
11507 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11508 .channel_mode = alc883_3ST_2ch_modes,
11509 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11510 .adc_nids = alc861_adc_nids,
11511 .input_mux = &alc861_capture_source,
11512 .unsol_event = alc861_toshiba_unsol_event,
11513 .init_hook = alc861_toshiba_automute,
11514 },
11515 [ALC861_ASUS] = {
11516 .mixers = { alc861_asus_mixer },
11517 .init_verbs = { alc861_asus_init_verbs },
11518 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11519 .dac_nids = alc861_dac_nids,
11520 .dig_out_nid = ALC861_DIGOUT_NID,
11521 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11522 .channel_mode = alc861_asus_modes,
11523 .need_dac_fix = 1,
11524 .hp_nid = 0x06,
11525 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11526 .adc_nids = alc861_adc_nids,
11527 .input_mux = &alc861_capture_source,
11528 },
11529 [ALC861_ASUS_LAPTOP] = {
11530 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11531 .init_verbs = { alc861_asus_init_verbs,
11532 alc861_asus_laptop_init_verbs },
11533 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11534 .dac_nids = alc861_dac_nids,
11535 .dig_out_nid = ALC861_DIGOUT_NID,
11536 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11537 .channel_mode = alc883_3ST_2ch_modes,
11538 .need_dac_fix = 1,
11539 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11540 .adc_nids = alc861_adc_nids,
11541 .input_mux = &alc861_capture_source,
11542 },
11543 };
11544
11545
11546 static int patch_alc861(struct hda_codec *codec)
11547 {
11548 struct alc_spec *spec;
11549 int board_config;
11550 int err;
11551
11552 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11553 if (spec == NULL)
11554 return -ENOMEM;
11555
11556 codec->spec = spec;
11557
11558 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11559 alc861_models,
11560 alc861_cfg_tbl);
11561
11562 if (board_config < 0) {
11563 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11564 "trying auto-probe from BIOS...\n");
11565 board_config = ALC861_AUTO;
11566 }
11567
11568 if (board_config == ALC861_AUTO) {
11569 /* automatic parse from the BIOS config */
11570 err = alc861_parse_auto_config(codec);
11571 if (err < 0) {
11572 alc_free(codec);
11573 return err;
11574 } else if (!err) {
11575 printk(KERN_INFO
11576 "hda_codec: Cannot set up configuration "
11577 "from BIOS. Using base mode...\n");
11578 board_config = ALC861_3ST_DIG;
11579 }
11580 }
11581
11582 if (board_config != ALC861_AUTO)
11583 setup_preset(spec, &alc861_presets[board_config]);
11584
11585 spec->stream_name_analog = "ALC861 Analog";
11586 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11587 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11588
11589 spec->stream_name_digital = "ALC861 Digital";
11590 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11591 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11592
11593 spec->vmaster_nid = 0x03;
11594
11595 codec->patch_ops = alc_patch_ops;
11596 if (board_config == ALC861_AUTO)
11597 spec->init_hook = alc861_auto_init;
11598 #ifdef CONFIG_SND_HDA_POWER_SAVE
11599 if (!spec->loopback.amplist)
11600 spec->loopback.amplist = alc861_loopbacks;
11601 #endif
11602
11603 return 0;
11604 }
11605
11606 /*
11607 * ALC861-VD support
11608 *
11609 * Based on ALC882
11610 *
11611 * In addition, an independent DAC
11612 */
11613 #define ALC861VD_DIGOUT_NID 0x06
11614
11615 static hda_nid_t alc861vd_dac_nids[4] = {
11616 /* front, surr, clfe, side surr */
11617 0x02, 0x03, 0x04, 0x05
11618 };
11619
11620 /* dac_nids for ALC660vd are in a different order - according to
11621 * Realtek's driver.
11622 * This should probably tesult in a different mixer for 6stack models
11623 * of ALC660vd codecs, but for now there is only 3stack mixer
11624 * - and it is the same as in 861vd.
11625 * adc_nids in ALC660vd are (is) the same as in 861vd
11626 */
11627 static hda_nid_t alc660vd_dac_nids[3] = {
11628 /* front, rear, clfe, rear_surr */
11629 0x02, 0x04, 0x03
11630 };
11631
11632 static hda_nid_t alc861vd_adc_nids[1] = {
11633 /* ADC0 */
11634 0x09,
11635 };
11636
11637 /* input MUX */
11638 /* FIXME: should be a matrix-type input source selection */
11639 static struct hda_input_mux alc861vd_capture_source = {
11640 .num_items = 4,
11641 .items = {
11642 { "Mic", 0x0 },
11643 { "Front Mic", 0x1 },
11644 { "Line", 0x2 },
11645 { "CD", 0x4 },
11646 },
11647 };
11648
11649 static struct hda_input_mux alc861vd_dallas_capture_source = {
11650 .num_items = 3,
11651 .items = {
11652 { "Front Mic", 0x0 },
11653 { "ATAPI Mic", 0x1 },
11654 { "Line In", 0x5 },
11655 },
11656 };
11657
11658 static struct hda_input_mux alc861vd_hp_capture_source = {
11659 .num_items = 2,
11660 .items = {
11661 { "Front Mic", 0x0 },
11662 { "ATAPI Mic", 0x1 },
11663 },
11664 };
11665
11666 #define alc861vd_mux_enum_info alc_mux_enum_info
11667 #define alc861vd_mux_enum_get alc_mux_enum_get
11668
11669 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11670 struct snd_ctl_elem_value *ucontrol)
11671 {
11672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11673 struct alc_spec *spec = codec->spec;
11674 const struct hda_input_mux *imux = spec->input_mux;
11675 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11676 static hda_nid_t capture_mixers[1] = { 0x22 };
11677 hda_nid_t nid = capture_mixers[adc_idx];
11678 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11679 unsigned int i, idx;
11680
11681 idx = ucontrol->value.enumerated.item[0];
11682 if (idx >= imux->num_items)
11683 idx = imux->num_items - 1;
11684 if (*cur_val == idx)
11685 return 0;
11686 for (i = 0; i < imux->num_items; i++) {
11687 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11688 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11689 imux->items[i].index,
11690 HDA_AMP_MUTE, v);
11691 }
11692 *cur_val = idx;
11693 return 1;
11694 }
11695
11696 /*
11697 * 2ch mode
11698 */
11699 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11700 { 2, NULL }
11701 };
11702
11703 /*
11704 * 6ch mode
11705 */
11706 static struct hda_verb alc861vd_6stack_ch6_init[] = {
11707 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11708 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11709 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11710 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11711 { } /* end */
11712 };
11713
11714 /*
11715 * 8ch mode
11716 */
11717 static struct hda_verb alc861vd_6stack_ch8_init[] = {
11718 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11719 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11720 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11721 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11722 { } /* end */
11723 };
11724
11725 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11726 { 6, alc861vd_6stack_ch6_init },
11727 { 8, alc861vd_6stack_ch8_init },
11728 };
11729
11730 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11731 {
11732 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11733 .name = "Channel Mode",
11734 .info = alc_ch_mode_info,
11735 .get = alc_ch_mode_get,
11736 .put = alc_ch_mode_put,
11737 },
11738 { } /* end */
11739 };
11740
11741 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11742 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11743 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11744
11745 {
11746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11747 /* The multiple "Capture Source" controls confuse alsamixer
11748 * So call somewhat different..
11749 */
11750 /* .name = "Capture Source", */
11751 .name = "Input Source",
11752 .count = 1,
11753 .info = alc861vd_mux_enum_info,
11754 .get = alc861vd_mux_enum_get,
11755 .put = alc861vd_mux_enum_put,
11756 },
11757 { } /* end */
11758 };
11759
11760 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11761 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11762 */
11763 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11764 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11765 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11766
11767 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11768 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11769
11770 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11771 HDA_OUTPUT),
11772 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11773 HDA_OUTPUT),
11774 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11775 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11776
11777 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11778 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11779
11780 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11781
11782 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11784 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11785
11786 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11787 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11788 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11789
11790 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11791 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11792
11793 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11794 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11795
11796 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11797 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11798
11799 { } /* end */
11800 };
11801
11802 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11803 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11804 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11805
11806 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11807
11808 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11811
11812 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11813 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11814 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11815
11816 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11817 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11818
11819 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11820 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11821
11822 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11823 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11824
11825 { } /* end */
11826 };
11827
11828 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
11829 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11830 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
11831 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11832
11833 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11834
11835 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11838
11839 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11840 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11841 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11842
11843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11845
11846 { } /* end */
11847 };
11848
11849 /* Pin assignment: Front=0x14, HP = 0x15,
11850 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
11851 */
11852 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
11853 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11854 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11855 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11856 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11857 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11858 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11859 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11860 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11861 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
11862 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
11863 { } /* end */
11864 };
11865
11866 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
11867 * Front Mic=0x18, ATAPI Mic = 0x19,
11868 */
11869 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
11870 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11871 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11872 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11873 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11874 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11875 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11876 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11877 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11878
11879 { } /* end */
11880 };
11881
11882 /*
11883 * generic initialization of ADC, input mixers and output mixers
11884 */
11885 static struct hda_verb alc861vd_volume_init_verbs[] = {
11886 /*
11887 * Unmute ADC0 and set the default input to mic-in
11888 */
11889 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11891
11892 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
11893 * the analog-loopback mixer widget
11894 */
11895 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11901
11902 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
11903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11907
11908 /*
11909 * Set up output mixers (0x02 - 0x05)
11910 */
11911 /* set vol=0 to output mixers */
11912 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11913 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11914 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11915 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11916
11917 /* set up input amps for analog loopback */
11918 /* Amp Indices: DAC = 0, mixer = 1 */
11919 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11920 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11922 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11925 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11926 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11927
11928 { }
11929 };
11930
11931 /*
11932 * 3-stack pin configuration:
11933 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
11934 */
11935 static struct hda_verb alc861vd_3stack_init_verbs[] = {
11936 /*
11937 * Set pin mode and muting
11938 */
11939 /* set front pin widgets 0x14 for output */
11940 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11941 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11942 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11943
11944 /* Mic (rear) pin: input vref at 80% */
11945 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11946 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11947 /* Front Mic pin: input vref at 80% */
11948 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11949 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11950 /* Line In pin: input */
11951 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11952 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11953 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11954 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11955 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11956 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11957 /* CD pin widget for input */
11958 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11959
11960 { }
11961 };
11962
11963 /*
11964 * 6-stack pin configuration:
11965 */
11966 static struct hda_verb alc861vd_6stack_init_verbs[] = {
11967 /*
11968 * Set pin mode and muting
11969 */
11970 /* set front pin widgets 0x14 for output */
11971 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11972 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11973 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11974
11975 /* Rear Pin: output 1 (0x0d) */
11976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11978 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11979 /* CLFE Pin: output 2 (0x0e) */
11980 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11981 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11982 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
11983 /* Side Pin: output 3 (0x0f) */
11984 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11985 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11986 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
11987
11988 /* Mic (rear) pin: input vref at 80% */
11989 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11990 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11991 /* Front Mic pin: input vref at 80% */
11992 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11993 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11994 /* Line In pin: input */
11995 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11996 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11997 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11998 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11999 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12000 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12001 /* CD pin widget for input */
12002 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12003
12004 { }
12005 };
12006
12007 static struct hda_verb alc861vd_eapd_verbs[] = {
12008 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12009 { }
12010 };
12011
12012 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12013 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12015 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12016 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12017 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12018 {}
12019 };
12020
12021 /* toggle speaker-output according to the hp-jack state */
12022 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12023 {
12024 unsigned int present;
12025 unsigned char bits;
12026
12027 present = snd_hda_codec_read(codec, 0x1b, 0,
12028 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12029 bits = present ? HDA_AMP_MUTE : 0;
12030 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12031 HDA_AMP_MUTE, bits);
12032 }
12033
12034 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12035 {
12036 unsigned int present;
12037 unsigned char bits;
12038
12039 present = snd_hda_codec_read(codec, 0x18, 0,
12040 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12041 bits = present ? HDA_AMP_MUTE : 0;
12042 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12043 HDA_AMP_MUTE, bits);
12044 }
12045
12046 static void alc861vd_lenovo_automute(struct hda_codec *codec)
12047 {
12048 alc861vd_lenovo_hp_automute(codec);
12049 alc861vd_lenovo_mic_automute(codec);
12050 }
12051
12052 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12053 unsigned int res)
12054 {
12055 switch (res >> 26) {
12056 case ALC880_HP_EVENT:
12057 alc861vd_lenovo_hp_automute(codec);
12058 break;
12059 case ALC880_MIC_EVENT:
12060 alc861vd_lenovo_mic_automute(codec);
12061 break;
12062 }
12063 }
12064
12065 static struct hda_verb alc861vd_dallas_verbs[] = {
12066 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12067 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12068 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12069 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12070
12071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12078 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12079
12080 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12081 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12082 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12084 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12085 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12086 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12087 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12088
12089 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12090 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12091 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12092 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12093 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12094 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12095 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12096 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12097
12098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12102
12103 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12104 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12105 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12106
12107 { } /* end */
12108 };
12109
12110 /* toggle speaker-output according to the hp-jack state */
12111 static void alc861vd_dallas_automute(struct hda_codec *codec)
12112 {
12113 unsigned int present;
12114
12115 present = snd_hda_codec_read(codec, 0x15, 0,
12116 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12117 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12118 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12119 }
12120
12121 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12122 {
12123 if ((res >> 26) == ALC880_HP_EVENT)
12124 alc861vd_dallas_automute(codec);
12125 }
12126
12127 #ifdef CONFIG_SND_HDA_POWER_SAVE
12128 #define alc861vd_loopbacks alc880_loopbacks
12129 #endif
12130
12131 /* pcm configuration: identiacal with ALC880 */
12132 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12133 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12134 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12135 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12136
12137 /*
12138 * configuration and preset
12139 */
12140 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12141 [ALC660VD_3ST] = "3stack-660",
12142 [ALC660VD_3ST_DIG] = "3stack-660-digout",
12143 [ALC861VD_3ST] = "3stack",
12144 [ALC861VD_3ST_DIG] = "3stack-digout",
12145 [ALC861VD_6ST_DIG] = "6stack-digout",
12146 [ALC861VD_LENOVO] = "lenovo",
12147 [ALC861VD_DALLAS] = "dallas",
12148 [ALC861VD_HP] = "hp",
12149 [ALC861VD_AUTO] = "auto",
12150 };
12151
12152 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
12153 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12154 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
12155 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
12156 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
12157 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
12158 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
12159 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
12160 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
12161 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
12162 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
12163 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
12164 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12165 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
12166 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
12167 {}
12168 };
12169
12170 static struct alc_config_preset alc861vd_presets[] = {
12171 [ALC660VD_3ST] = {
12172 .mixers = { alc861vd_3st_mixer },
12173 .init_verbs = { alc861vd_volume_init_verbs,
12174 alc861vd_3stack_init_verbs },
12175 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12176 .dac_nids = alc660vd_dac_nids,
12177 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12178 .adc_nids = alc861vd_adc_nids,
12179 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12180 .channel_mode = alc861vd_3stack_2ch_modes,
12181 .input_mux = &alc861vd_capture_source,
12182 },
12183 [ALC660VD_3ST_DIG] = {
12184 .mixers = { alc861vd_3st_mixer },
12185 .init_verbs = { alc861vd_volume_init_verbs,
12186 alc861vd_3stack_init_verbs },
12187 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12188 .dac_nids = alc660vd_dac_nids,
12189 .dig_out_nid = ALC861VD_DIGOUT_NID,
12190 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12191 .adc_nids = alc861vd_adc_nids,
12192 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12193 .channel_mode = alc861vd_3stack_2ch_modes,
12194 .input_mux = &alc861vd_capture_source,
12195 },
12196 [ALC861VD_3ST] = {
12197 .mixers = { alc861vd_3st_mixer },
12198 .init_verbs = { alc861vd_volume_init_verbs,
12199 alc861vd_3stack_init_verbs },
12200 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12201 .dac_nids = alc861vd_dac_nids,
12202 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12203 .channel_mode = alc861vd_3stack_2ch_modes,
12204 .input_mux = &alc861vd_capture_source,
12205 },
12206 [ALC861VD_3ST_DIG] = {
12207 .mixers = { alc861vd_3st_mixer },
12208 .init_verbs = { alc861vd_volume_init_verbs,
12209 alc861vd_3stack_init_verbs },
12210 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12211 .dac_nids = alc861vd_dac_nids,
12212 .dig_out_nid = ALC861VD_DIGOUT_NID,
12213 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12214 .channel_mode = alc861vd_3stack_2ch_modes,
12215 .input_mux = &alc861vd_capture_source,
12216 },
12217 [ALC861VD_6ST_DIG] = {
12218 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12219 .init_verbs = { alc861vd_volume_init_verbs,
12220 alc861vd_6stack_init_verbs },
12221 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12222 .dac_nids = alc861vd_dac_nids,
12223 .dig_out_nid = ALC861VD_DIGOUT_NID,
12224 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12225 .channel_mode = alc861vd_6stack_modes,
12226 .input_mux = &alc861vd_capture_source,
12227 },
12228 [ALC861VD_LENOVO] = {
12229 .mixers = { alc861vd_lenovo_mixer },
12230 .init_verbs = { alc861vd_volume_init_verbs,
12231 alc861vd_3stack_init_verbs,
12232 alc861vd_eapd_verbs,
12233 alc861vd_lenovo_unsol_verbs },
12234 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12235 .dac_nids = alc660vd_dac_nids,
12236 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12237 .adc_nids = alc861vd_adc_nids,
12238 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12239 .channel_mode = alc861vd_3stack_2ch_modes,
12240 .input_mux = &alc861vd_capture_source,
12241 .unsol_event = alc861vd_lenovo_unsol_event,
12242 .init_hook = alc861vd_lenovo_automute,
12243 },
12244 [ALC861VD_DALLAS] = {
12245 .mixers = { alc861vd_dallas_mixer },
12246 .init_verbs = { alc861vd_dallas_verbs },
12247 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12248 .dac_nids = alc861vd_dac_nids,
12249 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12250 .adc_nids = alc861vd_adc_nids,
12251 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12252 .channel_mode = alc861vd_3stack_2ch_modes,
12253 .input_mux = &alc861vd_dallas_capture_source,
12254 .unsol_event = alc861vd_dallas_unsol_event,
12255 .init_hook = alc861vd_dallas_automute,
12256 },
12257 [ALC861VD_HP] = {
12258 .mixers = { alc861vd_hp_mixer },
12259 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12260 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12261 .dac_nids = alc861vd_dac_nids,
12262 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12263 .dig_out_nid = ALC861VD_DIGOUT_NID,
12264 .adc_nids = alc861vd_adc_nids,
12265 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12266 .channel_mode = alc861vd_3stack_2ch_modes,
12267 .input_mux = &alc861vd_hp_capture_source,
12268 .unsol_event = alc861vd_dallas_unsol_event,
12269 .init_hook = alc861vd_dallas_automute,
12270 },
12271 };
12272
12273 /*
12274 * BIOS auto configuration
12275 */
12276 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12277 hda_nid_t nid, int pin_type, int dac_idx)
12278 {
12279 /* set as output */
12280 snd_hda_codec_write(codec, nid, 0,
12281 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12282 snd_hda_codec_write(codec, nid, 0,
12283 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12284 }
12285
12286 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12287 {
12288 struct alc_spec *spec = codec->spec;
12289 int i;
12290
12291 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
12292 for (i = 0; i <= HDA_SIDE; i++) {
12293 hda_nid_t nid = spec->autocfg.line_out_pins[i];
12294 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12295 if (nid)
12296 alc861vd_auto_set_output_and_unmute(codec, nid,
12297 pin_type, i);
12298 }
12299 }
12300
12301
12302 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12303 {
12304 struct alc_spec *spec = codec->spec;
12305 hda_nid_t pin;
12306
12307 pin = spec->autocfg.hp_pins[0];
12308 if (pin) /* connect to front and use dac 0 */
12309 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12310 }
12311
12312 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12313 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12314
12315 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12316 {
12317 struct alc_spec *spec = codec->spec;
12318 int i;
12319
12320 for (i = 0; i < AUTO_PIN_LAST; i++) {
12321 hda_nid_t nid = spec->autocfg.input_pins[i];
12322 if (alc861vd_is_input_pin(nid)) {
12323 snd_hda_codec_write(codec, nid, 0,
12324 AC_VERB_SET_PIN_WIDGET_CONTROL,
12325 i <= AUTO_PIN_FRONT_MIC ?
12326 PIN_VREF80 : PIN_IN);
12327 if (nid != ALC861VD_PIN_CD_NID)
12328 snd_hda_codec_write(codec, nid, 0,
12329 AC_VERB_SET_AMP_GAIN_MUTE,
12330 AMP_OUT_MUTE);
12331 }
12332 }
12333 }
12334
12335 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12336 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12337
12338 /* add playback controls from the parsed DAC table */
12339 /* Based on ALC880 version. But ALC861VD has separate,
12340 * different NIDs for mute/unmute switch and volume control */
12341 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12342 const struct auto_pin_cfg *cfg)
12343 {
12344 char name[32];
12345 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12346 hda_nid_t nid_v, nid_s;
12347 int i, err;
12348
12349 for (i = 0; i < cfg->line_outs; i++) {
12350 if (!spec->multiout.dac_nids[i])
12351 continue;
12352 nid_v = alc861vd_idx_to_mixer_vol(
12353 alc880_dac_to_idx(
12354 spec->multiout.dac_nids[i]));
12355 nid_s = alc861vd_idx_to_mixer_switch(
12356 alc880_dac_to_idx(
12357 spec->multiout.dac_nids[i]));
12358
12359 if (i == 2) {
12360 /* Center/LFE */
12361 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12362 "Center Playback Volume",
12363 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12364 HDA_OUTPUT));
12365 if (err < 0)
12366 return err;
12367 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12368 "LFE Playback Volume",
12369 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12370 HDA_OUTPUT));
12371 if (err < 0)
12372 return err;
12373 err = add_control(spec, ALC_CTL_BIND_MUTE,
12374 "Center Playback Switch",
12375 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12376 HDA_INPUT));
12377 if (err < 0)
12378 return err;
12379 err = add_control(spec, ALC_CTL_BIND_MUTE,
12380 "LFE Playback Switch",
12381 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12382 HDA_INPUT));
12383 if (err < 0)
12384 return err;
12385 } else {
12386 sprintf(name, "%s Playback Volume", chname[i]);
12387 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12388 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12389 HDA_OUTPUT));
12390 if (err < 0)
12391 return err;
12392 sprintf(name, "%s Playback Switch", chname[i]);
12393 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12394 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
12395 HDA_INPUT));
12396 if (err < 0)
12397 return err;
12398 }
12399 }
12400 return 0;
12401 }
12402
12403 /* add playback controls for speaker and HP outputs */
12404 /* Based on ALC880 version. But ALC861VD has separate,
12405 * different NIDs for mute/unmute switch and volume control */
12406 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12407 hda_nid_t pin, const char *pfx)
12408 {
12409 hda_nid_t nid_v, nid_s;
12410 int err;
12411 char name[32];
12412
12413 if (!pin)
12414 return 0;
12415
12416 if (alc880_is_fixed_pin(pin)) {
12417 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12418 /* specify the DAC as the extra output */
12419 if (!spec->multiout.hp_nid)
12420 spec->multiout.hp_nid = nid_v;
12421 else
12422 spec->multiout.extra_out_nid[0] = nid_v;
12423 /* control HP volume/switch on the output mixer amp */
12424 nid_v = alc861vd_idx_to_mixer_vol(
12425 alc880_fixed_pin_idx(pin));
12426 nid_s = alc861vd_idx_to_mixer_switch(
12427 alc880_fixed_pin_idx(pin));
12428
12429 sprintf(name, "%s Playback Volume", pfx);
12430 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12431 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12432 if (err < 0)
12433 return err;
12434 sprintf(name, "%s Playback Switch", pfx);
12435 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12436 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12437 if (err < 0)
12438 return err;
12439 } else if (alc880_is_multi_pin(pin)) {
12440 /* set manual connection */
12441 /* we have only a switch on HP-out PIN */
12442 sprintf(name, "%s Playback Switch", pfx);
12443 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12444 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12445 if (err < 0)
12446 return err;
12447 }
12448 return 0;
12449 }
12450
12451 /* parse the BIOS configuration and set up the alc_spec
12452 * return 1 if successful, 0 if the proper config is not found,
12453 * or a negative error code
12454 * Based on ALC880 version - had to change it to override
12455 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12456 static int alc861vd_parse_auto_config(struct hda_codec *codec)
12457 {
12458 struct alc_spec *spec = codec->spec;
12459 int err;
12460 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12461
12462 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12463 alc861vd_ignore);
12464 if (err < 0)
12465 return err;
12466 if (!spec->autocfg.line_outs)
12467 return 0; /* can't find valid BIOS pin config */
12468
12469 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12470 if (err < 0)
12471 return err;
12472 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12473 if (err < 0)
12474 return err;
12475 err = alc861vd_auto_create_extra_out(spec,
12476 spec->autocfg.speaker_pins[0],
12477 "Speaker");
12478 if (err < 0)
12479 return err;
12480 err = alc861vd_auto_create_extra_out(spec,
12481 spec->autocfg.hp_pins[0],
12482 "Headphone");
12483 if (err < 0)
12484 return err;
12485 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12486 if (err < 0)
12487 return err;
12488
12489 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12490
12491 if (spec->autocfg.dig_out_pin)
12492 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12493
12494 if (spec->kctl_alloc)
12495 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12496
12497 spec->init_verbs[spec->num_init_verbs++]
12498 = alc861vd_volume_init_verbs;
12499
12500 spec->num_mux_defs = 1;
12501 spec->input_mux = &spec->private_imux;
12502
12503 err = alc_auto_add_mic_boost(codec);
12504 if (err < 0)
12505 return err;
12506
12507 return 1;
12508 }
12509
12510 /* additional initialization for auto-configuration model */
12511 static void alc861vd_auto_init(struct hda_codec *codec)
12512 {
12513 alc861vd_auto_init_multi_out(codec);
12514 alc861vd_auto_init_hp_out(codec);
12515 alc861vd_auto_init_analog_input(codec);
12516 }
12517
12518 static int patch_alc861vd(struct hda_codec *codec)
12519 {
12520 struct alc_spec *spec;
12521 int err, board_config;
12522
12523 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12524 if (spec == NULL)
12525 return -ENOMEM;
12526
12527 codec->spec = spec;
12528
12529 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12530 alc861vd_models,
12531 alc861vd_cfg_tbl);
12532
12533 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12534 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12535 "ALC861VD, trying auto-probe from BIOS...\n");
12536 board_config = ALC861VD_AUTO;
12537 }
12538
12539 if (board_config == ALC861VD_AUTO) {
12540 /* automatic parse from the BIOS config */
12541 err = alc861vd_parse_auto_config(codec);
12542 if (err < 0) {
12543 alc_free(codec);
12544 return err;
12545 } else if (!err) {
12546 printk(KERN_INFO
12547 "hda_codec: Cannot set up configuration "
12548 "from BIOS. Using base mode...\n");
12549 board_config = ALC861VD_3ST;
12550 }
12551 }
12552
12553 if (board_config != ALC861VD_AUTO)
12554 setup_preset(spec, &alc861vd_presets[board_config]);
12555
12556 spec->stream_name_analog = "ALC861VD Analog";
12557 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12558 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12559
12560 spec->stream_name_digital = "ALC861VD Digital";
12561 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12562 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12563
12564 spec->adc_nids = alc861vd_adc_nids;
12565 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12566
12567 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12568 spec->num_mixers++;
12569
12570 spec->vmaster_nid = 0x02;
12571
12572 codec->patch_ops = alc_patch_ops;
12573
12574 if (board_config == ALC861VD_AUTO)
12575 spec->init_hook = alc861vd_auto_init;
12576 #ifdef CONFIG_SND_HDA_POWER_SAVE
12577 if (!spec->loopback.amplist)
12578 spec->loopback.amplist = alc861vd_loopbacks;
12579 #endif
12580
12581 return 0;
12582 }
12583
12584 /*
12585 * ALC662 support
12586 *
12587 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12588 * configuration. Each pin widget can choose any input DACs and a mixer.
12589 * Each ADC is connected from a mixer of all inputs. This makes possible
12590 * 6-channel independent captures.
12591 *
12592 * In addition, an independent DAC for the multi-playback (not used in this
12593 * driver yet).
12594 */
12595 #define ALC662_DIGOUT_NID 0x06
12596 #define ALC662_DIGIN_NID 0x0a
12597
12598 static hda_nid_t alc662_dac_nids[4] = {
12599 /* front, rear, clfe, rear_surr */
12600 0x02, 0x03, 0x04
12601 };
12602
12603 static hda_nid_t alc662_adc_nids[1] = {
12604 /* ADC1-2 */
12605 0x09,
12606 };
12607 /* input MUX */
12608 /* FIXME: should be a matrix-type input source selection */
12609
12610 static struct hda_input_mux alc662_capture_source = {
12611 .num_items = 4,
12612 .items = {
12613 { "Mic", 0x0 },
12614 { "Front Mic", 0x1 },
12615 { "Line", 0x2 },
12616 { "CD", 0x4 },
12617 },
12618 };
12619
12620 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12621 .num_items = 2,
12622 .items = {
12623 { "Mic", 0x1 },
12624 { "Line", 0x2 },
12625 },
12626 };
12627
12628 static struct hda_input_mux alc662_eeepc_capture_source = {
12629 .num_items = 2,
12630 .items = {
12631 { "i-Mic", 0x1 },
12632 { "e-Mic", 0x0 },
12633 },
12634 };
12635
12636 #define alc662_mux_enum_info alc_mux_enum_info
12637 #define alc662_mux_enum_get alc_mux_enum_get
12638
12639 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12640 struct snd_ctl_elem_value *ucontrol)
12641 {
12642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12643 struct alc_spec *spec = codec->spec;
12644 const struct hda_input_mux *imux = spec->input_mux;
12645 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
12646 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
12647 hda_nid_t nid = capture_mixers[adc_idx];
12648 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12649 unsigned int i, idx;
12650
12651 idx = ucontrol->value.enumerated.item[0];
12652 if (idx >= imux->num_items)
12653 idx = imux->num_items - 1;
12654 if (*cur_val == idx)
12655 return 0;
12656 for (i = 0; i < imux->num_items; i++) {
12657 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12658 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12659 imux->items[i].index,
12660 HDA_AMP_MUTE, v);
12661 }
12662 *cur_val = idx;
12663 return 1;
12664 }
12665 /*
12666 * 2ch mode
12667 */
12668 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12669 { 2, NULL }
12670 };
12671
12672 /*
12673 * 2ch mode
12674 */
12675 static struct hda_verb alc662_3ST_ch2_init[] = {
12676 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12677 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12678 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12679 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12680 { } /* end */
12681 };
12682
12683 /*
12684 * 6ch mode
12685 */
12686 static struct hda_verb alc662_3ST_ch6_init[] = {
12687 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12688 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12689 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12690 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12691 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12692 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12693 { } /* end */
12694 };
12695
12696 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12697 { 2, alc662_3ST_ch2_init },
12698 { 6, alc662_3ST_ch6_init },
12699 };
12700
12701 /*
12702 * 2ch mode
12703 */
12704 static struct hda_verb alc662_sixstack_ch6_init[] = {
12705 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12706 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12707 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12708 { } /* end */
12709 };
12710
12711 /*
12712 * 6ch mode
12713 */
12714 static struct hda_verb alc662_sixstack_ch8_init[] = {
12715 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12716 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12717 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12718 { } /* end */
12719 };
12720
12721 static struct hda_channel_mode alc662_5stack_modes[2] = {
12722 { 2, alc662_sixstack_ch6_init },
12723 { 6, alc662_sixstack_ch8_init },
12724 };
12725
12726 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12727 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12728 */
12729
12730 static struct snd_kcontrol_new alc662_base_mixer[] = {
12731 /* output mixer control */
12732 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12733 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12734 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12735 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12736 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12737 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12738 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12739 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12740 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12741
12742 /*Input mixer control */
12743 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12744 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12745 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12746 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12747 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12748 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12749 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12750 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
12751 { } /* end */
12752 };
12753
12754 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12755 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12756 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12758 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12759 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12760 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12761 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12764 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12765 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12766 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12767 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12768 { } /* end */
12769 };
12770
12771 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12772 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12773 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12774 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12775 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12776 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12777 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12778 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12779 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12780 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12781 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12782 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12783 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12784 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12785 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12787 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12788 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12789 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12790 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12791 { } /* end */
12792 };
12793
12794 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12795 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12796 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12797 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12798 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
12799 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12800 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12801 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12804 { } /* end */
12805 };
12806
12807 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
12808 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12809
12810 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12811 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12812
12813 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
12814 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12815 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12816
12817 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
12818 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12819 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12820 { } /* end */
12821 };
12822
12823 static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
12824 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12825 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12826 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12827 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12828 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12829 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12830 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12831 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12832 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12833 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
12834 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12835 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12838 { } /* end */
12839 };
12840
12841 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
12842 {
12843 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12844 .name = "Channel Mode",
12845 .info = alc_ch_mode_info,
12846 .get = alc_ch_mode_get,
12847 .put = alc_ch_mode_put,
12848 },
12849 { } /* end */
12850 };
12851
12852 static struct hda_verb alc662_init_verbs[] = {
12853 /* ADC: mute amp left and right */
12854 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12855 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12856 /* Front mixer: unmute input/output amp left and right (volume = 0) */
12857
12858 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12859 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12863
12864 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12865 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12866 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12867 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12868 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12869 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12870
12871 /* Front Pin: output 0 (0x0c) */
12872 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12873 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12874
12875 /* Rear Pin: output 1 (0x0d) */
12876 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12877 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12878
12879 /* CLFE Pin: output 2 (0x0e) */
12880 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12881 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12882
12883 /* Mic (rear) pin: input vref at 80% */
12884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12885 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12886 /* Front Mic pin: input vref at 80% */
12887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12889 /* Line In pin: input */
12890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12891 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12892 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12894 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12895 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12896 /* CD pin widget for input */
12897 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12898
12899 /* FIXME: use matrix-type input source selection */
12900 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12901 /* Input mixer */
12902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
12906
12907 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12908 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12909 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12910 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
12911 { }
12912 };
12913
12914 static struct hda_verb alc662_sue_init_verbs[] = {
12915 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
12916 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
12917 {}
12918 };
12919
12920 static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
12921 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12922 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12923 {}
12924 };
12925
12926 /* Set Unsolicited Event*/
12927 static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
12928 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12929 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12930 {}
12931 };
12932
12933 /*
12934 * generic initialization of ADC, input mixers and output mixers
12935 */
12936 static struct hda_verb alc662_auto_init_verbs[] = {
12937 /*
12938 * Unmute ADC and set the default input to mic-in
12939 */
12940 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12941 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12942
12943 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
12944 * mixer widget
12945 * Note: PASD motherboards uses the Line In 2 as the input for front
12946 * panel mic (mic 2)
12947 */
12948 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12953 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12954
12955 /*
12956 * Set up output mixers (0x0c - 0x0f)
12957 */
12958 /* set vol=0 to output mixers */
12959 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12960 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12961 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12962
12963 /* set up input amps for analog loopback */
12964 /* Amp Indices: DAC = 0, mixer = 1 */
12965 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12966 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12967 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12968 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12969 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12970 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12971
12972
12973 /* FIXME: use matrix-type input source selection */
12974 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12975 /* Input mixer */
12976 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12978 { }
12979 };
12980
12981 /* capture mixer elements */
12982 static struct snd_kcontrol_new alc662_capture_mixer[] = {
12983 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12984 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12985 {
12986 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12987 /* The multiple "Capture Source" controls confuse alsamixer
12988 * So call somewhat different..
12989 */
12990 /* .name = "Capture Source", */
12991 .name = "Input Source",
12992 .count = 1,
12993 .info = alc662_mux_enum_info,
12994 .get = alc662_mux_enum_get,
12995 .put = alc662_mux_enum_put,
12996 },
12997 { } /* end */
12998 };
12999
13000 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13001 {
13002 unsigned int present;
13003 unsigned char bits;
13004
13005 present = snd_hda_codec_read(codec, 0x14, 0,
13006 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13007 bits = present ? HDA_AMP_MUTE : 0;
13008 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13009 HDA_AMP_MUTE, bits);
13010 }
13011
13012 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13013 {
13014 unsigned int present;
13015 unsigned char bits;
13016
13017 present = snd_hda_codec_read(codec, 0x1b, 0,
13018 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13019 bits = present ? HDA_AMP_MUTE : 0;
13020 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13021 HDA_AMP_MUTE, bits);
13022 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13023 HDA_AMP_MUTE, bits);
13024 }
13025
13026 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13027 unsigned int res)
13028 {
13029 if ((res >> 26) == ALC880_HP_EVENT)
13030 alc662_lenovo_101e_all_automute(codec);
13031 if ((res >> 26) == ALC880_FRONT_EVENT)
13032 alc662_lenovo_101e_ispeaker_automute(codec);
13033 }
13034
13035 static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13036 {
13037 unsigned int present;
13038
13039 present = snd_hda_codec_read(codec, 0x18, 0,
13040 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13041 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13042 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13043 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13044 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13045 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13046 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13047 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13048 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13049 }
13050
13051 /* unsolicited event for HP jack sensing */
13052 static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13053 unsigned int res)
13054 {
13055 if ((res >> 26) == ALC880_HP_EVENT)
13056 alc262_hippo1_automute( codec );
13057
13058 if ((res >> 26) == ALC880_MIC_EVENT)
13059 alc662_eeepc_mic_automute(codec);
13060 }
13061
13062 static void alc662_eeepc_inithook(struct hda_codec *codec)
13063 {
13064 alc262_hippo1_automute( codec );
13065 alc662_eeepc_mic_automute(codec);
13066 }
13067
13068 static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13069 {
13070 unsigned int mute;
13071 unsigned int present;
13072
13073 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13074 present = snd_hda_codec_read(codec, 0x14, 0,
13075 AC_VERB_GET_PIN_SENSE, 0);
13076 present = (present & 0x80000000) != 0;
13077 if (present) {
13078 /* mute internal speaker */
13079 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13080 HDA_AMP_MUTE, HDA_AMP_MUTE);
13081 } else {
13082 /* unmute internal speaker if necessary */
13083 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13084 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13085 HDA_AMP_MUTE, mute);
13086 }
13087 }
13088
13089 /* unsolicited event for HP jack sensing */
13090 static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13091 unsigned int res)
13092 {
13093 if ((res >> 26) == ALC880_HP_EVENT)
13094 alc662_eeepc_ep20_automute(codec);
13095 }
13096
13097 static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13098 {
13099 alc662_eeepc_ep20_automute(codec);
13100 }
13101
13102 #ifdef CONFIG_SND_HDA_POWER_SAVE
13103 #define alc662_loopbacks alc880_loopbacks
13104 #endif
13105
13106
13107 /* pcm configuration: identiacal with ALC880 */
13108 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
13109 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
13110 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
13111 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
13112
13113 /*
13114 * configuration and preset
13115 */
13116 static const char *alc662_models[ALC662_MODEL_LAST] = {
13117 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13118 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13119 [ALC662_3ST_6ch] = "3stack-6ch",
13120 [ALC662_5ST_DIG] = "6stack-dig",
13121 [ALC662_LENOVO_101E] = "lenovo-101e",
13122 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
13123 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
13124 [ALC662_AUTO] = "auto",
13125 };
13126
13127 static struct snd_pci_quirk alc662_cfg_tbl[] = {
13128 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
13129 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
13130 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
13131 {}
13132 };
13133
13134 static struct alc_config_preset alc662_presets[] = {
13135 [ALC662_3ST_2ch_DIG] = {
13136 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
13137 .init_verbs = { alc662_init_verbs },
13138 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13139 .dac_nids = alc662_dac_nids,
13140 .dig_out_nid = ALC662_DIGOUT_NID,
13141 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13142 .adc_nids = alc662_adc_nids,
13143 .dig_in_nid = ALC662_DIGIN_NID,
13144 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13145 .channel_mode = alc662_3ST_2ch_modes,
13146 .input_mux = &alc662_capture_source,
13147 },
13148 [ALC662_3ST_6ch_DIG] = {
13149 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13150 alc662_capture_mixer },
13151 .init_verbs = { alc662_init_verbs },
13152 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13153 .dac_nids = alc662_dac_nids,
13154 .dig_out_nid = ALC662_DIGOUT_NID,
13155 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13156 .adc_nids = alc662_adc_nids,
13157 .dig_in_nid = ALC662_DIGIN_NID,
13158 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13159 .channel_mode = alc662_3ST_6ch_modes,
13160 .need_dac_fix = 1,
13161 .input_mux = &alc662_capture_source,
13162 },
13163 [ALC662_3ST_6ch] = {
13164 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13165 alc662_capture_mixer },
13166 .init_verbs = { alc662_init_verbs },
13167 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13168 .dac_nids = alc662_dac_nids,
13169 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13170 .adc_nids = alc662_adc_nids,
13171 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13172 .channel_mode = alc662_3ST_6ch_modes,
13173 .need_dac_fix = 1,
13174 .input_mux = &alc662_capture_source,
13175 },
13176 [ALC662_5ST_DIG] = {
13177 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13178 alc662_capture_mixer },
13179 .init_verbs = { alc662_init_verbs },
13180 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13181 .dac_nids = alc662_dac_nids,
13182 .dig_out_nid = ALC662_DIGOUT_NID,
13183 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13184 .adc_nids = alc662_adc_nids,
13185 .dig_in_nid = ALC662_DIGIN_NID,
13186 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13187 .channel_mode = alc662_5stack_modes,
13188 .input_mux = &alc662_capture_source,
13189 },
13190 [ALC662_LENOVO_101E] = {
13191 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
13192 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13193 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13194 .dac_nids = alc662_dac_nids,
13195 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13196 .adc_nids = alc662_adc_nids,
13197 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13198 .channel_mode = alc662_3ST_2ch_modes,
13199 .input_mux = &alc662_lenovo_101e_capture_source,
13200 .unsol_event = alc662_lenovo_101e_unsol_event,
13201 .init_hook = alc662_lenovo_101e_all_automute,
13202 },
13203 [ALC662_ASUS_EEEPC_P701] = {
13204 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13205 .init_verbs = { alc662_init_verbs,
13206 alc662_eeepc_sue_init_verbs },
13207 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13208 .dac_nids = alc662_dac_nids,
13209 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13210 .adc_nids = alc662_adc_nids,
13211 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13212 .channel_mode = alc662_3ST_2ch_modes,
13213 .input_mux = &alc662_eeepc_capture_source,
13214 .unsol_event = alc662_eeepc_unsol_event,
13215 .init_hook = alc662_eeepc_inithook,
13216 },
13217 [ALC662_ASUS_EEEPC_EP20] = {
13218 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13219 alc662_chmode_mixer },
13220 .init_verbs = { alc662_init_verbs,
13221 alc662_eeepc_ep20_sue_init_verbs },
13222 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13223 .dac_nids = alc662_dac_nids,
13224 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13225 .adc_nids = alc662_adc_nids,
13226 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13227 .channel_mode = alc662_3ST_6ch_modes,
13228 .input_mux = &alc662_lenovo_101e_capture_source,
13229 .unsol_event = alc662_eeepc_ep20_unsol_event,
13230 .init_hook = alc662_eeepc_ep20_inithook,
13231 },
13232
13233 };
13234
13235
13236 /*
13237 * BIOS auto configuration
13238 */
13239
13240 /* add playback controls from the parsed DAC table */
13241 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13242 const struct auto_pin_cfg *cfg)
13243 {
13244 char name[32];
13245 static const char *chname[4] = {
13246 "Front", "Surround", NULL /*CLFE*/, "Side"
13247 };
13248 hda_nid_t nid;
13249 int i, err;
13250
13251 for (i = 0; i < cfg->line_outs; i++) {
13252 if (!spec->multiout.dac_nids[i])
13253 continue;
13254 nid = alc880_idx_to_dac(i);
13255 if (i == 2) {
13256 /* Center/LFE */
13257 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13258 "Center Playback Volume",
13259 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13260 HDA_OUTPUT));
13261 if (err < 0)
13262 return err;
13263 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13264 "LFE Playback Volume",
13265 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13266 HDA_OUTPUT));
13267 if (err < 0)
13268 return err;
13269 err = add_control(spec, ALC_CTL_BIND_MUTE,
13270 "Center Playback Switch",
13271 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13272 HDA_INPUT));
13273 if (err < 0)
13274 return err;
13275 err = add_control(spec, ALC_CTL_BIND_MUTE,
13276 "LFE Playback Switch",
13277 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13278 HDA_INPUT));
13279 if (err < 0)
13280 return err;
13281 } else {
13282 sprintf(name, "%s Playback Volume", chname[i]);
13283 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13284 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13285 HDA_OUTPUT));
13286 if (err < 0)
13287 return err;
13288 sprintf(name, "%s Playback Switch", chname[i]);
13289 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13290 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13291 HDA_INPUT));
13292 if (err < 0)
13293 return err;
13294 }
13295 }
13296 return 0;
13297 }
13298
13299 /* add playback controls for speaker and HP outputs */
13300 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13301 const char *pfx)
13302 {
13303 hda_nid_t nid;
13304 int err;
13305 char name[32];
13306
13307 if (!pin)
13308 return 0;
13309
13310 if (alc880_is_fixed_pin(pin)) {
13311 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13312 /* printk("DAC nid=%x\n",nid); */
13313 /* specify the DAC as the extra output */
13314 if (!spec->multiout.hp_nid)
13315 spec->multiout.hp_nid = nid;
13316 else
13317 spec->multiout.extra_out_nid[0] = nid;
13318 /* control HP volume/switch on the output mixer amp */
13319 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13320 sprintf(name, "%s Playback Volume", pfx);
13321 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13322 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13323 if (err < 0)
13324 return err;
13325 sprintf(name, "%s Playback Switch", pfx);
13326 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13327 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13328 if (err < 0)
13329 return err;
13330 } else if (alc880_is_multi_pin(pin)) {
13331 /* set manual connection */
13332 /* we have only a switch on HP-out PIN */
13333 sprintf(name, "%s Playback Switch", pfx);
13334 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13335 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13336 if (err < 0)
13337 return err;
13338 }
13339 return 0;
13340 }
13341
13342 /* create playback/capture controls for input pins */
13343 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13344 const struct auto_pin_cfg *cfg)
13345 {
13346 struct hda_input_mux *imux = &spec->private_imux;
13347 int i, err, idx;
13348
13349 for (i = 0; i < AUTO_PIN_LAST; i++) {
13350 if (alc880_is_input_pin(cfg->input_pins[i])) {
13351 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13352 err = new_analog_input(spec, cfg->input_pins[i],
13353 auto_pin_cfg_labels[i],
13354 idx, 0x0b);
13355 if (err < 0)
13356 return err;
13357 imux->items[imux->num_items].label =
13358 auto_pin_cfg_labels[i];
13359 imux->items[imux->num_items].index =
13360 alc880_input_pin_idx(cfg->input_pins[i]);
13361 imux->num_items++;
13362 }
13363 }
13364 return 0;
13365 }
13366
13367 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13368 hda_nid_t nid, int pin_type,
13369 int dac_idx)
13370 {
13371 /* set as output */
13372 snd_hda_codec_write(codec, nid, 0,
13373 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13374 snd_hda_codec_write(codec, nid, 0,
13375 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13376 /* need the manual connection? */
13377 if (alc880_is_multi_pin(nid)) {
13378 struct alc_spec *spec = codec->spec;
13379 int idx = alc880_multi_pin_idx(nid);
13380 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13381 AC_VERB_SET_CONNECT_SEL,
13382 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13383 }
13384 }
13385
13386 static void alc662_auto_init_multi_out(struct hda_codec *codec)
13387 {
13388 struct alc_spec *spec = codec->spec;
13389 int i;
13390
13391 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
13392 for (i = 0; i <= HDA_SIDE; i++) {
13393 hda_nid_t nid = spec->autocfg.line_out_pins[i];
13394 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13395 if (nid)
13396 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
13397 i);
13398 }
13399 }
13400
13401 static void alc662_auto_init_hp_out(struct hda_codec *codec)
13402 {
13403 struct alc_spec *spec = codec->spec;
13404 hda_nid_t pin;
13405
13406 pin = spec->autocfg.hp_pins[0];
13407 if (pin) /* connect to front */
13408 /* use dac 0 */
13409 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13410 }
13411
13412 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13413 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13414
13415 static void alc662_auto_init_analog_input(struct hda_codec *codec)
13416 {
13417 struct alc_spec *spec = codec->spec;
13418 int i;
13419
13420 for (i = 0; i < AUTO_PIN_LAST; i++) {
13421 hda_nid_t nid = spec->autocfg.input_pins[i];
13422 if (alc662_is_input_pin(nid)) {
13423 snd_hda_codec_write(codec, nid, 0,
13424 AC_VERB_SET_PIN_WIDGET_CONTROL,
13425 (i <= AUTO_PIN_FRONT_MIC ?
13426 PIN_VREF80 : PIN_IN));
13427 if (nid != ALC662_PIN_CD_NID)
13428 snd_hda_codec_write(codec, nid, 0,
13429 AC_VERB_SET_AMP_GAIN_MUTE,
13430 AMP_OUT_MUTE);
13431 }
13432 }
13433 }
13434
13435 static int alc662_parse_auto_config(struct hda_codec *codec)
13436 {
13437 struct alc_spec *spec = codec->spec;
13438 int err;
13439 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13440
13441 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13442 alc662_ignore);
13443 if (err < 0)
13444 return err;
13445 if (!spec->autocfg.line_outs)
13446 return 0; /* can't find valid BIOS pin config */
13447
13448 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13449 if (err < 0)
13450 return err;
13451 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13452 if (err < 0)
13453 return err;
13454 err = alc662_auto_create_extra_out(spec,
13455 spec->autocfg.speaker_pins[0],
13456 "Speaker");
13457 if (err < 0)
13458 return err;
13459 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13460 "Headphone");
13461 if (err < 0)
13462 return err;
13463 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13464 if (err < 0)
13465 return err;
13466
13467 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13468
13469 if (spec->autocfg.dig_out_pin)
13470 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13471
13472 if (spec->kctl_alloc)
13473 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13474
13475 spec->num_mux_defs = 1;
13476 spec->input_mux = &spec->private_imux;
13477
13478 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
13479 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13480 spec->num_mixers++;
13481 return 1;
13482 }
13483
13484 /* additional initialization for auto-configuration model */
13485 static void alc662_auto_init(struct hda_codec *codec)
13486 {
13487 alc662_auto_init_multi_out(codec);
13488 alc662_auto_init_hp_out(codec);
13489 alc662_auto_init_analog_input(codec);
13490 }
13491
13492 static int patch_alc662(struct hda_codec *codec)
13493 {
13494 struct alc_spec *spec;
13495 int err, board_config;
13496
13497 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13498 if (!spec)
13499 return -ENOMEM;
13500
13501 codec->spec = spec;
13502
13503 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13504 alc662_models,
13505 alc662_cfg_tbl);
13506 if (board_config < 0) {
13507 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13508 "trying auto-probe from BIOS...\n");
13509 board_config = ALC662_AUTO;
13510 }
13511
13512 if (board_config == ALC662_AUTO) {
13513 /* automatic parse from the BIOS config */
13514 err = alc662_parse_auto_config(codec);
13515 if (err < 0) {
13516 alc_free(codec);
13517 return err;
13518 } else if (!err) {
13519 printk(KERN_INFO
13520 "hda_codec: Cannot set up configuration "
13521 "from BIOS. Using base mode...\n");
13522 board_config = ALC662_3ST_2ch_DIG;
13523 }
13524 }
13525
13526 if (board_config != ALC662_AUTO)
13527 setup_preset(spec, &alc662_presets[board_config]);
13528
13529 spec->stream_name_analog = "ALC662 Analog";
13530 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13531 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13532
13533 spec->stream_name_digital = "ALC662 Digital";
13534 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13535 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13536
13537 if (!spec->adc_nids && spec->input_mux) {
13538 spec->adc_nids = alc662_adc_nids;
13539 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13540 }
13541
13542 spec->vmaster_nid = 0x02;
13543
13544 codec->patch_ops = alc_patch_ops;
13545 if (board_config == ALC662_AUTO)
13546 spec->init_hook = alc662_auto_init;
13547 #ifdef CONFIG_SND_HDA_POWER_SAVE
13548 if (!spec->loopback.amplist)
13549 spec->loopback.amplist = alc662_loopbacks;
13550 #endif
13551
13552 return 0;
13553 }
13554
13555 /*
13556 * patch entries
13557 */
13558 struct hda_codec_preset snd_hda_preset_realtek[] = {
13559 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
13560 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
13561 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
13562 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
13563 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
13564 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
13565 .patch = patch_alc861 },
13566 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13567 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13568 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
13569 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13570 .patch = patch_alc883 },
13571 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13572 .patch = patch_alc662 },
13573 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
13574 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
13575 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
13576 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
13577 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
13578 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
13579 {} /* terminator */
13580 };