]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - sound/pci/hda/patch_realtek.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
[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 unsigned int master_sw: 1;
270
271 /* for virtual master */
272 hda_nid_t vmaster_nid;
273 u32 vmaster_tlv[4];
274 #ifdef CONFIG_SND_HDA_POWER_SAVE
275 struct hda_loopback_check loopback;
276 #endif
277 };
278
279 /*
280 * configuration template - to be copied to the spec instance
281 */
282 struct alc_config_preset {
283 struct snd_kcontrol_new *mixers[5]; /* should be identical size
284 * with spec
285 */
286 const struct hda_verb *init_verbs[5];
287 unsigned int num_dacs;
288 hda_nid_t *dac_nids;
289 hda_nid_t dig_out_nid; /* optional */
290 hda_nid_t hp_nid; /* optional */
291 unsigned int num_adc_nids;
292 hda_nid_t *adc_nids;
293 hda_nid_t dig_in_nid;
294 unsigned int num_channel_mode;
295 const struct hda_channel_mode *channel_mode;
296 int need_dac_fix;
297 unsigned int num_mux_defs;
298 const struct hda_input_mux *input_mux;
299 void (*unsol_event)(struct hda_codec *, unsigned int);
300 void (*init_hook)(struct hda_codec *);
301 #ifdef CONFIG_SND_HDA_POWER_SAVE
302 struct hda_amp_list *loopbacks;
303 #endif
304 };
305
306
307 /*
308 * input MUX handling
309 */
310 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
311 struct snd_ctl_elem_info *uinfo)
312 {
313 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
314 struct alc_spec *spec = codec->spec;
315 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
316 if (mux_idx >= spec->num_mux_defs)
317 mux_idx = 0;
318 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
319 }
320
321 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
322 struct snd_ctl_elem_value *ucontrol)
323 {
324 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
325 struct alc_spec *spec = codec->spec;
326 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
327
328 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
329 return 0;
330 }
331
332 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
333 struct snd_ctl_elem_value *ucontrol)
334 {
335 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
336 struct alc_spec *spec = codec->spec;
337 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
338 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
339 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
340 spec->adc_nids[adc_idx],
341 &spec->cur_mux[adc_idx]);
342 }
343
344
345 /*
346 * channel mode setting
347 */
348 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
349 struct snd_ctl_elem_info *uinfo)
350 {
351 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
352 struct alc_spec *spec = codec->spec;
353 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
354 spec->num_channel_mode);
355 }
356
357 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
358 struct snd_ctl_elem_value *ucontrol)
359 {
360 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
361 struct alc_spec *spec = codec->spec;
362 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
363 spec->num_channel_mode,
364 spec->multiout.max_channels);
365 }
366
367 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
368 struct snd_ctl_elem_value *ucontrol)
369 {
370 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
371 struct alc_spec *spec = codec->spec;
372 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
373 spec->num_channel_mode,
374 &spec->multiout.max_channels);
375 if (err >= 0 && spec->need_dac_fix)
376 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
377 return err;
378 }
379
380 /*
381 * Control the mode of pin widget settings via the mixer. "pc" is used
382 * instead of "%" to avoid consequences of accidently treating the % as
383 * being part of a format specifier. Maximum allowed length of a value is
384 * 63 characters plus NULL terminator.
385 *
386 * Note: some retasking pin complexes seem to ignore requests for input
387 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
388 * are requested. Therefore order this list so that this behaviour will not
389 * cause problems when mixer clients move through the enum sequentially.
390 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
391 * March 2006.
392 */
393 static char *alc_pin_mode_names[] = {
394 "Mic 50pc bias", "Mic 80pc bias",
395 "Line in", "Line out", "Headphone out",
396 };
397 static unsigned char alc_pin_mode_values[] = {
398 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
399 };
400 /* The control can present all 5 options, or it can limit the options based
401 * in the pin being assumed to be exclusively an input or an output pin. In
402 * addition, "input" pins may or may not process the mic bias option
403 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
404 * accept requests for bias as of chip versions up to March 2006) and/or
405 * wiring in the computer.
406 */
407 #define ALC_PIN_DIR_IN 0x00
408 #define ALC_PIN_DIR_OUT 0x01
409 #define ALC_PIN_DIR_INOUT 0x02
410 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
411 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
412
413 /* Info about the pin modes supported by the different pin direction modes.
414 * For each direction the minimum and maximum values are given.
415 */
416 static signed char alc_pin_mode_dir_info[5][2] = {
417 { 0, 2 }, /* ALC_PIN_DIR_IN */
418 { 3, 4 }, /* ALC_PIN_DIR_OUT */
419 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
420 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
421 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
422 };
423 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
424 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
425 #define alc_pin_mode_n_items(_dir) \
426 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
427
428 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
429 struct snd_ctl_elem_info *uinfo)
430 {
431 unsigned int item_num = uinfo->value.enumerated.item;
432 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
433
434 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
435 uinfo->count = 1;
436 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
437
438 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
439 item_num = alc_pin_mode_min(dir);
440 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
441 return 0;
442 }
443
444 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
445 struct snd_ctl_elem_value *ucontrol)
446 {
447 unsigned int i;
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 hda_nid_t nid = kcontrol->private_value & 0xffff;
450 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
451 long *valp = ucontrol->value.integer.value;
452 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
453 AC_VERB_GET_PIN_WIDGET_CONTROL,
454 0x00);
455
456 /* Find enumerated value for current pinctl setting */
457 i = alc_pin_mode_min(dir);
458 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
459 i++;
460 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
461 return 0;
462 }
463
464 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
465 struct snd_ctl_elem_value *ucontrol)
466 {
467 signed int change;
468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
469 hda_nid_t nid = kcontrol->private_value & 0xffff;
470 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
471 long val = *ucontrol->value.integer.value;
472 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
473 AC_VERB_GET_PIN_WIDGET_CONTROL,
474 0x00);
475
476 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
477 val = alc_pin_mode_min(dir);
478
479 change = pinctl != alc_pin_mode_values[val];
480 if (change) {
481 /* Set pin mode to that requested */
482 snd_hda_codec_write_cache(codec, nid, 0,
483 AC_VERB_SET_PIN_WIDGET_CONTROL,
484 alc_pin_mode_values[val]);
485
486 /* Also enable the retasking pin's input/output as required
487 * for the requested pin mode. Enum values of 2 or less are
488 * input modes.
489 *
490 * Dynamically switching the input/output buffers probably
491 * reduces noise slightly (particularly on input) so we'll
492 * do it. However, having both input and output buffers
493 * enabled simultaneously doesn't seem to be problematic if
494 * this turns out to be necessary in the future.
495 */
496 if (val <= 2) {
497 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
498 HDA_AMP_MUTE, HDA_AMP_MUTE);
499 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
500 HDA_AMP_MUTE, 0);
501 } else {
502 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
503 HDA_AMP_MUTE, HDA_AMP_MUTE);
504 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
505 HDA_AMP_MUTE, 0);
506 }
507 }
508 return change;
509 }
510
511 #define ALC_PIN_MODE(xname, nid, dir) \
512 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
513 .info = alc_pin_mode_info, \
514 .get = alc_pin_mode_get, \
515 .put = alc_pin_mode_put, \
516 .private_value = nid | (dir<<16) }
517
518 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
519 * together using a mask with more than one bit set. This control is
520 * currently used only by the ALC260 test model. At this stage they are not
521 * needed for any "production" models.
522 */
523 #ifdef CONFIG_SND_DEBUG
524 #define alc_gpio_data_info snd_ctl_boolean_mono_info
525
526 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
527 struct snd_ctl_elem_value *ucontrol)
528 {
529 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
530 hda_nid_t nid = kcontrol->private_value & 0xffff;
531 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
532 long *valp = ucontrol->value.integer.value;
533 unsigned int val = snd_hda_codec_read(codec, nid, 0,
534 AC_VERB_GET_GPIO_DATA, 0x00);
535
536 *valp = (val & mask) != 0;
537 return 0;
538 }
539 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
540 struct snd_ctl_elem_value *ucontrol)
541 {
542 signed int change;
543 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
544 hda_nid_t nid = kcontrol->private_value & 0xffff;
545 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
546 long val = *ucontrol->value.integer.value;
547 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
548 AC_VERB_GET_GPIO_DATA,
549 0x00);
550
551 /* Set/unset the masked GPIO bit(s) as needed */
552 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
553 if (val == 0)
554 gpio_data &= ~mask;
555 else
556 gpio_data |= mask;
557 snd_hda_codec_write_cache(codec, nid, 0,
558 AC_VERB_SET_GPIO_DATA, gpio_data);
559
560 return change;
561 }
562 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
563 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
564 .info = alc_gpio_data_info, \
565 .get = alc_gpio_data_get, \
566 .put = alc_gpio_data_put, \
567 .private_value = nid | (mask<<16) }
568 #endif /* CONFIG_SND_DEBUG */
569
570 /* A switch control to allow the enabling of the digital IO pins on the
571 * ALC260. This is incredibly simplistic; the intention of this control is
572 * to provide something in the test model allowing digital outputs to be
573 * identified if present. If models are found which can utilise these
574 * outputs a more complete mixer control can be devised for those models if
575 * necessary.
576 */
577 #ifdef CONFIG_SND_DEBUG
578 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
579
580 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
581 struct snd_ctl_elem_value *ucontrol)
582 {
583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
584 hda_nid_t nid = kcontrol->private_value & 0xffff;
585 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
586 long *valp = ucontrol->value.integer.value;
587 unsigned int val = snd_hda_codec_read(codec, nid, 0,
588 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
589
590 *valp = (val & mask) != 0;
591 return 0;
592 }
593 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
594 struct snd_ctl_elem_value *ucontrol)
595 {
596 signed int change;
597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
598 hda_nid_t nid = kcontrol->private_value & 0xffff;
599 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
600 long val = *ucontrol->value.integer.value;
601 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
602 AC_VERB_GET_DIGI_CONVERT_1,
603 0x00);
604
605 /* Set/unset the masked control bit(s) as needed */
606 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
607 if (val==0)
608 ctrl_data &= ~mask;
609 else
610 ctrl_data |= mask;
611 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
612 ctrl_data);
613
614 return change;
615 }
616 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
617 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
618 .info = alc_spdif_ctrl_info, \
619 .get = alc_spdif_ctrl_get, \
620 .put = alc_spdif_ctrl_put, \
621 .private_value = nid | (mask<<16) }
622 #endif /* CONFIG_SND_DEBUG */
623
624 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
625 * Again, this is only used in the ALC26x test models to help identify when
626 * the EAPD line must be asserted for features to work.
627 */
628 #ifdef CONFIG_SND_DEBUG
629 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
630
631 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
632 struct snd_ctl_elem_value *ucontrol)
633 {
634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
635 hda_nid_t nid = kcontrol->private_value & 0xffff;
636 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
637 long *valp = ucontrol->value.integer.value;
638 unsigned int val = snd_hda_codec_read(codec, nid, 0,
639 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
640
641 *valp = (val & mask) != 0;
642 return 0;
643 }
644
645 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
646 struct snd_ctl_elem_value *ucontrol)
647 {
648 int change;
649 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
650 hda_nid_t nid = kcontrol->private_value & 0xffff;
651 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
652 long val = *ucontrol->value.integer.value;
653 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
654 AC_VERB_GET_EAPD_BTLENABLE,
655 0x00);
656
657 /* Set/unset the masked control bit(s) as needed */
658 change = (!val ? 0 : mask) != (ctrl_data & mask);
659 if (!val)
660 ctrl_data &= ~mask;
661 else
662 ctrl_data |= mask;
663 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
664 ctrl_data);
665
666 return change;
667 }
668
669 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
670 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
671 .info = alc_eapd_ctrl_info, \
672 .get = alc_eapd_ctrl_get, \
673 .put = alc_eapd_ctrl_put, \
674 .private_value = nid | (mask<<16) }
675 #endif /* CONFIG_SND_DEBUG */
676
677 /*
678 * set up from the preset table
679 */
680 static void setup_preset(struct alc_spec *spec,
681 const struct alc_config_preset *preset)
682 {
683 int i;
684
685 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
686 spec->mixers[spec->num_mixers++] = preset->mixers[i];
687 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
688 i++)
689 spec->init_verbs[spec->num_init_verbs++] =
690 preset->init_verbs[i];
691
692 spec->channel_mode = preset->channel_mode;
693 spec->num_channel_mode = preset->num_channel_mode;
694 spec->need_dac_fix = preset->need_dac_fix;
695
696 spec->multiout.max_channels = spec->channel_mode[0].channels;
697
698 spec->multiout.num_dacs = preset->num_dacs;
699 spec->multiout.dac_nids = preset->dac_nids;
700 spec->multiout.dig_out_nid = preset->dig_out_nid;
701 spec->multiout.hp_nid = preset->hp_nid;
702
703 spec->num_mux_defs = preset->num_mux_defs;
704 if (!spec->num_mux_defs)
705 spec->num_mux_defs = 1;
706 spec->input_mux = preset->input_mux;
707
708 spec->num_adc_nids = preset->num_adc_nids;
709 spec->adc_nids = preset->adc_nids;
710 spec->dig_in_nid = preset->dig_in_nid;
711
712 spec->unsol_event = preset->unsol_event;
713 spec->init_hook = preset->init_hook;
714 #ifdef CONFIG_SND_HDA_POWER_SAVE
715 spec->loopback.amplist = preset->loopbacks;
716 #endif
717 }
718
719 /* Enable GPIO mask and set output */
720 static struct hda_verb alc_gpio1_init_verbs[] = {
721 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
722 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
723 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
724 { }
725 };
726
727 static struct hda_verb alc_gpio2_init_verbs[] = {
728 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
729 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
730 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
731 { }
732 };
733
734 static struct hda_verb alc_gpio3_init_verbs[] = {
735 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
736 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
737 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
738 { }
739 };
740
741 static void alc_sku_automute(struct hda_codec *codec)
742 {
743 struct alc_spec *spec = codec->spec;
744 unsigned int mute;
745 unsigned int present;
746 unsigned int hp_nid = spec->autocfg.hp_pins[0];
747 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
748
749 /* need to execute and sync at first */
750 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
751 present = snd_hda_codec_read(codec, hp_nid, 0,
752 AC_VERB_GET_PIN_SENSE, 0);
753 spec->jack_present = (present & 0x80000000) != 0;
754 if (spec->jack_present) {
755 /* mute internal speaker */
756 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
757 HDA_AMP_MUTE, HDA_AMP_MUTE);
758 } else {
759 /* unmute internal speaker if necessary */
760 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
761 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
762 HDA_AMP_MUTE, mute);
763 }
764 }
765
766 /* unsolicited event for HP jack sensing */
767 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
768 {
769 if (codec->vendor_id == 0x10ec0880)
770 res >>= 28;
771 else
772 res >>= 26;
773 if (res != ALC880_HP_EVENT)
774 return;
775
776 alc_sku_automute(codec);
777 }
778
779 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
780 * 31 ~ 16 : Manufacture ID
781 * 15 ~ 8 : SKU ID
782 * 7 ~ 0 : Assembly ID
783 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
784 */
785 static void alc_subsystem_id(struct hda_codec *codec,
786 unsigned int porta, unsigned int porte,
787 unsigned int portd)
788 {
789 unsigned int ass, tmp, i;
790 unsigned nid;
791 struct alc_spec *spec = codec->spec;
792
793 ass = codec->subsystem_id & 0xffff;
794 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
795 goto do_sku;
796
797 /*
798 * 31~30 : port conetcivity
799 * 29~21 : reserve
800 * 20 : PCBEEP input
801 * 19~16 : Check sum (15:1)
802 * 15~1 : Custom
803 * 0 : override
804 */
805 nid = 0x1d;
806 if (codec->vendor_id == 0x10ec0260)
807 nid = 0x17;
808 ass = snd_hda_codec_read(codec, nid, 0,
809 AC_VERB_GET_CONFIG_DEFAULT, 0);
810 if (!(ass & 1) && !(ass & 0x100000))
811 return;
812 if ((ass >> 30) != 1) /* no physical connection */
813 return;
814
815 /* check sum */
816 tmp = 0;
817 for (i = 1; i < 16; i++) {
818 if ((ass >> i) & 1)
819 tmp++;
820 }
821 if (((ass >> 16) & 0xf) != tmp)
822 return;
823 do_sku:
824 /*
825 * 0 : override
826 * 1 : Swap Jack
827 * 2 : 0 --> Desktop, 1 --> Laptop
828 * 3~5 : External Amplifier control
829 * 7~6 : Reserved
830 */
831 tmp = (ass & 0x38) >> 3; /* external Amp control */
832 switch (tmp) {
833 case 1:
834 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
835 break;
836 case 3:
837 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
838 break;
839 case 7:
840 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
841 break;
842 case 5: /* set EAPD output high */
843 switch (codec->vendor_id) {
844 case 0x10ec0260:
845 snd_hda_codec_write(codec, 0x0f, 0,
846 AC_VERB_SET_EAPD_BTLENABLE, 2);
847 snd_hda_codec_write(codec, 0x10, 0,
848 AC_VERB_SET_EAPD_BTLENABLE, 2);
849 break;
850 case 0x10ec0262:
851 case 0x10ec0267:
852 case 0x10ec0268:
853 case 0x10ec0269:
854 case 0x10ec0862:
855 case 0x10ec0662:
856 snd_hda_codec_write(codec, 0x14, 0,
857 AC_VERB_SET_EAPD_BTLENABLE, 2);
858 snd_hda_codec_write(codec, 0x15, 0,
859 AC_VERB_SET_EAPD_BTLENABLE, 2);
860 break;
861 }
862 switch (codec->vendor_id) {
863 case 0x10ec0260:
864 snd_hda_codec_write(codec, 0x1a, 0,
865 AC_VERB_SET_COEF_INDEX, 7);
866 tmp = snd_hda_codec_read(codec, 0x1a, 0,
867 AC_VERB_GET_PROC_COEF, 0);
868 snd_hda_codec_write(codec, 0x1a, 0,
869 AC_VERB_SET_COEF_INDEX, 7);
870 snd_hda_codec_write(codec, 0x1a, 0,
871 AC_VERB_SET_PROC_COEF,
872 tmp | 0x2010);
873 break;
874 case 0x10ec0262:
875 case 0x10ec0880:
876 case 0x10ec0882:
877 case 0x10ec0883:
878 case 0x10ec0885:
879 case 0x10ec0888:
880 snd_hda_codec_write(codec, 0x20, 0,
881 AC_VERB_SET_COEF_INDEX, 7);
882 tmp = snd_hda_codec_read(codec, 0x20, 0,
883 AC_VERB_GET_PROC_COEF, 0);
884 snd_hda_codec_write(codec, 0x20, 0,
885 AC_VERB_SET_COEF_INDEX, 7);
886 snd_hda_codec_write(codec, 0x20, 0,
887 AC_VERB_SET_PROC_COEF,
888 tmp | 0x2010);
889 break;
890 case 0x10ec0267:
891 case 0x10ec0268:
892 snd_hda_codec_write(codec, 0x20, 0,
893 AC_VERB_SET_COEF_INDEX, 7);
894 tmp = snd_hda_codec_read(codec, 0x20, 0,
895 AC_VERB_GET_PROC_COEF, 0);
896 snd_hda_codec_write(codec, 0x20, 0,
897 AC_VERB_SET_COEF_INDEX, 7);
898 snd_hda_codec_write(codec, 0x20, 0,
899 AC_VERB_SET_PROC_COEF,
900 tmp | 0x3000);
901 break;
902 }
903 default:
904 break;
905 }
906
907 /* is laptop or Desktop and enable the function "Mute internal speaker
908 * when the external headphone out jack is plugged"
909 */
910 if (!(ass & 0x8000))
911 return;
912 /*
913 * 10~8 : Jack location
914 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
915 * 14~13: Resvered
916 * 15 : 1 --> enable the function "Mute internal speaker
917 * when the external headphone out jack is plugged"
918 */
919 if (!spec->autocfg.speaker_pins[0]) {
920 if (spec->autocfg.line_out_pins[0])
921 spec->autocfg.speaker_pins[0] =
922 spec->autocfg.line_out_pins[0];
923 else
924 return;
925 }
926
927 if (!spec->autocfg.hp_pins[0]) {
928 tmp = (ass >> 11) & 0x3; /* HP to chassis */
929 if (tmp == 0)
930 spec->autocfg.hp_pins[0] = porta;
931 else if (tmp == 1)
932 spec->autocfg.hp_pins[0] = porte;
933 else if (tmp == 2)
934 spec->autocfg.hp_pins[0] = portd;
935 else
936 return;
937 }
938
939 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
940 AC_VERB_SET_UNSOLICITED_ENABLE,
941 AC_USRSP_EN | ALC880_HP_EVENT);
942 spec->unsol_event = alc_sku_unsol_event;
943 spec->init_hook = alc_sku_automute;
944 }
945
946 /*
947 * Fix-up pin default configurations
948 */
949
950 struct alc_pincfg {
951 hda_nid_t nid;
952 u32 val;
953 };
954
955 static void alc_fix_pincfg(struct hda_codec *codec,
956 const struct snd_pci_quirk *quirk,
957 const struct alc_pincfg **pinfix)
958 {
959 const struct alc_pincfg *cfg;
960
961 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
962 if (!quirk)
963 return;
964
965 cfg = pinfix[quirk->value];
966 for (; cfg->nid; cfg++) {
967 int i;
968 u32 val = cfg->val;
969 for (i = 0; i < 4; i++) {
970 snd_hda_codec_write(codec, cfg->nid, 0,
971 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
972 val & 0xff);
973 val >>= 8;
974 }
975 }
976 }
977
978 /*
979 * ALC880 3-stack model
980 *
981 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
982 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
983 * F-Mic = 0x1b, HP = 0x19
984 */
985
986 static hda_nid_t alc880_dac_nids[4] = {
987 /* front, rear, clfe, rear_surr */
988 0x02, 0x05, 0x04, 0x03
989 };
990
991 static hda_nid_t alc880_adc_nids[3] = {
992 /* ADC0-2 */
993 0x07, 0x08, 0x09,
994 };
995
996 /* The datasheet says the node 0x07 is connected from inputs,
997 * but it shows zero connection in the real implementation on some devices.
998 * Note: this is a 915GAV bug, fixed on 915GLV
999 */
1000 static hda_nid_t alc880_adc_nids_alt[2] = {
1001 /* ADC1-2 */
1002 0x08, 0x09,
1003 };
1004
1005 #define ALC880_DIGOUT_NID 0x06
1006 #define ALC880_DIGIN_NID 0x0a
1007
1008 static struct hda_input_mux alc880_capture_source = {
1009 .num_items = 4,
1010 .items = {
1011 { "Mic", 0x0 },
1012 { "Front Mic", 0x3 },
1013 { "Line", 0x2 },
1014 { "CD", 0x4 },
1015 },
1016 };
1017
1018 /* channel source setting (2/6 channel selection for 3-stack) */
1019 /* 2ch mode */
1020 static struct hda_verb alc880_threestack_ch2_init[] = {
1021 /* set line-in to input, mute it */
1022 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1023 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1024 /* set mic-in to input vref 80%, mute it */
1025 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1026 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1027 { } /* end */
1028 };
1029
1030 /* 6ch mode */
1031 static struct hda_verb alc880_threestack_ch6_init[] = {
1032 /* set line-in to output, unmute it */
1033 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1034 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1035 /* set mic-in to output, unmute it */
1036 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1037 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1038 { } /* end */
1039 };
1040
1041 static struct hda_channel_mode alc880_threestack_modes[2] = {
1042 { 2, alc880_threestack_ch2_init },
1043 { 6, alc880_threestack_ch6_init },
1044 };
1045
1046 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1047 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1048 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1049 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1050 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1051 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1052 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1053 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1054 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1055 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1056 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1057 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1058 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1061 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1062 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1063 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1064 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1065 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1066 {
1067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1068 .name = "Channel Mode",
1069 .info = alc_ch_mode_info,
1070 .get = alc_ch_mode_get,
1071 .put = alc_ch_mode_put,
1072 },
1073 { } /* end */
1074 };
1075
1076 /* capture mixer elements */
1077 static struct snd_kcontrol_new alc880_capture_mixer[] = {
1078 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1079 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1080 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1081 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1082 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1083 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1084 {
1085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1086 /* The multiple "Capture Source" controls confuse alsamixer
1087 * So call somewhat different..
1088 */
1089 /* .name = "Capture Source", */
1090 .name = "Input Source",
1091 .count = 3,
1092 .info = alc_mux_enum_info,
1093 .get = alc_mux_enum_get,
1094 .put = alc_mux_enum_put,
1095 },
1096 { } /* end */
1097 };
1098
1099 /* capture mixer elements (in case NID 0x07 not available) */
1100 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
1101 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1102 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1103 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1104 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1105 {
1106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1107 /* The multiple "Capture Source" controls confuse alsamixer
1108 * So call somewhat different..
1109 */
1110 /* .name = "Capture Source", */
1111 .name = "Input Source",
1112 .count = 2,
1113 .info = alc_mux_enum_info,
1114 .get = alc_mux_enum_get,
1115 .put = alc_mux_enum_put,
1116 },
1117 { } /* end */
1118 };
1119
1120
1121
1122 /*
1123 * ALC880 5-stack model
1124 *
1125 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1126 * Side = 0x02 (0xd)
1127 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1128 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1129 */
1130
1131 /* additional mixers to alc880_three_stack_mixer */
1132 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1133 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1134 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1135 { } /* end */
1136 };
1137
1138 /* channel source setting (6/8 channel selection for 5-stack) */
1139 /* 6ch mode */
1140 static struct hda_verb alc880_fivestack_ch6_init[] = {
1141 /* set line-in to input, mute it */
1142 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1143 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1144 { } /* end */
1145 };
1146
1147 /* 8ch mode */
1148 static struct hda_verb alc880_fivestack_ch8_init[] = {
1149 /* set line-in to output, unmute it */
1150 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1151 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1152 { } /* end */
1153 };
1154
1155 static struct hda_channel_mode alc880_fivestack_modes[2] = {
1156 { 6, alc880_fivestack_ch6_init },
1157 { 8, alc880_fivestack_ch8_init },
1158 };
1159
1160
1161 /*
1162 * ALC880 6-stack model
1163 *
1164 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1165 * Side = 0x05 (0x0f)
1166 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1167 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1168 */
1169
1170 static hda_nid_t alc880_6st_dac_nids[4] = {
1171 /* front, rear, clfe, rear_surr */
1172 0x02, 0x03, 0x04, 0x05
1173 };
1174
1175 static struct hda_input_mux alc880_6stack_capture_source = {
1176 .num_items = 4,
1177 .items = {
1178 { "Mic", 0x0 },
1179 { "Front Mic", 0x1 },
1180 { "Line", 0x2 },
1181 { "CD", 0x4 },
1182 },
1183 };
1184
1185 /* fixed 8-channels */
1186 static struct hda_channel_mode alc880_sixstack_modes[1] = {
1187 { 8, NULL },
1188 };
1189
1190 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1191 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1192 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1193 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1194 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1195 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1196 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1197 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1198 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1199 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1200 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1201 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1202 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1203 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1204 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1205 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1206 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1207 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1208 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1209 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1210 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1211 {
1212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1213 .name = "Channel Mode",
1214 .info = alc_ch_mode_info,
1215 .get = alc_ch_mode_get,
1216 .put = alc_ch_mode_put,
1217 },
1218 { } /* end */
1219 };
1220
1221
1222 /*
1223 * ALC880 W810 model
1224 *
1225 * W810 has rear IO for:
1226 * Front (DAC 02)
1227 * Surround (DAC 03)
1228 * Center/LFE (DAC 04)
1229 * Digital out (06)
1230 *
1231 * The system also has a pair of internal speakers, and a headphone jack.
1232 * These are both connected to Line2 on the codec, hence to DAC 02.
1233 *
1234 * There is a variable resistor to control the speaker or headphone
1235 * volume. This is a hardware-only device without a software API.
1236 *
1237 * Plugging headphones in will disable the internal speakers. This is
1238 * implemented in hardware, not via the driver using jack sense. In
1239 * a similar fashion, plugging into the rear socket marked "front" will
1240 * disable both the speakers and headphones.
1241 *
1242 * For input, there's a microphone jack, and an "audio in" jack.
1243 * These may not do anything useful with this driver yet, because I
1244 * haven't setup any initialization verbs for these yet...
1245 */
1246
1247 static hda_nid_t alc880_w810_dac_nids[3] = {
1248 /* front, rear/surround, clfe */
1249 0x02, 0x03, 0x04
1250 };
1251
1252 /* fixed 6 channels */
1253 static struct hda_channel_mode alc880_w810_modes[1] = {
1254 { 6, NULL }
1255 };
1256
1257 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1258 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1259 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1260 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1261 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1262 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1263 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1264 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1265 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1266 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1268 { } /* end */
1269 };
1270
1271
1272 /*
1273 * Z710V model
1274 *
1275 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1276 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1277 * Line = 0x1a
1278 */
1279
1280 static hda_nid_t alc880_z71v_dac_nids[1] = {
1281 0x02
1282 };
1283 #define ALC880_Z71V_HP_DAC 0x03
1284
1285 /* fixed 2 channels */
1286 static struct hda_channel_mode alc880_2_jack_modes[1] = {
1287 { 2, NULL }
1288 };
1289
1290 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1291 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1292 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1293 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1294 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1295 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1296 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1298 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1299 { } /* end */
1300 };
1301
1302
1303 /*
1304 * ALC880 F1734 model
1305 *
1306 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1307 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1308 */
1309
1310 static hda_nid_t alc880_f1734_dac_nids[1] = {
1311 0x03
1312 };
1313 #define ALC880_F1734_HP_DAC 0x02
1314
1315 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1316 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1317 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1318 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1319 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1320 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1321 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1322 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1323 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1324 { } /* end */
1325 };
1326
1327
1328 /*
1329 * ALC880 ASUS model
1330 *
1331 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1332 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1333 * Mic = 0x18, Line = 0x1a
1334 */
1335
1336 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1337 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1338
1339 static struct snd_kcontrol_new alc880_asus_mixer[] = {
1340 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1341 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1342 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1343 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1344 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1345 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1346 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1347 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1348 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1349 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1354 {
1355 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1356 .name = "Channel Mode",
1357 .info = alc_ch_mode_info,
1358 .get = alc_ch_mode_get,
1359 .put = alc_ch_mode_put,
1360 },
1361 { } /* end */
1362 };
1363
1364 /*
1365 * ALC880 ASUS W1V model
1366 *
1367 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1368 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1369 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1370 */
1371
1372 /* additional mixers to alc880_asus_mixer */
1373 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1374 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1375 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1376 { } /* end */
1377 };
1378
1379 /* additional mixers to alc880_asus_mixer */
1380 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1381 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1382 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1383 { } /* end */
1384 };
1385
1386 /* TCL S700 */
1387 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1388 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1389 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1391 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1392 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1395 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1396 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1397 {
1398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1399 /* The multiple "Capture Source" controls confuse alsamixer
1400 * So call somewhat different..
1401 */
1402 /* .name = "Capture Source", */
1403 .name = "Input Source",
1404 .count = 1,
1405 .info = alc_mux_enum_info,
1406 .get = alc_mux_enum_get,
1407 .put = alc_mux_enum_put,
1408 },
1409 { } /* end */
1410 };
1411
1412 /* Uniwill */
1413 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1414 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1415 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1416 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1417 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1418 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1419 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1420 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1421 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1422 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1423 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1424 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1425 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1426 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1427 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1428 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1429 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1430 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1431 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1432 {
1433 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1434 .name = "Channel Mode",
1435 .info = alc_ch_mode_info,
1436 .get = alc_ch_mode_get,
1437 .put = alc_ch_mode_put,
1438 },
1439 { } /* end */
1440 };
1441
1442 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1443 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1444 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1445 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1446 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1447 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1448 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1449 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1450 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1451 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1452 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1453 { } /* end */
1454 };
1455
1456 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1457 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1458 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1459 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1460 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1463 { } /* end */
1464 };
1465
1466 /*
1467 * virtual master controls
1468 */
1469
1470 /*
1471 * slave controls for virtual master
1472 */
1473 static const char *alc_slave_vols[] = {
1474 "Front Playback Volume",
1475 "Surround Playback Volume",
1476 "Center Playback Volume",
1477 "LFE Playback Volume",
1478 "Side Playback Volume",
1479 "Headphone Playback Volume",
1480 "Speaker Playback Volume",
1481 "Mono 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 "IEC958 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 /* update HP, line and mono out pins according to the master switch */
3834 static void alc260_hp_master_update(struct hda_codec *codec,
3835 hda_nid_t hp, hda_nid_t line,
3836 hda_nid_t mono)
3837 {
3838 struct alc_spec *spec = codec->spec;
3839 unsigned int val = spec->master_sw ? PIN_HP : 0;
3840 /* change HP and line-out pins */
3841 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3842 val);
3843 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3844 val);
3845 /* mono (speaker) depending on the HP jack sense */
3846 val = (val && !spec->jack_present) ? PIN_OUT : 0;
3847 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3848 val);
3849 }
3850
3851 static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
3852 struct snd_ctl_elem_value *ucontrol)
3853 {
3854 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3855 struct alc_spec *spec = codec->spec;
3856 *ucontrol->value.integer.value = spec->master_sw;
3857 return 0;
3858 }
3859
3860 static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
3861 struct snd_ctl_elem_value *ucontrol)
3862 {
3863 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3864 struct alc_spec *spec = codec->spec;
3865 int val = !!*ucontrol->value.integer.value;
3866 hda_nid_t hp, line, mono;
3867
3868 if (val == spec->master_sw)
3869 return 0;
3870 spec->master_sw = val;
3871 hp = (kcontrol->private_value >> 16) & 0xff;
3872 line = (kcontrol->private_value >> 8) & 0xff;
3873 mono = kcontrol->private_value & 0xff;
3874 alc260_hp_master_update(codec, hp, line, mono);
3875 return 1;
3876 }
3877
3878 static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
3879 {
3880 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3881 .name = "Master Playback Switch",
3882 .info = snd_ctl_boolean_mono_info,
3883 .get = alc260_hp_master_sw_get,
3884 .put = alc260_hp_master_sw_put,
3885 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
3886 },
3887 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3888 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3889 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3890 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3891 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
3892 HDA_OUTPUT),
3893 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3894 { } /* end */
3895 };
3896
3897 static struct hda_verb alc260_hp_unsol_verbs[] = {
3898 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3899 {},
3900 };
3901
3902 static void alc260_hp_automute(struct hda_codec *codec)
3903 {
3904 struct alc_spec *spec = codec->spec;
3905 unsigned int present;
3906
3907 present = snd_hda_codec_read(codec, 0x10, 0,
3908 AC_VERB_GET_PIN_SENSE, 0);
3909 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3910 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
3911 }
3912
3913 static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
3914 {
3915 if ((res >> 26) == ALC880_HP_EVENT)
3916 alc260_hp_automute(codec);
3917 }
3918
3919 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3920 {
3921 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3922 .name = "Master Playback Switch",
3923 .info = snd_ctl_boolean_mono_info,
3924 .get = alc260_hp_master_sw_get,
3925 .put = alc260_hp_master_sw_put,
3926 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
3927 },
3928 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3929 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3930 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3931 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3932 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3933 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3934 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3935 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3936 { } /* end */
3937 };
3938
3939 static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
3940 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3941 {},
3942 };
3943
3944 static void alc260_hp_3013_automute(struct hda_codec *codec)
3945 {
3946 struct alc_spec *spec = codec->spec;
3947 unsigned int present;
3948
3949 present = snd_hda_codec_read(codec, 0x15, 0,
3950 AC_VERB_GET_PIN_SENSE, 0);
3951 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
3952 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
3953 }
3954
3955 static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
3956 unsigned int res)
3957 {
3958 if ((res >> 26) == ALC880_HP_EVENT)
3959 alc260_hp_3013_automute(codec);
3960 }
3961
3962 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3963 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3964 */
3965 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3966 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3967 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3968 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3969 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3970 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3971 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3972 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3973 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3974 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3975 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3976 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3977 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3978 { } /* end */
3979 };
3980
3981 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3982 * versions of the ALC260 don't act on requests to enable mic bias from NID
3983 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3984 * datasheet doesn't mention this restriction. At this stage it's not clear
3985 * whether this behaviour is intentional or is a hardware bug in chip
3986 * revisions available in early 2006. Therefore for now allow the
3987 * "Headphone Jack Mode" control to span all choices, but if it turns out
3988 * that the lack of mic bias for this NID is intentional we could change the
3989 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3990 *
3991 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3992 * don't appear to make the mic bias available from the "line" jack, even
3993 * though the NID used for this jack (0x14) can supply it. The theory is
3994 * that perhaps Acer have included blocking capacitors between the ALC260
3995 * and the output jack. If this turns out to be the case for all such
3996 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3997 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3998 *
3999 * The C20x Tablet series have a mono internal speaker which is controlled
4000 * via the chip's Mono sum widget and pin complex, so include the necessary
4001 * controls for such models. On models without a "mono speaker" the control
4002 * won't do anything.
4003 */
4004 static struct snd_kcontrol_new alc260_acer_mixer[] = {
4005 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4006 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4007 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4008 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
4009 HDA_OUTPUT),
4010 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
4011 HDA_INPUT),
4012 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4013 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4014 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4015 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4016 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4017 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4018 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4019 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4020 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4021 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4022 { } /* end */
4023 };
4024
4025 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4026 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4027 */
4028 static struct snd_kcontrol_new alc260_will_mixer[] = {
4029 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4030 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4032 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4033 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4034 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4035 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4036 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4037 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4038 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4039 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4040 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4041 { } /* end */
4042 };
4043
4044 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4045 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4046 */
4047 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4048 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4049 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4051 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4052 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4053 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4054 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4055 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4056 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4057 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4058 { } /* end */
4059 };
4060
4061 /* capture mixer elements */
4062 static struct snd_kcontrol_new alc260_capture_mixer[] = {
4063 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4064 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
4065 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4066 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
4067 {
4068 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4069 /* The multiple "Capture Source" controls confuse alsamixer
4070 * So call somewhat different..
4071 */
4072 /* .name = "Capture Source", */
4073 .name = "Input Source",
4074 .count = 2,
4075 .info = alc_mux_enum_info,
4076 .get = alc_mux_enum_get,
4077 .put = alc_mux_enum_put,
4078 },
4079 { } /* end */
4080 };
4081
4082 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4083 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4084 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4085 {
4086 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4087 /* The multiple "Capture Source" controls confuse alsamixer
4088 * So call somewhat different..
4089 */
4090 /* .name = "Capture Source", */
4091 .name = "Input Source",
4092 .count = 1,
4093 .info = alc_mux_enum_info,
4094 .get = alc_mux_enum_get,
4095 .put = alc_mux_enum_put,
4096 },
4097 { } /* end */
4098 };
4099
4100 /*
4101 * initialization verbs
4102 */
4103 static struct hda_verb alc260_init_verbs[] = {
4104 /* Line In pin widget for input */
4105 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4106 /* CD pin widget for input */
4107 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4108 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4109 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4110 /* Mic2 (front panel) pin widget for input and vref at 80% */
4111 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4112 /* LINE-2 is used for line-out in rear */
4113 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4114 /* select line-out */
4115 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
4116 /* LINE-OUT pin */
4117 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4118 /* enable HP */
4119 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4120 /* enable Mono */
4121 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4122 /* mute capture amp left and right */
4123 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4124 /* set connection select to line in (default select for this ADC) */
4125 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4126 /* mute capture amp left and right */
4127 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4128 /* set connection select to line in (default select for this ADC) */
4129 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
4130 /* set vol=0 Line-Out mixer amp left and right */
4131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4132 /* unmute pin widget amp left and right (no gain on this amp) */
4133 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4134 /* set vol=0 HP mixer amp left and right */
4135 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4136 /* unmute pin widget amp left and right (no gain on this amp) */
4137 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4138 /* set vol=0 Mono mixer amp left and right */
4139 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4140 /* unmute pin widget amp left and right (no gain on this amp) */
4141 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4142 /* unmute LINE-2 out pin */
4143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4144 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4145 * Line In 2 = 0x03
4146 */
4147 /* mute analog inputs */
4148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4151 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4152 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4153 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4154 /* mute Front out path */
4155 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4157 /* mute Headphone out path */
4158 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4159 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4160 /* mute Mono out path */
4161 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4162 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4163 { }
4164 };
4165
4166 #if 0 /* should be identical with alc260_init_verbs? */
4167 static struct hda_verb alc260_hp_init_verbs[] = {
4168 /* Headphone and output */
4169 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4170 /* mono output */
4171 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4172 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4173 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4174 /* Mic2 (front panel) pin widget for input and vref at 80% */
4175 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4176 /* Line In pin widget for input */
4177 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4178 /* Line-2 pin widget for output */
4179 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4180 /* CD pin widget for input */
4181 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4182 /* unmute amp left and right */
4183 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4184 /* set connection select to line in (default select for this ADC) */
4185 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4186 /* unmute Line-Out mixer amp left and right (volume = 0) */
4187 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4188 /* mute pin widget amp left and right (no gain on this amp) */
4189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4190 /* unmute HP mixer amp left and right (volume = 0) */
4191 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4192 /* mute pin widget amp left and right (no gain on this amp) */
4193 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4194 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4195 * Line In 2 = 0x03
4196 */
4197 /* mute analog inputs */
4198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4201 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4203 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4204 /* Unmute Front out path */
4205 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4207 /* Unmute Headphone out path */
4208 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4209 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4210 /* Unmute Mono out path */
4211 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4212 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4213 { }
4214 };
4215 #endif
4216
4217 static struct hda_verb alc260_hp_3013_init_verbs[] = {
4218 /* Line out and output */
4219 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4220 /* mono output */
4221 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4222 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4223 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4224 /* Mic2 (front panel) pin widget for input and vref at 80% */
4225 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4226 /* Line In pin widget for input */
4227 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4228 /* Headphone pin widget for output */
4229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4230 /* CD pin widget for input */
4231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4232 /* unmute amp left and right */
4233 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4234 /* set connection select to line in (default select for this ADC) */
4235 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4236 /* unmute Line-Out mixer amp left and right (volume = 0) */
4237 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4238 /* mute pin widget amp left and right (no gain on this amp) */
4239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4240 /* unmute HP mixer amp left and right (volume = 0) */
4241 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4242 /* mute pin widget amp left and right (no gain on this amp) */
4243 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4244 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4245 * Line In 2 = 0x03
4246 */
4247 /* mute analog inputs */
4248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4253 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4254 /* Unmute Front out path */
4255 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4256 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4257 /* Unmute Headphone out path */
4258 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4259 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4260 /* Unmute Mono out path */
4261 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4262 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4263 { }
4264 };
4265
4266 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
4267 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4268 * audio = 0x16, internal speaker = 0x10.
4269 */
4270 static struct hda_verb alc260_fujitsu_init_verbs[] = {
4271 /* Disable all GPIOs */
4272 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4273 /* Internal speaker is connected to headphone pin */
4274 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4275 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4277 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4278 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4279 /* Ensure all other unused pins are disabled and muted. */
4280 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4281 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4282 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4283 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4284 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4285 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4288
4289 /* Disable digital (SPDIF) pins */
4290 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4291 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4292
4293 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4294 * when acting as an output.
4295 */
4296 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4297
4298 /* Start with output sum widgets muted and their output gains at min */
4299 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4300 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4301 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4302 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4303 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4304 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4305 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4306 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4307 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4308
4309 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4310 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4311 /* Unmute Line1 pin widget output buffer since it starts as an output.
4312 * If the pin mode is changed by the user the pin mode control will
4313 * take care of enabling the pin's input/output buffers as needed.
4314 * Therefore there's no need to enable the input buffer at this
4315 * stage.
4316 */
4317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4318 /* Unmute input buffer of pin widget used for Line-in (no equiv
4319 * mixer ctrl)
4320 */
4321 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4322
4323 /* Mute capture amp left and right */
4324 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4325 /* Set ADC connection select to match default mixer setting - line
4326 * in (on mic1 pin)
4327 */
4328 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4329
4330 /* Do the same for the second ADC: mute capture input amp and
4331 * set ADC connection to line in (on mic1 pin)
4332 */
4333 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4334 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4335
4336 /* Mute all inputs to mixer widget (even unconnected ones) */
4337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4341 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4342 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4343 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4344 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4345
4346 { }
4347 };
4348
4349 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4350 * similar laptops (adapted from Fujitsu init verbs).
4351 */
4352 static struct hda_verb alc260_acer_init_verbs[] = {
4353 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4354 * the headphone jack. Turn this on and rely on the standard mute
4355 * methods whenever the user wants to turn these outputs off.
4356 */
4357 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4358 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4359 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4360 /* Internal speaker/Headphone jack is connected to Line-out pin */
4361 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4362 /* Internal microphone/Mic jack is connected to Mic1 pin */
4363 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4364 /* Line In jack is connected to Line1 pin */
4365 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4366 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4367 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4368 /* Ensure all other unused pins are disabled and muted. */
4369 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4370 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4371 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4372 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4373 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4374 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4375 /* Disable digital (SPDIF) pins */
4376 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4377 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4378
4379 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4380 * bus when acting as outputs.
4381 */
4382 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4383 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4384
4385 /* Start with output sum widgets muted and their output gains at min */
4386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4388 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4389 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4390 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4391 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4392 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4393 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4394 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4395
4396 /* Unmute Line-out pin widget amp left and right
4397 * (no equiv mixer ctrl)
4398 */
4399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4400 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4401 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4402 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4403 * inputs. If the pin mode is changed by the user the pin mode control
4404 * will take care of enabling the pin's input/output buffers as needed.
4405 * Therefore there's no need to enable the input buffer at this
4406 * stage.
4407 */
4408 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4409 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4410
4411 /* Mute capture amp left and right */
4412 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4413 /* Set ADC connection select to match default mixer setting - mic
4414 * (on mic1 pin)
4415 */
4416 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4417
4418 /* Do similar with the second ADC: mute capture input amp and
4419 * set ADC connection to mic to match ALSA's default state.
4420 */
4421 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4422 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4423
4424 /* Mute all inputs to mixer widget (even unconnected ones) */
4425 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4426 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4428 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4429 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4430 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4433
4434 { }
4435 };
4436
4437 static struct hda_verb alc260_will_verbs[] = {
4438 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4439 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4440 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4441 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4442 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4443 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4444 {}
4445 };
4446
4447 static struct hda_verb alc260_replacer_672v_verbs[] = {
4448 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4449 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4450 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4451
4452 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4453 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4454 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4455
4456 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4457 {}
4458 };
4459
4460 /* toggle speaker-output according to the hp-jack state */
4461 static void alc260_replacer_672v_automute(struct hda_codec *codec)
4462 {
4463 unsigned int present;
4464
4465 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4466 present = snd_hda_codec_read(codec, 0x0f, 0,
4467 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4468 if (present) {
4469 snd_hda_codec_write_cache(codec, 0x01, 0,
4470 AC_VERB_SET_GPIO_DATA, 1);
4471 snd_hda_codec_write_cache(codec, 0x0f, 0,
4472 AC_VERB_SET_PIN_WIDGET_CONTROL,
4473 PIN_HP);
4474 } else {
4475 snd_hda_codec_write_cache(codec, 0x01, 0,
4476 AC_VERB_SET_GPIO_DATA, 0);
4477 snd_hda_codec_write_cache(codec, 0x0f, 0,
4478 AC_VERB_SET_PIN_WIDGET_CONTROL,
4479 PIN_OUT);
4480 }
4481 }
4482
4483 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4484 unsigned int res)
4485 {
4486 if ((res >> 26) == ALC880_HP_EVENT)
4487 alc260_replacer_672v_automute(codec);
4488 }
4489
4490 /* Test configuration for debugging, modelled after the ALC880 test
4491 * configuration.
4492 */
4493 #ifdef CONFIG_SND_DEBUG
4494 static hda_nid_t alc260_test_dac_nids[1] = {
4495 0x02,
4496 };
4497 static hda_nid_t alc260_test_adc_nids[2] = {
4498 0x04, 0x05,
4499 };
4500 /* For testing the ALC260, each input MUX needs its own definition since
4501 * the signal assignments are different. This assumes that the first ADC
4502 * is NID 0x04.
4503 */
4504 static struct hda_input_mux alc260_test_capture_sources[2] = {
4505 {
4506 .num_items = 7,
4507 .items = {
4508 { "MIC1 pin", 0x0 },
4509 { "MIC2 pin", 0x1 },
4510 { "LINE1 pin", 0x2 },
4511 { "LINE2 pin", 0x3 },
4512 { "CD pin", 0x4 },
4513 { "LINE-OUT pin", 0x5 },
4514 { "HP-OUT pin", 0x6 },
4515 },
4516 },
4517 {
4518 .num_items = 8,
4519 .items = {
4520 { "MIC1 pin", 0x0 },
4521 { "MIC2 pin", 0x1 },
4522 { "LINE1 pin", 0x2 },
4523 { "LINE2 pin", 0x3 },
4524 { "CD pin", 0x4 },
4525 { "Mixer", 0x5 },
4526 { "LINE-OUT pin", 0x6 },
4527 { "HP-OUT pin", 0x7 },
4528 },
4529 },
4530 };
4531 static struct snd_kcontrol_new alc260_test_mixer[] = {
4532 /* Output driver widgets */
4533 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4534 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4535 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4536 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4537 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4538 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4539
4540 /* Modes for retasking pin widgets
4541 * Note: the ALC260 doesn't seem to act on requests to enable mic
4542 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4543 * mention this restriction. At this stage it's not clear whether
4544 * this behaviour is intentional or is a hardware bug in chip
4545 * revisions available at least up until early 2006. Therefore for
4546 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4547 * choices, but if it turns out that the lack of mic bias for these
4548 * NIDs is intentional we could change their modes from
4549 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4550 */
4551 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4552 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4553 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4554 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4555 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4556 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4557
4558 /* Loopback mixer controls */
4559 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4560 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4561 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4562 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4563 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4564 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4565 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4566 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4567 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4568 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4569 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4570 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4571 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4572 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4573 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4574 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4575
4576 /* Controls for GPIO pins, assuming they are configured as outputs */
4577 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4578 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4579 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4580 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4581
4582 /* Switches to allow the digital IO pins to be enabled. The datasheet
4583 * is ambigious as to which NID is which; testing on laptops which
4584 * make this output available should provide clarification.
4585 */
4586 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4587 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4588
4589 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4590 * this output to turn on an external amplifier.
4591 */
4592 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4593 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4594
4595 { } /* end */
4596 };
4597 static struct hda_verb alc260_test_init_verbs[] = {
4598 /* Enable all GPIOs as outputs with an initial value of 0 */
4599 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4600 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4601 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4602
4603 /* Enable retasking pins as output, initially without power amp */
4604 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4605 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4606 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4607 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4608 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4609 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4610
4611 /* Disable digital (SPDIF) pins initially, but users can enable
4612 * them via a mixer switch. In the case of SPDIF-out, this initverb
4613 * payload also sets the generation to 0, output to be in "consumer"
4614 * PCM format, copyright asserted, no pre-emphasis and no validity
4615 * control.
4616 */
4617 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4618 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4619
4620 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4621 * OUT1 sum bus when acting as an output.
4622 */
4623 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4624 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4625 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4626 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4627
4628 /* Start with output sum widgets muted and their output gains at min */
4629 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4633 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4635 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4636 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4637 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4638
4639 /* Unmute retasking pin widget output buffers since the default
4640 * state appears to be output. As the pin mode is changed by the
4641 * user the pin mode control will take care of enabling the pin's
4642 * input/output buffers as needed.
4643 */
4644 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4645 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4647 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4648 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4649 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4650 /* Also unmute the mono-out pin widget */
4651 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4652
4653 /* Mute capture amp left and right */
4654 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4655 /* Set ADC connection select to match default mixer setting (mic1
4656 * pin)
4657 */
4658 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4659
4660 /* Do the same for the second ADC: mute capture input amp and
4661 * set ADC connection to mic1 pin
4662 */
4663 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4664 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4665
4666 /* Mute all inputs to mixer widget (even unconnected ones) */
4667 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4675
4676 { }
4677 };
4678 #endif
4679
4680 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4681 #define alc260_pcm_analog_capture alc880_pcm_analog_capture
4682
4683 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
4684 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
4685
4686 /*
4687 * for BIOS auto-configuration
4688 */
4689
4690 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4691 const char *pfx)
4692 {
4693 hda_nid_t nid_vol;
4694 unsigned long vol_val, sw_val;
4695 char name[32];
4696 int err;
4697
4698 if (nid >= 0x0f && nid < 0x11) {
4699 nid_vol = nid - 0x7;
4700 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4701 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4702 } else if (nid == 0x11) {
4703 nid_vol = nid - 0x7;
4704 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4705 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4706 } else if (nid >= 0x12 && nid <= 0x15) {
4707 nid_vol = 0x08;
4708 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4709 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4710 } else
4711 return 0; /* N/A */
4712
4713 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4714 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4715 if (err < 0)
4716 return err;
4717 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4718 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4719 if (err < 0)
4720 return err;
4721 return 1;
4722 }
4723
4724 /* add playback controls from the parsed DAC table */
4725 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4726 const struct auto_pin_cfg *cfg)
4727 {
4728 hda_nid_t nid;
4729 int err;
4730
4731 spec->multiout.num_dacs = 1;
4732 spec->multiout.dac_nids = spec->private_dac_nids;
4733 spec->multiout.dac_nids[0] = 0x02;
4734
4735 nid = cfg->line_out_pins[0];
4736 if (nid) {
4737 err = alc260_add_playback_controls(spec, nid, "Front");
4738 if (err < 0)
4739 return err;
4740 }
4741
4742 nid = cfg->speaker_pins[0];
4743 if (nid) {
4744 err = alc260_add_playback_controls(spec, nid, "Speaker");
4745 if (err < 0)
4746 return err;
4747 }
4748
4749 nid = cfg->hp_pins[0];
4750 if (nid) {
4751 err = alc260_add_playback_controls(spec, nid, "Headphone");
4752 if (err < 0)
4753 return err;
4754 }
4755 return 0;
4756 }
4757
4758 /* create playback/capture controls for input pins */
4759 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4760 const struct auto_pin_cfg *cfg)
4761 {
4762 struct hda_input_mux *imux = &spec->private_imux;
4763 int i, err, idx;
4764
4765 for (i = 0; i < AUTO_PIN_LAST; i++) {
4766 if (cfg->input_pins[i] >= 0x12) {
4767 idx = cfg->input_pins[i] - 0x12;
4768 err = new_analog_input(spec, cfg->input_pins[i],
4769 auto_pin_cfg_labels[i], idx,
4770 0x07);
4771 if (err < 0)
4772 return err;
4773 imux->items[imux->num_items].label =
4774 auto_pin_cfg_labels[i];
4775 imux->items[imux->num_items].index = idx;
4776 imux->num_items++;
4777 }
4778 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4779 idx = cfg->input_pins[i] - 0x09;
4780 err = new_analog_input(spec, cfg->input_pins[i],
4781 auto_pin_cfg_labels[i], idx,
4782 0x07);
4783 if (err < 0)
4784 return err;
4785 imux->items[imux->num_items].label =
4786 auto_pin_cfg_labels[i];
4787 imux->items[imux->num_items].index = idx;
4788 imux->num_items++;
4789 }
4790 }
4791 return 0;
4792 }
4793
4794 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4795 hda_nid_t nid, int pin_type,
4796 int sel_idx)
4797 {
4798 /* set as output */
4799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4800 pin_type);
4801 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4802 AMP_OUT_UNMUTE);
4803 /* need the manual connection? */
4804 if (nid >= 0x12) {
4805 int idx = nid - 0x12;
4806 snd_hda_codec_write(codec, idx + 0x0b, 0,
4807 AC_VERB_SET_CONNECT_SEL, sel_idx);
4808 }
4809 }
4810
4811 static void alc260_auto_init_multi_out(struct hda_codec *codec)
4812 {
4813 struct alc_spec *spec = codec->spec;
4814 hda_nid_t nid;
4815
4816 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4817 nid = spec->autocfg.line_out_pins[0];
4818 if (nid) {
4819 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4820 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4821 }
4822
4823 nid = spec->autocfg.speaker_pins[0];
4824 if (nid)
4825 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4826
4827 nid = spec->autocfg.hp_pins[0];
4828 if (nid)
4829 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4830 }
4831
4832 #define ALC260_PIN_CD_NID 0x16
4833 static void alc260_auto_init_analog_input(struct hda_codec *codec)
4834 {
4835 struct alc_spec *spec = codec->spec;
4836 int i;
4837
4838 for (i = 0; i < AUTO_PIN_LAST; i++) {
4839 hda_nid_t nid = spec->autocfg.input_pins[i];
4840 if (nid >= 0x12) {
4841 snd_hda_codec_write(codec, nid, 0,
4842 AC_VERB_SET_PIN_WIDGET_CONTROL,
4843 i <= AUTO_PIN_FRONT_MIC ?
4844 PIN_VREF80 : PIN_IN);
4845 if (nid != ALC260_PIN_CD_NID)
4846 snd_hda_codec_write(codec, nid, 0,
4847 AC_VERB_SET_AMP_GAIN_MUTE,
4848 AMP_OUT_MUTE);
4849 }
4850 }
4851 }
4852
4853 /*
4854 * generic initialization of ADC, input mixers and output mixers
4855 */
4856 static struct hda_verb alc260_volume_init_verbs[] = {
4857 /*
4858 * Unmute ADC0-1 and set the default input to mic-in
4859 */
4860 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4861 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4862 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4863 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4864
4865 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4866 * mixer widget
4867 * Note: PASD motherboards uses the Line In 2 as the input for
4868 * front panel mic (mic 2)
4869 */
4870 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4871 /* mute analog inputs */
4872 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4873 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4877
4878 /*
4879 * Set up output mixers (0x08 - 0x0a)
4880 */
4881 /* set vol=0 to output mixers */
4882 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4883 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4884 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4885 /* set up input amps for analog loopback */
4886 /* Amp Indices: DAC = 0, mixer = 1 */
4887 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4888 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4890 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4891 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4892 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4893
4894 { }
4895 };
4896
4897 static int alc260_parse_auto_config(struct hda_codec *codec)
4898 {
4899 struct alc_spec *spec = codec->spec;
4900 unsigned int wcap;
4901 int err;
4902 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4903
4904 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4905 alc260_ignore);
4906 if (err < 0)
4907 return err;
4908 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4909 if (err < 0)
4910 return err;
4911 if (!spec->kctl_alloc)
4912 return 0; /* can't find valid BIOS pin config */
4913 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4914 if (err < 0)
4915 return err;
4916
4917 spec->multiout.max_channels = 2;
4918
4919 if (spec->autocfg.dig_out_pin)
4920 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4921 if (spec->kctl_alloc)
4922 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4923
4924 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4925
4926 spec->num_mux_defs = 1;
4927 spec->input_mux = &spec->private_imux;
4928
4929 /* check whether NID 0x04 is valid */
4930 wcap = get_wcaps(codec, 0x04);
4931 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4932 if (wcap != AC_WID_AUD_IN) {
4933 spec->adc_nids = alc260_adc_nids_alt;
4934 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4935 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4936 } else {
4937 spec->adc_nids = alc260_adc_nids;
4938 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4939 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4940 }
4941 spec->num_mixers++;
4942
4943 return 1;
4944 }
4945
4946 /* additional initialization for auto-configuration model */
4947 static void alc260_auto_init(struct hda_codec *codec)
4948 {
4949 alc260_auto_init_multi_out(codec);
4950 alc260_auto_init_analog_input(codec);
4951 }
4952
4953 #ifdef CONFIG_SND_HDA_POWER_SAVE
4954 static struct hda_amp_list alc260_loopbacks[] = {
4955 { 0x07, HDA_INPUT, 0 },
4956 { 0x07, HDA_INPUT, 1 },
4957 { 0x07, HDA_INPUT, 2 },
4958 { 0x07, HDA_INPUT, 3 },
4959 { 0x07, HDA_INPUT, 4 },
4960 { } /* end */
4961 };
4962 #endif
4963
4964 /*
4965 * ALC260 configurations
4966 */
4967 static const char *alc260_models[ALC260_MODEL_LAST] = {
4968 [ALC260_BASIC] = "basic",
4969 [ALC260_HP] = "hp",
4970 [ALC260_HP_3013] = "hp-3013",
4971 [ALC260_FUJITSU_S702X] = "fujitsu",
4972 [ALC260_ACER] = "acer",
4973 [ALC260_WILL] = "will",
4974 [ALC260_REPLACER_672V] = "replacer",
4975 #ifdef CONFIG_SND_DEBUG
4976 [ALC260_TEST] = "test",
4977 #endif
4978 [ALC260_AUTO] = "auto",
4979 };
4980
4981 static struct snd_pci_quirk alc260_cfg_tbl[] = {
4982 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4983 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4984 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4985 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4986 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4987 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4988 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4989 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4990 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4991 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4992 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4993 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4994 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4995 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4996 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4997 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4998 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4999 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
5000 {}
5001 };
5002
5003 static struct alc_config_preset alc260_presets[] = {
5004 [ALC260_BASIC] = {
5005 .mixers = { alc260_base_output_mixer,
5006 alc260_input_mixer,
5007 alc260_pc_beep_mixer,
5008 alc260_capture_mixer },
5009 .init_verbs = { alc260_init_verbs },
5010 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5011 .dac_nids = alc260_dac_nids,
5012 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5013 .adc_nids = alc260_adc_nids,
5014 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5015 .channel_mode = alc260_modes,
5016 .input_mux = &alc260_capture_source,
5017 },
5018 [ALC260_HP] = {
5019 .mixers = { alc260_hp_output_mixer,
5020 alc260_input_mixer,
5021 alc260_capture_alt_mixer },
5022 .init_verbs = { alc260_init_verbs,
5023 alc260_hp_unsol_verbs },
5024 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5025 .dac_nids = alc260_dac_nids,
5026 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5027 .adc_nids = alc260_hp_adc_nids,
5028 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5029 .channel_mode = alc260_modes,
5030 .input_mux = &alc260_capture_source,
5031 .unsol_event = alc260_hp_unsol_event,
5032 .init_hook = alc260_hp_automute,
5033 },
5034 [ALC260_HP_3013] = {
5035 .mixers = { alc260_hp_3013_mixer,
5036 alc260_input_mixer,
5037 alc260_capture_alt_mixer },
5038 .init_verbs = { alc260_hp_3013_init_verbs,
5039 alc260_hp_3013_unsol_verbs },
5040 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5041 .dac_nids = alc260_dac_nids,
5042 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5043 .adc_nids = alc260_hp_adc_nids,
5044 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5045 .channel_mode = alc260_modes,
5046 .input_mux = &alc260_capture_source,
5047 .unsol_event = alc260_hp_3013_unsol_event,
5048 .init_hook = alc260_hp_3013_automute,
5049 },
5050 [ALC260_FUJITSU_S702X] = {
5051 .mixers = { alc260_fujitsu_mixer,
5052 alc260_capture_mixer },
5053 .init_verbs = { alc260_fujitsu_init_verbs },
5054 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5055 .dac_nids = alc260_dac_nids,
5056 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5057 .adc_nids = alc260_dual_adc_nids,
5058 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5059 .channel_mode = alc260_modes,
5060 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5061 .input_mux = alc260_fujitsu_capture_sources,
5062 },
5063 [ALC260_ACER] = {
5064 .mixers = { alc260_acer_mixer,
5065 alc260_capture_mixer },
5066 .init_verbs = { alc260_acer_init_verbs },
5067 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5068 .dac_nids = alc260_dac_nids,
5069 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5070 .adc_nids = alc260_dual_adc_nids,
5071 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5072 .channel_mode = alc260_modes,
5073 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5074 .input_mux = alc260_acer_capture_sources,
5075 },
5076 [ALC260_WILL] = {
5077 .mixers = { alc260_will_mixer,
5078 alc260_capture_mixer },
5079 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5080 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5081 .dac_nids = alc260_dac_nids,
5082 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5083 .adc_nids = alc260_adc_nids,
5084 .dig_out_nid = ALC260_DIGOUT_NID,
5085 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5086 .channel_mode = alc260_modes,
5087 .input_mux = &alc260_capture_source,
5088 },
5089 [ALC260_REPLACER_672V] = {
5090 .mixers = { alc260_replacer_672v_mixer,
5091 alc260_capture_mixer },
5092 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5093 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5094 .dac_nids = alc260_dac_nids,
5095 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5096 .adc_nids = alc260_adc_nids,
5097 .dig_out_nid = ALC260_DIGOUT_NID,
5098 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5099 .channel_mode = alc260_modes,
5100 .input_mux = &alc260_capture_source,
5101 .unsol_event = alc260_replacer_672v_unsol_event,
5102 .init_hook = alc260_replacer_672v_automute,
5103 },
5104 #ifdef CONFIG_SND_DEBUG
5105 [ALC260_TEST] = {
5106 .mixers = { alc260_test_mixer,
5107 alc260_capture_mixer },
5108 .init_verbs = { alc260_test_init_verbs },
5109 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5110 .dac_nids = alc260_test_dac_nids,
5111 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5112 .adc_nids = alc260_test_adc_nids,
5113 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5114 .channel_mode = alc260_modes,
5115 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5116 .input_mux = alc260_test_capture_sources,
5117 },
5118 #endif
5119 };
5120
5121 static int patch_alc260(struct hda_codec *codec)
5122 {
5123 struct alc_spec *spec;
5124 int err, board_config;
5125
5126 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5127 if (spec == NULL)
5128 return -ENOMEM;
5129
5130 codec->spec = spec;
5131
5132 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5133 alc260_models,
5134 alc260_cfg_tbl);
5135 if (board_config < 0) {
5136 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5137 "trying auto-probe from BIOS...\n");
5138 board_config = ALC260_AUTO;
5139 }
5140
5141 if (board_config == ALC260_AUTO) {
5142 /* automatic parse from the BIOS config */
5143 err = alc260_parse_auto_config(codec);
5144 if (err < 0) {
5145 alc_free(codec);
5146 return err;
5147 } else if (!err) {
5148 printk(KERN_INFO
5149 "hda_codec: Cannot set up configuration "
5150 "from BIOS. Using base mode...\n");
5151 board_config = ALC260_BASIC;
5152 }
5153 }
5154
5155 if (board_config != ALC260_AUTO)
5156 setup_preset(spec, &alc260_presets[board_config]);
5157
5158 spec->stream_name_analog = "ALC260 Analog";
5159 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5160 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5161
5162 spec->stream_name_digital = "ALC260 Digital";
5163 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5164 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5165
5166 spec->vmaster_nid = 0x08;
5167
5168 codec->patch_ops = alc_patch_ops;
5169 if (board_config == ALC260_AUTO)
5170 spec->init_hook = alc260_auto_init;
5171 #ifdef CONFIG_SND_HDA_POWER_SAVE
5172 if (!spec->loopback.amplist)
5173 spec->loopback.amplist = alc260_loopbacks;
5174 #endif
5175
5176 return 0;
5177 }
5178
5179
5180 /*
5181 * ALC882 support
5182 *
5183 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5184 * configuration. Each pin widget can choose any input DACs and a mixer.
5185 * Each ADC is connected from a mixer of all inputs. This makes possible
5186 * 6-channel independent captures.
5187 *
5188 * In addition, an independent DAC for the multi-playback (not used in this
5189 * driver yet).
5190 */
5191 #define ALC882_DIGOUT_NID 0x06
5192 #define ALC882_DIGIN_NID 0x0a
5193
5194 static struct hda_channel_mode alc882_ch_modes[1] = {
5195 { 8, NULL }
5196 };
5197
5198 static hda_nid_t alc882_dac_nids[4] = {
5199 /* front, rear, clfe, rear_surr */
5200 0x02, 0x03, 0x04, 0x05
5201 };
5202
5203 /* identical with ALC880 */
5204 #define alc882_adc_nids alc880_adc_nids
5205 #define alc882_adc_nids_alt alc880_adc_nids_alt
5206
5207 /* input MUX */
5208 /* FIXME: should be a matrix-type input source selection */
5209
5210 static struct hda_input_mux alc882_capture_source = {
5211 .num_items = 4,
5212 .items = {
5213 { "Mic", 0x0 },
5214 { "Front Mic", 0x1 },
5215 { "Line", 0x2 },
5216 { "CD", 0x4 },
5217 },
5218 };
5219 #define alc882_mux_enum_info alc_mux_enum_info
5220 #define alc882_mux_enum_get alc_mux_enum_get
5221
5222 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5223 struct snd_ctl_elem_value *ucontrol)
5224 {
5225 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5226 struct alc_spec *spec = codec->spec;
5227 const struct hda_input_mux *imux = spec->input_mux;
5228 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5229 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5230 hda_nid_t nid;
5231 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5232 unsigned int i, idx;
5233
5234 if (spec->num_adc_nids < 3)
5235 nid = capture_mixers[adc_idx + 1];
5236 else
5237 nid = capture_mixers[adc_idx];
5238 idx = ucontrol->value.enumerated.item[0];
5239 if (idx >= imux->num_items)
5240 idx = imux->num_items - 1;
5241 if (*cur_val == idx)
5242 return 0;
5243 for (i = 0; i < imux->num_items; i++) {
5244 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5245 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
5246 imux->items[i].index,
5247 HDA_AMP_MUTE, v);
5248 }
5249 *cur_val = idx;
5250 return 1;
5251 }
5252
5253 /*
5254 * 2ch mode
5255 */
5256 static struct hda_verb alc882_3ST_ch2_init[] = {
5257 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5258 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5259 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5260 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5261 { } /* end */
5262 };
5263
5264 /*
5265 * 6ch mode
5266 */
5267 static struct hda_verb alc882_3ST_ch6_init[] = {
5268 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5269 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5270 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5271 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5272 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5273 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5274 { } /* end */
5275 };
5276
5277 static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5278 { 2, alc882_3ST_ch2_init },
5279 { 6, alc882_3ST_ch6_init },
5280 };
5281
5282 /*
5283 * 6ch mode
5284 */
5285 static struct hda_verb alc882_sixstack_ch6_init[] = {
5286 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5287 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5288 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5289 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5290 { } /* end */
5291 };
5292
5293 /*
5294 * 8ch mode
5295 */
5296 static struct hda_verb alc882_sixstack_ch8_init[] = {
5297 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5298 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5299 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5300 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5301 { } /* end */
5302 };
5303
5304 static struct hda_channel_mode alc882_sixstack_modes[2] = {
5305 { 6, alc882_sixstack_ch6_init },
5306 { 8, alc882_sixstack_ch8_init },
5307 };
5308
5309 /*
5310 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5311 */
5312
5313 /*
5314 * 2ch mode
5315 */
5316 static struct hda_verb alc885_mbp_ch2_init[] = {
5317 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5318 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5319 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5320 { } /* end */
5321 };
5322
5323 /*
5324 * 6ch mode
5325 */
5326 static struct hda_verb alc885_mbp_ch6_init[] = {
5327 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5328 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5329 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5330 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5331 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5332 { } /* end */
5333 };
5334
5335 static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5336 { 2, alc885_mbp_ch2_init },
5337 { 6, alc885_mbp_ch6_init },
5338 };
5339
5340
5341 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5342 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5343 */
5344 static struct snd_kcontrol_new alc882_base_mixer[] = {
5345 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5346 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5347 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5348 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5349 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5350 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5351 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5352 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5353 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5354 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5355 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5358 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5359 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5361 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5363 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5364 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5365 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5366 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5367 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5368 { } /* end */
5369 };
5370
5371 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
5372 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5373 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5374 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5375 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5376 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5377 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5379 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
5380 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
5381 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5382 { } /* end */
5383 };
5384 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5385 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5386 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5387 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5388 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5389 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5390 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5392 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5394 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5395 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5396 { } /* end */
5397 };
5398
5399 static struct snd_kcontrol_new alc882_targa_mixer[] = {
5400 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5401 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5402 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5403 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5404 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5405 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5406 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5408 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5409 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5410 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5411 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5412 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5413 { } /* end */
5414 };
5415
5416 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5417 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5418 */
5419 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5420 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5421 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5422 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5423 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5424 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5425 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5426 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5427 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5428 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5429 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5432 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5433 { } /* end */
5434 };
5435
5436 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5437 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5438 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5440 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5441 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5445 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5446 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5447 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5448 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5449 { } /* end */
5450 };
5451
5452 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5453 {
5454 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5455 .name = "Channel Mode",
5456 .info = alc_ch_mode_info,
5457 .get = alc_ch_mode_get,
5458 .put = alc_ch_mode_put,
5459 },
5460 { } /* end */
5461 };
5462
5463 static struct hda_verb alc882_init_verbs[] = {
5464 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5468 /* Rear mixer */
5469 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5472 /* CLFE mixer */
5473 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5474 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5475 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5476 /* Side mixer */
5477 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5478 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5479 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5480
5481 /* Front Pin: output 0 (0x0c) */
5482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5484 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5485 /* Rear Pin: output 1 (0x0d) */
5486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5487 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5489 /* CLFE Pin: output 2 (0x0e) */
5490 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5491 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5492 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5493 /* Side Pin: output 3 (0x0f) */
5494 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5495 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5496 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5497 /* Mic (rear) pin: input vref at 80% */
5498 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5499 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5500 /* Front Mic pin: input vref at 80% */
5501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5502 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5503 /* Line In pin: input */
5504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5505 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5506 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5509 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5510 /* CD pin widget for input */
5511 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5512
5513 /* FIXME: use matrix-type input source selection */
5514 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5515 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5516 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5517 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5518 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5520 /* Input mixer2 */
5521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5523 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5525 /* Input mixer3 */
5526 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5530 /* ADC1: mute amp left and right */
5531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5532 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5533 /* ADC2: mute amp left and right */
5534 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5535 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5536 /* ADC3: mute amp left and right */
5537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5538 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5539
5540 { }
5541 };
5542
5543 static struct hda_verb alc882_eapd_verbs[] = {
5544 /* change to EAPD mode */
5545 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5546 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5547 { }
5548 };
5549
5550 /* Mac Pro test */
5551 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5552 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5553 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5555 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5556 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5557 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5558 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5559 { } /* end */
5560 };
5561
5562 static struct hda_verb alc882_macpro_init_verbs[] = {
5563 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5565 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5566 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5567 /* Front Pin: output 0 (0x0c) */
5568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5569 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5570 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5571 /* Front Mic pin: input vref at 80% */
5572 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5573 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5574 /* Speaker: output */
5575 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5577 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5578 /* Headphone output (output 0 - 0x0c) */
5579 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5580 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5581 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5582
5583 /* FIXME: use matrix-type input source selection */
5584 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5585 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5586 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5587 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5589 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5590 /* Input mixer2 */
5591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5594 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5595 /* Input mixer3 */
5596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5599 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5600 /* ADC1: mute amp left and right */
5601 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5602 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5603 /* ADC2: mute amp left and right */
5604 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5605 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5606 /* ADC3: mute amp left and right */
5607 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5608 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5609
5610 { }
5611 };
5612
5613 /* Macbook Pro rev3 */
5614 static struct hda_verb alc885_mbp3_init_verbs[] = {
5615 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5619 /* Rear mixer */
5620 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5621 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5622 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5623 /* Front Pin: output 0 (0x0c) */
5624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5625 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5626 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5627 /* HP Pin: output 0 (0x0d) */
5628 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5630 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5631 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5632 /* Mic (rear) pin: input vref at 80% */
5633 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5634 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5635 /* Front Mic pin: input vref at 80% */
5636 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5637 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5638 /* Line In pin: use output 1 when in LineOut mode */
5639 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5640 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5641 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5642
5643 /* FIXME: use matrix-type input source selection */
5644 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5645 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5646 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5647 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5648 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5649 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5650 /* Input mixer2 */
5651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5655 /* Input mixer3 */
5656 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5657 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5658 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5660 /* ADC1: mute amp left and right */
5661 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5662 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5663 /* ADC2: mute amp left and right */
5664 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5665 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5666 /* ADC3: mute amp left and right */
5667 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5668 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5669
5670 { }
5671 };
5672
5673 /* iMac 24 mixer. */
5674 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5675 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5676 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5677 { } /* end */
5678 };
5679
5680 /* iMac 24 init verbs. */
5681 static struct hda_verb alc885_imac24_init_verbs[] = {
5682 /* Internal speakers: output 0 (0x0c) */
5683 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5684 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5685 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5686 /* Internal speakers: output 0 (0x0c) */
5687 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5688 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5689 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5690 /* Headphone: output 0 (0x0c) */
5691 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5692 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5693 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5694 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5695 /* Front Mic: input vref at 80% */
5696 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5697 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5698 { }
5699 };
5700
5701 /* Toggle speaker-output according to the hp-jack state */
5702 static void alc885_imac24_automute(struct hda_codec *codec)
5703 {
5704 unsigned int present;
5705
5706 present = snd_hda_codec_read(codec, 0x14, 0,
5707 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5708 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5709 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5710 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5711 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5712 }
5713
5714 /* Processes unsolicited events. */
5715 static void alc885_imac24_unsol_event(struct hda_codec *codec,
5716 unsigned int res)
5717 {
5718 /* Headphone insertion or removal. */
5719 if ((res >> 26) == ALC880_HP_EVENT)
5720 alc885_imac24_automute(codec);
5721 }
5722
5723 static void alc885_mbp3_automute(struct hda_codec *codec)
5724 {
5725 unsigned int present;
5726
5727 present = snd_hda_codec_read(codec, 0x15, 0,
5728 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5729 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5730 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5731 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5732 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5733
5734 }
5735 static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5736 unsigned int res)
5737 {
5738 /* Headphone insertion or removal. */
5739 if ((res >> 26) == ALC880_HP_EVENT)
5740 alc885_mbp3_automute(codec);
5741 }
5742
5743
5744 static struct hda_verb alc882_targa_verbs[] = {
5745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5746 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5747
5748 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5749 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5750
5751 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5752 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5753 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5754
5755 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5756 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5757 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5758 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5759 { } /* end */
5760 };
5761
5762 /* toggle speaker-output according to the hp-jack state */
5763 static void alc882_targa_automute(struct hda_codec *codec)
5764 {
5765 unsigned int present;
5766
5767 present = snd_hda_codec_read(codec, 0x14, 0,
5768 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5769 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5770 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5771 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5772 present ? 1 : 3);
5773 }
5774
5775 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5776 {
5777 /* Looks like the unsol event is incompatible with the standard
5778 * definition. 4bit tag is placed at 26 bit!
5779 */
5780 if (((res >> 26) == ALC880_HP_EVENT)) {
5781 alc882_targa_automute(codec);
5782 }
5783 }
5784
5785 static struct hda_verb alc882_asus_a7j_verbs[] = {
5786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5788
5789 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5790 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5791 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5792
5793 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5794 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5795 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5796
5797 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5798 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5799 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5800 { } /* end */
5801 };
5802
5803 static struct hda_verb alc882_asus_a7m_verbs[] = {
5804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5806
5807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5808 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5809 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5810
5811 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5812 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5813 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5814
5815 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5816 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5817 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5818 { } /* end */
5819 };
5820
5821 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5822 {
5823 unsigned int gpiostate, gpiomask, gpiodir;
5824
5825 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5826 AC_VERB_GET_GPIO_DATA, 0);
5827
5828 if (!muted)
5829 gpiostate |= (1 << pin);
5830 else
5831 gpiostate &= ~(1 << pin);
5832
5833 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5834 AC_VERB_GET_GPIO_MASK, 0);
5835 gpiomask |= (1 << pin);
5836
5837 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5838 AC_VERB_GET_GPIO_DIRECTION, 0);
5839 gpiodir |= (1 << pin);
5840
5841
5842 snd_hda_codec_write(codec, codec->afg, 0,
5843 AC_VERB_SET_GPIO_MASK, gpiomask);
5844 snd_hda_codec_write(codec, codec->afg, 0,
5845 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5846
5847 msleep(1);
5848
5849 snd_hda_codec_write(codec, codec->afg, 0,
5850 AC_VERB_SET_GPIO_DATA, gpiostate);
5851 }
5852
5853 /* set up GPIO at initialization */
5854 static void alc885_macpro_init_hook(struct hda_codec *codec)
5855 {
5856 alc882_gpio_mute(codec, 0, 0);
5857 alc882_gpio_mute(codec, 1, 0);
5858 }
5859
5860 /* set up GPIO and update auto-muting at initialization */
5861 static void alc885_imac24_init_hook(struct hda_codec *codec)
5862 {
5863 alc885_macpro_init_hook(codec);
5864 alc885_imac24_automute(codec);
5865 }
5866
5867 /*
5868 * generic initialization of ADC, input mixers and output mixers
5869 */
5870 static struct hda_verb alc882_auto_init_verbs[] = {
5871 /*
5872 * Unmute ADC0-2 and set the default input to mic-in
5873 */
5874 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5876 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5877 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5878 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5879 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5880
5881 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5882 * mixer widget
5883 * Note: PASD motherboards uses the Line In 2 as the input for
5884 * front panel mic (mic 2)
5885 */
5886 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5888 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5889 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5890 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5891 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5892
5893 /*
5894 * Set up output mixers (0x0c - 0x0f)
5895 */
5896 /* set vol=0 to output mixers */
5897 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5898 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5899 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5900 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5901 /* set up input amps for analog loopback */
5902 /* Amp Indices: DAC = 0, mixer = 1 */
5903 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5905 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5906 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5907 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5908 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5909 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5910 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5911 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5912 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5913
5914 /* FIXME: use matrix-type input source selection */
5915 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5916 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5917 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5919 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5921 /* Input mixer2 */
5922 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5923 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5924 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5925 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5926 /* Input mixer3 */
5927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5929 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5930 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5931
5932 { }
5933 };
5934
5935 /* capture mixer elements */
5936 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5937 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5938 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5939 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5940 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5941 {
5942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5943 /* The multiple "Capture Source" controls confuse alsamixer
5944 * So call somewhat different..
5945 */
5946 /* .name = "Capture Source", */
5947 .name = "Input Source",
5948 .count = 2,
5949 .info = alc882_mux_enum_info,
5950 .get = alc882_mux_enum_get,
5951 .put = alc882_mux_enum_put,
5952 },
5953 { } /* end */
5954 };
5955
5956 static struct snd_kcontrol_new alc882_capture_mixer[] = {
5957 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5958 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5959 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5960 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5961 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5962 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5963 {
5964 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5965 /* The multiple "Capture Source" controls confuse alsamixer
5966 * So call somewhat different..
5967 */
5968 /* .name = "Capture Source", */
5969 .name = "Input Source",
5970 .count = 3,
5971 .info = alc882_mux_enum_info,
5972 .get = alc882_mux_enum_get,
5973 .put = alc882_mux_enum_put,
5974 },
5975 { } /* end */
5976 };
5977
5978 #ifdef CONFIG_SND_HDA_POWER_SAVE
5979 #define alc882_loopbacks alc880_loopbacks
5980 #endif
5981
5982 /* pcm configuration: identiacal with ALC880 */
5983 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
5984 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
5985 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
5986 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
5987
5988 /*
5989 * configuration and preset
5990 */
5991 static const char *alc882_models[ALC882_MODEL_LAST] = {
5992 [ALC882_3ST_DIG] = "3stack-dig",
5993 [ALC882_6ST_DIG] = "6stack-dig",
5994 [ALC882_ARIMA] = "arima",
5995 [ALC882_W2JC] = "w2jc",
5996 [ALC882_TARGA] = "targa",
5997 [ALC882_ASUS_A7J] = "asus-a7j",
5998 [ALC882_ASUS_A7M] = "asus-a7m",
5999 [ALC885_MACPRO] = "macpro",
6000 [ALC885_MBP3] = "mbp3",
6001 [ALC885_IMAC24] = "imac24",
6002 [ALC882_AUTO] = "auto",
6003 };
6004
6005 static struct snd_pci_quirk alc882_cfg_tbl[] = {
6006 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
6007 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
6008 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
6009 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
6010 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
6011 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
6012 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
6013 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
6014 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
6015 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6016 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6017 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
6018 {}
6019 };
6020
6021 static struct alc_config_preset alc882_presets[] = {
6022 [ALC882_3ST_DIG] = {
6023 .mixers = { alc882_base_mixer },
6024 .init_verbs = { alc882_init_verbs },
6025 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6026 .dac_nids = alc882_dac_nids,
6027 .dig_out_nid = ALC882_DIGOUT_NID,
6028 .dig_in_nid = ALC882_DIGIN_NID,
6029 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6030 .channel_mode = alc882_ch_modes,
6031 .need_dac_fix = 1,
6032 .input_mux = &alc882_capture_source,
6033 },
6034 [ALC882_6ST_DIG] = {
6035 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6036 .init_verbs = { alc882_init_verbs },
6037 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6038 .dac_nids = alc882_dac_nids,
6039 .dig_out_nid = ALC882_DIGOUT_NID,
6040 .dig_in_nid = ALC882_DIGIN_NID,
6041 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6042 .channel_mode = alc882_sixstack_modes,
6043 .input_mux = &alc882_capture_source,
6044 },
6045 [ALC882_ARIMA] = {
6046 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6047 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6048 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6049 .dac_nids = alc882_dac_nids,
6050 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6051 .channel_mode = alc882_sixstack_modes,
6052 .input_mux = &alc882_capture_source,
6053 },
6054 [ALC882_W2JC] = {
6055 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6056 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6057 alc880_gpio1_init_verbs },
6058 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6059 .dac_nids = alc882_dac_nids,
6060 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6061 .channel_mode = alc880_threestack_modes,
6062 .need_dac_fix = 1,
6063 .input_mux = &alc882_capture_source,
6064 .dig_out_nid = ALC882_DIGOUT_NID,
6065 },
6066 [ALC885_MBP3] = {
6067 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6068 .init_verbs = { alc885_mbp3_init_verbs,
6069 alc880_gpio1_init_verbs },
6070 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6071 .dac_nids = alc882_dac_nids,
6072 .channel_mode = alc885_mbp_6ch_modes,
6073 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6074 .input_mux = &alc882_capture_source,
6075 .dig_out_nid = ALC882_DIGOUT_NID,
6076 .dig_in_nid = ALC882_DIGIN_NID,
6077 .unsol_event = alc885_mbp3_unsol_event,
6078 .init_hook = alc885_mbp3_automute,
6079 },
6080 [ALC885_MACPRO] = {
6081 .mixers = { alc882_macpro_mixer },
6082 .init_verbs = { alc882_macpro_init_verbs },
6083 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6084 .dac_nids = alc882_dac_nids,
6085 .dig_out_nid = ALC882_DIGOUT_NID,
6086 .dig_in_nid = ALC882_DIGIN_NID,
6087 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6088 .channel_mode = alc882_ch_modes,
6089 .input_mux = &alc882_capture_source,
6090 .init_hook = alc885_macpro_init_hook,
6091 },
6092 [ALC885_IMAC24] = {
6093 .mixers = { alc885_imac24_mixer },
6094 .init_verbs = { alc885_imac24_init_verbs },
6095 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6096 .dac_nids = alc882_dac_nids,
6097 .dig_out_nid = ALC882_DIGOUT_NID,
6098 .dig_in_nid = ALC882_DIGIN_NID,
6099 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6100 .channel_mode = alc882_ch_modes,
6101 .input_mux = &alc882_capture_source,
6102 .unsol_event = alc885_imac24_unsol_event,
6103 .init_hook = alc885_imac24_init_hook,
6104 },
6105 [ALC882_TARGA] = {
6106 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6107 alc882_capture_mixer },
6108 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6109 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6110 .dac_nids = alc882_dac_nids,
6111 .dig_out_nid = ALC882_DIGOUT_NID,
6112 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6113 .adc_nids = alc882_adc_nids,
6114 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6115 .channel_mode = alc882_3ST_6ch_modes,
6116 .need_dac_fix = 1,
6117 .input_mux = &alc882_capture_source,
6118 .unsol_event = alc882_targa_unsol_event,
6119 .init_hook = alc882_targa_automute,
6120 },
6121 [ALC882_ASUS_A7J] = {
6122 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6123 alc882_capture_mixer },
6124 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6125 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6126 .dac_nids = alc882_dac_nids,
6127 .dig_out_nid = ALC882_DIGOUT_NID,
6128 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6129 .adc_nids = alc882_adc_nids,
6130 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6131 .channel_mode = alc882_3ST_6ch_modes,
6132 .need_dac_fix = 1,
6133 .input_mux = &alc882_capture_source,
6134 },
6135 [ALC882_ASUS_A7M] = {
6136 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6137 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6138 alc880_gpio1_init_verbs,
6139 alc882_asus_a7m_verbs },
6140 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6141 .dac_nids = alc882_dac_nids,
6142 .dig_out_nid = ALC882_DIGOUT_NID,
6143 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6144 .channel_mode = alc880_threestack_modes,
6145 .need_dac_fix = 1,
6146 .input_mux = &alc882_capture_source,
6147 },
6148 };
6149
6150
6151 /*
6152 * Pin config fixes
6153 */
6154 enum {
6155 PINFIX_ABIT_AW9D_MAX
6156 };
6157
6158 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6159 { 0x15, 0x01080104 }, /* side */
6160 { 0x16, 0x01011012 }, /* rear */
6161 { 0x17, 0x01016011 }, /* clfe */
6162 { }
6163 };
6164
6165 static const struct alc_pincfg *alc882_pin_fixes[] = {
6166 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6167 };
6168
6169 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6170 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6171 {}
6172 };
6173
6174 /*
6175 * BIOS auto configuration
6176 */
6177 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6178 hda_nid_t nid, int pin_type,
6179 int dac_idx)
6180 {
6181 /* set as output */
6182 struct alc_spec *spec = codec->spec;
6183 int idx;
6184
6185 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6186 idx = 4;
6187 else
6188 idx = spec->multiout.dac_nids[dac_idx] - 2;
6189
6190 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6191 pin_type);
6192 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6193 AMP_OUT_UNMUTE);
6194 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6195
6196 }
6197
6198 static void alc882_auto_init_multi_out(struct hda_codec *codec)
6199 {
6200 struct alc_spec *spec = codec->spec;
6201 int i;
6202
6203 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6204 for (i = 0; i <= HDA_SIDE; i++) {
6205 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6206 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6207 if (nid)
6208 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
6209 i);
6210 }
6211 }
6212
6213 static void alc882_auto_init_hp_out(struct hda_codec *codec)
6214 {
6215 struct alc_spec *spec = codec->spec;
6216 hda_nid_t pin;
6217
6218 pin = spec->autocfg.hp_pins[0];
6219 if (pin) /* connect to front */
6220 /* use dac 0 */
6221 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6222 }
6223
6224 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6225 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6226
6227 static void alc882_auto_init_analog_input(struct hda_codec *codec)
6228 {
6229 struct alc_spec *spec = codec->spec;
6230 int i;
6231
6232 for (i = 0; i < AUTO_PIN_LAST; i++) {
6233 hda_nid_t nid = spec->autocfg.input_pins[i];
6234 if (alc882_is_input_pin(nid)) {
6235 snd_hda_codec_write(codec, nid, 0,
6236 AC_VERB_SET_PIN_WIDGET_CONTROL,
6237 i <= AUTO_PIN_FRONT_MIC ?
6238 PIN_VREF80 : PIN_IN);
6239 if (nid != ALC882_PIN_CD_NID)
6240 snd_hda_codec_write(codec, nid, 0,
6241 AC_VERB_SET_AMP_GAIN_MUTE,
6242 AMP_OUT_MUTE);
6243 }
6244 }
6245 }
6246
6247 /* add mic boosts if needed */
6248 static int alc_auto_add_mic_boost(struct hda_codec *codec)
6249 {
6250 struct alc_spec *spec = codec->spec;
6251 int err;
6252 hda_nid_t nid;
6253
6254 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
6255 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6256 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6257 "Mic Boost",
6258 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6259 if (err < 0)
6260 return err;
6261 }
6262 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
6263 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6264 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6265 "Front Mic Boost",
6266 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6267 if (err < 0)
6268 return err;
6269 }
6270 return 0;
6271 }
6272
6273 /* almost identical with ALC880 parser... */
6274 static int alc882_parse_auto_config(struct hda_codec *codec)
6275 {
6276 struct alc_spec *spec = codec->spec;
6277 int err = alc880_parse_auto_config(codec);
6278
6279 if (err < 0)
6280 return err;
6281 else if (!err)
6282 return 0; /* no config found */
6283
6284 err = alc_auto_add_mic_boost(codec);
6285 if (err < 0)
6286 return err;
6287
6288 /* hack - override the init verbs */
6289 spec->init_verbs[0] = alc882_auto_init_verbs;
6290
6291 return 1; /* config found */
6292 }
6293
6294 /* additional initialization for auto-configuration model */
6295 static void alc882_auto_init(struct hda_codec *codec)
6296 {
6297 alc882_auto_init_multi_out(codec);
6298 alc882_auto_init_hp_out(codec);
6299 alc882_auto_init_analog_input(codec);
6300 }
6301
6302 static int patch_alc882(struct hda_codec *codec)
6303 {
6304 struct alc_spec *spec;
6305 int err, board_config;
6306
6307 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6308 if (spec == NULL)
6309 return -ENOMEM;
6310
6311 codec->spec = spec;
6312
6313 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6314 alc882_models,
6315 alc882_cfg_tbl);
6316
6317 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
6318 /* Pick up systems that don't supply PCI SSID */
6319 switch (codec->subsystem_id) {
6320 case 0x106b0c00: /* Mac Pro */
6321 board_config = ALC885_MACPRO;
6322 break;
6323 case 0x106b1000: /* iMac 24 */
6324 board_config = ALC885_IMAC24;
6325 break;
6326 case 0x106b00a1: /* Macbook */
6327 case 0x106b2c00: /* Macbook Pro rev3 */
6328 board_config = ALC885_MBP3;
6329 break;
6330 default:
6331 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6332 "trying auto-probe from BIOS...\n");
6333 board_config = ALC882_AUTO;
6334 }
6335 }
6336
6337 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6338
6339 if (board_config == ALC882_AUTO) {
6340 /* automatic parse from the BIOS config */
6341 err = alc882_parse_auto_config(codec);
6342 if (err < 0) {
6343 alc_free(codec);
6344 return err;
6345 } else if (!err) {
6346 printk(KERN_INFO
6347 "hda_codec: Cannot set up configuration "
6348 "from BIOS. Using base mode...\n");
6349 board_config = ALC882_3ST_DIG;
6350 }
6351 }
6352
6353 if (board_config != ALC882_AUTO)
6354 setup_preset(spec, &alc882_presets[board_config]);
6355
6356 spec->stream_name_analog = "ALC882 Analog";
6357 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6358 spec->stream_analog_capture = &alc882_pcm_analog_capture;
6359 /* FIXME: setup DAC5 */
6360 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6361 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
6362
6363 spec->stream_name_digital = "ALC882 Digital";
6364 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6365 spec->stream_digital_capture = &alc882_pcm_digital_capture;
6366
6367 if (!spec->adc_nids && spec->input_mux) {
6368 /* check whether NID 0x07 is valid */
6369 unsigned int wcap = get_wcaps(codec, 0x07);
6370 /* get type */
6371 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6372 if (wcap != AC_WID_AUD_IN) {
6373 spec->adc_nids = alc882_adc_nids_alt;
6374 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
6375 spec->mixers[spec->num_mixers] =
6376 alc882_capture_alt_mixer;
6377 spec->num_mixers++;
6378 } else {
6379 spec->adc_nids = alc882_adc_nids;
6380 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6381 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6382 spec->num_mixers++;
6383 }
6384 }
6385
6386 spec->vmaster_nid = 0x0c;
6387
6388 codec->patch_ops = alc_patch_ops;
6389 if (board_config == ALC882_AUTO)
6390 spec->init_hook = alc882_auto_init;
6391 #ifdef CONFIG_SND_HDA_POWER_SAVE
6392 if (!spec->loopback.amplist)
6393 spec->loopback.amplist = alc882_loopbacks;
6394 #endif
6395
6396 return 0;
6397 }
6398
6399 /*
6400 * ALC883 support
6401 *
6402 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6403 * configuration. Each pin widget can choose any input DACs and a mixer.
6404 * Each ADC is connected from a mixer of all inputs. This makes possible
6405 * 6-channel independent captures.
6406 *
6407 * In addition, an independent DAC for the multi-playback (not used in this
6408 * driver yet).
6409 */
6410 #define ALC883_DIGOUT_NID 0x06
6411 #define ALC883_DIGIN_NID 0x0a
6412
6413 static hda_nid_t alc883_dac_nids[4] = {
6414 /* front, rear, clfe, rear_surr */
6415 0x02, 0x04, 0x03, 0x05
6416 };
6417
6418 static hda_nid_t alc883_adc_nids[2] = {
6419 /* ADC1-2 */
6420 0x08, 0x09,
6421 };
6422
6423 /* input MUX */
6424 /* FIXME: should be a matrix-type input source selection */
6425
6426 static struct hda_input_mux alc883_capture_source = {
6427 .num_items = 4,
6428 .items = {
6429 { "Mic", 0x0 },
6430 { "Front Mic", 0x1 },
6431 { "Line", 0x2 },
6432 { "CD", 0x4 },
6433 },
6434 };
6435
6436 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6437 .num_items = 2,
6438 .items = {
6439 { "Mic", 0x1 },
6440 { "Line", 0x2 },
6441 },
6442 };
6443
6444 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6445 .num_items = 4,
6446 .items = {
6447 { "Mic", 0x0 },
6448 { "iMic", 0x1 },
6449 { "Line", 0x2 },
6450 { "CD", 0x4 },
6451 },
6452 };
6453
6454 #define alc883_mux_enum_info alc_mux_enum_info
6455 #define alc883_mux_enum_get alc_mux_enum_get
6456
6457 static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6458 struct snd_ctl_elem_value *ucontrol)
6459 {
6460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6461 struct alc_spec *spec = codec->spec;
6462 const struct hda_input_mux *imux = spec->input_mux;
6463 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6464 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
6465 hda_nid_t nid = capture_mixers[adc_idx];
6466 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6467 unsigned int i, idx;
6468
6469 idx = ucontrol->value.enumerated.item[0];
6470 if (idx >= imux->num_items)
6471 idx = imux->num_items - 1;
6472 if (*cur_val == idx)
6473 return 0;
6474 for (i = 0; i < imux->num_items; i++) {
6475 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6476 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
6477 imux->items[i].index,
6478 HDA_AMP_MUTE, v);
6479 }
6480 *cur_val = idx;
6481 return 1;
6482 }
6483
6484 /*
6485 * 2ch mode
6486 */
6487 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6488 { 2, NULL }
6489 };
6490
6491 /*
6492 * 2ch mode
6493 */
6494 static struct hda_verb alc883_3ST_ch2_init[] = {
6495 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6496 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6497 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6498 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6499 { } /* end */
6500 };
6501
6502 /*
6503 * 4ch mode
6504 */
6505 static struct hda_verb alc883_3ST_ch4_init[] = {
6506 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6507 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6508 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6509 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6510 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6511 { } /* end */
6512 };
6513
6514 /*
6515 * 6ch mode
6516 */
6517 static struct hda_verb alc883_3ST_ch6_init[] = {
6518 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6519 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6520 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6521 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6522 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6523 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6524 { } /* end */
6525 };
6526
6527 static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
6528 { 2, alc883_3ST_ch2_init },
6529 { 4, alc883_3ST_ch4_init },
6530 { 6, alc883_3ST_ch6_init },
6531 };
6532
6533 /*
6534 * 6ch mode
6535 */
6536 static struct hda_verb alc883_sixstack_ch6_init[] = {
6537 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6538 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6539 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6540 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6541 { } /* end */
6542 };
6543
6544 /*
6545 * 8ch mode
6546 */
6547 static struct hda_verb alc883_sixstack_ch8_init[] = {
6548 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6549 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6550 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6551 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6552 { } /* end */
6553 };
6554
6555 static struct hda_channel_mode alc883_sixstack_modes[2] = {
6556 { 6, alc883_sixstack_ch6_init },
6557 { 8, alc883_sixstack_ch8_init },
6558 };
6559
6560 static struct hda_verb alc883_medion_eapd_verbs[] = {
6561 /* eanable EAPD on medion laptop */
6562 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6563 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6564 { }
6565 };
6566
6567 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6568 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6569 */
6570
6571 static struct snd_kcontrol_new alc883_base_mixer[] = {
6572 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6573 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6574 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6575 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6576 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6577 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6578 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6579 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6580 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6581 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6582 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6583 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6584 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6585 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6586 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6588 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6590 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6591 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6592 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6593 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6594 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6595 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6596 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6597 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6598 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6599 {
6600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6601 /* .name = "Capture Source", */
6602 .name = "Input Source",
6603 .count = 2,
6604 .info = alc883_mux_enum_info,
6605 .get = alc883_mux_enum_get,
6606 .put = alc883_mux_enum_put,
6607 },
6608 { } /* end */
6609 };
6610
6611 static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6612 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6613 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6614 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6615 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6616 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6617 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6618 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6620 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6621 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6622 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6623 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6624 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6625 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6626 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6627 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6628 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6629 {
6630 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6631 /* .name = "Capture Source", */
6632 .name = "Input Source",
6633 .count = 2,
6634 .info = alc883_mux_enum_info,
6635 .get = alc883_mux_enum_get,
6636 .put = alc883_mux_enum_put,
6637 },
6638 { } /* end */
6639 };
6640
6641 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6642 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6643 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6644 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6645 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6646 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6647 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6648 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6649 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6650 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6651 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6652 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6653 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6654 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6655 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6656 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6657 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6658 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6659 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6660 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6661 {
6662 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6663 /* .name = "Capture Source", */
6664 .name = "Input Source",
6665 .count = 2,
6666 .info = alc883_mux_enum_info,
6667 .get = alc883_mux_enum_get,
6668 .put = alc883_mux_enum_put,
6669 },
6670 { } /* end */
6671 };
6672
6673 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6674 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6675 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6676 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6677 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6678 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6679 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6680 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6681 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6683 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6684 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6685 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6686 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6688 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6689 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6690 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6691 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6692 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6693 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6694 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6695 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6696 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6697 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6698 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6699 {
6700 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6701 /* .name = "Capture Source", */
6702 .name = "Input Source",
6703 .count = 2,
6704 .info = alc883_mux_enum_info,
6705 .get = alc883_mux_enum_get,
6706 .put = alc883_mux_enum_put,
6707 },
6708 { } /* end */
6709 };
6710
6711 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
6712 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6713 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6714 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6715 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6716 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6717 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6718 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6719 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6720 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6721 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6722 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6723 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6724 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6726 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6727 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6728 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6729 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6730 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6731 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6732 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6733 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6734 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6735
6736 {
6737 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6738 /* .name = "Capture Source", */
6739 .name = "Input Source",
6740 .count = 1,
6741 .info = alc883_mux_enum_info,
6742 .get = alc883_mux_enum_get,
6743 .put = alc883_mux_enum_put,
6744 },
6745 { } /* end */
6746 };
6747
6748 static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6749 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6750 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6751 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6752 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6753 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6754 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6755 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6756 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6757 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6758 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6759 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6760 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6761 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6763 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6765 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6766 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6767 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6768 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6769 {
6770 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6771 /* .name = "Capture Source", */
6772 .name = "Input Source",
6773 .count = 2,
6774 .info = alc883_mux_enum_info,
6775 .get = alc883_mux_enum_get,
6776 .put = alc883_mux_enum_put,
6777 },
6778 { } /* end */
6779 };
6780
6781 static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6782 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6783 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6784 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6785 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6786 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6788 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6789 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6790 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6791 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6792 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6793 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6794 {
6795 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6796 /* .name = "Capture Source", */
6797 .name = "Input Source",
6798 .count = 2,
6799 .info = alc883_mux_enum_info,
6800 .get = alc883_mux_enum_get,
6801 .put = alc883_mux_enum_put,
6802 },
6803 { } /* end */
6804 };
6805
6806 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6807 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6808 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6809 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6810 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6811 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6813 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6814 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6815 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6816 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6817 {
6818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6819 /* .name = "Capture Source", */
6820 .name = "Input Source",
6821 .count = 1,
6822 .info = alc883_mux_enum_info,
6823 .get = alc883_mux_enum_get,
6824 .put = alc883_mux_enum_put,
6825 },
6826 { } /* end */
6827 };
6828
6829 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6830 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6831 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6832 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6833 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6834 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6837 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6838 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6839 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6840 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6841 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6842 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6843 {
6844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6845 /* .name = "Capture Source", */
6846 .name = "Input Source",
6847 .count = 2,
6848 .info = alc883_mux_enum_info,
6849 .get = alc883_mux_enum_get,
6850 .put = alc883_mux_enum_put,
6851 },
6852 { } /* end */
6853 };
6854
6855 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6856 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6857 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6858 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6859 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6860 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6861 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6862 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6863 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6864 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6865 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6866 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6867 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6868 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6869 {
6870 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6871 /* .name = "Capture Source", */
6872 .name = "Input Source",
6873 .count = 2,
6874 .info = alc883_mux_enum_info,
6875 .get = alc883_mux_enum_get,
6876 .put = alc883_mux_enum_put,
6877 },
6878 { } /* end */
6879 };
6880
6881 static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6883 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6884 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6885 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6886 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6887 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6888 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6889 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6890 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6891 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6893 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6894 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6896 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6898 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6900 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6901 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6902 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6903 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6904 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6905 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6906 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6907 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6908 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6909 {
6910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6911 /* .name = "Capture Source", */
6912 .name = "Input Source",
6913 .count = 2,
6914 .info = alc883_mux_enum_info,
6915 .get = alc883_mux_enum_get,
6916 .put = alc883_mux_enum_put,
6917 },
6918 { } /* end */
6919 };
6920
6921 static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6922 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6923 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6924 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6925 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6926 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6927 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6928 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6929 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6938 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6939 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6940 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6941 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6942 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6943 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6944 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6945 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6946 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6947 {
6948 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6949 /* .name = "Capture Source", */
6950 .name = "Input Source",
6951 .count = 2,
6952 .info = alc883_mux_enum_info,
6953 .get = alc883_mux_enum_get,
6954 .put = alc883_mux_enum_put,
6955 },
6956 { } /* end */
6957 };
6958
6959 static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6960 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6961 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6962 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6963 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6964 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6965 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6966 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6967 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6968 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6969 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6970 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6971 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6972 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6973 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6974 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6975 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6976 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6977 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6978 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6979 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6980 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6981 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6982 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6983 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6984 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6985 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6986 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6987 {
6988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6989 /* .name = "Capture Source", */
6990 .name = "Input Source",
6991 .count = 2,
6992 .info = alc883_mux_enum_info,
6993 .get = alc883_mux_enum_get,
6994 .put = alc883_mux_enum_put,
6995 },
6996 { } /* end */
6997 };
6998
6999 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
7000 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7001 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7002 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7003 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7004 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7006 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7008 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7009 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7010 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7011 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7012 {
7013 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7014 /* .name = "Capture Source", */
7015 .name = "Input Source",
7016 .count = 2,
7017 .info = alc883_mux_enum_info,
7018 .get = alc883_mux_enum_get,
7019 .put = alc883_mux_enum_put,
7020 },
7021 { } /* end */
7022 };
7023
7024 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7025 {
7026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7027 .name = "Channel Mode",
7028 .info = alc_ch_mode_info,
7029 .get = alc_ch_mode_get,
7030 .put = alc_ch_mode_put,
7031 },
7032 { } /* end */
7033 };
7034
7035 static struct hda_verb alc883_init_verbs[] = {
7036 /* ADC1: mute amp left and right */
7037 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7038 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7039 /* ADC2: mute amp left and right */
7040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7041 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7042 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7043 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7044 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7046 /* Rear mixer */
7047 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7049 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7050 /* CLFE mixer */
7051 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7052 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7053 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7054 /* Side mixer */
7055 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7056 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7058
7059 /* mute analog input loopbacks */
7060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7065
7066 /* Front Pin: output 0 (0x0c) */
7067 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7068 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7069 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7070 /* Rear Pin: output 1 (0x0d) */
7071 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7074 /* CLFE Pin: output 2 (0x0e) */
7075 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7076 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7077 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7078 /* Side Pin: output 3 (0x0f) */
7079 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7080 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7081 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7082 /* Mic (rear) pin: input vref at 80% */
7083 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7084 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7085 /* Front Mic pin: input vref at 80% */
7086 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7087 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7088 /* Line In pin: input */
7089 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7090 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7091 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7092 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7093 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7094 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7095 /* CD pin widget for input */
7096 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7097
7098 /* FIXME: use matrix-type input source selection */
7099 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7100 /* Input mixer2 */
7101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7105 /* Input mixer3 */
7106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7107 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7108 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7110 { }
7111 };
7112
7113 /* toggle speaker-output according to the hp-jack state */
7114 static void alc883_mitac_hp_automute(struct hda_codec *codec)
7115 {
7116 unsigned int present;
7117
7118 present = snd_hda_codec_read(codec, 0x15, 0,
7119 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7120 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7121 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7122 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7123 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7124 }
7125
7126 /* auto-toggle front mic */
7127 /*
7128 static void alc883_mitac_mic_automute(struct hda_codec *codec)
7129 {
7130 unsigned int present;
7131 unsigned char bits;
7132
7133 present = snd_hda_codec_read(codec, 0x18, 0,
7134 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7135 bits = present ? HDA_AMP_MUTE : 0;
7136 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7137 }
7138 */
7139
7140 static void alc883_mitac_automute(struct hda_codec *codec)
7141 {
7142 alc883_mitac_hp_automute(codec);
7143 /* alc883_mitac_mic_automute(codec); */
7144 }
7145
7146 static void alc883_mitac_unsol_event(struct hda_codec *codec,
7147 unsigned int res)
7148 {
7149 switch (res >> 26) {
7150 case ALC880_HP_EVENT:
7151 alc883_mitac_hp_automute(codec);
7152 break;
7153 case ALC880_MIC_EVENT:
7154 /* alc883_mitac_mic_automute(codec); */
7155 break;
7156 }
7157 }
7158
7159 static struct hda_verb alc883_mitac_verbs[] = {
7160 /* HP */
7161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7163 /* Subwoofer */
7164 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7165 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7166
7167 /* enable unsolicited event */
7168 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7169 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7170
7171 { } /* end */
7172 };
7173
7174 static struct hda_verb alc883_tagra_verbs[] = {
7175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7177
7178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7179 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7180
7181 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7182 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7183 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7184
7185 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7186 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7187 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7188 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
7189
7190 { } /* end */
7191 };
7192
7193 static struct hda_verb alc883_lenovo_101e_verbs[] = {
7194 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7195 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7196 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7197 { } /* end */
7198 };
7199
7200 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7201 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7203 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7204 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7205 { } /* end */
7206 };
7207
7208 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7209 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7210 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7211 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7212 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7213 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7214 { } /* end */
7215 };
7216
7217 static struct hda_verb alc883_haier_w66_verbs[] = {
7218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7220
7221 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7222
7223 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7225 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7227 { } /* end */
7228 };
7229
7230 static struct hda_verb alc888_6st_hp_verbs[] = {
7231 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7232 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7233 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7234 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7235 { }
7236 };
7237
7238 static struct hda_verb alc888_3st_hp_verbs[] = {
7239 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7240 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7241 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7242 { }
7243 };
7244
7245 static struct hda_verb alc888_6st_dell_verbs[] = {
7246 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7248 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7249 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7250 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7251 { }
7252 };
7253
7254 static struct hda_verb alc888_3st_hp_2ch_init[] = {
7255 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7256 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7257 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7258 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7259 { }
7260 };
7261
7262 static struct hda_verb alc888_3st_hp_6ch_init[] = {
7263 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7264 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7265 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7266 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7267 { }
7268 };
7269
7270 static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7271 { 2, alc888_3st_hp_2ch_init },
7272 { 6, alc888_3st_hp_6ch_init },
7273 };
7274
7275 /* toggle front-jack and RCA according to the hp-jack state */
7276 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7277 {
7278 unsigned int present;
7279
7280 present = snd_hda_codec_read(codec, 0x1b, 0,
7281 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7282 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7283 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7284 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7285 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7286 }
7287
7288 /* toggle RCA according to the front-jack state */
7289 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7290 {
7291 unsigned int present;
7292
7293 present = snd_hda_codec_read(codec, 0x14, 0,
7294 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7295 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7296 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7297 }
7298
7299 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7300 unsigned int res)
7301 {
7302 if ((res >> 26) == ALC880_HP_EVENT)
7303 alc888_lenovo_ms7195_front_automute(codec);
7304 if ((res >> 26) == ALC880_FRONT_EVENT)
7305 alc888_lenovo_ms7195_rca_automute(codec);
7306 }
7307
7308 static struct hda_verb alc883_medion_md2_verbs[] = {
7309 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7311
7312 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7313
7314 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7315 { } /* end */
7316 };
7317
7318 /* toggle speaker-output according to the hp-jack state */
7319 static void alc883_medion_md2_automute(struct hda_codec *codec)
7320 {
7321 unsigned int present;
7322
7323 present = snd_hda_codec_read(codec, 0x14, 0,
7324 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7325 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7326 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7327 }
7328
7329 static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7330 unsigned int res)
7331 {
7332 if ((res >> 26) == ALC880_HP_EVENT)
7333 alc883_medion_md2_automute(codec);
7334 }
7335
7336 /* toggle speaker-output according to the hp-jack state */
7337 static void alc883_tagra_automute(struct hda_codec *codec)
7338 {
7339 unsigned int present;
7340 unsigned char bits;
7341
7342 present = snd_hda_codec_read(codec, 0x14, 0,
7343 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7344 bits = present ? HDA_AMP_MUTE : 0;
7345 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7346 HDA_AMP_MUTE, bits);
7347 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7348 present ? 1 : 3);
7349 }
7350
7351 static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7352 {
7353 if ((res >> 26) == ALC880_HP_EVENT)
7354 alc883_tagra_automute(codec);
7355 }
7356
7357 static void alc883_haier_w66_automute(struct hda_codec *codec)
7358 {
7359 unsigned int present;
7360 unsigned char bits;
7361
7362 present = snd_hda_codec_read(codec, 0x1b, 0,
7363 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7364 bits = present ? 0x80 : 0;
7365 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7366 0x80, bits);
7367 }
7368
7369 static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7370 unsigned int res)
7371 {
7372 if ((res >> 26) == ALC880_HP_EVENT)
7373 alc883_haier_w66_automute(codec);
7374 }
7375
7376 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7377 {
7378 unsigned int present;
7379 unsigned char bits;
7380
7381 present = snd_hda_codec_read(codec, 0x14, 0,
7382 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7383 bits = present ? HDA_AMP_MUTE : 0;
7384 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7385 HDA_AMP_MUTE, bits);
7386 }
7387
7388 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7389 {
7390 unsigned int present;
7391 unsigned char bits;
7392
7393 present = snd_hda_codec_read(codec, 0x1b, 0,
7394 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7395 bits = present ? HDA_AMP_MUTE : 0;
7396 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7397 HDA_AMP_MUTE, bits);
7398 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7399 HDA_AMP_MUTE, bits);
7400 }
7401
7402 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7403 unsigned int res)
7404 {
7405 if ((res >> 26) == ALC880_HP_EVENT)
7406 alc883_lenovo_101e_all_automute(codec);
7407 if ((res >> 26) == ALC880_FRONT_EVENT)
7408 alc883_lenovo_101e_ispeaker_automute(codec);
7409 }
7410
7411 /* toggle speaker-output according to the hp-jack state */
7412 static void alc883_acer_aspire_automute(struct hda_codec *codec)
7413 {
7414 unsigned int present;
7415
7416 present = snd_hda_codec_read(codec, 0x14, 0,
7417 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7418 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7419 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7420 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7421 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7422 }
7423
7424 static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7425 unsigned int res)
7426 {
7427 if ((res >> 26) == ALC880_HP_EVENT)
7428 alc883_acer_aspire_automute(codec);
7429 }
7430
7431 static struct hda_verb alc883_acer_eapd_verbs[] = {
7432 /* HP Pin: output 0 (0x0c) */
7433 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7434 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7435 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7436 /* Front Pin: output 0 (0x0c) */
7437 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7438 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7439 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7440 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7441 /* eanable EAPD on medion laptop */
7442 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7443 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7444 /* enable unsolicited event */
7445 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7446 { }
7447 };
7448
7449 static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7450 {
7451 unsigned int present;
7452
7453 present = snd_hda_codec_read(codec, 0x1b, 0,
7454 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7455 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7456 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7457 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7458 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7459 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7460 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7461 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7462 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7463 }
7464
7465 static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7466 unsigned int res)
7467 {
7468 switch (res >> 26) {
7469 case ALC880_HP_EVENT:
7470 printk("hp_event\n");
7471 alc888_6st_dell_front_automute(codec);
7472 break;
7473 }
7474 }
7475
7476 /*
7477 * generic initialization of ADC, input mixers and output mixers
7478 */
7479 static struct hda_verb alc883_auto_init_verbs[] = {
7480 /*
7481 * Unmute ADC0-2 and set the default input to mic-in
7482 */
7483 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7485 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7487
7488 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7489 * mixer widget
7490 * Note: PASD motherboards uses the Line In 2 as the input for
7491 * front panel mic (mic 2)
7492 */
7493 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7494 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7495 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7499
7500 /*
7501 * Set up output mixers (0x0c - 0x0f)
7502 */
7503 /* set vol=0 to output mixers */
7504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7506 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7507 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7508 /* set up input amps for analog loopback */
7509 /* Amp Indices: DAC = 0, mixer = 1 */
7510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7517 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7518 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7519 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7520
7521 /* FIXME: use matrix-type input source selection */
7522 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7523 /* Input mixer1 */
7524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7527 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7528 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7529 /* Input mixer2 */
7530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7533 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7534 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7535
7536 { }
7537 };
7538
7539 /* capture mixer elements */
7540 static struct snd_kcontrol_new alc883_capture_mixer[] = {
7541 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7542 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7543 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7544 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7545 {
7546 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7547 /* The multiple "Capture Source" controls confuse alsamixer
7548 * So call somewhat different..
7549 */
7550 /* .name = "Capture Source", */
7551 .name = "Input Source",
7552 .count = 2,
7553 .info = alc882_mux_enum_info,
7554 .get = alc882_mux_enum_get,
7555 .put = alc882_mux_enum_put,
7556 },
7557 { } /* end */
7558 };
7559
7560 #ifdef CONFIG_SND_HDA_POWER_SAVE
7561 #define alc883_loopbacks alc880_loopbacks
7562 #endif
7563
7564 /* pcm configuration: identiacal with ALC880 */
7565 #define alc883_pcm_analog_playback alc880_pcm_analog_playback
7566 #define alc883_pcm_analog_capture alc880_pcm_analog_capture
7567 #define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
7568 #define alc883_pcm_digital_playback alc880_pcm_digital_playback
7569 #define alc883_pcm_digital_capture alc880_pcm_digital_capture
7570
7571 /*
7572 * configuration and preset
7573 */
7574 static const char *alc883_models[ALC883_MODEL_LAST] = {
7575 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7576 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7577 [ALC883_3ST_6ch] = "3stack-6ch",
7578 [ALC883_6ST_DIG] = "6stack-dig",
7579 [ALC883_TARGA_DIG] = "targa-dig",
7580 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
7581 [ALC883_ACER] = "acer",
7582 [ALC883_ACER_ASPIRE] = "acer-aspire",
7583 [ALC883_MEDION] = "medion",
7584 [ALC883_MEDION_MD2] = "medion-md2",
7585 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
7586 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
7587 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7588 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
7589 [ALC883_HAIER_W66] = "haier-w66",
7590 [ALC888_6ST_HP] = "6stack-hp",
7591 [ALC888_3ST_HP] = "3stack-hp",
7592 [ALC888_6ST_DELL] = "6stack-dell",
7593 [ALC883_MITAC] = "mitac",
7594 [ALC883_AUTO] = "auto",
7595 };
7596
7597 static struct snd_pci_quirk alc883_cfg_tbl[] = {
7598 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
7599 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7600 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7601 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7602 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
7603 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
7604 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
7605 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7606 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7607 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7608 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7609 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
7610 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7611 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7612 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
7613 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
7614 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7615 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7616 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7617 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7618 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7619 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7620 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7621 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7622 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7623 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7624 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7625 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7626 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
7627 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7628 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7629 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7630 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7631 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7632 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
7633 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7634 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7635 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
7636 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7637 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7638 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7639 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7640 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7641 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
7642 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
7643 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
7644 {}
7645 };
7646
7647 static struct alc_config_preset alc883_presets[] = {
7648 [ALC883_3ST_2ch_DIG] = {
7649 .mixers = { alc883_3ST_2ch_mixer },
7650 .init_verbs = { alc883_init_verbs },
7651 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7652 .dac_nids = alc883_dac_nids,
7653 .dig_out_nid = ALC883_DIGOUT_NID,
7654 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7655 .adc_nids = alc883_adc_nids,
7656 .dig_in_nid = ALC883_DIGIN_NID,
7657 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7658 .channel_mode = alc883_3ST_2ch_modes,
7659 .input_mux = &alc883_capture_source,
7660 },
7661 [ALC883_3ST_6ch_DIG] = {
7662 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7663 .init_verbs = { alc883_init_verbs },
7664 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7665 .dac_nids = alc883_dac_nids,
7666 .dig_out_nid = ALC883_DIGOUT_NID,
7667 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7668 .adc_nids = alc883_adc_nids,
7669 .dig_in_nid = ALC883_DIGIN_NID,
7670 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7671 .channel_mode = alc883_3ST_6ch_modes,
7672 .need_dac_fix = 1,
7673 .input_mux = &alc883_capture_source,
7674 },
7675 [ALC883_3ST_6ch] = {
7676 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7677 .init_verbs = { alc883_init_verbs },
7678 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7679 .dac_nids = alc883_dac_nids,
7680 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7681 .adc_nids = alc883_adc_nids,
7682 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7683 .channel_mode = alc883_3ST_6ch_modes,
7684 .need_dac_fix = 1,
7685 .input_mux = &alc883_capture_source,
7686 },
7687 [ALC883_6ST_DIG] = {
7688 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7689 .init_verbs = { alc883_init_verbs },
7690 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7691 .dac_nids = alc883_dac_nids,
7692 .dig_out_nid = ALC883_DIGOUT_NID,
7693 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7694 .adc_nids = alc883_adc_nids,
7695 .dig_in_nid = ALC883_DIGIN_NID,
7696 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7697 .channel_mode = alc883_sixstack_modes,
7698 .input_mux = &alc883_capture_source,
7699 },
7700 [ALC883_TARGA_DIG] = {
7701 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7702 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7703 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7704 .dac_nids = alc883_dac_nids,
7705 .dig_out_nid = ALC883_DIGOUT_NID,
7706 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7707 .adc_nids = alc883_adc_nids,
7708 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7709 .channel_mode = alc883_3ST_6ch_modes,
7710 .need_dac_fix = 1,
7711 .input_mux = &alc883_capture_source,
7712 .unsol_event = alc883_tagra_unsol_event,
7713 .init_hook = alc883_tagra_automute,
7714 },
7715 [ALC883_TARGA_2ch_DIG] = {
7716 .mixers = { alc883_tagra_2ch_mixer},
7717 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7718 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7719 .dac_nids = alc883_dac_nids,
7720 .dig_out_nid = ALC883_DIGOUT_NID,
7721 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7722 .adc_nids = alc883_adc_nids,
7723 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7724 .channel_mode = alc883_3ST_2ch_modes,
7725 .input_mux = &alc883_capture_source,
7726 .unsol_event = alc883_tagra_unsol_event,
7727 .init_hook = alc883_tagra_automute,
7728 },
7729 [ALC883_ACER] = {
7730 .mixers = { alc883_base_mixer },
7731 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7732 * and the headphone jack. Turn this on and rely on the
7733 * standard mute methods whenever the user wants to turn
7734 * these outputs off.
7735 */
7736 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7737 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7738 .dac_nids = alc883_dac_nids,
7739 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7740 .adc_nids = alc883_adc_nids,
7741 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7742 .channel_mode = alc883_3ST_2ch_modes,
7743 .input_mux = &alc883_capture_source,
7744 },
7745 [ALC883_ACER_ASPIRE] = {
7746 .mixers = { alc883_acer_aspire_mixer },
7747 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
7748 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7749 .dac_nids = alc883_dac_nids,
7750 .dig_out_nid = ALC883_DIGOUT_NID,
7751 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7752 .adc_nids = alc883_adc_nids,
7753 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7754 .channel_mode = alc883_3ST_2ch_modes,
7755 .input_mux = &alc883_capture_source,
7756 .unsol_event = alc883_acer_aspire_unsol_event,
7757 .init_hook = alc883_acer_aspire_automute,
7758 },
7759 [ALC883_MEDION] = {
7760 .mixers = { alc883_fivestack_mixer,
7761 alc883_chmode_mixer },
7762 .init_verbs = { alc883_init_verbs,
7763 alc883_medion_eapd_verbs },
7764 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7765 .dac_nids = alc883_dac_nids,
7766 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7767 .adc_nids = alc883_adc_nids,
7768 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7769 .channel_mode = alc883_sixstack_modes,
7770 .input_mux = &alc883_capture_source,
7771 },
7772 [ALC883_MEDION_MD2] = {
7773 .mixers = { alc883_medion_md2_mixer},
7774 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7775 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7776 .dac_nids = alc883_dac_nids,
7777 .dig_out_nid = ALC883_DIGOUT_NID,
7778 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7779 .adc_nids = alc883_adc_nids,
7780 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7781 .channel_mode = alc883_3ST_2ch_modes,
7782 .input_mux = &alc883_capture_source,
7783 .unsol_event = alc883_medion_md2_unsol_event,
7784 .init_hook = alc883_medion_md2_automute,
7785 },
7786 [ALC883_LAPTOP_EAPD] = {
7787 .mixers = { alc883_base_mixer },
7788 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7789 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7790 .dac_nids = alc883_dac_nids,
7791 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7792 .adc_nids = alc883_adc_nids,
7793 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7794 .channel_mode = alc883_3ST_2ch_modes,
7795 .input_mux = &alc883_capture_source,
7796 },
7797 [ALC883_LENOVO_101E_2ch] = {
7798 .mixers = { alc883_lenovo_101e_2ch_mixer},
7799 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7800 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7801 .dac_nids = alc883_dac_nids,
7802 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7803 .adc_nids = alc883_adc_nids,
7804 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7805 .channel_mode = alc883_3ST_2ch_modes,
7806 .input_mux = &alc883_lenovo_101e_capture_source,
7807 .unsol_event = alc883_lenovo_101e_unsol_event,
7808 .init_hook = alc883_lenovo_101e_all_automute,
7809 },
7810 [ALC883_LENOVO_NB0763] = {
7811 .mixers = { alc883_lenovo_nb0763_mixer },
7812 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7813 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7814 .dac_nids = alc883_dac_nids,
7815 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7816 .adc_nids = alc883_adc_nids,
7817 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7818 .channel_mode = alc883_3ST_2ch_modes,
7819 .need_dac_fix = 1,
7820 .input_mux = &alc883_lenovo_nb0763_capture_source,
7821 .unsol_event = alc883_medion_md2_unsol_event,
7822 .init_hook = alc883_medion_md2_automute,
7823 },
7824 [ALC888_LENOVO_MS7195_DIG] = {
7825 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7826 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7827 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7828 .dac_nids = alc883_dac_nids,
7829 .dig_out_nid = ALC883_DIGOUT_NID,
7830 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7831 .adc_nids = alc883_adc_nids,
7832 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7833 .channel_mode = alc883_3ST_6ch_modes,
7834 .need_dac_fix = 1,
7835 .input_mux = &alc883_capture_source,
7836 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7837 .init_hook = alc888_lenovo_ms7195_front_automute,
7838 },
7839 [ALC883_HAIER_W66] = {
7840 .mixers = { alc883_tagra_2ch_mixer},
7841 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7842 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7843 .dac_nids = alc883_dac_nids,
7844 .dig_out_nid = ALC883_DIGOUT_NID,
7845 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7846 .adc_nids = alc883_adc_nids,
7847 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7848 .channel_mode = alc883_3ST_2ch_modes,
7849 .input_mux = &alc883_capture_source,
7850 .unsol_event = alc883_haier_w66_unsol_event,
7851 .init_hook = alc883_haier_w66_automute,
7852 },
7853 [ALC888_6ST_HP] = {
7854 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7855 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
7856 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7857 .dac_nids = alc883_dac_nids,
7858 .dig_out_nid = ALC883_DIGOUT_NID,
7859 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7860 .adc_nids = alc883_adc_nids,
7861 .dig_in_nid = ALC883_DIGIN_NID,
7862 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7863 .channel_mode = alc883_sixstack_modes,
7864 .input_mux = &alc883_capture_source,
7865 },
7866 [ALC888_3ST_HP] = {
7867 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7868 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
7869 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7870 .dac_nids = alc883_dac_nids,
7871 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7872 .adc_nids = alc883_adc_nids,
7873 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7874 .channel_mode = alc888_3st_hp_modes,
7875 .need_dac_fix = 1,
7876 .input_mux = &alc883_capture_source,
7877 },
7878 [ALC888_6ST_DELL] = {
7879 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7880 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7881 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7882 .dac_nids = alc883_dac_nids,
7883 .dig_out_nid = ALC883_DIGOUT_NID,
7884 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7885 .adc_nids = alc883_adc_nids,
7886 .dig_in_nid = ALC883_DIGIN_NID,
7887 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7888 .channel_mode = alc883_sixstack_modes,
7889 .input_mux = &alc883_capture_source,
7890 .unsol_event = alc888_6st_dell_unsol_event,
7891 .init_hook = alc888_6st_dell_front_automute,
7892 },
7893 [ALC883_MITAC] = {
7894 .mixers = { alc883_mitac_mixer },
7895 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7896 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7897 .dac_nids = alc883_dac_nids,
7898 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7899 .adc_nids = alc883_adc_nids,
7900 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7901 .channel_mode = alc883_3ST_2ch_modes,
7902 .input_mux = &alc883_capture_source,
7903 .unsol_event = alc883_mitac_unsol_event,
7904 .init_hook = alc883_mitac_automute,
7905 },
7906 };
7907
7908
7909 /*
7910 * BIOS auto configuration
7911 */
7912 static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7913 hda_nid_t nid, int pin_type,
7914 int dac_idx)
7915 {
7916 /* set as output */
7917 struct alc_spec *spec = codec->spec;
7918 int idx;
7919
7920 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7921 idx = 4;
7922 else
7923 idx = spec->multiout.dac_nids[dac_idx] - 2;
7924
7925 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7926 pin_type);
7927 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7928 AMP_OUT_UNMUTE);
7929 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7930
7931 }
7932
7933 static void alc883_auto_init_multi_out(struct hda_codec *codec)
7934 {
7935 struct alc_spec *spec = codec->spec;
7936 int i;
7937
7938 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
7939 for (i = 0; i <= HDA_SIDE; i++) {
7940 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7941 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7942 if (nid)
7943 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
7944 i);
7945 }
7946 }
7947
7948 static void alc883_auto_init_hp_out(struct hda_codec *codec)
7949 {
7950 struct alc_spec *spec = codec->spec;
7951 hda_nid_t pin;
7952
7953 pin = spec->autocfg.hp_pins[0];
7954 if (pin) /* connect to front */
7955 /* use dac 0 */
7956 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7957 }
7958
7959 #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7960 #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7961
7962 static void alc883_auto_init_analog_input(struct hda_codec *codec)
7963 {
7964 struct alc_spec *spec = codec->spec;
7965 int i;
7966
7967 for (i = 0; i < AUTO_PIN_LAST; i++) {
7968 hda_nid_t nid = spec->autocfg.input_pins[i];
7969 if (alc883_is_input_pin(nid)) {
7970 snd_hda_codec_write(codec, nid, 0,
7971 AC_VERB_SET_PIN_WIDGET_CONTROL,
7972 (i <= AUTO_PIN_FRONT_MIC ?
7973 PIN_VREF80 : PIN_IN));
7974 if (nid != ALC883_PIN_CD_NID)
7975 snd_hda_codec_write(codec, nid, 0,
7976 AC_VERB_SET_AMP_GAIN_MUTE,
7977 AMP_OUT_MUTE);
7978 }
7979 }
7980 }
7981
7982 /* almost identical with ALC880 parser... */
7983 static int alc883_parse_auto_config(struct hda_codec *codec)
7984 {
7985 struct alc_spec *spec = codec->spec;
7986 int err = alc880_parse_auto_config(codec);
7987
7988 if (err < 0)
7989 return err;
7990 else if (!err)
7991 return 0; /* no config found */
7992
7993 err = alc_auto_add_mic_boost(codec);
7994 if (err < 0)
7995 return err;
7996
7997 /* hack - override the init verbs */
7998 spec->init_verbs[0] = alc883_auto_init_verbs;
7999 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8000 spec->num_mixers++;
8001
8002 return 1; /* config found */
8003 }
8004
8005 /* additional initialization for auto-configuration model */
8006 static void alc883_auto_init(struct hda_codec *codec)
8007 {
8008 alc883_auto_init_multi_out(codec);
8009 alc883_auto_init_hp_out(codec);
8010 alc883_auto_init_analog_input(codec);
8011 }
8012
8013 static int patch_alc883(struct hda_codec *codec)
8014 {
8015 struct alc_spec *spec;
8016 int err, board_config;
8017
8018 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8019 if (spec == NULL)
8020 return -ENOMEM;
8021
8022 codec->spec = spec;
8023
8024 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8025 alc883_models,
8026 alc883_cfg_tbl);
8027 if (board_config < 0) {
8028 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8029 "trying auto-probe from BIOS...\n");
8030 board_config = ALC883_AUTO;
8031 }
8032
8033 if (board_config == ALC883_AUTO) {
8034 /* automatic parse from the BIOS config */
8035 err = alc883_parse_auto_config(codec);
8036 if (err < 0) {
8037 alc_free(codec);
8038 return err;
8039 } else if (!err) {
8040 printk(KERN_INFO
8041 "hda_codec: Cannot set up configuration "
8042 "from BIOS. Using base mode...\n");
8043 board_config = ALC883_3ST_2ch_DIG;
8044 }
8045 }
8046
8047 if (board_config != ALC883_AUTO)
8048 setup_preset(spec, &alc883_presets[board_config]);
8049
8050 spec->stream_name_analog = "ALC883 Analog";
8051 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8052 spec->stream_analog_capture = &alc883_pcm_analog_capture;
8053 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
8054
8055 spec->stream_name_digital = "ALC883 Digital";
8056 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8057 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8058
8059 if (!spec->adc_nids && spec->input_mux) {
8060 spec->adc_nids = alc883_adc_nids;
8061 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8062 }
8063
8064 spec->vmaster_nid = 0x0c;
8065
8066 codec->patch_ops = alc_patch_ops;
8067 if (board_config == ALC883_AUTO)
8068 spec->init_hook = alc883_auto_init;
8069 #ifdef CONFIG_SND_HDA_POWER_SAVE
8070 if (!spec->loopback.amplist)
8071 spec->loopback.amplist = alc883_loopbacks;
8072 #endif
8073
8074 return 0;
8075 }
8076
8077 /*
8078 * ALC262 support
8079 */
8080
8081 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8082 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
8083
8084 #define alc262_dac_nids alc260_dac_nids
8085 #define alc262_adc_nids alc882_adc_nids
8086 #define alc262_adc_nids_alt alc882_adc_nids_alt
8087
8088 #define alc262_modes alc260_modes
8089 #define alc262_capture_source alc882_capture_source
8090
8091 static struct snd_kcontrol_new alc262_base_mixer[] = {
8092 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8093 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8094 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8095 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8096 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8097 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8101 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8102 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8103 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8104 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8105 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8106 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8107 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8108 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8109 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8110 { } /* end */
8111 };
8112
8113 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8114 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8115 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8116 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8117 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8118 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8119 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8120 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8121 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8122 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8123 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8124 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8125 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8126 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8127 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8128 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8129 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8130 { } /* end */
8131 };
8132
8133 /* update HP, line and mono-out pins according to the master switch */
8134 static void alc262_hp_master_update(struct hda_codec *codec)
8135 {
8136 struct alc_spec *spec = codec->spec;
8137 int val = spec->master_sw;
8138
8139 /* HP & line-out */
8140 snd_hda_codec_write_cache(codec, 0x1b, 0,
8141 AC_VERB_SET_PIN_WIDGET_CONTROL,
8142 val ? PIN_HP : 0);
8143 snd_hda_codec_write_cache(codec, 0x15, 0,
8144 AC_VERB_SET_PIN_WIDGET_CONTROL,
8145 val ? PIN_HP : 0);
8146 /* mono (speaker) depending on the HP jack sense */
8147 val = val && !spec->jack_present;
8148 snd_hda_codec_write_cache(codec, 0x16, 0,
8149 AC_VERB_SET_PIN_WIDGET_CONTROL,
8150 val ? PIN_OUT : 0);
8151 }
8152
8153 static void alc262_hp_bpc_automute(struct hda_codec *codec)
8154 {
8155 struct alc_spec *spec = codec->spec;
8156 unsigned int presence;
8157 presence = snd_hda_codec_read(codec, 0x1b, 0,
8158 AC_VERB_GET_PIN_SENSE, 0);
8159 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8160 alc262_hp_master_update(codec);
8161 }
8162
8163 static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8164 {
8165 if ((res >> 26) != ALC880_HP_EVENT)
8166 return;
8167 alc262_hp_bpc_automute(codec);
8168 }
8169
8170 static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8171 {
8172 struct alc_spec *spec = codec->spec;
8173 unsigned int presence;
8174 presence = snd_hda_codec_read(codec, 0x15, 0,
8175 AC_VERB_GET_PIN_SENSE, 0);
8176 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8177 alc262_hp_master_update(codec);
8178 }
8179
8180 static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8181 unsigned int res)
8182 {
8183 if ((res >> 26) != ALC880_HP_EVENT)
8184 return;
8185 alc262_hp_wildwest_automute(codec);
8186 }
8187
8188 static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8189 struct snd_ctl_elem_value *ucontrol)
8190 {
8191 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8192 struct alc_spec *spec = codec->spec;
8193 *ucontrol->value.integer.value = spec->master_sw;
8194 return 0;
8195 }
8196
8197 static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8198 struct snd_ctl_elem_value *ucontrol)
8199 {
8200 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8201 struct alc_spec *spec = codec->spec;
8202 int val = !!*ucontrol->value.integer.value;
8203
8204 if (val == spec->master_sw)
8205 return 0;
8206 spec->master_sw = val;
8207 alc262_hp_master_update(codec);
8208 return 1;
8209 }
8210
8211 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
8212 {
8213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8214 .name = "Master Playback Switch",
8215 .info = snd_ctl_boolean_mono_info,
8216 .get = alc262_hp_master_sw_get,
8217 .put = alc262_hp_master_sw_put,
8218 },
8219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8220 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8221 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8222 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8223 HDA_OUTPUT),
8224 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8225 HDA_OUTPUT),
8226 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8227 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8228 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8229 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8230 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8231 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8232 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8233 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8234 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8235 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8236 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8237 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8238 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8239 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8240 { } /* end */
8241 };
8242
8243 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8244 {
8245 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8246 .name = "Master Playback Switch",
8247 .info = snd_ctl_boolean_mono_info,
8248 .get = alc262_hp_master_sw_get,
8249 .put = alc262_hp_master_sw_put,
8250 },
8251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8252 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8253 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8254 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8255 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8256 HDA_OUTPUT),
8257 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8258 HDA_OUTPUT),
8259 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8260 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
8261 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
8262 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8263 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8264 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8265 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8266 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8267 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8268 { } /* end */
8269 };
8270
8271 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8272 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8273 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8274 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
8275 { } /* end */
8276 };
8277
8278 /* mute/unmute internal speaker according to the hp jack and mute state */
8279 static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8280 {
8281 struct alc_spec *spec = codec->spec;
8282
8283 if (force || !spec->sense_updated) {
8284 unsigned int present;
8285 present = snd_hda_codec_read(codec, 0x15, 0,
8286 AC_VERB_GET_PIN_SENSE, 0);
8287 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
8288 spec->sense_updated = 1;
8289 }
8290 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8291 spec->jack_present ? HDA_AMP_MUTE : 0);
8292 }
8293
8294 static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8295 unsigned int res)
8296 {
8297 if ((res >> 26) != ALC880_HP_EVENT)
8298 return;
8299 alc262_hp_t5735_automute(codec, 1);
8300 }
8301
8302 static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8303 {
8304 alc262_hp_t5735_automute(codec, 1);
8305 }
8306
8307 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
8308 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8309 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8310 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8312 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8313 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8314 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8315 { } /* end */
8316 };
8317
8318 static struct hda_verb alc262_hp_t5735_verbs[] = {
8319 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8320 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8321
8322 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8323 { }
8324 };
8325
8326 static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
8327 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8328 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8329 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8330 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8331 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8332 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8333 { } /* end */
8334 };
8335
8336 static struct hda_verb alc262_hp_rp5700_verbs[] = {
8337 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8338 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8339 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8340 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8341 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8342 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8343 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8345 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8347 {}
8348 };
8349
8350 static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8351 .num_items = 1,
8352 .items = {
8353 { "Line", 0x1 },
8354 },
8355 };
8356
8357 /* bind hp and internal speaker mute (with plug check) */
8358 static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8359 struct snd_ctl_elem_value *ucontrol)
8360 {
8361 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8362 long *valp = ucontrol->value.integer.value;
8363 int change;
8364
8365 /* change hp mute */
8366 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8367 HDA_AMP_MUTE,
8368 valp[0] ? 0 : HDA_AMP_MUTE);
8369 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8370 HDA_AMP_MUTE,
8371 valp[1] ? 0 : HDA_AMP_MUTE);
8372 if (change) {
8373 /* change speaker according to HP jack state */
8374 struct alc_spec *spec = codec->spec;
8375 unsigned int mute;
8376 if (spec->jack_present)
8377 mute = HDA_AMP_MUTE;
8378 else
8379 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8380 HDA_OUTPUT, 0);
8381 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8382 HDA_AMP_MUTE, mute);
8383 }
8384 return change;
8385 }
8386
8387 static struct snd_kcontrol_new alc262_sony_mixer[] = {
8388 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8389 {
8390 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8391 .name = "Master Playback Switch",
8392 .info = snd_hda_mixer_amp_switch_info,
8393 .get = snd_hda_mixer_amp_switch_get,
8394 .put = alc262_sony_master_sw_put,
8395 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8396 },
8397 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8398 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8399 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8400 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8401 { } /* end */
8402 };
8403
8404 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8405 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8406 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8407 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8408 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8409 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8410 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8411 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8412 { } /* end */
8413 };
8414
8415 #define alc262_capture_mixer alc882_capture_mixer
8416 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
8417
8418 /*
8419 * generic initialization of ADC, input mixers and output mixers
8420 */
8421 static struct hda_verb alc262_init_verbs[] = {
8422 /*
8423 * Unmute ADC0-2 and set the default input to mic-in
8424 */
8425 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8426 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8427 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8428 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8429 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8430 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8431
8432 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8433 * mixer widget
8434 * Note: PASD motherboards uses the Line In 2 as the input for
8435 * front panel mic (mic 2)
8436 */
8437 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8438 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8439 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8440 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8443
8444 /*
8445 * Set up output mixers (0x0c - 0x0e)
8446 */
8447 /* set vol=0 to output mixers */
8448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8449 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8450 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8451 /* set up input amps for analog loopback */
8452 /* Amp Indices: DAC = 0, mixer = 1 */
8453 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8454 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8455 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8456 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8459
8460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8461 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8462 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8463 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8464 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8465 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8466
8467 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8468 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8469 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8471 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8472
8473 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8474 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8475
8476 /* FIXME: use matrix-type input source selection */
8477 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8478 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8479 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8480 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8481 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8483 /* Input mixer2 */
8484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8488 /* Input mixer3 */
8489 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8493
8494 { }
8495 };
8496
8497 static struct hda_verb alc262_hippo_unsol_verbs[] = {
8498 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8499 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8500 {}
8501 };
8502
8503 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8504 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8505 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8506 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8507
8508 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8509 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8510 {}
8511 };
8512
8513 static struct hda_verb alc262_sony_unsol_verbs[] = {
8514 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8515 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8516 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8517
8518 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8519 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8520 };
8521
8522 /* mute/unmute internal speaker according to the hp jack and mute state */
8523 static void alc262_hippo_automute(struct hda_codec *codec)
8524 {
8525 struct alc_spec *spec = codec->spec;
8526 unsigned int mute;
8527 unsigned int present;
8528
8529 /* need to execute and sync at first */
8530 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8531 present = snd_hda_codec_read(codec, 0x15, 0,
8532 AC_VERB_GET_PIN_SENSE, 0);
8533 spec->jack_present = (present & 0x80000000) != 0;
8534 if (spec->jack_present) {
8535 /* mute internal speaker */
8536 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8537 HDA_AMP_MUTE, HDA_AMP_MUTE);
8538 } else {
8539 /* unmute internal speaker if necessary */
8540 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8541 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8542 HDA_AMP_MUTE, mute);
8543 }
8544 }
8545
8546 /* unsolicited event for HP jack sensing */
8547 static void alc262_hippo_unsol_event(struct hda_codec *codec,
8548 unsigned int res)
8549 {
8550 if ((res >> 26) != ALC880_HP_EVENT)
8551 return;
8552 alc262_hippo_automute(codec);
8553 }
8554
8555 static void alc262_hippo1_automute(struct hda_codec *codec)
8556 {
8557 unsigned int mute;
8558 unsigned int present;
8559
8560 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8561 present = snd_hda_codec_read(codec, 0x1b, 0,
8562 AC_VERB_GET_PIN_SENSE, 0);
8563 present = (present & 0x80000000) != 0;
8564 if (present) {
8565 /* mute internal speaker */
8566 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8567 HDA_AMP_MUTE, HDA_AMP_MUTE);
8568 } else {
8569 /* unmute internal speaker if necessary */
8570 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8571 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8572 HDA_AMP_MUTE, mute);
8573 }
8574 }
8575
8576 /* unsolicited event for HP jack sensing */
8577 static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8578 unsigned int res)
8579 {
8580 if ((res >> 26) != ALC880_HP_EVENT)
8581 return;
8582 alc262_hippo1_automute(codec);
8583 }
8584
8585 /*
8586 * fujitsu model
8587 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8588 */
8589
8590 #define ALC_HP_EVENT 0x37
8591
8592 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8593 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8594 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8595 {}
8596 };
8597
8598 static struct hda_input_mux alc262_fujitsu_capture_source = {
8599 .num_items = 3,
8600 .items = {
8601 { "Mic", 0x0 },
8602 { "Int Mic", 0x1 },
8603 { "CD", 0x4 },
8604 },
8605 };
8606
8607 static struct hda_input_mux alc262_HP_capture_source = {
8608 .num_items = 5,
8609 .items = {
8610 { "Mic", 0x0 },
8611 { "Front Mic", 0x1 },
8612 { "Line", 0x2 },
8613 { "CD", 0x4 },
8614 { "AUX IN", 0x6 },
8615 },
8616 };
8617
8618 static struct hda_input_mux alc262_HP_D7000_capture_source = {
8619 .num_items = 4,
8620 .items = {
8621 { "Mic", 0x0 },
8622 { "Front Mic", 0x2 },
8623 { "Line", 0x1 },
8624 { "CD", 0x4 },
8625 },
8626 };
8627
8628 /* mute/unmute internal speaker according to the hp jack and mute state */
8629 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8630 {
8631 struct alc_spec *spec = codec->spec;
8632 unsigned int mute;
8633
8634 if (force || !spec->sense_updated) {
8635 unsigned int present;
8636 /* need to execute and sync at first */
8637 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8638 present = snd_hda_codec_read(codec, 0x14, 0,
8639 AC_VERB_GET_PIN_SENSE, 0);
8640 spec->jack_present = (present & 0x80000000) != 0;
8641 spec->sense_updated = 1;
8642 }
8643 if (spec->jack_present) {
8644 /* mute internal speaker */
8645 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8646 HDA_AMP_MUTE, HDA_AMP_MUTE);
8647 } else {
8648 /* unmute internal speaker if necessary */
8649 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
8650 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8651 HDA_AMP_MUTE, mute);
8652 }
8653 }
8654
8655 /* unsolicited event for HP jack sensing */
8656 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8657 unsigned int res)
8658 {
8659 if ((res >> 26) != ALC_HP_EVENT)
8660 return;
8661 alc262_fujitsu_automute(codec, 1);
8662 }
8663
8664 /* bind volumes of both NID 0x0c and 0x0d */
8665 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8666 .ops = &snd_hda_bind_vol,
8667 .values = {
8668 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8669 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8670 0
8671 },
8672 };
8673
8674 /* bind hp and internal speaker mute (with plug check) */
8675 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8676 struct snd_ctl_elem_value *ucontrol)
8677 {
8678 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8679 long *valp = ucontrol->value.integer.value;
8680 int change;
8681
8682 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
8683 HDA_AMP_MUTE,
8684 valp[0] ? 0 : HDA_AMP_MUTE);
8685 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
8686 HDA_AMP_MUTE,
8687 valp[1] ? 0 : HDA_AMP_MUTE);
8688 if (change)
8689 alc262_fujitsu_automute(codec, 0);
8690 return change;
8691 }
8692
8693 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
8694 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
8695 {
8696 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8697 .name = "Master Playback Switch",
8698 .info = snd_hda_mixer_amp_switch_info,
8699 .get = snd_hda_mixer_amp_switch_get,
8700 .put = alc262_fujitsu_master_sw_put,
8701 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8702 },
8703 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8704 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8705 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8708 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8709 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8710 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8711 { } /* end */
8712 };
8713
8714 /* additional init verbs for Benq laptops */
8715 static struct hda_verb alc262_EAPD_verbs[] = {
8716 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8717 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8718 {}
8719 };
8720
8721 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8723 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8724
8725 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8726 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8727 {}
8728 };
8729
8730 /* Samsung Q1 Ultra Vista model setup */
8731 static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8732 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8733 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8734 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8735 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8736 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8737 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8738 { } /* end */
8739 };
8740
8741 static struct hda_verb alc262_ultra_verbs[] = {
8742 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8743 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8744 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8745 /* Mic is on Node 0x19 */
8746 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8747 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8749 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8750 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8751 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8752 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8753 {}
8754 };
8755
8756 static struct hda_input_mux alc262_ultra_capture_source = {
8757 .num_items = 1,
8758 .items = {
8759 { "Mic", 0x1 },
8760 },
8761 };
8762
8763 /* mute/unmute internal speaker according to the hp jack and mute state */
8764 static void alc262_ultra_automute(struct hda_codec *codec)
8765 {
8766 struct alc_spec *spec = codec->spec;
8767 unsigned int mute;
8768 unsigned int present;
8769
8770 /* need to execute and sync at first */
8771 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8772 present = snd_hda_codec_read(codec, 0x15, 0,
8773 AC_VERB_GET_PIN_SENSE, 0);
8774 spec->jack_present = (present & 0x80000000) != 0;
8775 if (spec->jack_present) {
8776 /* mute internal speaker */
8777 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8778 HDA_AMP_MUTE, HDA_AMP_MUTE);
8779 } else {
8780 /* unmute internal speaker if necessary */
8781 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8782 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8783 HDA_AMP_MUTE, mute);
8784 }
8785 }
8786
8787 /* unsolicited event for HP jack sensing */
8788 static void alc262_ultra_unsol_event(struct hda_codec *codec,
8789 unsigned int res)
8790 {
8791 if ((res >> 26) != ALC880_HP_EVENT)
8792 return;
8793 alc262_ultra_automute(codec);
8794 }
8795
8796 /* add playback controls from the parsed DAC table */
8797 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8798 const struct auto_pin_cfg *cfg)
8799 {
8800 hda_nid_t nid;
8801 int err;
8802
8803 spec->multiout.num_dacs = 1; /* only use one dac */
8804 spec->multiout.dac_nids = spec->private_dac_nids;
8805 spec->multiout.dac_nids[0] = 2;
8806
8807 nid = cfg->line_out_pins[0];
8808 if (nid) {
8809 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8810 "Front Playback Volume",
8811 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8812 if (err < 0)
8813 return err;
8814 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8815 "Front Playback Switch",
8816 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8817 if (err < 0)
8818 return err;
8819 }
8820
8821 nid = cfg->speaker_pins[0];
8822 if (nid) {
8823 if (nid == 0x16) {
8824 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8825 "Speaker Playback Volume",
8826 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8827 HDA_OUTPUT));
8828 if (err < 0)
8829 return err;
8830 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8831 "Speaker Playback Switch",
8832 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8833 HDA_OUTPUT));
8834 if (err < 0)
8835 return err;
8836 } else {
8837 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8838 "Speaker Playback Switch",
8839 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8840 HDA_OUTPUT));
8841 if (err < 0)
8842 return err;
8843 }
8844 }
8845 nid = cfg->hp_pins[0];
8846 if (nid) {
8847 /* spec->multiout.hp_nid = 2; */
8848 if (nid == 0x16) {
8849 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8850 "Headphone Playback Volume",
8851 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8852 HDA_OUTPUT));
8853 if (err < 0)
8854 return err;
8855 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8856 "Headphone Playback Switch",
8857 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8858 HDA_OUTPUT));
8859 if (err < 0)
8860 return err;
8861 } else {
8862 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8863 "Headphone Playback Switch",
8864 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8865 HDA_OUTPUT));
8866 if (err < 0)
8867 return err;
8868 }
8869 }
8870 return 0;
8871 }
8872
8873 /* identical with ALC880 */
8874 #define alc262_auto_create_analog_input_ctls \
8875 alc880_auto_create_analog_input_ctls
8876
8877 /*
8878 * generic initialization of ADC, input mixers and output mixers
8879 */
8880 static struct hda_verb alc262_volume_init_verbs[] = {
8881 /*
8882 * Unmute ADC0-2 and set the default input to mic-in
8883 */
8884 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8886 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8887 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8888 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890
8891 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8892 * mixer widget
8893 * Note: PASD motherboards uses the Line In 2 as the input for
8894 * front panel mic (mic 2)
8895 */
8896 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8902
8903 /*
8904 * Set up output mixers (0x0c - 0x0f)
8905 */
8906 /* set vol=0 to output mixers */
8907 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8908 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8909 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8910
8911 /* set up input amps for analog loopback */
8912 /* Amp Indices: DAC = 0, mixer = 1 */
8913 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8917 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8919
8920 /* FIXME: use matrix-type input source selection */
8921 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8922 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8923 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8924 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8925 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8926 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8927 /* Input mixer2 */
8928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8929 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8930 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8931 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8932 /* Input mixer3 */
8933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8937
8938 { }
8939 };
8940
8941 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8942 /*
8943 * Unmute ADC0-2 and set the default input to mic-in
8944 */
8945 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8947 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8949 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8950 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8951
8952 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8953 * mixer widget
8954 * Note: PASD motherboards uses the Line In 2 as the input for
8955 * front panel mic (mic 2)
8956 */
8957 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8958 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8959 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8960 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8961 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8962 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8963 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8964 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8965
8966 /*
8967 * Set up output mixers (0x0c - 0x0e)
8968 */
8969 /* set vol=0 to output mixers */
8970 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8971 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8972 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8973
8974 /* set up input amps for analog loopback */
8975 /* Amp Indices: DAC = 0, mixer = 1 */
8976 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8977 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8978 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8979 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8980 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8981 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8982
8983 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8985 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8986
8987 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8988 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8989
8990 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8991 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8992
8993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8994 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8995 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8996 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8997 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8998
8999 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9000 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9001 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9002 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9003 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9004 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9005
9006
9007 /* FIXME: use matrix-type input source selection */
9008 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9009 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9010 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9011 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9012 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9013 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9014 /* Input mixer2 */
9015 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9016 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9017 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9018 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9019 /* Input mixer3 */
9020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9021 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9022 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9023 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9024
9025 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9026
9027 { }
9028 };
9029
9030 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9031 /*
9032 * Unmute ADC0-2 and set the default input to mic-in
9033 */
9034 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9036 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9037 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9038 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9039 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9040
9041 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9042 * mixer widget
9043 * Note: PASD motherboards uses the Line In 2 as the input for front
9044 * panel mic (mic 2)
9045 */
9046 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9047 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9048 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9049 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9050 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9053 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9055 /*
9056 * Set up output mixers (0x0c - 0x0e)
9057 */
9058 /* set vol=0 to output mixers */
9059 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9060 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9061 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9062
9063 /* set up input amps for analog loopback */
9064 /* Amp Indices: DAC = 0, mixer = 1 */
9065 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9066 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9067 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9068 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9069 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9070 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9071
9072
9073 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9074 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9075 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9076 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9077 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9078 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9079 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9080
9081 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9083
9084 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9085 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9086
9087 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9088 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9089 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9090 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9091 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9092 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9093
9094 /* FIXME: use matrix-type input source selection */
9095 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9096 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9097 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9098 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9099 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9100 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9101 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9102 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9103 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9104 /* Input mixer2 */
9105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9106 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9107 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9108 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9109 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9110 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9112 /* Input mixer3 */
9113 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9114 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9118 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9120
9121 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9122
9123 { }
9124 };
9125
9126 #ifdef CONFIG_SND_HDA_POWER_SAVE
9127 #define alc262_loopbacks alc880_loopbacks
9128 #endif
9129
9130 /* pcm configuration: identiacal with ALC880 */
9131 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
9132 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
9133 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
9134 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
9135
9136 /*
9137 * BIOS auto configuration
9138 */
9139 static int alc262_parse_auto_config(struct hda_codec *codec)
9140 {
9141 struct alc_spec *spec = codec->spec;
9142 int err;
9143 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9144
9145 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9146 alc262_ignore);
9147 if (err < 0)
9148 return err;
9149 if (!spec->autocfg.line_outs)
9150 return 0; /* can't find valid BIOS pin config */
9151 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9152 if (err < 0)
9153 return err;
9154 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9155 if (err < 0)
9156 return err;
9157
9158 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9159
9160 if (spec->autocfg.dig_out_pin)
9161 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9162 if (spec->autocfg.dig_in_pin)
9163 spec->dig_in_nid = ALC262_DIGIN_NID;
9164
9165 if (spec->kctl_alloc)
9166 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9167
9168 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
9169 spec->num_mux_defs = 1;
9170 spec->input_mux = &spec->private_imux;
9171
9172 err = alc_auto_add_mic_boost(codec);
9173 if (err < 0)
9174 return err;
9175
9176 return 1;
9177 }
9178
9179 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
9180 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
9181 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
9182
9183
9184 /* init callback for auto-configuration model -- overriding the default init */
9185 static void alc262_auto_init(struct hda_codec *codec)
9186 {
9187 alc262_auto_init_multi_out(codec);
9188 alc262_auto_init_hp_out(codec);
9189 alc262_auto_init_analog_input(codec);
9190 }
9191
9192 /*
9193 * configuration and preset
9194 */
9195 static const char *alc262_models[ALC262_MODEL_LAST] = {
9196 [ALC262_BASIC] = "basic",
9197 [ALC262_HIPPO] = "hippo",
9198 [ALC262_HIPPO_1] = "hippo_1",
9199 [ALC262_FUJITSU] = "fujitsu",
9200 [ALC262_HP_BPC] = "hp-bpc",
9201 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
9202 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
9203 [ALC262_HP_RP5700] = "hp-rp5700",
9204 [ALC262_BENQ_ED8] = "benq",
9205 [ALC262_BENQ_T31] = "benq-t31",
9206 [ALC262_SONY_ASSAMD] = "sony-assamd",
9207 [ALC262_ULTRA] = "ultra",
9208 [ALC262_AUTO] = "auto",
9209 };
9210
9211 static struct snd_pci_quirk alc262_cfg_tbl[] = {
9212 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9213 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
9214 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
9215 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9216 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
9217 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
9218 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
9219 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
9220 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
9221 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
9222 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
9223 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
9224 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
9225 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
9226 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
9227 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
9228 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
9229 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9230 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9231 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
9232 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9233 ALC262_HP_TC_T5735),
9234 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
9235 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9236 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
9237 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9238 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9239 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
9240 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
9241 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
9242 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
9243 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
9244 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
9245 {}
9246 };
9247
9248 static struct alc_config_preset alc262_presets[] = {
9249 [ALC262_BASIC] = {
9250 .mixers = { alc262_base_mixer },
9251 .init_verbs = { alc262_init_verbs },
9252 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9253 .dac_nids = alc262_dac_nids,
9254 .hp_nid = 0x03,
9255 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9256 .channel_mode = alc262_modes,
9257 .input_mux = &alc262_capture_source,
9258 },
9259 [ALC262_HIPPO] = {
9260 .mixers = { alc262_base_mixer },
9261 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9262 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9263 .dac_nids = alc262_dac_nids,
9264 .hp_nid = 0x03,
9265 .dig_out_nid = ALC262_DIGOUT_NID,
9266 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9267 .channel_mode = alc262_modes,
9268 .input_mux = &alc262_capture_source,
9269 .unsol_event = alc262_hippo_unsol_event,
9270 .init_hook = alc262_hippo_automute,
9271 },
9272 [ALC262_HIPPO_1] = {
9273 .mixers = { alc262_hippo1_mixer },
9274 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9275 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9276 .dac_nids = alc262_dac_nids,
9277 .hp_nid = 0x02,
9278 .dig_out_nid = ALC262_DIGOUT_NID,
9279 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9280 .channel_mode = alc262_modes,
9281 .input_mux = &alc262_capture_source,
9282 .unsol_event = alc262_hippo1_unsol_event,
9283 .init_hook = alc262_hippo1_automute,
9284 },
9285 [ALC262_FUJITSU] = {
9286 .mixers = { alc262_fujitsu_mixer },
9287 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9288 alc262_fujitsu_unsol_verbs },
9289 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9290 .dac_nids = alc262_dac_nids,
9291 .hp_nid = 0x03,
9292 .dig_out_nid = ALC262_DIGOUT_NID,
9293 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9294 .channel_mode = alc262_modes,
9295 .input_mux = &alc262_fujitsu_capture_source,
9296 .unsol_event = alc262_fujitsu_unsol_event,
9297 },
9298 [ALC262_HP_BPC] = {
9299 .mixers = { alc262_HP_BPC_mixer },
9300 .init_verbs = { alc262_HP_BPC_init_verbs },
9301 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9302 .dac_nids = alc262_dac_nids,
9303 .hp_nid = 0x03,
9304 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9305 .channel_mode = alc262_modes,
9306 .input_mux = &alc262_HP_capture_source,
9307 .unsol_event = alc262_hp_bpc_unsol_event,
9308 .init_hook = alc262_hp_bpc_automute,
9309 },
9310 [ALC262_HP_BPC_D7000_WF] = {
9311 .mixers = { alc262_HP_BPC_WildWest_mixer },
9312 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9313 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9314 .dac_nids = alc262_dac_nids,
9315 .hp_nid = 0x03,
9316 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9317 .channel_mode = alc262_modes,
9318 .input_mux = &alc262_HP_D7000_capture_source,
9319 .unsol_event = alc262_hp_wildwest_unsol_event,
9320 .init_hook = alc262_hp_wildwest_automute,
9321 },
9322 [ALC262_HP_BPC_D7000_WL] = {
9323 .mixers = { alc262_HP_BPC_WildWest_mixer,
9324 alc262_HP_BPC_WildWest_option_mixer },
9325 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9326 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9327 .dac_nids = alc262_dac_nids,
9328 .hp_nid = 0x03,
9329 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9330 .channel_mode = alc262_modes,
9331 .input_mux = &alc262_HP_D7000_capture_source,
9332 .unsol_event = alc262_hp_wildwest_unsol_event,
9333 .init_hook = alc262_hp_wildwest_automute,
9334 },
9335 [ALC262_HP_TC_T5735] = {
9336 .mixers = { alc262_hp_t5735_mixer },
9337 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9338 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9339 .dac_nids = alc262_dac_nids,
9340 .hp_nid = 0x03,
9341 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9342 .channel_mode = alc262_modes,
9343 .input_mux = &alc262_capture_source,
9344 .unsol_event = alc262_hp_t5735_unsol_event,
9345 .init_hook = alc262_hp_t5735_init_hook,
9346 },
9347 [ALC262_HP_RP5700] = {
9348 .mixers = { alc262_hp_rp5700_mixer },
9349 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9350 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9351 .dac_nids = alc262_dac_nids,
9352 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9353 .channel_mode = alc262_modes,
9354 .input_mux = &alc262_hp_rp5700_capture_source,
9355 },
9356 [ALC262_BENQ_ED8] = {
9357 .mixers = { alc262_base_mixer },
9358 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9359 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9360 .dac_nids = alc262_dac_nids,
9361 .hp_nid = 0x03,
9362 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9363 .channel_mode = alc262_modes,
9364 .input_mux = &alc262_capture_source,
9365 },
9366 [ALC262_SONY_ASSAMD] = {
9367 .mixers = { alc262_sony_mixer },
9368 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9369 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9370 .dac_nids = alc262_dac_nids,
9371 .hp_nid = 0x02,
9372 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9373 .channel_mode = alc262_modes,
9374 .input_mux = &alc262_capture_source,
9375 .unsol_event = alc262_hippo_unsol_event,
9376 .init_hook = alc262_hippo_automute,
9377 },
9378 [ALC262_BENQ_T31] = {
9379 .mixers = { alc262_benq_t31_mixer },
9380 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9381 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9382 .dac_nids = alc262_dac_nids,
9383 .hp_nid = 0x03,
9384 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9385 .channel_mode = alc262_modes,
9386 .input_mux = &alc262_capture_source,
9387 .unsol_event = alc262_hippo_unsol_event,
9388 .init_hook = alc262_hippo_automute,
9389 },
9390 [ALC262_ULTRA] = {
9391 .mixers = { alc262_ultra_mixer },
9392 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9393 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9394 .dac_nids = alc262_dac_nids,
9395 .hp_nid = 0x03,
9396 .dig_out_nid = ALC262_DIGOUT_NID,
9397 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9398 .channel_mode = alc262_modes,
9399 .input_mux = &alc262_ultra_capture_source,
9400 .unsol_event = alc262_ultra_unsol_event,
9401 .init_hook = alc262_ultra_automute,
9402 },
9403 };
9404
9405 static int patch_alc262(struct hda_codec *codec)
9406 {
9407 struct alc_spec *spec;
9408 int board_config;
9409 int err;
9410
9411 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9412 if (spec == NULL)
9413 return -ENOMEM;
9414
9415 codec->spec = spec;
9416 #if 0
9417 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9418 * under-run
9419 */
9420 {
9421 int tmp;
9422 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9423 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9424 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9425 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9426 }
9427 #endif
9428
9429 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9430 alc262_models,
9431 alc262_cfg_tbl);
9432
9433 if (board_config < 0) {
9434 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9435 "trying auto-probe from BIOS...\n");
9436 board_config = ALC262_AUTO;
9437 }
9438
9439 if (board_config == ALC262_AUTO) {
9440 /* automatic parse from the BIOS config */
9441 err = alc262_parse_auto_config(codec);
9442 if (err < 0) {
9443 alc_free(codec);
9444 return err;
9445 } else if (!err) {
9446 printk(KERN_INFO
9447 "hda_codec: Cannot set up configuration "
9448 "from BIOS. Using base mode...\n");
9449 board_config = ALC262_BASIC;
9450 }
9451 }
9452
9453 if (board_config != ALC262_AUTO)
9454 setup_preset(spec, &alc262_presets[board_config]);
9455
9456 spec->stream_name_analog = "ALC262 Analog";
9457 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9458 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9459
9460 spec->stream_name_digital = "ALC262 Digital";
9461 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9462 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9463
9464 if (!spec->adc_nids && spec->input_mux) {
9465 /* check whether NID 0x07 is valid */
9466 unsigned int wcap = get_wcaps(codec, 0x07);
9467
9468 /* get type */
9469 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9470 if (wcap != AC_WID_AUD_IN) {
9471 spec->adc_nids = alc262_adc_nids_alt;
9472 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
9473 spec->mixers[spec->num_mixers] =
9474 alc262_capture_alt_mixer;
9475 spec->num_mixers++;
9476 } else {
9477 spec->adc_nids = alc262_adc_nids;
9478 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9479 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9480 spec->num_mixers++;
9481 }
9482 }
9483
9484 spec->vmaster_nid = 0x0c;
9485
9486 codec->patch_ops = alc_patch_ops;
9487 if (board_config == ALC262_AUTO)
9488 spec->init_hook = alc262_auto_init;
9489 #ifdef CONFIG_SND_HDA_POWER_SAVE
9490 if (!spec->loopback.amplist)
9491 spec->loopback.amplist = alc262_loopbacks;
9492 #endif
9493
9494 return 0;
9495 }
9496
9497 /*
9498 * ALC268 channel source setting (2 channel)
9499 */
9500 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9501 #define alc268_modes alc260_modes
9502
9503 static hda_nid_t alc268_dac_nids[2] = {
9504 /* front, hp */
9505 0x02, 0x03
9506 };
9507
9508 static hda_nid_t alc268_adc_nids[2] = {
9509 /* ADC0-1 */
9510 0x08, 0x07
9511 };
9512
9513 static hda_nid_t alc268_adc_nids_alt[1] = {
9514 /* ADC0 */
9515 0x08
9516 };
9517
9518 static struct snd_kcontrol_new alc268_base_mixer[] = {
9519 /* output mixer control */
9520 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9521 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9522 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9523 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9524 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9525 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9526 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
9527 { }
9528 };
9529
9530 static struct hda_verb alc268_eapd_verbs[] = {
9531 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9532 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9533 { }
9534 };
9535
9536 /* Toshiba specific */
9537 #define alc268_toshiba_automute alc262_hippo_automute
9538
9539 static struct hda_verb alc268_toshiba_verbs[] = {
9540 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9541 { } /* end */
9542 };
9543
9544 /* Acer specific */
9545 /* bind volumes of both NID 0x02 and 0x03 */
9546 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9547 .ops = &snd_hda_bind_vol,
9548 .values = {
9549 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9550 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9551 0
9552 },
9553 };
9554
9555 /* mute/unmute internal speaker according to the hp jack and mute state */
9556 static void alc268_acer_automute(struct hda_codec *codec, int force)
9557 {
9558 struct alc_spec *spec = codec->spec;
9559 unsigned int mute;
9560
9561 if (force || !spec->sense_updated) {
9562 unsigned int present;
9563 present = snd_hda_codec_read(codec, 0x14, 0,
9564 AC_VERB_GET_PIN_SENSE, 0);
9565 spec->jack_present = (present & 0x80000000) != 0;
9566 spec->sense_updated = 1;
9567 }
9568 if (spec->jack_present)
9569 mute = HDA_AMP_MUTE; /* mute internal speaker */
9570 else /* unmute internal speaker if necessary */
9571 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9572 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9573 HDA_AMP_MUTE, mute);
9574 }
9575
9576
9577 /* bind hp and internal speaker mute (with plug check) */
9578 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9579 struct snd_ctl_elem_value *ucontrol)
9580 {
9581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9582 long *valp = ucontrol->value.integer.value;
9583 int change;
9584
9585 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9586 HDA_AMP_MUTE,
9587 valp[0] ? 0 : HDA_AMP_MUTE);
9588 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9589 HDA_AMP_MUTE,
9590 valp[1] ? 0 : HDA_AMP_MUTE);
9591 if (change)
9592 alc268_acer_automute(codec, 0);
9593 return change;
9594 }
9595
9596 static struct snd_kcontrol_new alc268_acer_mixer[] = {
9597 /* output mixer control */
9598 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9599 {
9600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9601 .name = "Master Playback Switch",
9602 .info = snd_hda_mixer_amp_switch_info,
9603 .get = snd_hda_mixer_amp_switch_get,
9604 .put = alc268_acer_master_sw_put,
9605 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9606 },
9607 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9608 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9609 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
9610 { }
9611 };
9612
9613 static struct hda_verb alc268_acer_verbs[] = {
9614 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9615 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9616
9617 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9618 { }
9619 };
9620
9621 /* unsolicited event for HP jack sensing */
9622 static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9623 unsigned int res)
9624 {
9625 if ((res >> 26) != ALC880_HP_EVENT)
9626 return;
9627 alc268_toshiba_automute(codec);
9628 }
9629
9630 static void alc268_acer_unsol_event(struct hda_codec *codec,
9631 unsigned int res)
9632 {
9633 if ((res >> 26) != ALC880_HP_EVENT)
9634 return;
9635 alc268_acer_automute(codec, 1);
9636 }
9637
9638 static void alc268_acer_init_hook(struct hda_codec *codec)
9639 {
9640 alc268_acer_automute(codec, 1);
9641 }
9642
9643 static struct snd_kcontrol_new alc268_dell_mixer[] = {
9644 /* output mixer control */
9645 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9646 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9647 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9648 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9649 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9650 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9651 { }
9652 };
9653
9654 static struct hda_verb alc268_dell_verbs[] = {
9655 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9657 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9658 { }
9659 };
9660
9661 /* mute/unmute internal speaker according to the hp jack and mute state */
9662 static void alc268_dell_automute(struct hda_codec *codec)
9663 {
9664 unsigned int present;
9665 unsigned int mute;
9666
9667 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9668 if (present & 0x80000000)
9669 mute = HDA_AMP_MUTE;
9670 else
9671 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9672 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9673 HDA_AMP_MUTE, mute);
9674 }
9675
9676 static void alc268_dell_unsol_event(struct hda_codec *codec,
9677 unsigned int res)
9678 {
9679 if ((res >> 26) != ALC880_HP_EVENT)
9680 return;
9681 alc268_dell_automute(codec);
9682 }
9683
9684 #define alc268_dell_init_hook alc268_dell_automute
9685
9686 /*
9687 * generic initialization of ADC, input mixers and output mixers
9688 */
9689 static struct hda_verb alc268_base_init_verbs[] = {
9690 /* Unmute DAC0-1 and set vol = 0 */
9691 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9692 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9693 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9694 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9695 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9696 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9697
9698 /*
9699 * Set up output mixers (0x0c - 0x0e)
9700 */
9701 /* set vol=0 to output mixers */
9702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9704 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9705 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9706
9707 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9708 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9709
9710 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9712 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9713 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9714 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9715 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9716 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9717 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9718
9719 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9720 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9721 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9722 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9723 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9724 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9725 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9726 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9727
9728 /* Unmute Selector 23h,24h and set the default input to mic-in */
9729
9730 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9731 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9732 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9734
9735 { }
9736 };
9737
9738 /*
9739 * generic initialization of ADC, input mixers and output mixers
9740 */
9741 static struct hda_verb alc268_volume_init_verbs[] = {
9742 /* set output DAC */
9743 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9744 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9745 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9746 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9747
9748 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9749 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9750 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9751 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9752 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9753
9754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9757 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9758 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9759
9760 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9761 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9762 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9763 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9764
9765 /* set PCBEEP vol = 0 */
9766 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9767
9768 { }
9769 };
9770
9771 #define alc268_mux_enum_info alc_mux_enum_info
9772 #define alc268_mux_enum_get alc_mux_enum_get
9773
9774 static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9775 struct snd_ctl_elem_value *ucontrol)
9776 {
9777 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9778 struct alc_spec *spec = codec->spec;
9779
9780 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9781 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9782 hda_nid_t nid = capture_mixers[adc_idx];
9783
9784 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9785 nid,
9786 &spec->cur_mux[adc_idx]);
9787 }
9788
9789 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9790 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9791 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9792 {
9793 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9794 /* The multiple "Capture Source" controls confuse alsamixer
9795 * So call somewhat different..
9796 */
9797 /* .name = "Capture Source", */
9798 .name = "Input Source",
9799 .count = 1,
9800 .info = alc268_mux_enum_info,
9801 .get = alc268_mux_enum_get,
9802 .put = alc268_mux_enum_put,
9803 },
9804 { } /* end */
9805 };
9806
9807 static struct snd_kcontrol_new alc268_capture_mixer[] = {
9808 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9809 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9810 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9811 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9812 {
9813 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9814 /* The multiple "Capture Source" controls confuse alsamixer
9815 * So call somewhat different..
9816 */
9817 /* .name = "Capture Source", */
9818 .name = "Input Source",
9819 .count = 2,
9820 .info = alc268_mux_enum_info,
9821 .get = alc268_mux_enum_get,
9822 .put = alc268_mux_enum_put,
9823 },
9824 { } /* end */
9825 };
9826
9827 static struct hda_input_mux alc268_capture_source = {
9828 .num_items = 4,
9829 .items = {
9830 { "Mic", 0x0 },
9831 { "Front Mic", 0x1 },
9832 { "Line", 0x2 },
9833 { "CD", 0x3 },
9834 },
9835 };
9836
9837 #ifdef CONFIG_SND_DEBUG
9838 static struct snd_kcontrol_new alc268_test_mixer[] = {
9839 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9840 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9841 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9843
9844 /* Volume widgets */
9845 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9846 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9847 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9848 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9849 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9850 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9851 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9852 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9853 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9854 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9855 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9856 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9857 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
9858 /* The below appears problematic on some hardwares */
9859 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
9860 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9861 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9862 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9863 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9864
9865 /* Modes for retasking pin widgets */
9866 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9867 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9868 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9869 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9870
9871 /* Controls for GPIO pins, assuming they are configured as outputs */
9872 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9873 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9874 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9875 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9876
9877 /* Switches to allow the digital SPDIF output pin to be enabled.
9878 * The ALC268 does not have an SPDIF input.
9879 */
9880 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9881
9882 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9883 * this output to turn on an external amplifier.
9884 */
9885 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9886 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9887
9888 { } /* end */
9889 };
9890 #endif
9891
9892 /* create input playback/capture controls for the given pin */
9893 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9894 const char *ctlname, int idx)
9895 {
9896 char name[32];
9897 int err;
9898
9899 sprintf(name, "%s Playback Volume", ctlname);
9900 if (nid == 0x14) {
9901 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9902 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9903 HDA_OUTPUT));
9904 if (err < 0)
9905 return err;
9906 } else if (nid == 0x15) {
9907 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9908 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9909 HDA_OUTPUT));
9910 if (err < 0)
9911 return err;
9912 } else
9913 return -1;
9914 sprintf(name, "%s Playback Switch", ctlname);
9915 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9916 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9917 if (err < 0)
9918 return err;
9919 return 0;
9920 }
9921
9922 /* add playback controls from the parsed DAC table */
9923 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9924 const struct auto_pin_cfg *cfg)
9925 {
9926 hda_nid_t nid;
9927 int err;
9928
9929 spec->multiout.num_dacs = 2; /* only use one dac */
9930 spec->multiout.dac_nids = spec->private_dac_nids;
9931 spec->multiout.dac_nids[0] = 2;
9932 spec->multiout.dac_nids[1] = 3;
9933
9934 nid = cfg->line_out_pins[0];
9935 if (nid)
9936 alc268_new_analog_output(spec, nid, "Front", 0);
9937
9938 nid = cfg->speaker_pins[0];
9939 if (nid == 0x1d) {
9940 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9941 "Speaker Playback Volume",
9942 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9943 if (err < 0)
9944 return err;
9945 }
9946 nid = cfg->hp_pins[0];
9947 if (nid)
9948 alc268_new_analog_output(spec, nid, "Headphone", 0);
9949
9950 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9951 if (nid == 0x16) {
9952 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9953 "Mono Playback Switch",
9954 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9955 if (err < 0)
9956 return err;
9957 }
9958 return 0;
9959 }
9960
9961 /* create playback/capture controls for input pins */
9962 static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9963 const struct auto_pin_cfg *cfg)
9964 {
9965 struct hda_input_mux *imux = &spec->private_imux;
9966 int i, idx1;
9967
9968 for (i = 0; i < AUTO_PIN_LAST; i++) {
9969 switch(cfg->input_pins[i]) {
9970 case 0x18:
9971 idx1 = 0; /* Mic 1 */
9972 break;
9973 case 0x19:
9974 idx1 = 1; /* Mic 2 */
9975 break;
9976 case 0x1a:
9977 idx1 = 2; /* Line In */
9978 break;
9979 case 0x1c:
9980 idx1 = 3; /* CD */
9981 break;
9982 default:
9983 continue;
9984 }
9985 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9986 imux->items[imux->num_items].index = idx1;
9987 imux->num_items++;
9988 }
9989 return 0;
9990 }
9991
9992 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9993 {
9994 struct alc_spec *spec = codec->spec;
9995 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9996 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9997 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9998 unsigned int dac_vol1, dac_vol2;
9999
10000 if (speaker_nid) {
10001 snd_hda_codec_write(codec, speaker_nid, 0,
10002 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10003 snd_hda_codec_write(codec, 0x0f, 0,
10004 AC_VERB_SET_AMP_GAIN_MUTE,
10005 AMP_IN_UNMUTE(1));
10006 snd_hda_codec_write(codec, 0x10, 0,
10007 AC_VERB_SET_AMP_GAIN_MUTE,
10008 AMP_IN_UNMUTE(1));
10009 } else {
10010 snd_hda_codec_write(codec, 0x0f, 0,
10011 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10012 snd_hda_codec_write(codec, 0x10, 0,
10013 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10014 }
10015
10016 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10017 if (line_nid == 0x14)
10018 dac_vol2 = AMP_OUT_ZERO;
10019 else if (line_nid == 0x15)
10020 dac_vol1 = AMP_OUT_ZERO;
10021 if (hp_nid == 0x14)
10022 dac_vol2 = AMP_OUT_ZERO;
10023 else if (hp_nid == 0x15)
10024 dac_vol1 = AMP_OUT_ZERO;
10025 if (line_nid != 0x16 || hp_nid != 0x16 ||
10026 spec->autocfg.line_out_pins[1] != 0x16 ||
10027 spec->autocfg.line_out_pins[2] != 0x16)
10028 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10029
10030 snd_hda_codec_write(codec, 0x02, 0,
10031 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10032 snd_hda_codec_write(codec, 0x03, 0,
10033 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10034 }
10035
10036 /* pcm configuration: identiacal with ALC880 */
10037 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
10038 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
10039 #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
10040 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
10041
10042 /*
10043 * BIOS auto configuration
10044 */
10045 static int alc268_parse_auto_config(struct hda_codec *codec)
10046 {
10047 struct alc_spec *spec = codec->spec;
10048 int err;
10049 static hda_nid_t alc268_ignore[] = { 0 };
10050
10051 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10052 alc268_ignore);
10053 if (err < 0)
10054 return err;
10055 if (!spec->autocfg.line_outs)
10056 return 0; /* can't find valid BIOS pin config */
10057
10058 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10059 if (err < 0)
10060 return err;
10061 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10062 if (err < 0)
10063 return err;
10064
10065 spec->multiout.max_channels = 2;
10066
10067 /* digital only support output */
10068 if (spec->autocfg.dig_out_pin)
10069 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10070
10071 if (spec->kctl_alloc)
10072 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10073
10074 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10075 spec->num_mux_defs = 1;
10076 spec->input_mux = &spec->private_imux;
10077
10078 err = alc_auto_add_mic_boost(codec);
10079 if (err < 0)
10080 return err;
10081
10082 return 1;
10083 }
10084
10085 #define alc268_auto_init_multi_out alc882_auto_init_multi_out
10086 #define alc268_auto_init_hp_out alc882_auto_init_hp_out
10087 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
10088
10089 /* init callback for auto-configuration model -- overriding the default init */
10090 static void alc268_auto_init(struct hda_codec *codec)
10091 {
10092 alc268_auto_init_multi_out(codec);
10093 alc268_auto_init_hp_out(codec);
10094 alc268_auto_init_mono_speaker_out(codec);
10095 alc268_auto_init_analog_input(codec);
10096 }
10097
10098 /*
10099 * configuration and preset
10100 */
10101 static const char *alc268_models[ALC268_MODEL_LAST] = {
10102 [ALC268_3ST] = "3stack",
10103 [ALC268_TOSHIBA] = "toshiba",
10104 [ALC268_ACER] = "acer",
10105 [ALC268_DELL] = "dell",
10106 #ifdef CONFIG_SND_DEBUG
10107 [ALC268_TEST] = "test",
10108 #endif
10109 [ALC268_AUTO] = "auto",
10110 };
10111
10112 static struct snd_pci_quirk alc268_cfg_tbl[] = {
10113 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
10114 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
10115 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
10116 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
10117 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
10118 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
10119 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
10120 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
10121 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
10122 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
10123 {}
10124 };
10125
10126 static struct alc_config_preset alc268_presets[] = {
10127 [ALC268_3ST] = {
10128 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
10129 .init_verbs = { alc268_base_init_verbs },
10130 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10131 .dac_nids = alc268_dac_nids,
10132 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10133 .adc_nids = alc268_adc_nids_alt,
10134 .hp_nid = 0x03,
10135 .dig_out_nid = ALC268_DIGOUT_NID,
10136 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10137 .channel_mode = alc268_modes,
10138 .input_mux = &alc268_capture_source,
10139 },
10140 [ALC268_TOSHIBA] = {
10141 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
10142 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10143 alc268_toshiba_verbs },
10144 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10145 .dac_nids = alc268_dac_nids,
10146 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10147 .adc_nids = alc268_adc_nids_alt,
10148 .hp_nid = 0x03,
10149 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10150 .channel_mode = alc268_modes,
10151 .input_mux = &alc268_capture_source,
10152 .unsol_event = alc268_toshiba_unsol_event,
10153 .init_hook = alc268_toshiba_automute,
10154 },
10155 [ALC268_ACER] = {
10156 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
10157 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10158 alc268_acer_verbs },
10159 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10160 .dac_nids = alc268_dac_nids,
10161 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10162 .adc_nids = alc268_adc_nids_alt,
10163 .hp_nid = 0x02,
10164 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10165 .channel_mode = alc268_modes,
10166 .input_mux = &alc268_capture_source,
10167 .unsol_event = alc268_acer_unsol_event,
10168 .init_hook = alc268_acer_init_hook,
10169 },
10170 [ALC268_DELL] = {
10171 .mixers = { alc268_dell_mixer },
10172 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10173 alc268_dell_verbs },
10174 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10175 .dac_nids = alc268_dac_nids,
10176 .hp_nid = 0x02,
10177 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10178 .channel_mode = alc268_modes,
10179 .unsol_event = alc268_dell_unsol_event,
10180 .init_hook = alc268_dell_init_hook,
10181 .input_mux = &alc268_capture_source,
10182 },
10183 #ifdef CONFIG_SND_DEBUG
10184 [ALC268_TEST] = {
10185 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10186 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10187 alc268_volume_init_verbs },
10188 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10189 .dac_nids = alc268_dac_nids,
10190 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10191 .adc_nids = alc268_adc_nids_alt,
10192 .hp_nid = 0x03,
10193 .dig_out_nid = ALC268_DIGOUT_NID,
10194 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10195 .channel_mode = alc268_modes,
10196 .input_mux = &alc268_capture_source,
10197 },
10198 #endif
10199 };
10200
10201 static int patch_alc268(struct hda_codec *codec)
10202 {
10203 struct alc_spec *spec;
10204 int board_config;
10205 int err;
10206
10207 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10208 if (spec == NULL)
10209 return -ENOMEM;
10210
10211 codec->spec = spec;
10212
10213 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10214 alc268_models,
10215 alc268_cfg_tbl);
10216
10217 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10218 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10219 "trying auto-probe from BIOS...\n");
10220 board_config = ALC268_AUTO;
10221 }
10222
10223 if (board_config == ALC268_AUTO) {
10224 /* automatic parse from the BIOS config */
10225 err = alc268_parse_auto_config(codec);
10226 if (err < 0) {
10227 alc_free(codec);
10228 return err;
10229 } else if (!err) {
10230 printk(KERN_INFO
10231 "hda_codec: Cannot set up configuration "
10232 "from BIOS. Using base mode...\n");
10233 board_config = ALC268_3ST;
10234 }
10235 }
10236
10237 if (board_config != ALC268_AUTO)
10238 setup_preset(spec, &alc268_presets[board_config]);
10239
10240 spec->stream_name_analog = "ALC268 Analog";
10241 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10242 spec->stream_analog_capture = &alc268_pcm_analog_capture;
10243 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
10244
10245 spec->stream_name_digital = "ALC268 Digital";
10246 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10247
10248 if (!spec->adc_nids && spec->input_mux) {
10249 /* check whether NID 0x07 is valid */
10250 unsigned int wcap = get_wcaps(codec, 0x07);
10251
10252 /* get type */
10253 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10254 if (wcap != AC_WID_AUD_IN) {
10255 spec->adc_nids = alc268_adc_nids_alt;
10256 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10257 spec->mixers[spec->num_mixers] =
10258 alc268_capture_alt_mixer;
10259 spec->num_mixers++;
10260 } else {
10261 spec->adc_nids = alc268_adc_nids;
10262 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10263 spec->mixers[spec->num_mixers] =
10264 alc268_capture_mixer;
10265 spec->num_mixers++;
10266 }
10267 }
10268
10269 spec->vmaster_nid = 0x02;
10270
10271 codec->patch_ops = alc_patch_ops;
10272 if (board_config == ALC268_AUTO)
10273 spec->init_hook = alc268_auto_init;
10274
10275 return 0;
10276 }
10277
10278 /*
10279 * ALC269 channel source setting (2 channel)
10280 */
10281 #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10282
10283 #define alc269_dac_nids alc260_dac_nids
10284
10285 static hda_nid_t alc269_adc_nids[1] = {
10286 /* ADC1 */
10287 0x07,
10288 };
10289
10290 #define alc269_modes alc260_modes
10291 #define alc269_capture_source alc880_lg_lw_capture_source
10292
10293 static struct snd_kcontrol_new alc269_base_mixer[] = {
10294 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10295 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10296 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10297 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10298 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10299 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10300 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10301 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10302 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10303 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10304 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10305 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10306 { } /* end */
10307 };
10308
10309 /* capture mixer elements */
10310 static struct snd_kcontrol_new alc269_capture_mixer[] = {
10311 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10312 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10313 {
10314 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10315 /* The multiple "Capture Source" controls confuse alsamixer
10316 * So call somewhat different..
10317 */
10318 /* .name = "Capture Source", */
10319 .name = "Input Source",
10320 .count = 1,
10321 .info = alc_mux_enum_info,
10322 .get = alc_mux_enum_get,
10323 .put = alc_mux_enum_put,
10324 },
10325 { } /* end */
10326 };
10327
10328 /*
10329 * generic initialization of ADC, input mixers and output mixers
10330 */
10331 static struct hda_verb alc269_init_verbs[] = {
10332 /*
10333 * Unmute ADC0 and set the default input to mic-in
10334 */
10335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10336
10337 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10338 * analog-loopback mixer widget
10339 * Note: PASD motherboards uses the Line In 2 as the input for
10340 * front panel mic (mic 2)
10341 */
10342 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10343 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10344 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10345 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10346 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10347 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10348
10349 /*
10350 * Set up output mixers (0x0c - 0x0e)
10351 */
10352 /* set vol=0 to output mixers */
10353 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10354 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10355
10356 /* set up input amps for analog loopback */
10357 /* Amp Indices: DAC = 0, mixer = 1 */
10358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10359 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10361 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10362 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10363 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10364
10365 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10367 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10368 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10369 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10370 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10371 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10372
10373 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10374 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10375 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10376 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10377 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10379 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10380
10381 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10382 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10383
10384 /* FIXME: use matrix-type input source selection */
10385 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10386 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10387 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10388 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10391
10392 /* set EAPD */
10393 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10394 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10395 { }
10396 };
10397
10398 /* add playback controls from the parsed DAC table */
10399 static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10400 const struct auto_pin_cfg *cfg)
10401 {
10402 hda_nid_t nid;
10403 int err;
10404
10405 spec->multiout.num_dacs = 1; /* only use one dac */
10406 spec->multiout.dac_nids = spec->private_dac_nids;
10407 spec->multiout.dac_nids[0] = 2;
10408
10409 nid = cfg->line_out_pins[0];
10410 if (nid) {
10411 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10412 "Front Playback Volume",
10413 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10414 if (err < 0)
10415 return err;
10416 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10417 "Front Playback Switch",
10418 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10419 if (err < 0)
10420 return err;
10421 }
10422
10423 nid = cfg->speaker_pins[0];
10424 if (nid) {
10425 if (!cfg->line_out_pins[0]) {
10426 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10427 "Speaker Playback Volume",
10428 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10429 HDA_OUTPUT));
10430 if (err < 0)
10431 return err;
10432 }
10433 if (nid == 0x16) {
10434 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10435 "Speaker Playback Switch",
10436 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10437 HDA_OUTPUT));
10438 if (err < 0)
10439 return err;
10440 } else {
10441 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10442 "Speaker Playback Switch",
10443 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10444 HDA_OUTPUT));
10445 if (err < 0)
10446 return err;
10447 }
10448 }
10449 nid = cfg->hp_pins[0];
10450 if (nid) {
10451 /* spec->multiout.hp_nid = 2; */
10452 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10453 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10454 "Headphone Playback Volume",
10455 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10456 HDA_OUTPUT));
10457 if (err < 0)
10458 return err;
10459 }
10460 if (nid == 0x16) {
10461 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10462 "Headphone Playback Switch",
10463 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10464 HDA_OUTPUT));
10465 if (err < 0)
10466 return err;
10467 } else {
10468 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10469 "Headphone Playback Switch",
10470 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10471 HDA_OUTPUT));
10472 if (err < 0)
10473 return err;
10474 }
10475 }
10476 return 0;
10477 }
10478
10479 #define alc269_auto_create_analog_input_ctls \
10480 alc880_auto_create_analog_input_ctls
10481
10482 #ifdef CONFIG_SND_HDA_POWER_SAVE
10483 #define alc269_loopbacks alc880_loopbacks
10484 #endif
10485
10486 /* pcm configuration: identiacal with ALC880 */
10487 #define alc269_pcm_analog_playback alc880_pcm_analog_playback
10488 #define alc269_pcm_analog_capture alc880_pcm_analog_capture
10489 #define alc269_pcm_digital_playback alc880_pcm_digital_playback
10490 #define alc269_pcm_digital_capture alc880_pcm_digital_capture
10491
10492 /*
10493 * BIOS auto configuration
10494 */
10495 static int alc269_parse_auto_config(struct hda_codec *codec)
10496 {
10497 struct alc_spec *spec = codec->spec;
10498 int err;
10499 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10500
10501 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10502 alc269_ignore);
10503 if (err < 0)
10504 return err;
10505
10506 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10507 if (err < 0)
10508 return err;
10509 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10510 if (err < 0)
10511 return err;
10512
10513 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10514
10515 if (spec->autocfg.dig_out_pin)
10516 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10517
10518 if (spec->kctl_alloc)
10519 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10520
10521 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10522 spec->num_mux_defs = 1;
10523 spec->input_mux = &spec->private_imux;
10524
10525 err = alc_auto_add_mic_boost(codec);
10526 if (err < 0)
10527 return err;
10528
10529 return 1;
10530 }
10531
10532 #define alc269_auto_init_multi_out alc882_auto_init_multi_out
10533 #define alc269_auto_init_hp_out alc882_auto_init_hp_out
10534 #define alc269_auto_init_analog_input alc882_auto_init_analog_input
10535
10536
10537 /* init callback for auto-configuration model -- overriding the default init */
10538 static void alc269_auto_init(struct hda_codec *codec)
10539 {
10540 alc269_auto_init_multi_out(codec);
10541 alc269_auto_init_hp_out(codec);
10542 alc269_auto_init_analog_input(codec);
10543 }
10544
10545 /*
10546 * configuration and preset
10547 */
10548 static const char *alc269_models[ALC269_MODEL_LAST] = {
10549 [ALC269_BASIC] = "basic",
10550 };
10551
10552 static struct snd_pci_quirk alc269_cfg_tbl[] = {
10553 {}
10554 };
10555
10556 static struct alc_config_preset alc269_presets[] = {
10557 [ALC269_BASIC] = {
10558 .mixers = { alc269_base_mixer },
10559 .init_verbs = { alc269_init_verbs },
10560 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10561 .dac_nids = alc269_dac_nids,
10562 .hp_nid = 0x03,
10563 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10564 .channel_mode = alc269_modes,
10565 .input_mux = &alc269_capture_source,
10566 },
10567 };
10568
10569 static int patch_alc269(struct hda_codec *codec)
10570 {
10571 struct alc_spec *spec;
10572 int board_config;
10573 int err;
10574
10575 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10576 if (spec == NULL)
10577 return -ENOMEM;
10578
10579 codec->spec = spec;
10580
10581 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10582 alc269_models,
10583 alc269_cfg_tbl);
10584
10585 if (board_config < 0) {
10586 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10587 "trying auto-probe from BIOS...\n");
10588 board_config = ALC269_AUTO;
10589 }
10590
10591 if (board_config == ALC269_AUTO) {
10592 /* automatic parse from the BIOS config */
10593 err = alc269_parse_auto_config(codec);
10594 if (err < 0) {
10595 alc_free(codec);
10596 return err;
10597 } else if (!err) {
10598 printk(KERN_INFO
10599 "hda_codec: Cannot set up configuration "
10600 "from BIOS. Using base mode...\n");
10601 board_config = ALC269_BASIC;
10602 }
10603 }
10604
10605 if (board_config != ALC269_AUTO)
10606 setup_preset(spec, &alc269_presets[board_config]);
10607
10608 spec->stream_name_analog = "ALC269 Analog";
10609 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10610 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10611
10612 spec->stream_name_digital = "ALC269 Digital";
10613 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10614 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10615
10616 spec->adc_nids = alc269_adc_nids;
10617 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10618 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10619 spec->num_mixers++;
10620
10621 codec->patch_ops = alc_patch_ops;
10622 if (board_config == ALC269_AUTO)
10623 spec->init_hook = alc269_auto_init;
10624 #ifdef CONFIG_SND_HDA_POWER_SAVE
10625 if (!spec->loopback.amplist)
10626 spec->loopback.amplist = alc269_loopbacks;
10627 #endif
10628
10629 return 0;
10630 }
10631
10632 /*
10633 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10634 */
10635
10636 /*
10637 * set the path ways for 2 channel output
10638 * need to set the codec line out and mic 1 pin widgets to inputs
10639 */
10640 static struct hda_verb alc861_threestack_ch2_init[] = {
10641 /* set pin widget 1Ah (line in) for input */
10642 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10643 /* set pin widget 18h (mic1/2) for input, for mic also enable
10644 * the vref
10645 */
10646 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10647
10648 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10649 #if 0
10650 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10651 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10652 #endif
10653 { } /* end */
10654 };
10655 /*
10656 * 6ch mode
10657 * need to set the codec line out and mic 1 pin widgets to outputs
10658 */
10659 static struct hda_verb alc861_threestack_ch6_init[] = {
10660 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10661 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10662 /* set pin widget 18h (mic1) for output (CLFE)*/
10663 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10664
10665 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10666 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10667
10668 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10669 #if 0
10670 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10671 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10672 #endif
10673 { } /* end */
10674 };
10675
10676 static struct hda_channel_mode alc861_threestack_modes[2] = {
10677 { 2, alc861_threestack_ch2_init },
10678 { 6, alc861_threestack_ch6_init },
10679 };
10680 /* Set mic1 as input and unmute the mixer */
10681 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10682 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10683 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10684 { } /* end */
10685 };
10686 /* Set mic1 as output and mute mixer */
10687 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10688 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10689 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10690 { } /* end */
10691 };
10692
10693 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10694 { 2, alc861_uniwill_m31_ch2_init },
10695 { 4, alc861_uniwill_m31_ch4_init },
10696 };
10697
10698 /* Set mic1 and line-in as input and unmute the mixer */
10699 static struct hda_verb alc861_asus_ch2_init[] = {
10700 /* set pin widget 1Ah (line in) for input */
10701 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10702 /* set pin widget 18h (mic1/2) for input, for mic also enable
10703 * the vref
10704 */
10705 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10706
10707 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10708 #if 0
10709 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10710 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10711 #endif
10712 { } /* end */
10713 };
10714 /* Set mic1 nad line-in as output and mute mixer */
10715 static struct hda_verb alc861_asus_ch6_init[] = {
10716 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10717 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10718 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10719 /* set pin widget 18h (mic1) for output (CLFE)*/
10720 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10721 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10722 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10723 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10724
10725 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10726 #if 0
10727 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10728 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10729 #endif
10730 { } /* end */
10731 };
10732
10733 static struct hda_channel_mode alc861_asus_modes[2] = {
10734 { 2, alc861_asus_ch2_init },
10735 { 6, alc861_asus_ch6_init },
10736 };
10737
10738 /* patch-ALC861 */
10739
10740 static struct snd_kcontrol_new alc861_base_mixer[] = {
10741 /* output mixer control */
10742 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10743 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10744 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10745 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10746 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10747
10748 /*Input mixer control */
10749 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10750 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10751 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10752 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10753 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10754 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10756 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10757 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10759
10760 /* Capture mixer control */
10761 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10762 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10763 {
10764 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10765 .name = "Capture Source",
10766 .count = 1,
10767 .info = alc_mux_enum_info,
10768 .get = alc_mux_enum_get,
10769 .put = alc_mux_enum_put,
10770 },
10771 { } /* end */
10772 };
10773
10774 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10775 /* output mixer control */
10776 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10777 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10778 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10779 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10780 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10781
10782 /* Input mixer control */
10783 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10784 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10785 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10786 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10787 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10788 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10789 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10790 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10791 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10792 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10793
10794 /* Capture mixer control */
10795 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10796 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10797 {
10798 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10799 .name = "Capture Source",
10800 .count = 1,
10801 .info = alc_mux_enum_info,
10802 .get = alc_mux_enum_get,
10803 .put = alc_mux_enum_put,
10804 },
10805 {
10806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10807 .name = "Channel Mode",
10808 .info = alc_ch_mode_info,
10809 .get = alc_ch_mode_get,
10810 .put = alc_ch_mode_put,
10811 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10812 },
10813 { } /* end */
10814 };
10815
10816 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
10817 /* output mixer control */
10818 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10820 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10821
10822 /*Capture mixer control */
10823 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10824 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10825 {
10826 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10827 .name = "Capture Source",
10828 .count = 1,
10829 .info = alc_mux_enum_info,
10830 .get = alc_mux_enum_get,
10831 .put = alc_mux_enum_put,
10832 },
10833
10834 { } /* end */
10835 };
10836
10837 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10838 /* output mixer control */
10839 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10840 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10841 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10842 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10843 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10844
10845 /* Input mixer control */
10846 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10847 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10848 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10849 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10850 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10851 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10853 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10854 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10855 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10856
10857 /* Capture mixer control */
10858 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10859 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10860 {
10861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10862 .name = "Capture Source",
10863 .count = 1,
10864 .info = alc_mux_enum_info,
10865 .get = alc_mux_enum_get,
10866 .put = alc_mux_enum_put,
10867 },
10868 {
10869 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10870 .name = "Channel Mode",
10871 .info = alc_ch_mode_info,
10872 .get = alc_ch_mode_get,
10873 .put = alc_ch_mode_put,
10874 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10875 },
10876 { } /* end */
10877 };
10878
10879 static struct snd_kcontrol_new alc861_asus_mixer[] = {
10880 /* output mixer control */
10881 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10882 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10883 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10884 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10885 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10886
10887 /* Input mixer control */
10888 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10889 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10890 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10891 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10892 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10893 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10894 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10895 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10896 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10898
10899 /* Capture mixer control */
10900 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10901 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10902 {
10903 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10904 .name = "Capture Source",
10905 .count = 1,
10906 .info = alc_mux_enum_info,
10907 .get = alc_mux_enum_get,
10908 .put = alc_mux_enum_put,
10909 },
10910 {
10911 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10912 .name = "Channel Mode",
10913 .info = alc_ch_mode_info,
10914 .get = alc_ch_mode_get,
10915 .put = alc_ch_mode_put,
10916 .private_value = ARRAY_SIZE(alc861_asus_modes),
10917 },
10918 { }
10919 };
10920
10921 /* additional mixer */
10922 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
10923 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10924 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10925 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10926 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10927 { }
10928 };
10929
10930 /*
10931 * generic initialization of ADC, input mixers and output mixers
10932 */
10933 static struct hda_verb alc861_base_init_verbs[] = {
10934 /*
10935 * Unmute ADC0 and set the default input to mic-in
10936 */
10937 /* port-A for surround (rear panel) */
10938 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10939 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10940 /* port-B for mic-in (rear panel) with vref */
10941 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10942 /* port-C for line-in (rear panel) */
10943 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10944 /* port-D for Front */
10945 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10946 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10947 /* port-E for HP out (front panel) */
10948 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10949 /* route front PCM to HP */
10950 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10951 /* port-F for mic-in (front panel) with vref */
10952 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10953 /* port-G for CLFE (rear panel) */
10954 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10955 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10956 /* port-H for side (rear panel) */
10957 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10958 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10959 /* CD-in */
10960 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10961 /* route front mic to ADC1*/
10962 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10963 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10964
10965 /* Unmute DAC0~3 & spdif out*/
10966 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10967 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10968 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10969 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10971
10972 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10973 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10974 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10975 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10976 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10977
10978 /* Unmute Stereo Mixer 15 */
10979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10982 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
10983
10984 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10985 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10986 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10987 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10988 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10989 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10990 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10991 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10992 /* hp used DAC 3 (Front) */
10993 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10994 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10995
10996 { }
10997 };
10998
10999 static struct hda_verb alc861_threestack_init_verbs[] = {
11000 /*
11001 * Unmute ADC0 and set the default input to mic-in
11002 */
11003 /* port-A for surround (rear panel) */
11004 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11005 /* port-B for mic-in (rear panel) with vref */
11006 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11007 /* port-C for line-in (rear panel) */
11008 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11009 /* port-D for Front */
11010 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11011 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11012 /* port-E for HP out (front panel) */
11013 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11014 /* route front PCM to HP */
11015 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11016 /* port-F for mic-in (front panel) with vref */
11017 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11018 /* port-G for CLFE (rear panel) */
11019 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11020 /* port-H for side (rear panel) */
11021 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11022 /* CD-in */
11023 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11024 /* route front mic to ADC1*/
11025 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11026 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11027 /* Unmute DAC0~3 & spdif out*/
11028 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11029 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11030 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11031 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11033
11034 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11035 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11036 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11037 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11038 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11039
11040 /* Unmute Stereo Mixer 15 */
11041 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11042 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11043 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11044 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11045
11046 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11047 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11048 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11049 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11050 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11051 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11052 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11053 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11054 /* hp used DAC 3 (Front) */
11055 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11056 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11057 { }
11058 };
11059
11060 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11061 /*
11062 * Unmute ADC0 and set the default input to mic-in
11063 */
11064 /* port-A for surround (rear panel) */
11065 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11066 /* port-B for mic-in (rear panel) with vref */
11067 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11068 /* port-C for line-in (rear panel) */
11069 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11070 /* port-D for Front */
11071 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11072 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11073 /* port-E for HP out (front panel) */
11074 /* this has to be set to VREF80 */
11075 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11076 /* route front PCM to HP */
11077 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11078 /* port-F for mic-in (front panel) with vref */
11079 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11080 /* port-G for CLFE (rear panel) */
11081 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11082 /* port-H for side (rear panel) */
11083 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11084 /* CD-in */
11085 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11086 /* route front mic to ADC1*/
11087 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11088 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11089 /* Unmute DAC0~3 & spdif out*/
11090 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11091 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11092 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11093 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11094 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11095
11096 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11097 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11098 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11099 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11100 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11101
11102 /* Unmute Stereo Mixer 15 */
11103 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11104 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11105 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11106 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11107
11108 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11109 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11110 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11111 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11112 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11113 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11114 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11115 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11116 /* hp used DAC 3 (Front) */
11117 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11118 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11119 { }
11120 };
11121
11122 static struct hda_verb alc861_asus_init_verbs[] = {
11123 /*
11124 * Unmute ADC0 and set the default input to mic-in
11125 */
11126 /* port-A for surround (rear panel)
11127 * according to codec#0 this is the HP jack
11128 */
11129 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11130 /* route front PCM to HP */
11131 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11132 /* port-B for mic-in (rear panel) with vref */
11133 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11134 /* port-C for line-in (rear panel) */
11135 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11136 /* port-D for Front */
11137 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11138 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11139 /* port-E for HP out (front panel) */
11140 /* this has to be set to VREF80 */
11141 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11142 /* route front PCM to HP */
11143 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11144 /* port-F for mic-in (front panel) with vref */
11145 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11146 /* port-G for CLFE (rear panel) */
11147 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11148 /* port-H for side (rear panel) */
11149 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11150 /* CD-in */
11151 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11152 /* route front mic to ADC1*/
11153 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11154 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11155 /* Unmute DAC0~3 & spdif out*/
11156 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11157 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11158 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11159 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11161 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11162 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11163 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11164 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11165 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11166
11167 /* Unmute Stereo Mixer 15 */
11168 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11169 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11170 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11171 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11172
11173 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11174 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11175 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11176 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11177 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11178 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11179 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11180 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11181 /* hp used DAC 3 (Front) */
11182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11183 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11184 { }
11185 };
11186
11187 /* additional init verbs for ASUS laptops */
11188 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11189 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11190 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11191 { }
11192 };
11193
11194 /*
11195 * generic initialization of ADC, input mixers and output mixers
11196 */
11197 static struct hda_verb alc861_auto_init_verbs[] = {
11198 /*
11199 * Unmute ADC0 and set the default input to mic-in
11200 */
11201 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
11202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11203
11204 /* Unmute DAC0~3 & spdif out*/
11205 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11206 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11207 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11208 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11210
11211 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11212 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11213 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11214 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11215 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11216
11217 /* Unmute Stereo Mixer 15 */
11218 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11222
11223 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11224 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11225 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11226 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11227 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11228 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11229 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11230 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11231
11232 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11233 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11234 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11235 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11236 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11237 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11238 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11239 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11240
11241 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
11242
11243 { }
11244 };
11245
11246 static struct hda_verb alc861_toshiba_init_verbs[] = {
11247 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11248
11249 { }
11250 };
11251
11252 /* toggle speaker-output according to the hp-jack state */
11253 static void alc861_toshiba_automute(struct hda_codec *codec)
11254 {
11255 unsigned int present;
11256
11257 present = snd_hda_codec_read(codec, 0x0f, 0,
11258 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11259 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11260 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11261 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11262 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
11263 }
11264
11265 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11266 unsigned int res)
11267 {
11268 if ((res >> 26) == ALC880_HP_EVENT)
11269 alc861_toshiba_automute(codec);
11270 }
11271
11272 /* pcm configuration: identiacal with ALC880 */
11273 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
11274 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
11275 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
11276 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
11277
11278
11279 #define ALC861_DIGOUT_NID 0x07
11280
11281 static struct hda_channel_mode alc861_8ch_modes[1] = {
11282 { 8, NULL }
11283 };
11284
11285 static hda_nid_t alc861_dac_nids[4] = {
11286 /* front, surround, clfe, side */
11287 0x03, 0x06, 0x05, 0x04
11288 };
11289
11290 static hda_nid_t alc660_dac_nids[3] = {
11291 /* front, clfe, surround */
11292 0x03, 0x05, 0x06
11293 };
11294
11295 static hda_nid_t alc861_adc_nids[1] = {
11296 /* ADC0-2 */
11297 0x08,
11298 };
11299
11300 static struct hda_input_mux alc861_capture_source = {
11301 .num_items = 5,
11302 .items = {
11303 { "Mic", 0x0 },
11304 { "Front Mic", 0x3 },
11305 { "Line", 0x1 },
11306 { "CD", 0x4 },
11307 { "Mixer", 0x5 },
11308 },
11309 };
11310
11311 /* fill in the dac_nids table from the parsed pin configuration */
11312 static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11313 const struct auto_pin_cfg *cfg)
11314 {
11315 int i;
11316 hda_nid_t nid;
11317
11318 spec->multiout.dac_nids = spec->private_dac_nids;
11319 for (i = 0; i < cfg->line_outs; i++) {
11320 nid = cfg->line_out_pins[i];
11321 if (nid) {
11322 if (i >= ARRAY_SIZE(alc861_dac_nids))
11323 continue;
11324 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11325 }
11326 }
11327 spec->multiout.num_dacs = cfg->line_outs;
11328 return 0;
11329 }
11330
11331 /* add playback controls from the parsed DAC table */
11332 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11333 const struct auto_pin_cfg *cfg)
11334 {
11335 char name[32];
11336 static const char *chname[4] = {
11337 "Front", "Surround", NULL /*CLFE*/, "Side"
11338 };
11339 hda_nid_t nid;
11340 int i, idx, err;
11341
11342 for (i = 0; i < cfg->line_outs; i++) {
11343 nid = spec->multiout.dac_nids[i];
11344 if (!nid)
11345 continue;
11346 if (nid == 0x05) {
11347 /* Center/LFE */
11348 err = add_control(spec, ALC_CTL_BIND_MUTE,
11349 "Center Playback Switch",
11350 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11351 HDA_OUTPUT));
11352 if (err < 0)
11353 return err;
11354 err = add_control(spec, ALC_CTL_BIND_MUTE,
11355 "LFE Playback Switch",
11356 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11357 HDA_OUTPUT));
11358 if (err < 0)
11359 return err;
11360 } else {
11361 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11362 idx++)
11363 if (nid == alc861_dac_nids[idx])
11364 break;
11365 sprintf(name, "%s Playback Switch", chname[idx]);
11366 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11367 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11368 HDA_OUTPUT));
11369 if (err < 0)
11370 return err;
11371 }
11372 }
11373 return 0;
11374 }
11375
11376 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11377 {
11378 int err;
11379 hda_nid_t nid;
11380
11381 if (!pin)
11382 return 0;
11383
11384 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11385 nid = 0x03;
11386 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11387 "Headphone Playback Switch",
11388 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11389 if (err < 0)
11390 return err;
11391 spec->multiout.hp_nid = nid;
11392 }
11393 return 0;
11394 }
11395
11396 /* create playback/capture controls for input pins */
11397 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11398 const struct auto_pin_cfg *cfg)
11399 {
11400 struct hda_input_mux *imux = &spec->private_imux;
11401 int i, err, idx, idx1;
11402
11403 for (i = 0; i < AUTO_PIN_LAST; i++) {
11404 switch (cfg->input_pins[i]) {
11405 case 0x0c:
11406 idx1 = 1;
11407 idx = 2; /* Line In */
11408 break;
11409 case 0x0f:
11410 idx1 = 2;
11411 idx = 2; /* Line In */
11412 break;
11413 case 0x0d:
11414 idx1 = 0;
11415 idx = 1; /* Mic In */
11416 break;
11417 case 0x10:
11418 idx1 = 3;
11419 idx = 1; /* Mic In */
11420 break;
11421 case 0x11:
11422 idx1 = 4;
11423 idx = 0; /* CD */
11424 break;
11425 default:
11426 continue;
11427 }
11428
11429 err = new_analog_input(spec, cfg->input_pins[i],
11430 auto_pin_cfg_labels[i], idx, 0x15);
11431 if (err < 0)
11432 return err;
11433
11434 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11435 imux->items[imux->num_items].index = idx1;
11436 imux->num_items++;
11437 }
11438 return 0;
11439 }
11440
11441 static struct snd_kcontrol_new alc861_capture_mixer[] = {
11442 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11443 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11444
11445 {
11446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11447 /* The multiple "Capture Source" controls confuse alsamixer
11448 * So call somewhat different..
11449 */
11450 /* .name = "Capture Source", */
11451 .name = "Input Source",
11452 .count = 1,
11453 .info = alc_mux_enum_info,
11454 .get = alc_mux_enum_get,
11455 .put = alc_mux_enum_put,
11456 },
11457 { } /* end */
11458 };
11459
11460 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11461 hda_nid_t nid,
11462 int pin_type, int dac_idx)
11463 {
11464 /* set as output */
11465
11466 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11467 pin_type);
11468 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11469 AMP_OUT_UNMUTE);
11470
11471 }
11472
11473 static void alc861_auto_init_multi_out(struct hda_codec *codec)
11474 {
11475 struct alc_spec *spec = codec->spec;
11476 int i;
11477
11478 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
11479 for (i = 0; i < spec->autocfg.line_outs; i++) {
11480 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11481 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11482 if (nid)
11483 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
11484 spec->multiout.dac_nids[i]);
11485 }
11486 }
11487
11488 static void alc861_auto_init_hp_out(struct hda_codec *codec)
11489 {
11490 struct alc_spec *spec = codec->spec;
11491 hda_nid_t pin;
11492
11493 pin = spec->autocfg.hp_pins[0];
11494 if (pin) /* connect to front */
11495 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11496 spec->multiout.dac_nids[0]);
11497 }
11498
11499 static void alc861_auto_init_analog_input(struct hda_codec *codec)
11500 {
11501 struct alc_spec *spec = codec->spec;
11502 int i;
11503
11504 for (i = 0; i < AUTO_PIN_LAST; i++) {
11505 hda_nid_t nid = spec->autocfg.input_pins[i];
11506 if (nid >= 0x0c && nid <= 0x11) {
11507 snd_hda_codec_write(codec, nid, 0,
11508 AC_VERB_SET_PIN_WIDGET_CONTROL,
11509 i <= AUTO_PIN_FRONT_MIC ?
11510 PIN_VREF80 : PIN_IN);
11511 }
11512 }
11513 }
11514
11515 /* parse the BIOS configuration and set up the alc_spec */
11516 /* return 1 if successful, 0 if the proper config is not found,
11517 * or a negative error code
11518 */
11519 static int alc861_parse_auto_config(struct hda_codec *codec)
11520 {
11521 struct alc_spec *spec = codec->spec;
11522 int err;
11523 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11524
11525 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11526 alc861_ignore);
11527 if (err < 0)
11528 return err;
11529 if (!spec->autocfg.line_outs)
11530 return 0; /* can't find valid BIOS pin config */
11531
11532 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11533 if (err < 0)
11534 return err;
11535 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11536 if (err < 0)
11537 return err;
11538 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11539 if (err < 0)
11540 return err;
11541 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11542 if (err < 0)
11543 return err;
11544
11545 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11546
11547 if (spec->autocfg.dig_out_pin)
11548 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11549
11550 if (spec->kctl_alloc)
11551 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11552
11553 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11554
11555 spec->num_mux_defs = 1;
11556 spec->input_mux = &spec->private_imux;
11557
11558 spec->adc_nids = alc861_adc_nids;
11559 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11560 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11561 spec->num_mixers++;
11562
11563 return 1;
11564 }
11565
11566 /* additional initialization for auto-configuration model */
11567 static void alc861_auto_init(struct hda_codec *codec)
11568 {
11569 alc861_auto_init_multi_out(codec);
11570 alc861_auto_init_hp_out(codec);
11571 alc861_auto_init_analog_input(codec);
11572 }
11573
11574 #ifdef CONFIG_SND_HDA_POWER_SAVE
11575 static struct hda_amp_list alc861_loopbacks[] = {
11576 { 0x15, HDA_INPUT, 0 },
11577 { 0x15, HDA_INPUT, 1 },
11578 { 0x15, HDA_INPUT, 2 },
11579 { 0x15, HDA_INPUT, 3 },
11580 { } /* end */
11581 };
11582 #endif
11583
11584
11585 /*
11586 * configuration and preset
11587 */
11588 static const char *alc861_models[ALC861_MODEL_LAST] = {
11589 [ALC861_3ST] = "3stack",
11590 [ALC660_3ST] = "3stack-660",
11591 [ALC861_3ST_DIG] = "3stack-dig",
11592 [ALC861_6ST_DIG] = "6stack-dig",
11593 [ALC861_UNIWILL_M31] = "uniwill-m31",
11594 [ALC861_TOSHIBA] = "toshiba",
11595 [ALC861_ASUS] = "asus",
11596 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11597 [ALC861_AUTO] = "auto",
11598 };
11599
11600 static struct snd_pci_quirk alc861_cfg_tbl[] = {
11601 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
11602 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11603 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11604 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
11605 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
11606 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
11607 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
11608 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11609 * Any other models that need this preset?
11610 */
11611 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
11612 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11613 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
11614 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11615 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11616 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11617 /* FIXME: the below seems conflict */
11618 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11619 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11620 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
11621 {}
11622 };
11623
11624 static struct alc_config_preset alc861_presets[] = {
11625 [ALC861_3ST] = {
11626 .mixers = { alc861_3ST_mixer },
11627 .init_verbs = { alc861_threestack_init_verbs },
11628 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11629 .dac_nids = alc861_dac_nids,
11630 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11631 .channel_mode = alc861_threestack_modes,
11632 .need_dac_fix = 1,
11633 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11634 .adc_nids = alc861_adc_nids,
11635 .input_mux = &alc861_capture_source,
11636 },
11637 [ALC861_3ST_DIG] = {
11638 .mixers = { alc861_base_mixer },
11639 .init_verbs = { alc861_threestack_init_verbs },
11640 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11641 .dac_nids = alc861_dac_nids,
11642 .dig_out_nid = ALC861_DIGOUT_NID,
11643 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11644 .channel_mode = alc861_threestack_modes,
11645 .need_dac_fix = 1,
11646 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11647 .adc_nids = alc861_adc_nids,
11648 .input_mux = &alc861_capture_source,
11649 },
11650 [ALC861_6ST_DIG] = {
11651 .mixers = { alc861_base_mixer },
11652 .init_verbs = { alc861_base_init_verbs },
11653 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11654 .dac_nids = alc861_dac_nids,
11655 .dig_out_nid = ALC861_DIGOUT_NID,
11656 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11657 .channel_mode = alc861_8ch_modes,
11658 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11659 .adc_nids = alc861_adc_nids,
11660 .input_mux = &alc861_capture_source,
11661 },
11662 [ALC660_3ST] = {
11663 .mixers = { alc861_3ST_mixer },
11664 .init_verbs = { alc861_threestack_init_verbs },
11665 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11666 .dac_nids = alc660_dac_nids,
11667 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11668 .channel_mode = alc861_threestack_modes,
11669 .need_dac_fix = 1,
11670 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11671 .adc_nids = alc861_adc_nids,
11672 .input_mux = &alc861_capture_source,
11673 },
11674 [ALC861_UNIWILL_M31] = {
11675 .mixers = { alc861_uniwill_m31_mixer },
11676 .init_verbs = { alc861_uniwill_m31_init_verbs },
11677 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11678 .dac_nids = alc861_dac_nids,
11679 .dig_out_nid = ALC861_DIGOUT_NID,
11680 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11681 .channel_mode = alc861_uniwill_m31_modes,
11682 .need_dac_fix = 1,
11683 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11684 .adc_nids = alc861_adc_nids,
11685 .input_mux = &alc861_capture_source,
11686 },
11687 [ALC861_TOSHIBA] = {
11688 .mixers = { alc861_toshiba_mixer },
11689 .init_verbs = { alc861_base_init_verbs,
11690 alc861_toshiba_init_verbs },
11691 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11692 .dac_nids = alc861_dac_nids,
11693 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11694 .channel_mode = alc883_3ST_2ch_modes,
11695 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11696 .adc_nids = alc861_adc_nids,
11697 .input_mux = &alc861_capture_source,
11698 .unsol_event = alc861_toshiba_unsol_event,
11699 .init_hook = alc861_toshiba_automute,
11700 },
11701 [ALC861_ASUS] = {
11702 .mixers = { alc861_asus_mixer },
11703 .init_verbs = { alc861_asus_init_verbs },
11704 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11705 .dac_nids = alc861_dac_nids,
11706 .dig_out_nid = ALC861_DIGOUT_NID,
11707 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11708 .channel_mode = alc861_asus_modes,
11709 .need_dac_fix = 1,
11710 .hp_nid = 0x06,
11711 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11712 .adc_nids = alc861_adc_nids,
11713 .input_mux = &alc861_capture_source,
11714 },
11715 [ALC861_ASUS_LAPTOP] = {
11716 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11717 .init_verbs = { alc861_asus_init_verbs,
11718 alc861_asus_laptop_init_verbs },
11719 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11720 .dac_nids = alc861_dac_nids,
11721 .dig_out_nid = ALC861_DIGOUT_NID,
11722 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11723 .channel_mode = alc883_3ST_2ch_modes,
11724 .need_dac_fix = 1,
11725 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11726 .adc_nids = alc861_adc_nids,
11727 .input_mux = &alc861_capture_source,
11728 },
11729 };
11730
11731
11732 static int patch_alc861(struct hda_codec *codec)
11733 {
11734 struct alc_spec *spec;
11735 int board_config;
11736 int err;
11737
11738 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11739 if (spec == NULL)
11740 return -ENOMEM;
11741
11742 codec->spec = spec;
11743
11744 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11745 alc861_models,
11746 alc861_cfg_tbl);
11747
11748 if (board_config < 0) {
11749 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11750 "trying auto-probe from BIOS...\n");
11751 board_config = ALC861_AUTO;
11752 }
11753
11754 if (board_config == ALC861_AUTO) {
11755 /* automatic parse from the BIOS config */
11756 err = alc861_parse_auto_config(codec);
11757 if (err < 0) {
11758 alc_free(codec);
11759 return err;
11760 } else if (!err) {
11761 printk(KERN_INFO
11762 "hda_codec: Cannot set up configuration "
11763 "from BIOS. Using base mode...\n");
11764 board_config = ALC861_3ST_DIG;
11765 }
11766 }
11767
11768 if (board_config != ALC861_AUTO)
11769 setup_preset(spec, &alc861_presets[board_config]);
11770
11771 spec->stream_name_analog = "ALC861 Analog";
11772 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11773 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11774
11775 spec->stream_name_digital = "ALC861 Digital";
11776 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11777 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11778
11779 spec->vmaster_nid = 0x03;
11780
11781 codec->patch_ops = alc_patch_ops;
11782 if (board_config == ALC861_AUTO)
11783 spec->init_hook = alc861_auto_init;
11784 #ifdef CONFIG_SND_HDA_POWER_SAVE
11785 if (!spec->loopback.amplist)
11786 spec->loopback.amplist = alc861_loopbacks;
11787 #endif
11788
11789 return 0;
11790 }
11791
11792 /*
11793 * ALC861-VD support
11794 *
11795 * Based on ALC882
11796 *
11797 * In addition, an independent DAC
11798 */
11799 #define ALC861VD_DIGOUT_NID 0x06
11800
11801 static hda_nid_t alc861vd_dac_nids[4] = {
11802 /* front, surr, clfe, side surr */
11803 0x02, 0x03, 0x04, 0x05
11804 };
11805
11806 /* dac_nids for ALC660vd are in a different order - according to
11807 * Realtek's driver.
11808 * This should probably tesult in a different mixer for 6stack models
11809 * of ALC660vd codecs, but for now there is only 3stack mixer
11810 * - and it is the same as in 861vd.
11811 * adc_nids in ALC660vd are (is) the same as in 861vd
11812 */
11813 static hda_nid_t alc660vd_dac_nids[3] = {
11814 /* front, rear, clfe, rear_surr */
11815 0x02, 0x04, 0x03
11816 };
11817
11818 static hda_nid_t alc861vd_adc_nids[1] = {
11819 /* ADC0 */
11820 0x09,
11821 };
11822
11823 /* input MUX */
11824 /* FIXME: should be a matrix-type input source selection */
11825 static struct hda_input_mux alc861vd_capture_source = {
11826 .num_items = 4,
11827 .items = {
11828 { "Mic", 0x0 },
11829 { "Front Mic", 0x1 },
11830 { "Line", 0x2 },
11831 { "CD", 0x4 },
11832 },
11833 };
11834
11835 static struct hda_input_mux alc861vd_dallas_capture_source = {
11836 .num_items = 3,
11837 .items = {
11838 { "Front Mic", 0x0 },
11839 { "ATAPI Mic", 0x1 },
11840 { "Line In", 0x5 },
11841 },
11842 };
11843
11844 static struct hda_input_mux alc861vd_hp_capture_source = {
11845 .num_items = 2,
11846 .items = {
11847 { "Front Mic", 0x0 },
11848 { "ATAPI Mic", 0x1 },
11849 },
11850 };
11851
11852 #define alc861vd_mux_enum_info alc_mux_enum_info
11853 #define alc861vd_mux_enum_get alc_mux_enum_get
11854
11855 static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11856 struct snd_ctl_elem_value *ucontrol)
11857 {
11858 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11859 struct alc_spec *spec = codec->spec;
11860 const struct hda_input_mux *imux = spec->input_mux;
11861 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11862 static hda_nid_t capture_mixers[1] = { 0x22 };
11863 hda_nid_t nid = capture_mixers[adc_idx];
11864 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11865 unsigned int i, idx;
11866
11867 idx = ucontrol->value.enumerated.item[0];
11868 if (idx >= imux->num_items)
11869 idx = imux->num_items - 1;
11870 if (*cur_val == idx)
11871 return 0;
11872 for (i = 0; i < imux->num_items; i++) {
11873 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11874 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11875 imux->items[i].index,
11876 HDA_AMP_MUTE, v);
11877 }
11878 *cur_val = idx;
11879 return 1;
11880 }
11881
11882 /*
11883 * 2ch mode
11884 */
11885 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11886 { 2, NULL }
11887 };
11888
11889 /*
11890 * 6ch mode
11891 */
11892 static struct hda_verb alc861vd_6stack_ch6_init[] = {
11893 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11894 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11895 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11896 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11897 { } /* end */
11898 };
11899
11900 /*
11901 * 8ch mode
11902 */
11903 static struct hda_verb alc861vd_6stack_ch8_init[] = {
11904 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11905 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11906 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11907 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11908 { } /* end */
11909 };
11910
11911 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11912 { 6, alc861vd_6stack_ch6_init },
11913 { 8, alc861vd_6stack_ch8_init },
11914 };
11915
11916 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11917 {
11918 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11919 .name = "Channel Mode",
11920 .info = alc_ch_mode_info,
11921 .get = alc_ch_mode_get,
11922 .put = alc_ch_mode_put,
11923 },
11924 { } /* end */
11925 };
11926
11927 static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11928 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11929 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11930
11931 {
11932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11933 /* The multiple "Capture Source" controls confuse alsamixer
11934 * So call somewhat different..
11935 */
11936 /* .name = "Capture Source", */
11937 .name = "Input Source",
11938 .count = 1,
11939 .info = alc861vd_mux_enum_info,
11940 .get = alc861vd_mux_enum_get,
11941 .put = alc861vd_mux_enum_put,
11942 },
11943 { } /* end */
11944 };
11945
11946 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11947 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11948 */
11949 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11950 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11951 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11952
11953 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11954 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11955
11956 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11957 HDA_OUTPUT),
11958 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11959 HDA_OUTPUT),
11960 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11961 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11962
11963 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11964 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11965
11966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11967
11968 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11971
11972 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11973 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11974 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11975
11976 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11977 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11978
11979 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11980 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11981
11982 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11983 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11984
11985 { } /* end */
11986 };
11987
11988 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11989 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11990 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11991
11992 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11993
11994 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11996 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11997
11998 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11999 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12000 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12001
12002 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12003 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12004
12005 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12006 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12007
12008 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12009 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12010
12011 { } /* end */
12012 };
12013
12014 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12015 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12016 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12017 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12018
12019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12020
12021 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12024
12025 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12026 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12027 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12028
12029 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12030 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12031
12032 { } /* end */
12033 };
12034
12035 /* Pin assignment: Front=0x14, HP = 0x15,
12036 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
12037 */
12038 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
12039 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12040 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12041 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12042 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12043 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12044 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12045 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12046 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12047 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
12048 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
12049 { } /* end */
12050 };
12051
12052 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
12053 * Front Mic=0x18, ATAPI Mic = 0x19,
12054 */
12055 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12056 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12057 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12058 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12059 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12060 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12061 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12062 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12063 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12064
12065 { } /* end */
12066 };
12067
12068 /*
12069 * generic initialization of ADC, input mixers and output mixers
12070 */
12071 static struct hda_verb alc861vd_volume_init_verbs[] = {
12072 /*
12073 * Unmute ADC0 and set the default input to mic-in
12074 */
12075 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12076 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12077
12078 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12079 * the analog-loopback mixer widget
12080 */
12081 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12087
12088 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
12089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
12093
12094 /*
12095 * Set up output mixers (0x02 - 0x05)
12096 */
12097 /* set vol=0 to output mixers */
12098 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12099 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12100 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12101 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12102
12103 /* set up input amps for analog loopback */
12104 /* Amp Indices: DAC = 0, mixer = 1 */
12105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12107 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12108 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12109 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12111 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12113
12114 { }
12115 };
12116
12117 /*
12118 * 3-stack pin configuration:
12119 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12120 */
12121 static struct hda_verb alc861vd_3stack_init_verbs[] = {
12122 /*
12123 * Set pin mode and muting
12124 */
12125 /* set front pin widgets 0x14 for output */
12126 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12127 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12128 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12129
12130 /* Mic (rear) pin: input vref at 80% */
12131 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12132 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12133 /* Front Mic pin: input vref at 80% */
12134 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12135 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12136 /* Line In pin: input */
12137 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12138 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12139 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12140 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12142 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12143 /* CD pin widget for input */
12144 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12145
12146 { }
12147 };
12148
12149 /*
12150 * 6-stack pin configuration:
12151 */
12152 static struct hda_verb alc861vd_6stack_init_verbs[] = {
12153 /*
12154 * Set pin mode and muting
12155 */
12156 /* set front pin widgets 0x14 for output */
12157 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12158 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12159 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12160
12161 /* Rear Pin: output 1 (0x0d) */
12162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12163 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12164 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12165 /* CLFE Pin: output 2 (0x0e) */
12166 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12167 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12168 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12169 /* Side Pin: output 3 (0x0f) */
12170 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12171 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12172 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12173
12174 /* Mic (rear) pin: input vref at 80% */
12175 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12176 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12177 /* Front Mic pin: input vref at 80% */
12178 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12179 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12180 /* Line In pin: input */
12181 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12183 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12185 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12186 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12187 /* CD pin widget for input */
12188 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12189
12190 { }
12191 };
12192
12193 static struct hda_verb alc861vd_eapd_verbs[] = {
12194 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12195 { }
12196 };
12197
12198 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12199 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12200 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12202 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12203 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12204 {}
12205 };
12206
12207 /* toggle speaker-output according to the hp-jack state */
12208 static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12209 {
12210 unsigned int present;
12211 unsigned char bits;
12212
12213 present = snd_hda_codec_read(codec, 0x1b, 0,
12214 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12215 bits = present ? HDA_AMP_MUTE : 0;
12216 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12217 HDA_AMP_MUTE, bits);
12218 }
12219
12220 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12221 {
12222 unsigned int present;
12223 unsigned char bits;
12224
12225 present = snd_hda_codec_read(codec, 0x18, 0,
12226 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12227 bits = present ? HDA_AMP_MUTE : 0;
12228 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12229 HDA_AMP_MUTE, bits);
12230 }
12231
12232 static void alc861vd_lenovo_automute(struct hda_codec *codec)
12233 {
12234 alc861vd_lenovo_hp_automute(codec);
12235 alc861vd_lenovo_mic_automute(codec);
12236 }
12237
12238 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12239 unsigned int res)
12240 {
12241 switch (res >> 26) {
12242 case ALC880_HP_EVENT:
12243 alc861vd_lenovo_hp_automute(codec);
12244 break;
12245 case ALC880_MIC_EVENT:
12246 alc861vd_lenovo_mic_automute(codec);
12247 break;
12248 }
12249 }
12250
12251 static struct hda_verb alc861vd_dallas_verbs[] = {
12252 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12253 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12254 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12255 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12256
12257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12259 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12260 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12261 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12262 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12263 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12264 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12265
12266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12267 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12269 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12270 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12271 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12272 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12273 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12274
12275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12276 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12277 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12278 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12279 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12280 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12281 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12282 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12283
12284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12288
12289 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12290 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12291 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12292
12293 { } /* end */
12294 };
12295
12296 /* toggle speaker-output according to the hp-jack state */
12297 static void alc861vd_dallas_automute(struct hda_codec *codec)
12298 {
12299 unsigned int present;
12300
12301 present = snd_hda_codec_read(codec, 0x15, 0,
12302 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12303 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12304 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12305 }
12306
12307 static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12308 {
12309 if ((res >> 26) == ALC880_HP_EVENT)
12310 alc861vd_dallas_automute(codec);
12311 }
12312
12313 #ifdef CONFIG_SND_HDA_POWER_SAVE
12314 #define alc861vd_loopbacks alc880_loopbacks
12315 #endif
12316
12317 /* pcm configuration: identiacal with ALC880 */
12318 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12319 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12320 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12321 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12322
12323 /*
12324 * configuration and preset
12325 */
12326 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12327 [ALC660VD_3ST] = "3stack-660",
12328 [ALC660VD_3ST_DIG] = "3stack-660-digout",
12329 [ALC861VD_3ST] = "3stack",
12330 [ALC861VD_3ST_DIG] = "3stack-digout",
12331 [ALC861VD_6ST_DIG] = "6stack-digout",
12332 [ALC861VD_LENOVO] = "lenovo",
12333 [ALC861VD_DALLAS] = "dallas",
12334 [ALC861VD_HP] = "hp",
12335 [ALC861VD_AUTO] = "auto",
12336 };
12337
12338 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
12339 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12340 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
12341 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
12342 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
12343 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
12344 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
12345 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
12346 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
12347 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
12348 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
12349 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
12350 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12351 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
12352 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
12353 {}
12354 };
12355
12356 static struct alc_config_preset alc861vd_presets[] = {
12357 [ALC660VD_3ST] = {
12358 .mixers = { alc861vd_3st_mixer },
12359 .init_verbs = { alc861vd_volume_init_verbs,
12360 alc861vd_3stack_init_verbs },
12361 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12362 .dac_nids = alc660vd_dac_nids,
12363 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12364 .adc_nids = alc861vd_adc_nids,
12365 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12366 .channel_mode = alc861vd_3stack_2ch_modes,
12367 .input_mux = &alc861vd_capture_source,
12368 },
12369 [ALC660VD_3ST_DIG] = {
12370 .mixers = { alc861vd_3st_mixer },
12371 .init_verbs = { alc861vd_volume_init_verbs,
12372 alc861vd_3stack_init_verbs },
12373 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12374 .dac_nids = alc660vd_dac_nids,
12375 .dig_out_nid = ALC861VD_DIGOUT_NID,
12376 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12377 .adc_nids = alc861vd_adc_nids,
12378 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12379 .channel_mode = alc861vd_3stack_2ch_modes,
12380 .input_mux = &alc861vd_capture_source,
12381 },
12382 [ALC861VD_3ST] = {
12383 .mixers = { alc861vd_3st_mixer },
12384 .init_verbs = { alc861vd_volume_init_verbs,
12385 alc861vd_3stack_init_verbs },
12386 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12387 .dac_nids = alc861vd_dac_nids,
12388 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12389 .channel_mode = alc861vd_3stack_2ch_modes,
12390 .input_mux = &alc861vd_capture_source,
12391 },
12392 [ALC861VD_3ST_DIG] = {
12393 .mixers = { alc861vd_3st_mixer },
12394 .init_verbs = { alc861vd_volume_init_verbs,
12395 alc861vd_3stack_init_verbs },
12396 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12397 .dac_nids = alc861vd_dac_nids,
12398 .dig_out_nid = ALC861VD_DIGOUT_NID,
12399 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12400 .channel_mode = alc861vd_3stack_2ch_modes,
12401 .input_mux = &alc861vd_capture_source,
12402 },
12403 [ALC861VD_6ST_DIG] = {
12404 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12405 .init_verbs = { alc861vd_volume_init_verbs,
12406 alc861vd_6stack_init_verbs },
12407 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12408 .dac_nids = alc861vd_dac_nids,
12409 .dig_out_nid = ALC861VD_DIGOUT_NID,
12410 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12411 .channel_mode = alc861vd_6stack_modes,
12412 .input_mux = &alc861vd_capture_source,
12413 },
12414 [ALC861VD_LENOVO] = {
12415 .mixers = { alc861vd_lenovo_mixer },
12416 .init_verbs = { alc861vd_volume_init_verbs,
12417 alc861vd_3stack_init_verbs,
12418 alc861vd_eapd_verbs,
12419 alc861vd_lenovo_unsol_verbs },
12420 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12421 .dac_nids = alc660vd_dac_nids,
12422 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12423 .adc_nids = alc861vd_adc_nids,
12424 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12425 .channel_mode = alc861vd_3stack_2ch_modes,
12426 .input_mux = &alc861vd_capture_source,
12427 .unsol_event = alc861vd_lenovo_unsol_event,
12428 .init_hook = alc861vd_lenovo_automute,
12429 },
12430 [ALC861VD_DALLAS] = {
12431 .mixers = { alc861vd_dallas_mixer },
12432 .init_verbs = { alc861vd_dallas_verbs },
12433 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12434 .dac_nids = alc861vd_dac_nids,
12435 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12436 .adc_nids = alc861vd_adc_nids,
12437 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12438 .channel_mode = alc861vd_3stack_2ch_modes,
12439 .input_mux = &alc861vd_dallas_capture_source,
12440 .unsol_event = alc861vd_dallas_unsol_event,
12441 .init_hook = alc861vd_dallas_automute,
12442 },
12443 [ALC861VD_HP] = {
12444 .mixers = { alc861vd_hp_mixer },
12445 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12446 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12447 .dac_nids = alc861vd_dac_nids,
12448 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12449 .dig_out_nid = ALC861VD_DIGOUT_NID,
12450 .adc_nids = alc861vd_adc_nids,
12451 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12452 .channel_mode = alc861vd_3stack_2ch_modes,
12453 .input_mux = &alc861vd_hp_capture_source,
12454 .unsol_event = alc861vd_dallas_unsol_event,
12455 .init_hook = alc861vd_dallas_automute,
12456 },
12457 };
12458
12459 /*
12460 * BIOS auto configuration
12461 */
12462 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12463 hda_nid_t nid, int pin_type, int dac_idx)
12464 {
12465 /* set as output */
12466 snd_hda_codec_write(codec, nid, 0,
12467 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12468 snd_hda_codec_write(codec, nid, 0,
12469 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12470 }
12471
12472 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12473 {
12474 struct alc_spec *spec = codec->spec;
12475 int i;
12476
12477 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
12478 for (i = 0; i <= HDA_SIDE; i++) {
12479 hda_nid_t nid = spec->autocfg.line_out_pins[i];
12480 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12481 if (nid)
12482 alc861vd_auto_set_output_and_unmute(codec, nid,
12483 pin_type, i);
12484 }
12485 }
12486
12487
12488 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12489 {
12490 struct alc_spec *spec = codec->spec;
12491 hda_nid_t pin;
12492
12493 pin = spec->autocfg.hp_pins[0];
12494 if (pin) /* connect to front and use dac 0 */
12495 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12496 }
12497
12498 #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12499 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12500
12501 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12502 {
12503 struct alc_spec *spec = codec->spec;
12504 int i;
12505
12506 for (i = 0; i < AUTO_PIN_LAST; i++) {
12507 hda_nid_t nid = spec->autocfg.input_pins[i];
12508 if (alc861vd_is_input_pin(nid)) {
12509 snd_hda_codec_write(codec, nid, 0,
12510 AC_VERB_SET_PIN_WIDGET_CONTROL,
12511 i <= AUTO_PIN_FRONT_MIC ?
12512 PIN_VREF80 : PIN_IN);
12513 if (nid != ALC861VD_PIN_CD_NID)
12514 snd_hda_codec_write(codec, nid, 0,
12515 AC_VERB_SET_AMP_GAIN_MUTE,
12516 AMP_OUT_MUTE);
12517 }
12518 }
12519 }
12520
12521 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12522 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12523
12524 /* add playback controls from the parsed DAC table */
12525 /* Based on ALC880 version. But ALC861VD has separate,
12526 * different NIDs for mute/unmute switch and volume control */
12527 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12528 const struct auto_pin_cfg *cfg)
12529 {
12530 char name[32];
12531 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12532 hda_nid_t nid_v, nid_s;
12533 int i, err;
12534
12535 for (i = 0; i < cfg->line_outs; i++) {
12536 if (!spec->multiout.dac_nids[i])
12537 continue;
12538 nid_v = alc861vd_idx_to_mixer_vol(
12539 alc880_dac_to_idx(
12540 spec->multiout.dac_nids[i]));
12541 nid_s = alc861vd_idx_to_mixer_switch(
12542 alc880_dac_to_idx(
12543 spec->multiout.dac_nids[i]));
12544
12545 if (i == 2) {
12546 /* Center/LFE */
12547 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12548 "Center Playback Volume",
12549 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12550 HDA_OUTPUT));
12551 if (err < 0)
12552 return err;
12553 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12554 "LFE Playback Volume",
12555 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12556 HDA_OUTPUT));
12557 if (err < 0)
12558 return err;
12559 err = add_control(spec, ALC_CTL_BIND_MUTE,
12560 "Center Playback Switch",
12561 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12562 HDA_INPUT));
12563 if (err < 0)
12564 return err;
12565 err = add_control(spec, ALC_CTL_BIND_MUTE,
12566 "LFE Playback Switch",
12567 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12568 HDA_INPUT));
12569 if (err < 0)
12570 return err;
12571 } else {
12572 sprintf(name, "%s Playback Volume", chname[i]);
12573 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12574 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12575 HDA_OUTPUT));
12576 if (err < 0)
12577 return err;
12578 sprintf(name, "%s Playback Switch", chname[i]);
12579 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12580 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
12581 HDA_INPUT));
12582 if (err < 0)
12583 return err;
12584 }
12585 }
12586 return 0;
12587 }
12588
12589 /* add playback controls for speaker and HP outputs */
12590 /* Based on ALC880 version. But ALC861VD has separate,
12591 * different NIDs for mute/unmute switch and volume control */
12592 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12593 hda_nid_t pin, const char *pfx)
12594 {
12595 hda_nid_t nid_v, nid_s;
12596 int err;
12597 char name[32];
12598
12599 if (!pin)
12600 return 0;
12601
12602 if (alc880_is_fixed_pin(pin)) {
12603 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12604 /* specify the DAC as the extra output */
12605 if (!spec->multiout.hp_nid)
12606 spec->multiout.hp_nid = nid_v;
12607 else
12608 spec->multiout.extra_out_nid[0] = nid_v;
12609 /* control HP volume/switch on the output mixer amp */
12610 nid_v = alc861vd_idx_to_mixer_vol(
12611 alc880_fixed_pin_idx(pin));
12612 nid_s = alc861vd_idx_to_mixer_switch(
12613 alc880_fixed_pin_idx(pin));
12614
12615 sprintf(name, "%s Playback Volume", pfx);
12616 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12617 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12618 if (err < 0)
12619 return err;
12620 sprintf(name, "%s Playback Switch", pfx);
12621 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12622 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12623 if (err < 0)
12624 return err;
12625 } else if (alc880_is_multi_pin(pin)) {
12626 /* set manual connection */
12627 /* we have only a switch on HP-out PIN */
12628 sprintf(name, "%s Playback Switch", pfx);
12629 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12630 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12631 if (err < 0)
12632 return err;
12633 }
12634 return 0;
12635 }
12636
12637 /* parse the BIOS configuration and set up the alc_spec
12638 * return 1 if successful, 0 if the proper config is not found,
12639 * or a negative error code
12640 * Based on ALC880 version - had to change it to override
12641 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12642 static int alc861vd_parse_auto_config(struct hda_codec *codec)
12643 {
12644 struct alc_spec *spec = codec->spec;
12645 int err;
12646 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12647
12648 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12649 alc861vd_ignore);
12650 if (err < 0)
12651 return err;
12652 if (!spec->autocfg.line_outs)
12653 return 0; /* can't find valid BIOS pin config */
12654
12655 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12656 if (err < 0)
12657 return err;
12658 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12659 if (err < 0)
12660 return err;
12661 err = alc861vd_auto_create_extra_out(spec,
12662 spec->autocfg.speaker_pins[0],
12663 "Speaker");
12664 if (err < 0)
12665 return err;
12666 err = alc861vd_auto_create_extra_out(spec,
12667 spec->autocfg.hp_pins[0],
12668 "Headphone");
12669 if (err < 0)
12670 return err;
12671 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12672 if (err < 0)
12673 return err;
12674
12675 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12676
12677 if (spec->autocfg.dig_out_pin)
12678 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12679
12680 if (spec->kctl_alloc)
12681 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12682
12683 spec->init_verbs[spec->num_init_verbs++]
12684 = alc861vd_volume_init_verbs;
12685
12686 spec->num_mux_defs = 1;
12687 spec->input_mux = &spec->private_imux;
12688
12689 err = alc_auto_add_mic_boost(codec);
12690 if (err < 0)
12691 return err;
12692
12693 return 1;
12694 }
12695
12696 /* additional initialization for auto-configuration model */
12697 static void alc861vd_auto_init(struct hda_codec *codec)
12698 {
12699 alc861vd_auto_init_multi_out(codec);
12700 alc861vd_auto_init_hp_out(codec);
12701 alc861vd_auto_init_analog_input(codec);
12702 }
12703
12704 static int patch_alc861vd(struct hda_codec *codec)
12705 {
12706 struct alc_spec *spec;
12707 int err, board_config;
12708
12709 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12710 if (spec == NULL)
12711 return -ENOMEM;
12712
12713 codec->spec = spec;
12714
12715 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12716 alc861vd_models,
12717 alc861vd_cfg_tbl);
12718
12719 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12720 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12721 "ALC861VD, trying auto-probe from BIOS...\n");
12722 board_config = ALC861VD_AUTO;
12723 }
12724
12725 if (board_config == ALC861VD_AUTO) {
12726 /* automatic parse from the BIOS config */
12727 err = alc861vd_parse_auto_config(codec);
12728 if (err < 0) {
12729 alc_free(codec);
12730 return err;
12731 } else if (!err) {
12732 printk(KERN_INFO
12733 "hda_codec: Cannot set up configuration "
12734 "from BIOS. Using base mode...\n");
12735 board_config = ALC861VD_3ST;
12736 }
12737 }
12738
12739 if (board_config != ALC861VD_AUTO)
12740 setup_preset(spec, &alc861vd_presets[board_config]);
12741
12742 spec->stream_name_analog = "ALC861VD Analog";
12743 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12744 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12745
12746 spec->stream_name_digital = "ALC861VD Digital";
12747 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12748 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12749
12750 spec->adc_nids = alc861vd_adc_nids;
12751 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12752
12753 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12754 spec->num_mixers++;
12755
12756 spec->vmaster_nid = 0x02;
12757
12758 codec->patch_ops = alc_patch_ops;
12759
12760 if (board_config == ALC861VD_AUTO)
12761 spec->init_hook = alc861vd_auto_init;
12762 #ifdef CONFIG_SND_HDA_POWER_SAVE
12763 if (!spec->loopback.amplist)
12764 spec->loopback.amplist = alc861vd_loopbacks;
12765 #endif
12766
12767 return 0;
12768 }
12769
12770 /*
12771 * ALC662 support
12772 *
12773 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12774 * configuration. Each pin widget can choose any input DACs and a mixer.
12775 * Each ADC is connected from a mixer of all inputs. This makes possible
12776 * 6-channel independent captures.
12777 *
12778 * In addition, an independent DAC for the multi-playback (not used in this
12779 * driver yet).
12780 */
12781 #define ALC662_DIGOUT_NID 0x06
12782 #define ALC662_DIGIN_NID 0x0a
12783
12784 static hda_nid_t alc662_dac_nids[4] = {
12785 /* front, rear, clfe, rear_surr */
12786 0x02, 0x03, 0x04
12787 };
12788
12789 static hda_nid_t alc662_adc_nids[1] = {
12790 /* ADC1-2 */
12791 0x09,
12792 };
12793 /* input MUX */
12794 /* FIXME: should be a matrix-type input source selection */
12795
12796 static struct hda_input_mux alc662_capture_source = {
12797 .num_items = 4,
12798 .items = {
12799 { "Mic", 0x0 },
12800 { "Front Mic", 0x1 },
12801 { "Line", 0x2 },
12802 { "CD", 0x4 },
12803 },
12804 };
12805
12806 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12807 .num_items = 2,
12808 .items = {
12809 { "Mic", 0x1 },
12810 { "Line", 0x2 },
12811 },
12812 };
12813
12814 static struct hda_input_mux alc662_eeepc_capture_source = {
12815 .num_items = 2,
12816 .items = {
12817 { "i-Mic", 0x1 },
12818 { "e-Mic", 0x0 },
12819 },
12820 };
12821
12822 #define alc662_mux_enum_info alc_mux_enum_info
12823 #define alc662_mux_enum_get alc_mux_enum_get
12824
12825 static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12826 struct snd_ctl_elem_value *ucontrol)
12827 {
12828 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12829 struct alc_spec *spec = codec->spec;
12830 const struct hda_input_mux *imux = spec->input_mux;
12831 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
12832 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
12833 hda_nid_t nid = capture_mixers[adc_idx];
12834 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12835 unsigned int i, idx;
12836
12837 idx = ucontrol->value.enumerated.item[0];
12838 if (idx >= imux->num_items)
12839 idx = imux->num_items - 1;
12840 if (*cur_val == idx)
12841 return 0;
12842 for (i = 0; i < imux->num_items; i++) {
12843 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12844 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12845 imux->items[i].index,
12846 HDA_AMP_MUTE, v);
12847 }
12848 *cur_val = idx;
12849 return 1;
12850 }
12851 /*
12852 * 2ch mode
12853 */
12854 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12855 { 2, NULL }
12856 };
12857
12858 /*
12859 * 2ch mode
12860 */
12861 static struct hda_verb alc662_3ST_ch2_init[] = {
12862 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12863 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12864 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12865 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12866 { } /* end */
12867 };
12868
12869 /*
12870 * 6ch mode
12871 */
12872 static struct hda_verb alc662_3ST_ch6_init[] = {
12873 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12874 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12875 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12876 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12877 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12878 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12879 { } /* end */
12880 };
12881
12882 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12883 { 2, alc662_3ST_ch2_init },
12884 { 6, alc662_3ST_ch6_init },
12885 };
12886
12887 /*
12888 * 2ch mode
12889 */
12890 static struct hda_verb alc662_sixstack_ch6_init[] = {
12891 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12892 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12893 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12894 { } /* end */
12895 };
12896
12897 /*
12898 * 6ch mode
12899 */
12900 static struct hda_verb alc662_sixstack_ch8_init[] = {
12901 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12902 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12903 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12904 { } /* end */
12905 };
12906
12907 static struct hda_channel_mode alc662_5stack_modes[2] = {
12908 { 2, alc662_sixstack_ch6_init },
12909 { 6, alc662_sixstack_ch8_init },
12910 };
12911
12912 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12913 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12914 */
12915
12916 static struct snd_kcontrol_new alc662_base_mixer[] = {
12917 /* output mixer control */
12918 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12919 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12920 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12921 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12922 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12923 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12924 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12925 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12926 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12927
12928 /*Input mixer control */
12929 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12930 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12931 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12932 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12933 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12934 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12935 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12936 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
12937 { } /* end */
12938 };
12939
12940 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12941 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12942 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12943 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12944 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12945 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12946 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12947 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12950 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12951 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12952 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12953 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12954 { } /* end */
12955 };
12956
12957 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12958 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12959 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12960 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12961 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12962 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12963 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12964 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12965 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12967 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12968 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12969 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12970 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12972 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12973 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12974 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12975 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12976 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12977 { } /* end */
12978 };
12979
12980 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12981 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12982 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12983 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12984 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
12985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12986 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12987 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12989 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12990 { } /* end */
12991 };
12992
12993 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
12994 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12995
12996 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12997 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12998
12999 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13000 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13001 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13002
13003 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13004 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13005 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13006 { } /* end */
13007 };
13008
13009 static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
13010 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13011 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13012 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13013 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13014 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13015 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13016 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13017 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
13018 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13019 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13020 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13021 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13024 { } /* end */
13025 };
13026
13027 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13028 {
13029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13030 .name = "Channel Mode",
13031 .info = alc_ch_mode_info,
13032 .get = alc_ch_mode_get,
13033 .put = alc_ch_mode_put,
13034 },
13035 { } /* end */
13036 };
13037
13038 static struct hda_verb alc662_init_verbs[] = {
13039 /* ADC: mute amp left and right */
13040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13041 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13042 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13043
13044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13047 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13048 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13049
13050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13051 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13052 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13053 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13055 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13056
13057 /* Front Pin: output 0 (0x0c) */
13058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13059 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13060
13061 /* Rear Pin: output 1 (0x0d) */
13062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13064
13065 /* CLFE Pin: output 2 (0x0e) */
13066 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13067 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13068
13069 /* Mic (rear) pin: input vref at 80% */
13070 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13071 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13072 /* Front Mic pin: input vref at 80% */
13073 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13074 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13075 /* Line In pin: input */
13076 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13077 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13078 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13079 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13080 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13081 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13082 /* CD pin widget for input */
13083 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13084
13085 /* FIXME: use matrix-type input source selection */
13086 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13087 /* Input mixer */
13088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
13092
13093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13096 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
13097 { }
13098 };
13099
13100 static struct hda_verb alc662_sue_init_verbs[] = {
13101 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13102 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
13103 {}
13104 };
13105
13106 static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13107 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13108 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13109 {}
13110 };
13111
13112 /* Set Unsolicited Event*/
13113 static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13115 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13116 {}
13117 };
13118
13119 /*
13120 * generic initialization of ADC, input mixers and output mixers
13121 */
13122 static struct hda_verb alc662_auto_init_verbs[] = {
13123 /*
13124 * Unmute ADC and set the default input to mic-in
13125 */
13126 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13127 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13128
13129 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13130 * mixer widget
13131 * Note: PASD motherboards uses the Line In 2 as the input for front
13132 * panel mic (mic 2)
13133 */
13134 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13136 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13139 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13140
13141 /*
13142 * Set up output mixers (0x0c - 0x0f)
13143 */
13144 /* set vol=0 to output mixers */
13145 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13146 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13147 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13148
13149 /* set up input amps for analog loopback */
13150 /* Amp Indices: DAC = 0, mixer = 1 */
13151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13152 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13153 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13154 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13155 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13156 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13157
13158
13159 /* FIXME: use matrix-type input source selection */
13160 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13161 /* Input mixer */
13162 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13163 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13164 { }
13165 };
13166
13167 /* capture mixer elements */
13168 static struct snd_kcontrol_new alc662_capture_mixer[] = {
13169 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13170 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13171 {
13172 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13173 /* The multiple "Capture Source" controls confuse alsamixer
13174 * So call somewhat different..
13175 */
13176 /* .name = "Capture Source", */
13177 .name = "Input Source",
13178 .count = 1,
13179 .info = alc662_mux_enum_info,
13180 .get = alc662_mux_enum_get,
13181 .put = alc662_mux_enum_put,
13182 },
13183 { } /* end */
13184 };
13185
13186 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13187 {
13188 unsigned int present;
13189 unsigned char bits;
13190
13191 present = snd_hda_codec_read(codec, 0x14, 0,
13192 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13193 bits = present ? HDA_AMP_MUTE : 0;
13194 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13195 HDA_AMP_MUTE, bits);
13196 }
13197
13198 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13199 {
13200 unsigned int present;
13201 unsigned char bits;
13202
13203 present = snd_hda_codec_read(codec, 0x1b, 0,
13204 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13205 bits = present ? HDA_AMP_MUTE : 0;
13206 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13207 HDA_AMP_MUTE, bits);
13208 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13209 HDA_AMP_MUTE, bits);
13210 }
13211
13212 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13213 unsigned int res)
13214 {
13215 if ((res >> 26) == ALC880_HP_EVENT)
13216 alc662_lenovo_101e_all_automute(codec);
13217 if ((res >> 26) == ALC880_FRONT_EVENT)
13218 alc662_lenovo_101e_ispeaker_automute(codec);
13219 }
13220
13221 static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13222 {
13223 unsigned int present;
13224
13225 present = snd_hda_codec_read(codec, 0x18, 0,
13226 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13227 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13228 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13229 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13230 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13231 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13232 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13233 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13234 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13235 }
13236
13237 /* unsolicited event for HP jack sensing */
13238 static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13239 unsigned int res)
13240 {
13241 if ((res >> 26) == ALC880_HP_EVENT)
13242 alc262_hippo1_automute( codec );
13243
13244 if ((res >> 26) == ALC880_MIC_EVENT)
13245 alc662_eeepc_mic_automute(codec);
13246 }
13247
13248 static void alc662_eeepc_inithook(struct hda_codec *codec)
13249 {
13250 alc262_hippo1_automute( codec );
13251 alc662_eeepc_mic_automute(codec);
13252 }
13253
13254 static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13255 {
13256 unsigned int mute;
13257 unsigned int present;
13258
13259 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13260 present = snd_hda_codec_read(codec, 0x14, 0,
13261 AC_VERB_GET_PIN_SENSE, 0);
13262 present = (present & 0x80000000) != 0;
13263 if (present) {
13264 /* mute internal speaker */
13265 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13266 HDA_AMP_MUTE, HDA_AMP_MUTE);
13267 } else {
13268 /* unmute internal speaker if necessary */
13269 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13270 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13271 HDA_AMP_MUTE, mute);
13272 }
13273 }
13274
13275 /* unsolicited event for HP jack sensing */
13276 static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13277 unsigned int res)
13278 {
13279 if ((res >> 26) == ALC880_HP_EVENT)
13280 alc662_eeepc_ep20_automute(codec);
13281 }
13282
13283 static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13284 {
13285 alc662_eeepc_ep20_automute(codec);
13286 }
13287
13288 #ifdef CONFIG_SND_HDA_POWER_SAVE
13289 #define alc662_loopbacks alc880_loopbacks
13290 #endif
13291
13292
13293 /* pcm configuration: identiacal with ALC880 */
13294 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
13295 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
13296 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
13297 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
13298
13299 /*
13300 * configuration and preset
13301 */
13302 static const char *alc662_models[ALC662_MODEL_LAST] = {
13303 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13304 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13305 [ALC662_3ST_6ch] = "3stack-6ch",
13306 [ALC662_5ST_DIG] = "6stack-dig",
13307 [ALC662_LENOVO_101E] = "lenovo-101e",
13308 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
13309 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
13310 [ALC662_AUTO] = "auto",
13311 };
13312
13313 static struct snd_pci_quirk alc662_cfg_tbl[] = {
13314 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
13315 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
13316 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
13317 {}
13318 };
13319
13320 static struct alc_config_preset alc662_presets[] = {
13321 [ALC662_3ST_2ch_DIG] = {
13322 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
13323 .init_verbs = { alc662_init_verbs },
13324 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13325 .dac_nids = alc662_dac_nids,
13326 .dig_out_nid = ALC662_DIGOUT_NID,
13327 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13328 .adc_nids = alc662_adc_nids,
13329 .dig_in_nid = ALC662_DIGIN_NID,
13330 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13331 .channel_mode = alc662_3ST_2ch_modes,
13332 .input_mux = &alc662_capture_source,
13333 },
13334 [ALC662_3ST_6ch_DIG] = {
13335 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13336 alc662_capture_mixer },
13337 .init_verbs = { alc662_init_verbs },
13338 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13339 .dac_nids = alc662_dac_nids,
13340 .dig_out_nid = ALC662_DIGOUT_NID,
13341 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13342 .adc_nids = alc662_adc_nids,
13343 .dig_in_nid = ALC662_DIGIN_NID,
13344 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13345 .channel_mode = alc662_3ST_6ch_modes,
13346 .need_dac_fix = 1,
13347 .input_mux = &alc662_capture_source,
13348 },
13349 [ALC662_3ST_6ch] = {
13350 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13351 alc662_capture_mixer },
13352 .init_verbs = { alc662_init_verbs },
13353 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13354 .dac_nids = alc662_dac_nids,
13355 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13356 .adc_nids = alc662_adc_nids,
13357 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13358 .channel_mode = alc662_3ST_6ch_modes,
13359 .need_dac_fix = 1,
13360 .input_mux = &alc662_capture_source,
13361 },
13362 [ALC662_5ST_DIG] = {
13363 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13364 alc662_capture_mixer },
13365 .init_verbs = { alc662_init_verbs },
13366 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13367 .dac_nids = alc662_dac_nids,
13368 .dig_out_nid = ALC662_DIGOUT_NID,
13369 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13370 .adc_nids = alc662_adc_nids,
13371 .dig_in_nid = ALC662_DIGIN_NID,
13372 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13373 .channel_mode = alc662_5stack_modes,
13374 .input_mux = &alc662_capture_source,
13375 },
13376 [ALC662_LENOVO_101E] = {
13377 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
13378 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13379 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13380 .dac_nids = alc662_dac_nids,
13381 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13382 .adc_nids = alc662_adc_nids,
13383 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13384 .channel_mode = alc662_3ST_2ch_modes,
13385 .input_mux = &alc662_lenovo_101e_capture_source,
13386 .unsol_event = alc662_lenovo_101e_unsol_event,
13387 .init_hook = alc662_lenovo_101e_all_automute,
13388 },
13389 [ALC662_ASUS_EEEPC_P701] = {
13390 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13391 .init_verbs = { alc662_init_verbs,
13392 alc662_eeepc_sue_init_verbs },
13393 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13394 .dac_nids = alc662_dac_nids,
13395 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13396 .adc_nids = alc662_adc_nids,
13397 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13398 .channel_mode = alc662_3ST_2ch_modes,
13399 .input_mux = &alc662_eeepc_capture_source,
13400 .unsol_event = alc662_eeepc_unsol_event,
13401 .init_hook = alc662_eeepc_inithook,
13402 },
13403 [ALC662_ASUS_EEEPC_EP20] = {
13404 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13405 alc662_chmode_mixer },
13406 .init_verbs = { alc662_init_verbs,
13407 alc662_eeepc_ep20_sue_init_verbs },
13408 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13409 .dac_nids = alc662_dac_nids,
13410 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13411 .adc_nids = alc662_adc_nids,
13412 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13413 .channel_mode = alc662_3ST_6ch_modes,
13414 .input_mux = &alc662_lenovo_101e_capture_source,
13415 .unsol_event = alc662_eeepc_ep20_unsol_event,
13416 .init_hook = alc662_eeepc_ep20_inithook,
13417 },
13418
13419 };
13420
13421
13422 /*
13423 * BIOS auto configuration
13424 */
13425
13426 /* add playback controls from the parsed DAC table */
13427 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13428 const struct auto_pin_cfg *cfg)
13429 {
13430 char name[32];
13431 static const char *chname[4] = {
13432 "Front", "Surround", NULL /*CLFE*/, "Side"
13433 };
13434 hda_nid_t nid;
13435 int i, err;
13436
13437 for (i = 0; i < cfg->line_outs; i++) {
13438 if (!spec->multiout.dac_nids[i])
13439 continue;
13440 nid = alc880_idx_to_dac(i);
13441 if (i == 2) {
13442 /* Center/LFE */
13443 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13444 "Center Playback Volume",
13445 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13446 HDA_OUTPUT));
13447 if (err < 0)
13448 return err;
13449 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13450 "LFE Playback Volume",
13451 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13452 HDA_OUTPUT));
13453 if (err < 0)
13454 return err;
13455 err = add_control(spec, ALC_CTL_BIND_MUTE,
13456 "Center Playback Switch",
13457 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13458 HDA_INPUT));
13459 if (err < 0)
13460 return err;
13461 err = add_control(spec, ALC_CTL_BIND_MUTE,
13462 "LFE Playback Switch",
13463 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13464 HDA_INPUT));
13465 if (err < 0)
13466 return err;
13467 } else {
13468 sprintf(name, "%s Playback Volume", chname[i]);
13469 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13470 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13471 HDA_OUTPUT));
13472 if (err < 0)
13473 return err;
13474 sprintf(name, "%s Playback Switch", chname[i]);
13475 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13476 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13477 HDA_INPUT));
13478 if (err < 0)
13479 return err;
13480 }
13481 }
13482 return 0;
13483 }
13484
13485 /* add playback controls for speaker and HP outputs */
13486 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13487 const char *pfx)
13488 {
13489 hda_nid_t nid;
13490 int err;
13491 char name[32];
13492
13493 if (!pin)
13494 return 0;
13495
13496 if (alc880_is_fixed_pin(pin)) {
13497 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13498 /* printk("DAC nid=%x\n",nid); */
13499 /* specify the DAC as the extra output */
13500 if (!spec->multiout.hp_nid)
13501 spec->multiout.hp_nid = nid;
13502 else
13503 spec->multiout.extra_out_nid[0] = nid;
13504 /* control HP volume/switch on the output mixer amp */
13505 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13506 sprintf(name, "%s Playback Volume", pfx);
13507 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13508 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13509 if (err < 0)
13510 return err;
13511 sprintf(name, "%s Playback Switch", pfx);
13512 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13513 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13514 if (err < 0)
13515 return err;
13516 } else if (alc880_is_multi_pin(pin)) {
13517 /* set manual connection */
13518 /* we have only a switch on HP-out PIN */
13519 sprintf(name, "%s Playback Switch", pfx);
13520 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13521 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13522 if (err < 0)
13523 return err;
13524 }
13525 return 0;
13526 }
13527
13528 /* create playback/capture controls for input pins */
13529 static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13530 const struct auto_pin_cfg *cfg)
13531 {
13532 struct hda_input_mux *imux = &spec->private_imux;
13533 int i, err, idx;
13534
13535 for (i = 0; i < AUTO_PIN_LAST; i++) {
13536 if (alc880_is_input_pin(cfg->input_pins[i])) {
13537 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13538 err = new_analog_input(spec, cfg->input_pins[i],
13539 auto_pin_cfg_labels[i],
13540 idx, 0x0b);
13541 if (err < 0)
13542 return err;
13543 imux->items[imux->num_items].label =
13544 auto_pin_cfg_labels[i];
13545 imux->items[imux->num_items].index =
13546 alc880_input_pin_idx(cfg->input_pins[i]);
13547 imux->num_items++;
13548 }
13549 }
13550 return 0;
13551 }
13552
13553 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13554 hda_nid_t nid, int pin_type,
13555 int dac_idx)
13556 {
13557 /* set as output */
13558 snd_hda_codec_write(codec, nid, 0,
13559 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13560 snd_hda_codec_write(codec, nid, 0,
13561 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13562 /* need the manual connection? */
13563 if (alc880_is_multi_pin(nid)) {
13564 struct alc_spec *spec = codec->spec;
13565 int idx = alc880_multi_pin_idx(nid);
13566 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13567 AC_VERB_SET_CONNECT_SEL,
13568 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13569 }
13570 }
13571
13572 static void alc662_auto_init_multi_out(struct hda_codec *codec)
13573 {
13574 struct alc_spec *spec = codec->spec;
13575 int i;
13576
13577 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
13578 for (i = 0; i <= HDA_SIDE; i++) {
13579 hda_nid_t nid = spec->autocfg.line_out_pins[i];
13580 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13581 if (nid)
13582 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
13583 i);
13584 }
13585 }
13586
13587 static void alc662_auto_init_hp_out(struct hda_codec *codec)
13588 {
13589 struct alc_spec *spec = codec->spec;
13590 hda_nid_t pin;
13591
13592 pin = spec->autocfg.hp_pins[0];
13593 if (pin) /* connect to front */
13594 /* use dac 0 */
13595 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13596 }
13597
13598 #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13599 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13600
13601 static void alc662_auto_init_analog_input(struct hda_codec *codec)
13602 {
13603 struct alc_spec *spec = codec->spec;
13604 int i;
13605
13606 for (i = 0; i < AUTO_PIN_LAST; i++) {
13607 hda_nid_t nid = spec->autocfg.input_pins[i];
13608 if (alc662_is_input_pin(nid)) {
13609 snd_hda_codec_write(codec, nid, 0,
13610 AC_VERB_SET_PIN_WIDGET_CONTROL,
13611 (i <= AUTO_PIN_FRONT_MIC ?
13612 PIN_VREF80 : PIN_IN));
13613 if (nid != ALC662_PIN_CD_NID)
13614 snd_hda_codec_write(codec, nid, 0,
13615 AC_VERB_SET_AMP_GAIN_MUTE,
13616 AMP_OUT_MUTE);
13617 }
13618 }
13619 }
13620
13621 static int alc662_parse_auto_config(struct hda_codec *codec)
13622 {
13623 struct alc_spec *spec = codec->spec;
13624 int err;
13625 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13626
13627 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13628 alc662_ignore);
13629 if (err < 0)
13630 return err;
13631 if (!spec->autocfg.line_outs)
13632 return 0; /* can't find valid BIOS pin config */
13633
13634 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13635 if (err < 0)
13636 return err;
13637 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13638 if (err < 0)
13639 return err;
13640 err = alc662_auto_create_extra_out(spec,
13641 spec->autocfg.speaker_pins[0],
13642 "Speaker");
13643 if (err < 0)
13644 return err;
13645 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13646 "Headphone");
13647 if (err < 0)
13648 return err;
13649 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13650 if (err < 0)
13651 return err;
13652
13653 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13654
13655 if (spec->autocfg.dig_out_pin)
13656 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13657
13658 if (spec->kctl_alloc)
13659 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13660
13661 spec->num_mux_defs = 1;
13662 spec->input_mux = &spec->private_imux;
13663
13664 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
13665 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13666 spec->num_mixers++;
13667 return 1;
13668 }
13669
13670 /* additional initialization for auto-configuration model */
13671 static void alc662_auto_init(struct hda_codec *codec)
13672 {
13673 alc662_auto_init_multi_out(codec);
13674 alc662_auto_init_hp_out(codec);
13675 alc662_auto_init_analog_input(codec);
13676 }
13677
13678 static int patch_alc662(struct hda_codec *codec)
13679 {
13680 struct alc_spec *spec;
13681 int err, board_config;
13682
13683 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13684 if (!spec)
13685 return -ENOMEM;
13686
13687 codec->spec = spec;
13688
13689 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13690 alc662_models,
13691 alc662_cfg_tbl);
13692 if (board_config < 0) {
13693 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13694 "trying auto-probe from BIOS...\n");
13695 board_config = ALC662_AUTO;
13696 }
13697
13698 if (board_config == ALC662_AUTO) {
13699 /* automatic parse from the BIOS config */
13700 err = alc662_parse_auto_config(codec);
13701 if (err < 0) {
13702 alc_free(codec);
13703 return err;
13704 } else if (!err) {
13705 printk(KERN_INFO
13706 "hda_codec: Cannot set up configuration "
13707 "from BIOS. Using base mode...\n");
13708 board_config = ALC662_3ST_2ch_DIG;
13709 }
13710 }
13711
13712 if (board_config != ALC662_AUTO)
13713 setup_preset(spec, &alc662_presets[board_config]);
13714
13715 spec->stream_name_analog = "ALC662 Analog";
13716 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13717 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13718
13719 spec->stream_name_digital = "ALC662 Digital";
13720 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13721 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13722
13723 if (!spec->adc_nids && spec->input_mux) {
13724 spec->adc_nids = alc662_adc_nids;
13725 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13726 }
13727
13728 spec->vmaster_nid = 0x02;
13729
13730 codec->patch_ops = alc_patch_ops;
13731 if (board_config == ALC662_AUTO)
13732 spec->init_hook = alc662_auto_init;
13733 #ifdef CONFIG_SND_HDA_POWER_SAVE
13734 if (!spec->loopback.amplist)
13735 spec->loopback.amplist = alc662_loopbacks;
13736 #endif
13737
13738 return 0;
13739 }
13740
13741 /*
13742 * patch entries
13743 */
13744 struct hda_codec_preset snd_hda_preset_realtek[] = {
13745 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
13746 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
13747 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
13748 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
13749 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
13750 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
13751 .patch = patch_alc861 },
13752 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13753 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13754 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
13755 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13756 .patch = patch_alc883 },
13757 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13758 .patch = patch_alc662 },
13759 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
13760 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
13761 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
13762 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
13763 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
13764 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
13765 {} /* terminator */
13766 };