]> git.ipfire.org Git - thirdparty/linux.git/blame_incremental - sound/pci/hda/patch_realtek.c
[ALSA] hda - support intel DG33 motherboards
[thirdparty/linux.git] / sound / pci / hda / patch_realtek.c
... / ...
CommitLineData
1/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
8 * Takashi Iwai <tiwai@suse.de>
9 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
10 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
33#include "hda_patch.h"
34
35#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
39
40/* ALC880 board config type */
41enum {
42 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
47 ALC880_Z71V,
48 ALC880_6ST,
49 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
54 ALC880_ASUS_DIG2,
55 ALC880_FUJITSU,
56 ALC880_UNIWILL_DIG,
57 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
59 ALC880_CLEVO,
60 ALC880_TCL_S700,
61 ALC880_LG,
62 ALC880_LG_LW,
63 ALC880_MEDION_RIM,
64#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
67 ALC880_AUTO,
68 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
75 ALC260_HP_3013,
76 ALC260_FUJITSU_S702X,
77 ALC260_ACER,
78 ALC260_WILL,
79 ALC260_REPLACER_672V,
80#ifdef CONFIG_SND_DEBUG
81 ALC260_TEST,
82#endif
83 ALC260_AUTO,
84 ALC260_MODEL_LAST /* last tag */
85};
86
87/* ALC262 models */
88enum {
89 ALC262_BASIC,
90 ALC262_HIPPO,
91 ALC262_HIPPO_1,
92 ALC262_FUJITSU,
93 ALC262_HP_BPC,
94 ALC262_HP_BPC_D7000_WL,
95 ALC262_HP_BPC_D7000_WF,
96 ALC262_HP_TC_T5735,
97 ALC262_HP_RP5700,
98 ALC262_BENQ_ED8,
99 ALC262_SONY_ASSAMD,
100 ALC262_BENQ_T31,
101 ALC262_ULTRA,
102 ALC262_LENOVO_3000,
103 ALC262_AUTO,
104 ALC262_MODEL_LAST /* last tag */
105};
106
107/* ALC268 models */
108enum {
109 ALC267_QUANTA_IL1,
110 ALC268_3ST,
111 ALC268_TOSHIBA,
112 ALC268_ACER,
113 ALC268_DELL,
114 ALC268_ZEPTO,
115#ifdef CONFIG_SND_DEBUG
116 ALC268_TEST,
117#endif
118 ALC268_AUTO,
119 ALC268_MODEL_LAST /* last tag */
120};
121
122/* ALC269 models */
123enum {
124 ALC269_BASIC,
125 ALC269_AUTO,
126 ALC269_MODEL_LAST /* last tag */
127};
128
129/* ALC861 models */
130enum {
131 ALC861_3ST,
132 ALC660_3ST,
133 ALC861_3ST_DIG,
134 ALC861_6ST_DIG,
135 ALC861_UNIWILL_M31,
136 ALC861_TOSHIBA,
137 ALC861_ASUS,
138 ALC861_ASUS_LAPTOP,
139 ALC861_AUTO,
140 ALC861_MODEL_LAST,
141};
142
143/* ALC861-VD models */
144enum {
145 ALC660VD_3ST,
146 ALC660VD_3ST_DIG,
147 ALC861VD_3ST,
148 ALC861VD_3ST_DIG,
149 ALC861VD_6ST_DIG,
150 ALC861VD_LENOVO,
151 ALC861VD_DALLAS,
152 ALC861VD_HP,
153 ALC861VD_AUTO,
154 ALC861VD_MODEL_LAST,
155};
156
157/* ALC662 models */
158enum {
159 ALC662_3ST_2ch_DIG,
160 ALC662_3ST_6ch_DIG,
161 ALC662_3ST_6ch,
162 ALC662_5ST_DIG,
163 ALC662_LENOVO_101E,
164 ALC662_ASUS_EEEPC_P701,
165 ALC662_ASUS_EEEPC_EP20,
166 ALC663_ASUS_M51VA,
167 ALC663_ASUS_G71V,
168 ALC663_ASUS_H13,
169 ALC663_ASUS_G50V,
170 ALC662_AUTO,
171 ALC662_MODEL_LAST,
172};
173
174/* ALC882 models */
175enum {
176 ALC882_3ST_DIG,
177 ALC882_6ST_DIG,
178 ALC882_ARIMA,
179 ALC882_W2JC,
180 ALC882_TARGA,
181 ALC882_ASUS_A7J,
182 ALC882_ASUS_A7M,
183 ALC885_MACPRO,
184 ALC885_MBP3,
185 ALC885_IMAC24,
186 ALC882_AUTO,
187 ALC882_MODEL_LAST,
188};
189
190/* ALC883 models */
191enum {
192 ALC883_3ST_2ch_DIG,
193 ALC883_3ST_6ch_DIG,
194 ALC883_3ST_6ch,
195 ALC883_6ST_DIG,
196 ALC883_TARGA_DIG,
197 ALC883_TARGA_2ch_DIG,
198 ALC883_ACER,
199 ALC883_ACER_ASPIRE,
200 ALC883_MEDION,
201 ALC883_MEDION_MD2,
202 ALC883_LAPTOP_EAPD,
203 ALC883_LENOVO_101E_2ch,
204 ALC883_LENOVO_NB0763,
205 ALC888_LENOVO_MS7195_DIG,
206 ALC883_HAIER_W66,
207 ALC888_3ST_HP,
208 ALC888_6ST_DELL,
209 ALC883_MITAC,
210 ALC883_CLEVO_M720,
211 ALC883_FUJITSU_PI2515,
212 ALC883_3ST_6ch_INTEL,
213 ALC883_AUTO,
214 ALC883_MODEL_LAST,
215};
216
217/* for GPIO Poll */
218#define GPIO_MASK 0x03
219
220struct alc_spec {
221 /* codec parameterization */
222 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
223 unsigned int num_mixers;
224
225 const struct hda_verb *init_verbs[5]; /* initialization verbs
226 * don't forget NULL
227 * termination!
228 */
229 unsigned int num_init_verbs;
230
231 char *stream_name_analog; /* analog PCM stream */
232 struct hda_pcm_stream *stream_analog_playback;
233 struct hda_pcm_stream *stream_analog_capture;
234 struct hda_pcm_stream *stream_analog_alt_playback;
235 struct hda_pcm_stream *stream_analog_alt_capture;
236
237 char *stream_name_digital; /* digital PCM stream */
238 struct hda_pcm_stream *stream_digital_playback;
239 struct hda_pcm_stream *stream_digital_capture;
240
241 /* playback */
242 struct hda_multi_out multiout; /* playback set-up
243 * max_channels, dacs must be set
244 * dig_out_nid and hp_nid are optional
245 */
246 hda_nid_t alt_dac_nid;
247
248 /* capture */
249 unsigned int num_adc_nids;
250 hda_nid_t *adc_nids;
251 hda_nid_t *capsrc_nids;
252 hda_nid_t dig_in_nid; /* digital-in NID; optional */
253
254 /* capture source */
255 unsigned int num_mux_defs;
256 const struct hda_input_mux *input_mux;
257 unsigned int cur_mux[3];
258
259 /* channel model */
260 const struct hda_channel_mode *channel_mode;
261 int num_channel_mode;
262 int need_dac_fix;
263
264 /* PCM information */
265 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
266
267 /* dynamic controls, init_verbs and input_mux */
268 struct auto_pin_cfg autocfg;
269 unsigned int num_kctl_alloc, num_kctl_used;
270 struct snd_kcontrol_new *kctl_alloc;
271 struct hda_input_mux private_imux;
272 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
273
274 /* hooks */
275 void (*init_hook)(struct hda_codec *codec);
276 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
277
278 /* for pin sensing */
279 unsigned int sense_updated: 1;
280 unsigned int jack_present: 1;
281 unsigned int master_sw: 1;
282
283 /* for virtual master */
284 hda_nid_t vmaster_nid;
285#ifdef CONFIG_SND_HDA_POWER_SAVE
286 struct hda_loopback_check loopback;
287#endif
288};
289
290/*
291 * configuration template - to be copied to the spec instance
292 */
293struct alc_config_preset {
294 struct snd_kcontrol_new *mixers[5]; /* should be identical size
295 * with spec
296 */
297 const struct hda_verb *init_verbs[5];
298 unsigned int num_dacs;
299 hda_nid_t *dac_nids;
300 hda_nid_t dig_out_nid; /* optional */
301 hda_nid_t hp_nid; /* optional */
302 unsigned int num_adc_nids;
303 hda_nid_t *adc_nids;
304 hda_nid_t *capsrc_nids;
305 hda_nid_t dig_in_nid;
306 unsigned int num_channel_mode;
307 const struct hda_channel_mode *channel_mode;
308 int need_dac_fix;
309 unsigned int num_mux_defs;
310 const struct hda_input_mux *input_mux;
311 void (*unsol_event)(struct hda_codec *, unsigned int);
312 void (*init_hook)(struct hda_codec *);
313#ifdef CONFIG_SND_HDA_POWER_SAVE
314 struct hda_amp_list *loopbacks;
315#endif
316};
317
318
319/*
320 * input MUX handling
321 */
322static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
323 struct snd_ctl_elem_info *uinfo)
324{
325 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
326 struct alc_spec *spec = codec->spec;
327 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
328 if (mux_idx >= spec->num_mux_defs)
329 mux_idx = 0;
330 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
331}
332
333static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
334 struct snd_ctl_elem_value *ucontrol)
335{
336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
337 struct alc_spec *spec = codec->spec;
338 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
339
340 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
341 return 0;
342}
343
344static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
345 struct snd_ctl_elem_value *ucontrol)
346{
347 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
348 struct alc_spec *spec = codec->spec;
349 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
350 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
351 hda_nid_t nid = spec->capsrc_nids ?
352 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
353 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
354 nid, &spec->cur_mux[adc_idx]);
355}
356
357
358/*
359 * channel mode setting
360 */
361static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
362 struct snd_ctl_elem_info *uinfo)
363{
364 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
365 struct alc_spec *spec = codec->spec;
366 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
367 spec->num_channel_mode);
368}
369
370static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
371 struct snd_ctl_elem_value *ucontrol)
372{
373 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
374 struct alc_spec *spec = codec->spec;
375 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
376 spec->num_channel_mode,
377 spec->multiout.max_channels);
378}
379
380static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
381 struct snd_ctl_elem_value *ucontrol)
382{
383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
384 struct alc_spec *spec = codec->spec;
385 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
386 spec->num_channel_mode,
387 &spec->multiout.max_channels);
388 if (err >= 0 && spec->need_dac_fix)
389 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
390 return err;
391}
392
393/*
394 * Control the mode of pin widget settings via the mixer. "pc" is used
395 * instead of "%" to avoid consequences of accidently treating the % as
396 * being part of a format specifier. Maximum allowed length of a value is
397 * 63 characters plus NULL terminator.
398 *
399 * Note: some retasking pin complexes seem to ignore requests for input
400 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
401 * are requested. Therefore order this list so that this behaviour will not
402 * cause problems when mixer clients move through the enum sequentially.
403 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
404 * March 2006.
405 */
406static char *alc_pin_mode_names[] = {
407 "Mic 50pc bias", "Mic 80pc bias",
408 "Line in", "Line out", "Headphone out",
409};
410static unsigned char alc_pin_mode_values[] = {
411 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
412};
413/* The control can present all 5 options, or it can limit the options based
414 * in the pin being assumed to be exclusively an input or an output pin. In
415 * addition, "input" pins may or may not process the mic bias option
416 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
417 * accept requests for bias as of chip versions up to March 2006) and/or
418 * wiring in the computer.
419 */
420#define ALC_PIN_DIR_IN 0x00
421#define ALC_PIN_DIR_OUT 0x01
422#define ALC_PIN_DIR_INOUT 0x02
423#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
424#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
425
426/* Info about the pin modes supported by the different pin direction modes.
427 * For each direction the minimum and maximum values are given.
428 */
429static signed char alc_pin_mode_dir_info[5][2] = {
430 { 0, 2 }, /* ALC_PIN_DIR_IN */
431 { 3, 4 }, /* ALC_PIN_DIR_OUT */
432 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
433 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
434 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
435};
436#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
437#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
438#define alc_pin_mode_n_items(_dir) \
439 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
440
441static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
442 struct snd_ctl_elem_info *uinfo)
443{
444 unsigned int item_num = uinfo->value.enumerated.item;
445 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
446
447 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
448 uinfo->count = 1;
449 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
450
451 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
452 item_num = alc_pin_mode_min(dir);
453 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
454 return 0;
455}
456
457static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
458 struct snd_ctl_elem_value *ucontrol)
459{
460 unsigned int i;
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 hda_nid_t nid = kcontrol->private_value & 0xffff;
463 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
464 long *valp = ucontrol->value.integer.value;
465 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
466 AC_VERB_GET_PIN_WIDGET_CONTROL,
467 0x00);
468
469 /* Find enumerated value for current pinctl setting */
470 i = alc_pin_mode_min(dir);
471 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
472 i++;
473 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
474 return 0;
475}
476
477static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
479{
480 signed int change;
481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
482 hda_nid_t nid = kcontrol->private_value & 0xffff;
483 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
484 long val = *ucontrol->value.integer.value;
485 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
486 AC_VERB_GET_PIN_WIDGET_CONTROL,
487 0x00);
488
489 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
490 val = alc_pin_mode_min(dir);
491
492 change = pinctl != alc_pin_mode_values[val];
493 if (change) {
494 /* Set pin mode to that requested */
495 snd_hda_codec_write_cache(codec, nid, 0,
496 AC_VERB_SET_PIN_WIDGET_CONTROL,
497 alc_pin_mode_values[val]);
498
499 /* Also enable the retasking pin's input/output as required
500 * for the requested pin mode. Enum values of 2 or less are
501 * input modes.
502 *
503 * Dynamically switching the input/output buffers probably
504 * reduces noise slightly (particularly on input) so we'll
505 * do it. However, having both input and output buffers
506 * enabled simultaneously doesn't seem to be problematic if
507 * this turns out to be necessary in the future.
508 */
509 if (val <= 2) {
510 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
511 HDA_AMP_MUTE, HDA_AMP_MUTE);
512 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
513 HDA_AMP_MUTE, 0);
514 } else {
515 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
516 HDA_AMP_MUTE, HDA_AMP_MUTE);
517 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
518 HDA_AMP_MUTE, 0);
519 }
520 }
521 return change;
522}
523
524#define ALC_PIN_MODE(xname, nid, dir) \
525 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
526 .info = alc_pin_mode_info, \
527 .get = alc_pin_mode_get, \
528 .put = alc_pin_mode_put, \
529 .private_value = nid | (dir<<16) }
530
531/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
532 * together using a mask with more than one bit set. This control is
533 * currently used only by the ALC260 test model. At this stage they are not
534 * needed for any "production" models.
535 */
536#ifdef CONFIG_SND_DEBUG
537#define alc_gpio_data_info snd_ctl_boolean_mono_info
538
539static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
540 struct snd_ctl_elem_value *ucontrol)
541{
542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
543 hda_nid_t nid = kcontrol->private_value & 0xffff;
544 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
545 long *valp = ucontrol->value.integer.value;
546 unsigned int val = snd_hda_codec_read(codec, nid, 0,
547 AC_VERB_GET_GPIO_DATA, 0x00);
548
549 *valp = (val & mask) != 0;
550 return 0;
551}
552static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
553 struct snd_ctl_elem_value *ucontrol)
554{
555 signed int change;
556 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
557 hda_nid_t nid = kcontrol->private_value & 0xffff;
558 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
559 long val = *ucontrol->value.integer.value;
560 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
561 AC_VERB_GET_GPIO_DATA,
562 0x00);
563
564 /* Set/unset the masked GPIO bit(s) as needed */
565 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
566 if (val == 0)
567 gpio_data &= ~mask;
568 else
569 gpio_data |= mask;
570 snd_hda_codec_write_cache(codec, nid, 0,
571 AC_VERB_SET_GPIO_DATA, gpio_data);
572
573 return change;
574}
575#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
576 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
577 .info = alc_gpio_data_info, \
578 .get = alc_gpio_data_get, \
579 .put = alc_gpio_data_put, \
580 .private_value = nid | (mask<<16) }
581#endif /* CONFIG_SND_DEBUG */
582
583/* A switch control to allow the enabling of the digital IO pins on the
584 * ALC260. This is incredibly simplistic; the intention of this control is
585 * to provide something in the test model allowing digital outputs to be
586 * identified if present. If models are found which can utilise these
587 * outputs a more complete mixer control can be devised for those models if
588 * necessary.
589 */
590#ifdef CONFIG_SND_DEBUG
591#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
592
593static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
594 struct snd_ctl_elem_value *ucontrol)
595{
596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
597 hda_nid_t nid = kcontrol->private_value & 0xffff;
598 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
599 long *valp = ucontrol->value.integer.value;
600 unsigned int val = snd_hda_codec_read(codec, nid, 0,
601 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
602
603 *valp = (val & mask) != 0;
604 return 0;
605}
606static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
607 struct snd_ctl_elem_value *ucontrol)
608{
609 signed int change;
610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
611 hda_nid_t nid = kcontrol->private_value & 0xffff;
612 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
613 long val = *ucontrol->value.integer.value;
614 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
615 AC_VERB_GET_DIGI_CONVERT_1,
616 0x00);
617
618 /* Set/unset the masked control bit(s) as needed */
619 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
620 if (val==0)
621 ctrl_data &= ~mask;
622 else
623 ctrl_data |= mask;
624 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
625 ctrl_data);
626
627 return change;
628}
629#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
630 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
631 .info = alc_spdif_ctrl_info, \
632 .get = alc_spdif_ctrl_get, \
633 .put = alc_spdif_ctrl_put, \
634 .private_value = nid | (mask<<16) }
635#endif /* CONFIG_SND_DEBUG */
636
637/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
638 * Again, this is only used in the ALC26x test models to help identify when
639 * the EAPD line must be asserted for features to work.
640 */
641#ifdef CONFIG_SND_DEBUG
642#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
643
644static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_value *ucontrol)
646{
647 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
648 hda_nid_t nid = kcontrol->private_value & 0xffff;
649 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
650 long *valp = ucontrol->value.integer.value;
651 unsigned int val = snd_hda_codec_read(codec, nid, 0,
652 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
653
654 *valp = (val & mask) != 0;
655 return 0;
656}
657
658static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
659 struct snd_ctl_elem_value *ucontrol)
660{
661 int change;
662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
663 hda_nid_t nid = kcontrol->private_value & 0xffff;
664 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
665 long val = *ucontrol->value.integer.value;
666 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
667 AC_VERB_GET_EAPD_BTLENABLE,
668 0x00);
669
670 /* Set/unset the masked control bit(s) as needed */
671 change = (!val ? 0 : mask) != (ctrl_data & mask);
672 if (!val)
673 ctrl_data &= ~mask;
674 else
675 ctrl_data |= mask;
676 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
677 ctrl_data);
678
679 return change;
680}
681
682#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
683 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
684 .info = alc_eapd_ctrl_info, \
685 .get = alc_eapd_ctrl_get, \
686 .put = alc_eapd_ctrl_put, \
687 .private_value = nid | (mask<<16) }
688#endif /* CONFIG_SND_DEBUG */
689
690/*
691 * set up from the preset table
692 */
693static void setup_preset(struct alc_spec *spec,
694 const struct alc_config_preset *preset)
695{
696 int i;
697
698 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
699 spec->mixers[spec->num_mixers++] = preset->mixers[i];
700 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
701 i++)
702 spec->init_verbs[spec->num_init_verbs++] =
703 preset->init_verbs[i];
704
705 spec->channel_mode = preset->channel_mode;
706 spec->num_channel_mode = preset->num_channel_mode;
707 spec->need_dac_fix = preset->need_dac_fix;
708
709 spec->multiout.max_channels = spec->channel_mode[0].channels;
710
711 spec->multiout.num_dacs = preset->num_dacs;
712 spec->multiout.dac_nids = preset->dac_nids;
713 spec->multiout.dig_out_nid = preset->dig_out_nid;
714 spec->multiout.hp_nid = preset->hp_nid;
715
716 spec->num_mux_defs = preset->num_mux_defs;
717 if (!spec->num_mux_defs)
718 spec->num_mux_defs = 1;
719 spec->input_mux = preset->input_mux;
720
721 spec->num_adc_nids = preset->num_adc_nids;
722 spec->adc_nids = preset->adc_nids;
723 spec->capsrc_nids = preset->capsrc_nids;
724 spec->dig_in_nid = preset->dig_in_nid;
725
726 spec->unsol_event = preset->unsol_event;
727 spec->init_hook = preset->init_hook;
728#ifdef CONFIG_SND_HDA_POWER_SAVE
729 spec->loopback.amplist = preset->loopbacks;
730#endif
731}
732
733/* Enable GPIO mask and set output */
734static struct hda_verb alc_gpio1_init_verbs[] = {
735 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
736 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
737 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
738 { }
739};
740
741static struct hda_verb alc_gpio2_init_verbs[] = {
742 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
743 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
744 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
745 { }
746};
747
748static struct hda_verb alc_gpio3_init_verbs[] = {
749 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
750 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
751 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
752 { }
753};
754
755static void alc_sku_automute(struct hda_codec *codec)
756{
757 struct alc_spec *spec = codec->spec;
758 unsigned int present;
759 unsigned int hp_nid = spec->autocfg.hp_pins[0];
760 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
761
762 /* need to execute and sync at first */
763 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
764 present = snd_hda_codec_read(codec, hp_nid, 0,
765 AC_VERB_GET_PIN_SENSE, 0);
766 spec->jack_present = (present & 0x80000000) != 0;
767 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
768 spec->jack_present ? 0 : PIN_OUT);
769}
770
771/* unsolicited event for HP jack sensing */
772static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
773{
774 if (codec->vendor_id == 0x10ec0880)
775 res >>= 28;
776 else
777 res >>= 26;
778 if (res != ALC880_HP_EVENT)
779 return;
780
781 alc_sku_automute(codec);
782}
783
784/* additional initialization for ALC888 variants */
785static void alc888_coef_init(struct hda_codec *codec)
786{
787 unsigned int tmp;
788
789 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
790 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
791 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
792 if ((tmp & 0xf0) == 2)
793 /* alc888S-VC */
794 snd_hda_codec_read(codec, 0x20, 0,
795 AC_VERB_SET_PROC_COEF, 0x830);
796 else
797 /* alc888-VB */
798 snd_hda_codec_read(codec, 0x20, 0,
799 AC_VERB_SET_PROC_COEF, 0x3030);
800}
801
802/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
803 * 31 ~ 16 : Manufacture ID
804 * 15 ~ 8 : SKU ID
805 * 7 ~ 0 : Assembly ID
806 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
807 */
808static void alc_subsystem_id(struct hda_codec *codec,
809 unsigned int porta, unsigned int porte,
810 unsigned int portd)
811{
812 unsigned int ass, tmp, i;
813 unsigned nid;
814 struct alc_spec *spec = codec->spec;
815
816 ass = codec->subsystem_id & 0xffff;
817 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
818 goto do_sku;
819
820 /*
821 * 31~30 : port conetcivity
822 * 29~21 : reserve
823 * 20 : PCBEEP input
824 * 19~16 : Check sum (15:1)
825 * 15~1 : Custom
826 * 0 : override
827 */
828 nid = 0x1d;
829 if (codec->vendor_id == 0x10ec0260)
830 nid = 0x17;
831 ass = snd_hda_codec_read(codec, nid, 0,
832 AC_VERB_GET_CONFIG_DEFAULT, 0);
833 if (!(ass & 1) && !(ass & 0x100000))
834 return;
835 if ((ass >> 30) != 1) /* no physical connection */
836 return;
837
838 /* check sum */
839 tmp = 0;
840 for (i = 1; i < 16; i++) {
841 if ((ass >> i) & 1)
842 tmp++;
843 }
844 if (((ass >> 16) & 0xf) != tmp)
845 return;
846do_sku:
847 /*
848 * 0 : override
849 * 1 : Swap Jack
850 * 2 : 0 --> Desktop, 1 --> Laptop
851 * 3~5 : External Amplifier control
852 * 7~6 : Reserved
853 */
854 tmp = (ass & 0x38) >> 3; /* external Amp control */
855 switch (tmp) {
856 case 1:
857 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
858 break;
859 case 3:
860 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
861 break;
862 case 7:
863 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
864 break;
865 case 5: /* set EAPD output high */
866 switch (codec->vendor_id) {
867 case 0x10ec0260:
868 snd_hda_codec_write(codec, 0x0f, 0,
869 AC_VERB_SET_EAPD_BTLENABLE, 2);
870 snd_hda_codec_write(codec, 0x10, 0,
871 AC_VERB_SET_EAPD_BTLENABLE, 2);
872 break;
873 case 0x10ec0262:
874 case 0x10ec0267:
875 case 0x10ec0268:
876 case 0x10ec0269:
877 case 0x10ec0660:
878 case 0x10ec0662:
879 case 0x10ec0663:
880 case 0x10ec0862:
881 case 0x10ec0889:
882 snd_hda_codec_write(codec, 0x14, 0,
883 AC_VERB_SET_EAPD_BTLENABLE, 2);
884 snd_hda_codec_write(codec, 0x15, 0,
885 AC_VERB_SET_EAPD_BTLENABLE, 2);
886 break;
887 }
888 switch (codec->vendor_id) {
889 case 0x10ec0260:
890 snd_hda_codec_write(codec, 0x1a, 0,
891 AC_VERB_SET_COEF_INDEX, 7);
892 tmp = snd_hda_codec_read(codec, 0x1a, 0,
893 AC_VERB_GET_PROC_COEF, 0);
894 snd_hda_codec_write(codec, 0x1a, 0,
895 AC_VERB_SET_COEF_INDEX, 7);
896 snd_hda_codec_write(codec, 0x1a, 0,
897 AC_VERB_SET_PROC_COEF,
898 tmp | 0x2010);
899 break;
900 case 0x10ec0262:
901 case 0x10ec0880:
902 case 0x10ec0882:
903 case 0x10ec0883:
904 case 0x10ec0885:
905 case 0x10ec0889:
906 snd_hda_codec_write(codec, 0x20, 0,
907 AC_VERB_SET_COEF_INDEX, 7);
908 tmp = snd_hda_codec_read(codec, 0x20, 0,
909 AC_VERB_GET_PROC_COEF, 0);
910 snd_hda_codec_write(codec, 0x20, 0,
911 AC_VERB_SET_COEF_INDEX, 7);
912 snd_hda_codec_write(codec, 0x20, 0,
913 AC_VERB_SET_PROC_COEF,
914 tmp | 0x2010);
915 break;
916 case 0x10ec0888:
917 alc888_coef_init(codec);
918 break;
919 case 0x10ec0267:
920 case 0x10ec0268:
921 snd_hda_codec_write(codec, 0x20, 0,
922 AC_VERB_SET_COEF_INDEX, 7);
923 tmp = snd_hda_codec_read(codec, 0x20, 0,
924 AC_VERB_GET_PROC_COEF, 0);
925 snd_hda_codec_write(codec, 0x20, 0,
926 AC_VERB_SET_COEF_INDEX, 7);
927 snd_hda_codec_write(codec, 0x20, 0,
928 AC_VERB_SET_PROC_COEF,
929 tmp | 0x3000);
930 break;
931 }
932 default:
933 break;
934 }
935
936 /* is laptop or Desktop and enable the function "Mute internal speaker
937 * when the external headphone out jack is plugged"
938 */
939 if (!(ass & 0x8000))
940 return;
941 /*
942 * 10~8 : Jack location
943 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
944 * 14~13: Resvered
945 * 15 : 1 --> enable the function "Mute internal speaker
946 * when the external headphone out jack is plugged"
947 */
948 if (!spec->autocfg.speaker_pins[0]) {
949 if (spec->autocfg.line_out_pins[0])
950 spec->autocfg.speaker_pins[0] =
951 spec->autocfg.line_out_pins[0];
952 else
953 return;
954 }
955
956 if (!spec->autocfg.hp_pins[0]) {
957 tmp = (ass >> 11) & 0x3; /* HP to chassis */
958 if (tmp == 0)
959 spec->autocfg.hp_pins[0] = porta;
960 else if (tmp == 1)
961 spec->autocfg.hp_pins[0] = porte;
962 else if (tmp == 2)
963 spec->autocfg.hp_pins[0] = portd;
964 else
965 return;
966 }
967
968 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
969 AC_VERB_SET_UNSOLICITED_ENABLE,
970 AC_USRSP_EN | ALC880_HP_EVENT);
971 spec->unsol_event = alc_sku_unsol_event;
972}
973
974/*
975 * Fix-up pin default configurations
976 */
977
978struct alc_pincfg {
979 hda_nid_t nid;
980 u32 val;
981};
982
983static void alc_fix_pincfg(struct hda_codec *codec,
984 const struct snd_pci_quirk *quirk,
985 const struct alc_pincfg **pinfix)
986{
987 const struct alc_pincfg *cfg;
988
989 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
990 if (!quirk)
991 return;
992
993 cfg = pinfix[quirk->value];
994 for (; cfg->nid; cfg++) {
995 int i;
996 u32 val = cfg->val;
997 for (i = 0; i < 4; i++) {
998 snd_hda_codec_write(codec, cfg->nid, 0,
999 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1000 val & 0xff);
1001 val >>= 8;
1002 }
1003 }
1004}
1005
1006/*
1007 * ALC880 3-stack model
1008 *
1009 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1010 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1011 * F-Mic = 0x1b, HP = 0x19
1012 */
1013
1014static hda_nid_t alc880_dac_nids[4] = {
1015 /* front, rear, clfe, rear_surr */
1016 0x02, 0x05, 0x04, 0x03
1017};
1018
1019static hda_nid_t alc880_adc_nids[3] = {
1020 /* ADC0-2 */
1021 0x07, 0x08, 0x09,
1022};
1023
1024/* The datasheet says the node 0x07 is connected from inputs,
1025 * but it shows zero connection in the real implementation on some devices.
1026 * Note: this is a 915GAV bug, fixed on 915GLV
1027 */
1028static hda_nid_t alc880_adc_nids_alt[2] = {
1029 /* ADC1-2 */
1030 0x08, 0x09,
1031};
1032
1033#define ALC880_DIGOUT_NID 0x06
1034#define ALC880_DIGIN_NID 0x0a
1035
1036static struct hda_input_mux alc880_capture_source = {
1037 .num_items = 4,
1038 .items = {
1039 { "Mic", 0x0 },
1040 { "Front Mic", 0x3 },
1041 { "Line", 0x2 },
1042 { "CD", 0x4 },
1043 },
1044};
1045
1046/* channel source setting (2/6 channel selection for 3-stack) */
1047/* 2ch mode */
1048static struct hda_verb alc880_threestack_ch2_init[] = {
1049 /* set line-in to input, mute it */
1050 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1051 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1052 /* set mic-in to input vref 80%, mute it */
1053 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1054 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1055 { } /* end */
1056};
1057
1058/* 6ch mode */
1059static struct hda_verb alc880_threestack_ch6_init[] = {
1060 /* set line-in to output, unmute it */
1061 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1062 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1063 /* set mic-in to output, unmute it */
1064 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1065 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1066 { } /* end */
1067};
1068
1069static struct hda_channel_mode alc880_threestack_modes[2] = {
1070 { 2, alc880_threestack_ch2_init },
1071 { 6, alc880_threestack_ch6_init },
1072};
1073
1074static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1075 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1076 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1077 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1078 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1079 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1080 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1081 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1082 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1083 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1084 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1085 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1086 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1087 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1088 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1089 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1090 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1091 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1092 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1093 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1094 {
1095 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1096 .name = "Channel Mode",
1097 .info = alc_ch_mode_info,
1098 .get = alc_ch_mode_get,
1099 .put = alc_ch_mode_put,
1100 },
1101 { } /* end */
1102};
1103
1104/* capture mixer elements */
1105static struct snd_kcontrol_new alc880_capture_mixer[] = {
1106 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1107 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1108 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1109 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1110 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1111 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1112 {
1113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1114 /* The multiple "Capture Source" controls confuse alsamixer
1115 * So call somewhat different..
1116 */
1117 /* .name = "Capture Source", */
1118 .name = "Input Source",
1119 .count = 3,
1120 .info = alc_mux_enum_info,
1121 .get = alc_mux_enum_get,
1122 .put = alc_mux_enum_put,
1123 },
1124 { } /* end */
1125};
1126
1127/* capture mixer elements (in case NID 0x07 not available) */
1128static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
1129 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1130 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1131 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1132 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1133 {
1134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1135 /* The multiple "Capture Source" controls confuse alsamixer
1136 * So call somewhat different..
1137 */
1138 /* .name = "Capture Source", */
1139 .name = "Input Source",
1140 .count = 2,
1141 .info = alc_mux_enum_info,
1142 .get = alc_mux_enum_get,
1143 .put = alc_mux_enum_put,
1144 },
1145 { } /* end */
1146};
1147
1148
1149
1150/*
1151 * ALC880 5-stack model
1152 *
1153 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1154 * Side = 0x02 (0xd)
1155 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1156 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1157 */
1158
1159/* additional mixers to alc880_three_stack_mixer */
1160static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1161 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1162 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1163 { } /* end */
1164};
1165
1166/* channel source setting (6/8 channel selection for 5-stack) */
1167/* 6ch mode */
1168static struct hda_verb alc880_fivestack_ch6_init[] = {
1169 /* set line-in to input, mute it */
1170 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1171 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1172 { } /* end */
1173};
1174
1175/* 8ch mode */
1176static struct hda_verb alc880_fivestack_ch8_init[] = {
1177 /* set line-in to output, unmute it */
1178 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1179 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1180 { } /* end */
1181};
1182
1183static struct hda_channel_mode alc880_fivestack_modes[2] = {
1184 { 6, alc880_fivestack_ch6_init },
1185 { 8, alc880_fivestack_ch8_init },
1186};
1187
1188
1189/*
1190 * ALC880 6-stack model
1191 *
1192 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1193 * Side = 0x05 (0x0f)
1194 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1195 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1196 */
1197
1198static hda_nid_t alc880_6st_dac_nids[4] = {
1199 /* front, rear, clfe, rear_surr */
1200 0x02, 0x03, 0x04, 0x05
1201};
1202
1203static struct hda_input_mux alc880_6stack_capture_source = {
1204 .num_items = 4,
1205 .items = {
1206 { "Mic", 0x0 },
1207 { "Front Mic", 0x1 },
1208 { "Line", 0x2 },
1209 { "CD", 0x4 },
1210 },
1211};
1212
1213/* fixed 8-channels */
1214static struct hda_channel_mode alc880_sixstack_modes[1] = {
1215 { 8, NULL },
1216};
1217
1218static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1220 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1221 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1222 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1223 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1224 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1225 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1226 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1227 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1228 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1229 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1230 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1231 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1232 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1234 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1235 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1236 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1237 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1238 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1239 {
1240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1241 .name = "Channel Mode",
1242 .info = alc_ch_mode_info,
1243 .get = alc_ch_mode_get,
1244 .put = alc_ch_mode_put,
1245 },
1246 { } /* end */
1247};
1248
1249
1250/*
1251 * ALC880 W810 model
1252 *
1253 * W810 has rear IO for:
1254 * Front (DAC 02)
1255 * Surround (DAC 03)
1256 * Center/LFE (DAC 04)
1257 * Digital out (06)
1258 *
1259 * The system also has a pair of internal speakers, and a headphone jack.
1260 * These are both connected to Line2 on the codec, hence to DAC 02.
1261 *
1262 * There is a variable resistor to control the speaker or headphone
1263 * volume. This is a hardware-only device without a software API.
1264 *
1265 * Plugging headphones in will disable the internal speakers. This is
1266 * implemented in hardware, not via the driver using jack sense. In
1267 * a similar fashion, plugging into the rear socket marked "front" will
1268 * disable both the speakers and headphones.
1269 *
1270 * For input, there's a microphone jack, and an "audio in" jack.
1271 * These may not do anything useful with this driver yet, because I
1272 * haven't setup any initialization verbs for these yet...
1273 */
1274
1275static hda_nid_t alc880_w810_dac_nids[3] = {
1276 /* front, rear/surround, clfe */
1277 0x02, 0x03, 0x04
1278};
1279
1280/* fixed 6 channels */
1281static struct hda_channel_mode alc880_w810_modes[1] = {
1282 { 6, NULL }
1283};
1284
1285/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1286static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1287 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1288 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1289 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1290 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1291 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1292 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1293 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1294 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1295 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1296 { } /* end */
1297};
1298
1299
1300/*
1301 * Z710V model
1302 *
1303 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1304 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1305 * Line = 0x1a
1306 */
1307
1308static hda_nid_t alc880_z71v_dac_nids[1] = {
1309 0x02
1310};
1311#define ALC880_Z71V_HP_DAC 0x03
1312
1313/* fixed 2 channels */
1314static struct hda_channel_mode alc880_2_jack_modes[1] = {
1315 { 2, NULL }
1316};
1317
1318static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1319 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1320 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1321 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1322 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1323 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1324 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1325 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1326 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1327 { } /* end */
1328};
1329
1330
1331/*
1332 * ALC880 F1734 model
1333 *
1334 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1335 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1336 */
1337
1338static hda_nid_t alc880_f1734_dac_nids[1] = {
1339 0x03
1340};
1341#define ALC880_F1734_HP_DAC 0x02
1342
1343static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1344 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1345 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1346 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1347 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 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("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1351 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1352 { } /* end */
1353};
1354
1355static struct hda_input_mux alc880_f1734_capture_source = {
1356 .num_items = 2,
1357 .items = {
1358 { "Mic", 0x1 },
1359 { "CD", 0x4 },
1360 },
1361};
1362
1363
1364/*
1365 * ALC880 ASUS 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
1370 */
1371
1372#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1373#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1374
1375static struct snd_kcontrol_new alc880_asus_mixer[] = {
1376 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1377 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1378 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1379 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1380 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1381 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1382 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1383 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1384 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1385 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1386 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1387 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1389 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1390 {
1391 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1392 .name = "Channel Mode",
1393 .info = alc_ch_mode_info,
1394 .get = alc_ch_mode_get,
1395 .put = alc_ch_mode_put,
1396 },
1397 { } /* end */
1398};
1399
1400/*
1401 * ALC880 ASUS W1V model
1402 *
1403 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1404 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1405 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1406 */
1407
1408/* additional mixers to alc880_asus_mixer */
1409static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1410 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1411 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1412 { } /* end */
1413};
1414
1415/* additional mixers to alc880_asus_mixer */
1416static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1417 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1418 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1419 { } /* end */
1420};
1421
1422/* TCL S700 */
1423static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1424 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1425 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1426 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1427 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1428 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1429 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1430 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1431 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1432 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1433 {
1434 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1435 /* The multiple "Capture Source" controls confuse alsamixer
1436 * So call somewhat different..
1437 */
1438 /* .name = "Capture Source", */
1439 .name = "Input Source",
1440 .count = 1,
1441 .info = alc_mux_enum_info,
1442 .get = alc_mux_enum_get,
1443 .put = alc_mux_enum_put,
1444 },
1445 { } /* end */
1446};
1447
1448/* Uniwill */
1449static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1450 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1451 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1452 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1453 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1454 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1455 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1456 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1457 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1458 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1459 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1460 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1461 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1464 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1465 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1466 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1467 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1468 {
1469 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1470 .name = "Channel Mode",
1471 .info = alc_ch_mode_info,
1472 .get = alc_ch_mode_get,
1473 .put = alc_ch_mode_put,
1474 },
1475 { } /* end */
1476};
1477
1478static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1479 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1480 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1481 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1482 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1483 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1484 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1485 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1486 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1487 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1488 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1489 { } /* end */
1490};
1491
1492static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1493 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1494 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1495 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1496 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1497 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1498 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1499 { } /* end */
1500};
1501
1502/*
1503 * virtual master controls
1504 */
1505
1506/*
1507 * slave controls for virtual master
1508 */
1509static const char *alc_slave_vols[] = {
1510 "Front Playback Volume",
1511 "Surround Playback Volume",
1512 "Center Playback Volume",
1513 "LFE Playback Volume",
1514 "Side Playback Volume",
1515 "Headphone Playback Volume",
1516 "Speaker Playback Volume",
1517 "Mono Playback Volume",
1518 "Line-Out Playback Volume",
1519 NULL,
1520};
1521
1522static const char *alc_slave_sws[] = {
1523 "Front Playback Switch",
1524 "Surround Playback Switch",
1525 "Center Playback Switch",
1526 "LFE Playback Switch",
1527 "Side Playback Switch",
1528 "Headphone Playback Switch",
1529 "Speaker Playback Switch",
1530 "Mono Playback Switch",
1531 "IEC958 Playback Switch",
1532 NULL,
1533};
1534
1535/*
1536 * build control elements
1537 */
1538static int alc_build_controls(struct hda_codec *codec)
1539{
1540 struct alc_spec *spec = codec->spec;
1541 int err;
1542 int i;
1543
1544 for (i = 0; i < spec->num_mixers; i++) {
1545 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1546 if (err < 0)
1547 return err;
1548 }
1549
1550 if (spec->multiout.dig_out_nid) {
1551 err = snd_hda_create_spdif_out_ctls(codec,
1552 spec->multiout.dig_out_nid);
1553 if (err < 0)
1554 return err;
1555 err = snd_hda_create_spdif_share_sw(codec,
1556 &spec->multiout);
1557 if (err < 0)
1558 return err;
1559 spec->multiout.share_spdif = 1;
1560 }
1561 if (spec->dig_in_nid) {
1562 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1563 if (err < 0)
1564 return err;
1565 }
1566
1567 /* if we have no master control, let's create it */
1568 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1569 unsigned int vmaster_tlv[4];
1570 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1571 HDA_OUTPUT, vmaster_tlv);
1572 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1573 vmaster_tlv, alc_slave_vols);
1574 if (err < 0)
1575 return err;
1576 }
1577 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1578 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1579 NULL, alc_slave_sws);
1580 if (err < 0)
1581 return err;
1582 }
1583
1584 return 0;
1585}
1586
1587
1588/*
1589 * initialize the codec volumes, etc
1590 */
1591
1592/*
1593 * generic initialization of ADC, input mixers and output mixers
1594 */
1595static struct hda_verb alc880_volume_init_verbs[] = {
1596 /*
1597 * Unmute ADC0-2 and set the default input to mic-in
1598 */
1599 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1600 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1601 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1602 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1603 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1604 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1605
1606 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1607 * mixer widget
1608 * Note: PASD motherboards uses the Line In 2 as the input for front
1609 * panel mic (mic 2)
1610 */
1611 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1612 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1613 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1614 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1618 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1619
1620 /*
1621 * Set up output mixers (0x0c - 0x0f)
1622 */
1623 /* set vol=0 to output mixers */
1624 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1625 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1626 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1627 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1628 /* set up input amps for analog loopback */
1629 /* Amp Indices: DAC = 0, mixer = 1 */
1630 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1631 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1632 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1633 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1634 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1635 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1636 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1637 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1638
1639 { }
1640};
1641
1642/*
1643 * 3-stack pin configuration:
1644 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1645 */
1646static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1647 /*
1648 * preset connection lists of input pins
1649 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1650 */
1651 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1652 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1653 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1654
1655 /*
1656 * Set pin mode and muting
1657 */
1658 /* set front pin widgets 0x14 for output */
1659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1662 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1663 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1664 /* Mic2 (as headphone out) for HP output */
1665 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1666 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1667 /* Line In pin widget for input */
1668 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1669 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1670 /* Line2 (as front mic) pin widget for input and vref at 80% */
1671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1672 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1673 /* CD pin widget for input */
1674 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1675
1676 { }
1677};
1678
1679/*
1680 * 5-stack pin configuration:
1681 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1682 * line-in/side = 0x1a, f-mic = 0x1b
1683 */
1684static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1685 /*
1686 * preset connection lists of input pins
1687 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1688 */
1689 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1690 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1691
1692 /*
1693 * Set pin mode and muting
1694 */
1695 /* set pin widgets 0x14-0x17 for output */
1696 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1697 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1698 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1699 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1700 /* unmute pins for output (no gain on this amp) */
1701 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1702 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1703 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1704 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705
1706 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1709 /* Mic2 (as headphone out) for HP output */
1710 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1711 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1712 /* Line In pin widget for input */
1713 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1714 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1715 /* Line2 (as front mic) pin widget for input and vref at 80% */
1716 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1717 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1718 /* CD pin widget for input */
1719 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1720
1721 { }
1722};
1723
1724/*
1725 * W810 pin configuration:
1726 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1727 */
1728static struct hda_verb alc880_pin_w810_init_verbs[] = {
1729 /* hphone/speaker input selector: front DAC */
1730 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1731
1732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1734 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1736 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1737 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1738
1739 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1740 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1741
1742 { }
1743};
1744
1745/*
1746 * Z71V pin configuration:
1747 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1748 */
1749static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1750 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1751 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1752 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1753 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1754
1755 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1756 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1757 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1758 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1759
1760 { }
1761};
1762
1763/*
1764 * 6-stack pin configuration:
1765 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1766 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1767 */
1768static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1769 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1770
1771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1775 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1776 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1777 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1778 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1779
1780 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1781 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1782 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1783 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1784 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1785 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1786 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1787 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1788 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1789
1790 { }
1791};
1792
1793/*
1794 * Uniwill pin configuration:
1795 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1796 * line = 0x1a
1797 */
1798static struct hda_verb alc880_uniwill_init_verbs[] = {
1799 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1800
1801 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1802 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1803 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1804 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1805 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1806 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1807 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1808 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1809 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1811 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1812 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1813 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1814 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1815
1816 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1817 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1818 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1819 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1820 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1821 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1822 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1823 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1824 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1825
1826 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1827 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1828
1829 { }
1830};
1831
1832/*
1833* Uniwill P53
1834* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1835 */
1836static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1837 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1838
1839 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1843 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1844 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1847 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1848 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1849 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1850 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1851
1852 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1853 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1854 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1855 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1856 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1857 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1858
1859 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1860 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1861
1862 { }
1863};
1864
1865static struct hda_verb alc880_beep_init_verbs[] = {
1866 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1867 { }
1868};
1869
1870/* toggle speaker-output according to the hp-jack state */
1871static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1872{
1873 unsigned int present;
1874 unsigned char bits;
1875
1876 present = snd_hda_codec_read(codec, 0x14, 0,
1877 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1878 bits = present ? HDA_AMP_MUTE : 0;
1879 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1880 HDA_AMP_MUTE, bits);
1881 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1882 HDA_AMP_MUTE, bits);
1883}
1884
1885/* auto-toggle front mic */
1886static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1887{
1888 unsigned int present;
1889 unsigned char bits;
1890
1891 present = snd_hda_codec_read(codec, 0x18, 0,
1892 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1893 bits = present ? HDA_AMP_MUTE : 0;
1894 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1895}
1896
1897static void alc880_uniwill_automute(struct hda_codec *codec)
1898{
1899 alc880_uniwill_hp_automute(codec);
1900 alc880_uniwill_mic_automute(codec);
1901}
1902
1903static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1904 unsigned int res)
1905{
1906 /* Looks like the unsol event is incompatible with the standard
1907 * definition. 4bit tag is placed at 28 bit!
1908 */
1909 switch (res >> 28) {
1910 case ALC880_HP_EVENT:
1911 alc880_uniwill_hp_automute(codec);
1912 break;
1913 case ALC880_MIC_EVENT:
1914 alc880_uniwill_mic_automute(codec);
1915 break;
1916 }
1917}
1918
1919static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1920{
1921 unsigned int present;
1922 unsigned char bits;
1923
1924 present = snd_hda_codec_read(codec, 0x14, 0,
1925 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1926 bits = present ? HDA_AMP_MUTE : 0;
1927 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
1928}
1929
1930static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1931{
1932 unsigned int present;
1933
1934 present = snd_hda_codec_read(codec, 0x21, 0,
1935 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1936 present &= HDA_AMP_VOLMASK;
1937 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1938 HDA_AMP_VOLMASK, present);
1939 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1940 HDA_AMP_VOLMASK, present);
1941}
1942
1943static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1944 unsigned int res)
1945{
1946 /* Looks like the unsol event is incompatible with the standard
1947 * definition. 4bit tag is placed at 28 bit!
1948 */
1949 if ((res >> 28) == ALC880_HP_EVENT)
1950 alc880_uniwill_p53_hp_automute(codec);
1951 if ((res >> 28) == ALC880_DCVOL_EVENT)
1952 alc880_uniwill_p53_dcvol_automute(codec);
1953}
1954
1955/*
1956 * F1734 pin configuration:
1957 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1958 */
1959static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1960 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
1961 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1962 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1963 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1964 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1965
1966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1970
1971 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1972 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1973 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
1974 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1975 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1976 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1977 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1978 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1979 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1980
1981 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
1982 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
1983
1984 { }
1985};
1986
1987/*
1988 * ASUS pin configuration:
1989 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1990 */
1991static struct hda_verb alc880_pin_asus_init_verbs[] = {
1992 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1993 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1994 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1995 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1996
1997 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1998 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1999 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2000 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2001 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2002 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2003 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2004 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2005
2006 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2008 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2009 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2010 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2012 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2014 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2015
2016 { }
2017};
2018
2019/* Enable GPIO mask and set output */
2020#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2021#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2022
2023/* Clevo m520g init */
2024static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2025 /* headphone output */
2026 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2027 /* line-out */
2028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2029 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2030 /* Line-in */
2031 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2032 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2033 /* CD */
2034 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2035 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2036 /* Mic1 (rear panel) */
2037 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2038 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2039 /* Mic2 (front panel) */
2040 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2041 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2042 /* headphone */
2043 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2044 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2045 /* change to EAPD mode */
2046 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2047 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2048
2049 { }
2050};
2051
2052static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2053 /* change to EAPD mode */
2054 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2055 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2056
2057 /* Headphone output */
2058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2059 /* Front output*/
2060 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2061 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2062
2063 /* Line In pin widget for input */
2064 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2065 /* CD pin widget for input */
2066 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2067 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2069
2070 /* change to EAPD mode */
2071 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2072 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2073
2074 { }
2075};
2076
2077/*
2078 * LG m1 express dual
2079 *
2080 * Pin assignment:
2081 * Rear Line-In/Out (blue): 0x14
2082 * Build-in Mic-In: 0x15
2083 * Speaker-out: 0x17
2084 * HP-Out (green): 0x1b
2085 * Mic-In/Out (red): 0x19
2086 * SPDIF-Out: 0x1e
2087 */
2088
2089/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2090static hda_nid_t alc880_lg_dac_nids[3] = {
2091 0x05, 0x02, 0x03
2092};
2093
2094/* seems analog CD is not working */
2095static struct hda_input_mux alc880_lg_capture_source = {
2096 .num_items = 3,
2097 .items = {
2098 { "Mic", 0x1 },
2099 { "Line", 0x5 },
2100 { "Internal Mic", 0x6 },
2101 },
2102};
2103
2104/* 2,4,6 channel modes */
2105static struct hda_verb alc880_lg_ch2_init[] = {
2106 /* set line-in and mic-in to input */
2107 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2108 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2109 { }
2110};
2111
2112static struct hda_verb alc880_lg_ch4_init[] = {
2113 /* set line-in to out and mic-in to input */
2114 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2115 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2116 { }
2117};
2118
2119static struct hda_verb alc880_lg_ch6_init[] = {
2120 /* set line-in and mic-in to output */
2121 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2122 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2123 { }
2124};
2125
2126static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2127 { 2, alc880_lg_ch2_init },
2128 { 4, alc880_lg_ch4_init },
2129 { 6, alc880_lg_ch6_init },
2130};
2131
2132static struct snd_kcontrol_new alc880_lg_mixer[] = {
2133 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2134 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2135 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2136 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2137 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2138 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2139 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2140 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2143 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2144 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2145 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2146 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2147 {
2148 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2149 .name = "Channel Mode",
2150 .info = alc_ch_mode_info,
2151 .get = alc_ch_mode_get,
2152 .put = alc_ch_mode_put,
2153 },
2154 { } /* end */
2155};
2156
2157static struct hda_verb alc880_lg_init_verbs[] = {
2158 /* set capture source to mic-in */
2159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2160 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2162 /* mute all amp mixer inputs */
2163 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2165 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2166 /* line-in to input */
2167 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2168 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2169 /* built-in mic */
2170 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2171 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2172 /* speaker-out */
2173 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2174 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2175 /* mic-in to input */
2176 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2177 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2178 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2179 /* HP-out */
2180 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2181 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2182 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2183 /* jack sense */
2184 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2185 { }
2186};
2187
2188/* toggle speaker-output according to the hp-jack state */
2189static void alc880_lg_automute(struct hda_codec *codec)
2190{
2191 unsigned int present;
2192 unsigned char bits;
2193
2194 present = snd_hda_codec_read(codec, 0x1b, 0,
2195 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2196 bits = present ? HDA_AMP_MUTE : 0;
2197 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2198 HDA_AMP_MUTE, bits);
2199}
2200
2201static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2202{
2203 /* Looks like the unsol event is incompatible with the standard
2204 * definition. 4bit tag is placed at 28 bit!
2205 */
2206 if ((res >> 28) == 0x01)
2207 alc880_lg_automute(codec);
2208}
2209
2210/*
2211 * LG LW20
2212 *
2213 * Pin assignment:
2214 * Speaker-out: 0x14
2215 * Mic-In: 0x18
2216 * Built-in Mic-In: 0x19
2217 * Line-In: 0x1b
2218 * HP-Out: 0x1a
2219 * SPDIF-Out: 0x1e
2220 */
2221
2222static struct hda_input_mux alc880_lg_lw_capture_source = {
2223 .num_items = 3,
2224 .items = {
2225 { "Mic", 0x0 },
2226 { "Internal Mic", 0x1 },
2227 { "Line In", 0x2 },
2228 },
2229};
2230
2231#define alc880_lg_lw_modes alc880_threestack_modes
2232
2233static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2234 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2235 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2236 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2237 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2238 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2239 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2240 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2241 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2242 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2243 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2246 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2247 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2248 {
2249 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2250 .name = "Channel Mode",
2251 .info = alc_ch_mode_info,
2252 .get = alc_ch_mode_get,
2253 .put = alc_ch_mode_put,
2254 },
2255 { } /* end */
2256};
2257
2258static struct hda_verb alc880_lg_lw_init_verbs[] = {
2259 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2260 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2261 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2262
2263 /* set capture source to mic-in */
2264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2266 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2268 /* speaker-out */
2269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2271 /* HP-out */
2272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2274 /* mic-in to input */
2275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2276 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2277 /* built-in mic */
2278 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2279 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2280 /* jack sense */
2281 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2282 { }
2283};
2284
2285/* toggle speaker-output according to the hp-jack state */
2286static void alc880_lg_lw_automute(struct hda_codec *codec)
2287{
2288 unsigned int present;
2289 unsigned char bits;
2290
2291 present = snd_hda_codec_read(codec, 0x1b, 0,
2292 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2293 bits = present ? HDA_AMP_MUTE : 0;
2294 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2295 HDA_AMP_MUTE, bits);
2296}
2297
2298static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2299{
2300 /* Looks like the unsol event is incompatible with the standard
2301 * definition. 4bit tag is placed at 28 bit!
2302 */
2303 if ((res >> 28) == 0x01)
2304 alc880_lg_lw_automute(codec);
2305}
2306
2307static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2308 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2309 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2310 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2311 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2312 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2313 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2314 { } /* end */
2315};
2316
2317static struct hda_input_mux alc880_medion_rim_capture_source = {
2318 .num_items = 2,
2319 .items = {
2320 { "Mic", 0x0 },
2321 { "Internal Mic", 0x1 },
2322 },
2323};
2324
2325static struct hda_verb alc880_medion_rim_init_verbs[] = {
2326 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2327
2328 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2329 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2330
2331 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2332 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2333 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2334 /* Mic2 (as headphone out) for HP output */
2335 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2336 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2337 /* Internal Speaker */
2338 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2339 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2340
2341 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2342 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2343
2344 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2345 { }
2346};
2347
2348/* toggle speaker-output according to the hp-jack state */
2349static void alc880_medion_rim_automute(struct hda_codec *codec)
2350{
2351 unsigned int present;
2352 unsigned char bits;
2353
2354 present = snd_hda_codec_read(codec, 0x14, 0,
2355 AC_VERB_GET_PIN_SENSE, 0)
2356 & AC_PINSENSE_PRESENCE;
2357 bits = present ? HDA_AMP_MUTE : 0;
2358 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2359 HDA_AMP_MUTE, bits);
2360 if (present)
2361 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2362 else
2363 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2364}
2365
2366static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2367 unsigned int res)
2368{
2369 /* Looks like the unsol event is incompatible with the standard
2370 * definition. 4bit tag is placed at 28 bit!
2371 */
2372 if ((res >> 28) == ALC880_HP_EVENT)
2373 alc880_medion_rim_automute(codec);
2374}
2375
2376#ifdef CONFIG_SND_HDA_POWER_SAVE
2377static struct hda_amp_list alc880_loopbacks[] = {
2378 { 0x0b, HDA_INPUT, 0 },
2379 { 0x0b, HDA_INPUT, 1 },
2380 { 0x0b, HDA_INPUT, 2 },
2381 { 0x0b, HDA_INPUT, 3 },
2382 { 0x0b, HDA_INPUT, 4 },
2383 { } /* end */
2384};
2385
2386static struct hda_amp_list alc880_lg_loopbacks[] = {
2387 { 0x0b, HDA_INPUT, 1 },
2388 { 0x0b, HDA_INPUT, 6 },
2389 { 0x0b, HDA_INPUT, 7 },
2390 { } /* end */
2391};
2392#endif
2393
2394/*
2395 * Common callbacks
2396 */
2397
2398static int alc_init(struct hda_codec *codec)
2399{
2400 struct alc_spec *spec = codec->spec;
2401 unsigned int i;
2402
2403 for (i = 0; i < spec->num_init_verbs; i++)
2404 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2405
2406 if (spec->init_hook)
2407 spec->init_hook(codec);
2408
2409 return 0;
2410}
2411
2412static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2413{
2414 struct alc_spec *spec = codec->spec;
2415
2416 if (spec->unsol_event)
2417 spec->unsol_event(codec, res);
2418}
2419
2420#ifdef CONFIG_SND_HDA_POWER_SAVE
2421static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2422{
2423 struct alc_spec *spec = codec->spec;
2424 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2425}
2426#endif
2427
2428/*
2429 * Analog playback callbacks
2430 */
2431static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2432 struct hda_codec *codec,
2433 struct snd_pcm_substream *substream)
2434{
2435 struct alc_spec *spec = codec->spec;
2436 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2437 hinfo);
2438}
2439
2440static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2441 struct hda_codec *codec,
2442 unsigned int stream_tag,
2443 unsigned int format,
2444 struct snd_pcm_substream *substream)
2445{
2446 struct alc_spec *spec = codec->spec;
2447 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2448 stream_tag, format, substream);
2449}
2450
2451static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2452 struct hda_codec *codec,
2453 struct snd_pcm_substream *substream)
2454{
2455 struct alc_spec *spec = codec->spec;
2456 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2457}
2458
2459/*
2460 * Digital out
2461 */
2462static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2463 struct hda_codec *codec,
2464 struct snd_pcm_substream *substream)
2465{
2466 struct alc_spec *spec = codec->spec;
2467 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2468}
2469
2470static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2471 struct hda_codec *codec,
2472 unsigned int stream_tag,
2473 unsigned int format,
2474 struct snd_pcm_substream *substream)
2475{
2476 struct alc_spec *spec = codec->spec;
2477 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2478 stream_tag, format, substream);
2479}
2480
2481static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2482 struct hda_codec *codec,
2483 struct snd_pcm_substream *substream)
2484{
2485 struct alc_spec *spec = codec->spec;
2486 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2487}
2488
2489/*
2490 * Analog capture
2491 */
2492static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2493 struct hda_codec *codec,
2494 unsigned int stream_tag,
2495 unsigned int format,
2496 struct snd_pcm_substream *substream)
2497{
2498 struct alc_spec *spec = codec->spec;
2499
2500 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2501 stream_tag, 0, format);
2502 return 0;
2503}
2504
2505static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2506 struct hda_codec *codec,
2507 struct snd_pcm_substream *substream)
2508{
2509 struct alc_spec *spec = codec->spec;
2510
2511 snd_hda_codec_cleanup_stream(codec,
2512 spec->adc_nids[substream->number + 1]);
2513 return 0;
2514}
2515
2516
2517/*
2518 */
2519static struct hda_pcm_stream alc880_pcm_analog_playback = {
2520 .substreams = 1,
2521 .channels_min = 2,
2522 .channels_max = 8,
2523 /* NID is set in alc_build_pcms */
2524 .ops = {
2525 .open = alc880_playback_pcm_open,
2526 .prepare = alc880_playback_pcm_prepare,
2527 .cleanup = alc880_playback_pcm_cleanup
2528 },
2529};
2530
2531static struct hda_pcm_stream alc880_pcm_analog_capture = {
2532 .substreams = 1,
2533 .channels_min = 2,
2534 .channels_max = 2,
2535 /* NID is set in alc_build_pcms */
2536};
2537
2538static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2539 .substreams = 1,
2540 .channels_min = 2,
2541 .channels_max = 2,
2542 /* NID is set in alc_build_pcms */
2543};
2544
2545static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2546 .substreams = 2, /* can be overridden */
2547 .channels_min = 2,
2548 .channels_max = 2,
2549 /* NID is set in alc_build_pcms */
2550 .ops = {
2551 .prepare = alc880_alt_capture_pcm_prepare,
2552 .cleanup = alc880_alt_capture_pcm_cleanup
2553 },
2554};
2555
2556static struct hda_pcm_stream alc880_pcm_digital_playback = {
2557 .substreams = 1,
2558 .channels_min = 2,
2559 .channels_max = 2,
2560 /* NID is set in alc_build_pcms */
2561 .ops = {
2562 .open = alc880_dig_playback_pcm_open,
2563 .close = alc880_dig_playback_pcm_close,
2564 .prepare = alc880_dig_playback_pcm_prepare
2565 },
2566};
2567
2568static struct hda_pcm_stream alc880_pcm_digital_capture = {
2569 .substreams = 1,
2570 .channels_min = 2,
2571 .channels_max = 2,
2572 /* NID is set in alc_build_pcms */
2573};
2574
2575/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2576static struct hda_pcm_stream alc_pcm_null_stream = {
2577 .substreams = 0,
2578 .channels_min = 0,
2579 .channels_max = 0,
2580};
2581
2582static int alc_build_pcms(struct hda_codec *codec)
2583{
2584 struct alc_spec *spec = codec->spec;
2585 struct hda_pcm *info = spec->pcm_rec;
2586 int i;
2587
2588 codec->num_pcms = 1;
2589 codec->pcm_info = info;
2590
2591 info->name = spec->stream_name_analog;
2592 if (spec->stream_analog_playback) {
2593 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2594 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2595 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2596 }
2597 if (spec->stream_analog_capture) {
2598 snd_assert(spec->adc_nids, return -EINVAL);
2599 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2600 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2601 }
2602
2603 if (spec->channel_mode) {
2604 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2605 for (i = 0; i < spec->num_channel_mode; i++) {
2606 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2607 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2608 }
2609 }
2610 }
2611
2612 /* SPDIF for stream index #1 */
2613 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2614 codec->num_pcms = 2;
2615 info = spec->pcm_rec + 1;
2616 info->name = spec->stream_name_digital;
2617 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2618 if (spec->multiout.dig_out_nid &&
2619 spec->stream_digital_playback) {
2620 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2621 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2622 }
2623 if (spec->dig_in_nid &&
2624 spec->stream_digital_capture) {
2625 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2626 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2627 }
2628 }
2629
2630 /* If the use of more than one ADC is requested for the current
2631 * model, configure a second analog capture-only PCM.
2632 */
2633 /* Additional Analaog capture for index #2 */
2634 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2635 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
2636 codec->num_pcms = 3;
2637 info = spec->pcm_rec + 2;
2638 info->name = spec->stream_name_analog;
2639 if (spec->alt_dac_nid) {
2640 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2641 *spec->stream_analog_alt_playback;
2642 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2643 spec->alt_dac_nid;
2644 } else {
2645 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2646 alc_pcm_null_stream;
2647 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2648 }
2649 if (spec->num_adc_nids > 1) {
2650 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2651 *spec->stream_analog_alt_capture;
2652 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2653 spec->adc_nids[1];
2654 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2655 spec->num_adc_nids - 1;
2656 } else {
2657 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2658 alc_pcm_null_stream;
2659 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2660 }
2661 }
2662
2663 return 0;
2664}
2665
2666static void alc_free(struct hda_codec *codec)
2667{
2668 struct alc_spec *spec = codec->spec;
2669 unsigned int i;
2670
2671 if (!spec)
2672 return;
2673
2674 if (spec->kctl_alloc) {
2675 for (i = 0; i < spec->num_kctl_used; i++)
2676 kfree(spec->kctl_alloc[i].name);
2677 kfree(spec->kctl_alloc);
2678 }
2679 kfree(spec);
2680 codec->spec = NULL; /* to be sure */
2681}
2682
2683/*
2684 */
2685static struct hda_codec_ops alc_patch_ops = {
2686 .build_controls = alc_build_controls,
2687 .build_pcms = alc_build_pcms,
2688 .init = alc_init,
2689 .free = alc_free,
2690 .unsol_event = alc_unsol_event,
2691#ifdef CONFIG_SND_HDA_POWER_SAVE
2692 .check_power_status = alc_check_power_status,
2693#endif
2694};
2695
2696
2697/*
2698 * Test configuration for debugging
2699 *
2700 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2701 * enum controls.
2702 */
2703#ifdef CONFIG_SND_DEBUG
2704static hda_nid_t alc880_test_dac_nids[4] = {
2705 0x02, 0x03, 0x04, 0x05
2706};
2707
2708static struct hda_input_mux alc880_test_capture_source = {
2709 .num_items = 7,
2710 .items = {
2711 { "In-1", 0x0 },
2712 { "In-2", 0x1 },
2713 { "In-3", 0x2 },
2714 { "In-4", 0x3 },
2715 { "CD", 0x4 },
2716 { "Front", 0x5 },
2717 { "Surround", 0x6 },
2718 },
2719};
2720
2721static struct hda_channel_mode alc880_test_modes[4] = {
2722 { 2, NULL },
2723 { 4, NULL },
2724 { 6, NULL },
2725 { 8, NULL },
2726};
2727
2728static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2729 struct snd_ctl_elem_info *uinfo)
2730{
2731 static char *texts[] = {
2732 "N/A", "Line Out", "HP Out",
2733 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2734 };
2735 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2736 uinfo->count = 1;
2737 uinfo->value.enumerated.items = 8;
2738 if (uinfo->value.enumerated.item >= 8)
2739 uinfo->value.enumerated.item = 7;
2740 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2741 return 0;
2742}
2743
2744static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2745 struct snd_ctl_elem_value *ucontrol)
2746{
2747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2748 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2749 unsigned int pin_ctl, item = 0;
2750
2751 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2752 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2753 if (pin_ctl & AC_PINCTL_OUT_EN) {
2754 if (pin_ctl & AC_PINCTL_HP_EN)
2755 item = 2;
2756 else
2757 item = 1;
2758 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2759 switch (pin_ctl & AC_PINCTL_VREFEN) {
2760 case AC_PINCTL_VREF_HIZ: item = 3; break;
2761 case AC_PINCTL_VREF_50: item = 4; break;
2762 case AC_PINCTL_VREF_GRD: item = 5; break;
2763 case AC_PINCTL_VREF_80: item = 6; break;
2764 case AC_PINCTL_VREF_100: item = 7; break;
2765 }
2766 }
2767 ucontrol->value.enumerated.item[0] = item;
2768 return 0;
2769}
2770
2771static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2772 struct snd_ctl_elem_value *ucontrol)
2773{
2774 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2775 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2776 static unsigned int ctls[] = {
2777 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2778 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2779 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2780 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2781 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2782 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2783 };
2784 unsigned int old_ctl, new_ctl;
2785
2786 old_ctl = snd_hda_codec_read(codec, nid, 0,
2787 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2788 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2789 if (old_ctl != new_ctl) {
2790 int val;
2791 snd_hda_codec_write_cache(codec, nid, 0,
2792 AC_VERB_SET_PIN_WIDGET_CONTROL,
2793 new_ctl);
2794 val = ucontrol->value.enumerated.item[0] >= 3 ?
2795 HDA_AMP_MUTE : 0;
2796 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2797 HDA_AMP_MUTE, val);
2798 return 1;
2799 }
2800 return 0;
2801}
2802
2803static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2804 struct snd_ctl_elem_info *uinfo)
2805{
2806 static char *texts[] = {
2807 "Front", "Surround", "CLFE", "Side"
2808 };
2809 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2810 uinfo->count = 1;
2811 uinfo->value.enumerated.items = 4;
2812 if (uinfo->value.enumerated.item >= 4)
2813 uinfo->value.enumerated.item = 3;
2814 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2815 return 0;
2816}
2817
2818static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2819 struct snd_ctl_elem_value *ucontrol)
2820{
2821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2822 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2823 unsigned int sel;
2824
2825 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2826 ucontrol->value.enumerated.item[0] = sel & 3;
2827 return 0;
2828}
2829
2830static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2831 struct snd_ctl_elem_value *ucontrol)
2832{
2833 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2834 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2835 unsigned int sel;
2836
2837 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2838 if (ucontrol->value.enumerated.item[0] != sel) {
2839 sel = ucontrol->value.enumerated.item[0] & 3;
2840 snd_hda_codec_write_cache(codec, nid, 0,
2841 AC_VERB_SET_CONNECT_SEL, sel);
2842 return 1;
2843 }
2844 return 0;
2845}
2846
2847#define PIN_CTL_TEST(xname,nid) { \
2848 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2849 .name = xname, \
2850 .info = alc_test_pin_ctl_info, \
2851 .get = alc_test_pin_ctl_get, \
2852 .put = alc_test_pin_ctl_put, \
2853 .private_value = nid \
2854 }
2855
2856#define PIN_SRC_TEST(xname,nid) { \
2857 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2858 .name = xname, \
2859 .info = alc_test_pin_src_info, \
2860 .get = alc_test_pin_src_get, \
2861 .put = alc_test_pin_src_put, \
2862 .private_value = nid \
2863 }
2864
2865static struct snd_kcontrol_new alc880_test_mixer[] = {
2866 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2867 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2868 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2869 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2870 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2871 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2872 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2873 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2874 PIN_CTL_TEST("Front Pin Mode", 0x14),
2875 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2876 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2877 PIN_CTL_TEST("Side Pin Mode", 0x17),
2878 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2879 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2880 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2881 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2882 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2883 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2884 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2885 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2886 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2887 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2888 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2889 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2890 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2891 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2892 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2893 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2894 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2895 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2896 {
2897 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2898 .name = "Channel Mode",
2899 .info = alc_ch_mode_info,
2900 .get = alc_ch_mode_get,
2901 .put = alc_ch_mode_put,
2902 },
2903 { } /* end */
2904};
2905
2906static struct hda_verb alc880_test_init_verbs[] = {
2907 /* Unmute inputs of 0x0c - 0x0f */
2908 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2909 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2910 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2911 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2912 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2913 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2914 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2915 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2916 /* Vol output for 0x0c-0x0f */
2917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2918 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2920 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2921 /* Set output pins 0x14-0x17 */
2922 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2923 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2924 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2925 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2926 /* Unmute output pins 0x14-0x17 */
2927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2928 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2929 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2930 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2931 /* Set input pins 0x18-0x1c */
2932 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2933 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2935 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2937 /* Mute input pins 0x18-0x1b */
2938 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2939 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2940 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2941 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2942 /* ADC set up */
2943 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2944 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2945 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2946 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2947 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2948 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2949 /* Analog input/passthru */
2950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2953 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2954 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2955 { }
2956};
2957#endif
2958
2959/*
2960 */
2961
2962static const char *alc880_models[ALC880_MODEL_LAST] = {
2963 [ALC880_3ST] = "3stack",
2964 [ALC880_TCL_S700] = "tcl",
2965 [ALC880_3ST_DIG] = "3stack-digout",
2966 [ALC880_CLEVO] = "clevo",
2967 [ALC880_5ST] = "5stack",
2968 [ALC880_5ST_DIG] = "5stack-digout",
2969 [ALC880_W810] = "w810",
2970 [ALC880_Z71V] = "z71v",
2971 [ALC880_6ST] = "6stack",
2972 [ALC880_6ST_DIG] = "6stack-digout",
2973 [ALC880_ASUS] = "asus",
2974 [ALC880_ASUS_W1V] = "asus-w1v",
2975 [ALC880_ASUS_DIG] = "asus-dig",
2976 [ALC880_ASUS_DIG2] = "asus-dig2",
2977 [ALC880_UNIWILL_DIG] = "uniwill",
2978 [ALC880_UNIWILL_P53] = "uniwill-p53",
2979 [ALC880_FUJITSU] = "fujitsu",
2980 [ALC880_F1734] = "F1734",
2981 [ALC880_LG] = "lg",
2982 [ALC880_LG_LW] = "lg-lw",
2983 [ALC880_MEDION_RIM] = "medion",
2984#ifdef CONFIG_SND_DEBUG
2985 [ALC880_TEST] = "test",
2986#endif
2987 [ALC880_AUTO] = "auto",
2988};
2989
2990static struct snd_pci_quirk alc880_cfg_tbl[] = {
2991 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2992 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2993 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2994 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2995 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2996 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2997 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2998 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2999 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
3000 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3001 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
3002 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3003 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3004 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3005 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3006 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3007 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3008 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3009 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3010 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3011 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
3012 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
3013 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3014 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3015 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
3016 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
3017 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
3018 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3019 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
3020 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3021 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
3022 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3023 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3024 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3025 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
3026 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3027 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
3028 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
3029 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
3030 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
3031 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
3032 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3033 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
3034 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
3035 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
3036 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
3037 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
3038 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
3039 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
3040 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
3041 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
3042 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3043 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
3044 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
3045 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3046 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3047 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3048 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
3049 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3050 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
3051 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
3052 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
3053 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3054 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
3055 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3056 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3057 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
3058 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3059 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3060 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
3061 {}
3062};
3063
3064/*
3065 * ALC880 codec presets
3066 */
3067static struct alc_config_preset alc880_presets[] = {
3068 [ALC880_3ST] = {
3069 .mixers = { alc880_three_stack_mixer },
3070 .init_verbs = { alc880_volume_init_verbs,
3071 alc880_pin_3stack_init_verbs },
3072 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3073 .dac_nids = alc880_dac_nids,
3074 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3075 .channel_mode = alc880_threestack_modes,
3076 .need_dac_fix = 1,
3077 .input_mux = &alc880_capture_source,
3078 },
3079 [ALC880_3ST_DIG] = {
3080 .mixers = { alc880_three_stack_mixer },
3081 .init_verbs = { alc880_volume_init_verbs,
3082 alc880_pin_3stack_init_verbs },
3083 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3084 .dac_nids = alc880_dac_nids,
3085 .dig_out_nid = ALC880_DIGOUT_NID,
3086 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3087 .channel_mode = alc880_threestack_modes,
3088 .need_dac_fix = 1,
3089 .input_mux = &alc880_capture_source,
3090 },
3091 [ALC880_TCL_S700] = {
3092 .mixers = { alc880_tcl_s700_mixer },
3093 .init_verbs = { alc880_volume_init_verbs,
3094 alc880_pin_tcl_S700_init_verbs,
3095 alc880_gpio2_init_verbs },
3096 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3097 .dac_nids = alc880_dac_nids,
3098 .hp_nid = 0x03,
3099 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3100 .channel_mode = alc880_2_jack_modes,
3101 .input_mux = &alc880_capture_source,
3102 },
3103 [ALC880_5ST] = {
3104 .mixers = { alc880_three_stack_mixer,
3105 alc880_five_stack_mixer},
3106 .init_verbs = { alc880_volume_init_verbs,
3107 alc880_pin_5stack_init_verbs },
3108 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3109 .dac_nids = alc880_dac_nids,
3110 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3111 .channel_mode = alc880_fivestack_modes,
3112 .input_mux = &alc880_capture_source,
3113 },
3114 [ALC880_5ST_DIG] = {
3115 .mixers = { alc880_three_stack_mixer,
3116 alc880_five_stack_mixer },
3117 .init_verbs = { alc880_volume_init_verbs,
3118 alc880_pin_5stack_init_verbs },
3119 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3120 .dac_nids = alc880_dac_nids,
3121 .dig_out_nid = ALC880_DIGOUT_NID,
3122 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3123 .channel_mode = alc880_fivestack_modes,
3124 .input_mux = &alc880_capture_source,
3125 },
3126 [ALC880_6ST] = {
3127 .mixers = { alc880_six_stack_mixer },
3128 .init_verbs = { alc880_volume_init_verbs,
3129 alc880_pin_6stack_init_verbs },
3130 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3131 .dac_nids = alc880_6st_dac_nids,
3132 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3133 .channel_mode = alc880_sixstack_modes,
3134 .input_mux = &alc880_6stack_capture_source,
3135 },
3136 [ALC880_6ST_DIG] = {
3137 .mixers = { alc880_six_stack_mixer },
3138 .init_verbs = { alc880_volume_init_verbs,
3139 alc880_pin_6stack_init_verbs },
3140 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3141 .dac_nids = alc880_6st_dac_nids,
3142 .dig_out_nid = ALC880_DIGOUT_NID,
3143 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3144 .channel_mode = alc880_sixstack_modes,
3145 .input_mux = &alc880_6stack_capture_source,
3146 },
3147 [ALC880_W810] = {
3148 .mixers = { alc880_w810_base_mixer },
3149 .init_verbs = { alc880_volume_init_verbs,
3150 alc880_pin_w810_init_verbs,
3151 alc880_gpio2_init_verbs },
3152 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3153 .dac_nids = alc880_w810_dac_nids,
3154 .dig_out_nid = ALC880_DIGOUT_NID,
3155 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3156 .channel_mode = alc880_w810_modes,
3157 .input_mux = &alc880_capture_source,
3158 },
3159 [ALC880_Z71V] = {
3160 .mixers = { alc880_z71v_mixer },
3161 .init_verbs = { alc880_volume_init_verbs,
3162 alc880_pin_z71v_init_verbs },
3163 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3164 .dac_nids = alc880_z71v_dac_nids,
3165 .dig_out_nid = ALC880_DIGOUT_NID,
3166 .hp_nid = 0x03,
3167 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3168 .channel_mode = alc880_2_jack_modes,
3169 .input_mux = &alc880_capture_source,
3170 },
3171 [ALC880_F1734] = {
3172 .mixers = { alc880_f1734_mixer },
3173 .init_verbs = { alc880_volume_init_verbs,
3174 alc880_pin_f1734_init_verbs },
3175 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3176 .dac_nids = alc880_f1734_dac_nids,
3177 .hp_nid = 0x02,
3178 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3179 .channel_mode = alc880_2_jack_modes,
3180 .input_mux = &alc880_f1734_capture_source,
3181 .unsol_event = alc880_uniwill_p53_unsol_event,
3182 .init_hook = alc880_uniwill_p53_hp_automute,
3183 },
3184 [ALC880_ASUS] = {
3185 .mixers = { alc880_asus_mixer },
3186 .init_verbs = { alc880_volume_init_verbs,
3187 alc880_pin_asus_init_verbs,
3188 alc880_gpio1_init_verbs },
3189 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3190 .dac_nids = alc880_asus_dac_nids,
3191 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3192 .channel_mode = alc880_asus_modes,
3193 .need_dac_fix = 1,
3194 .input_mux = &alc880_capture_source,
3195 },
3196 [ALC880_ASUS_DIG] = {
3197 .mixers = { alc880_asus_mixer },
3198 .init_verbs = { alc880_volume_init_verbs,
3199 alc880_pin_asus_init_verbs,
3200 alc880_gpio1_init_verbs },
3201 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3202 .dac_nids = alc880_asus_dac_nids,
3203 .dig_out_nid = ALC880_DIGOUT_NID,
3204 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3205 .channel_mode = alc880_asus_modes,
3206 .need_dac_fix = 1,
3207 .input_mux = &alc880_capture_source,
3208 },
3209 [ALC880_ASUS_DIG2] = {
3210 .mixers = { alc880_asus_mixer },
3211 .init_verbs = { alc880_volume_init_verbs,
3212 alc880_pin_asus_init_verbs,
3213 alc880_gpio2_init_verbs }, /* use GPIO2 */
3214 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3215 .dac_nids = alc880_asus_dac_nids,
3216 .dig_out_nid = ALC880_DIGOUT_NID,
3217 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3218 .channel_mode = alc880_asus_modes,
3219 .need_dac_fix = 1,
3220 .input_mux = &alc880_capture_source,
3221 },
3222 [ALC880_ASUS_W1V] = {
3223 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
3224 .init_verbs = { alc880_volume_init_verbs,
3225 alc880_pin_asus_init_verbs,
3226 alc880_gpio1_init_verbs },
3227 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3228 .dac_nids = alc880_asus_dac_nids,
3229 .dig_out_nid = ALC880_DIGOUT_NID,
3230 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3231 .channel_mode = alc880_asus_modes,
3232 .need_dac_fix = 1,
3233 .input_mux = &alc880_capture_source,
3234 },
3235 [ALC880_UNIWILL_DIG] = {
3236 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
3237 .init_verbs = { alc880_volume_init_verbs,
3238 alc880_pin_asus_init_verbs },
3239 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3240 .dac_nids = alc880_asus_dac_nids,
3241 .dig_out_nid = ALC880_DIGOUT_NID,
3242 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3243 .channel_mode = alc880_asus_modes,
3244 .need_dac_fix = 1,
3245 .input_mux = &alc880_capture_source,
3246 },
3247 [ALC880_UNIWILL] = {
3248 .mixers = { alc880_uniwill_mixer },
3249 .init_verbs = { alc880_volume_init_verbs,
3250 alc880_uniwill_init_verbs },
3251 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3252 .dac_nids = alc880_asus_dac_nids,
3253 .dig_out_nid = ALC880_DIGOUT_NID,
3254 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3255 .channel_mode = alc880_threestack_modes,
3256 .need_dac_fix = 1,
3257 .input_mux = &alc880_capture_source,
3258 .unsol_event = alc880_uniwill_unsol_event,
3259 .init_hook = alc880_uniwill_automute,
3260 },
3261 [ALC880_UNIWILL_P53] = {
3262 .mixers = { alc880_uniwill_p53_mixer },
3263 .init_verbs = { alc880_volume_init_verbs,
3264 alc880_uniwill_p53_init_verbs },
3265 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3266 .dac_nids = alc880_asus_dac_nids,
3267 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3268 .channel_mode = alc880_threestack_modes,
3269 .input_mux = &alc880_capture_source,
3270 .unsol_event = alc880_uniwill_p53_unsol_event,
3271 .init_hook = alc880_uniwill_p53_hp_automute,
3272 },
3273 [ALC880_FUJITSU] = {
3274 .mixers = { alc880_fujitsu_mixer,
3275 alc880_pcbeep_mixer, },
3276 .init_verbs = { alc880_volume_init_verbs,
3277 alc880_uniwill_p53_init_verbs,
3278 alc880_beep_init_verbs },
3279 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3280 .dac_nids = alc880_dac_nids,
3281 .dig_out_nid = ALC880_DIGOUT_NID,
3282 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3283 .channel_mode = alc880_2_jack_modes,
3284 .input_mux = &alc880_capture_source,
3285 .unsol_event = alc880_uniwill_p53_unsol_event,
3286 .init_hook = alc880_uniwill_p53_hp_automute,
3287 },
3288 [ALC880_CLEVO] = {
3289 .mixers = { alc880_three_stack_mixer },
3290 .init_verbs = { alc880_volume_init_verbs,
3291 alc880_pin_clevo_init_verbs },
3292 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3293 .dac_nids = alc880_dac_nids,
3294 .hp_nid = 0x03,
3295 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3296 .channel_mode = alc880_threestack_modes,
3297 .need_dac_fix = 1,
3298 .input_mux = &alc880_capture_source,
3299 },
3300 [ALC880_LG] = {
3301 .mixers = { alc880_lg_mixer },
3302 .init_verbs = { alc880_volume_init_verbs,
3303 alc880_lg_init_verbs },
3304 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3305 .dac_nids = alc880_lg_dac_nids,
3306 .dig_out_nid = ALC880_DIGOUT_NID,
3307 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3308 .channel_mode = alc880_lg_ch_modes,
3309 .need_dac_fix = 1,
3310 .input_mux = &alc880_lg_capture_source,
3311 .unsol_event = alc880_lg_unsol_event,
3312 .init_hook = alc880_lg_automute,
3313#ifdef CONFIG_SND_HDA_POWER_SAVE
3314 .loopbacks = alc880_lg_loopbacks,
3315#endif
3316 },
3317 [ALC880_LG_LW] = {
3318 .mixers = { alc880_lg_lw_mixer },
3319 .init_verbs = { alc880_volume_init_verbs,
3320 alc880_lg_lw_init_verbs },
3321 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3322 .dac_nids = alc880_dac_nids,
3323 .dig_out_nid = ALC880_DIGOUT_NID,
3324 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3325 .channel_mode = alc880_lg_lw_modes,
3326 .input_mux = &alc880_lg_lw_capture_source,
3327 .unsol_event = alc880_lg_lw_unsol_event,
3328 .init_hook = alc880_lg_lw_automute,
3329 },
3330 [ALC880_MEDION_RIM] = {
3331 .mixers = { alc880_medion_rim_mixer },
3332 .init_verbs = { alc880_volume_init_verbs,
3333 alc880_medion_rim_init_verbs,
3334 alc_gpio2_init_verbs },
3335 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3336 .dac_nids = alc880_dac_nids,
3337 .dig_out_nid = ALC880_DIGOUT_NID,
3338 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3339 .channel_mode = alc880_2_jack_modes,
3340 .input_mux = &alc880_medion_rim_capture_source,
3341 .unsol_event = alc880_medion_rim_unsol_event,
3342 .init_hook = alc880_medion_rim_automute,
3343 },
3344#ifdef CONFIG_SND_DEBUG
3345 [ALC880_TEST] = {
3346 .mixers = { alc880_test_mixer },
3347 .init_verbs = { alc880_test_init_verbs },
3348 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3349 .dac_nids = alc880_test_dac_nids,
3350 .dig_out_nid = ALC880_DIGOUT_NID,
3351 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3352 .channel_mode = alc880_test_modes,
3353 .input_mux = &alc880_test_capture_source,
3354 },
3355#endif
3356};
3357
3358/*
3359 * Automatic parse of I/O pins from the BIOS configuration
3360 */
3361
3362#define NUM_CONTROL_ALLOC 32
3363#define NUM_VERB_ALLOC 32
3364
3365enum {
3366 ALC_CTL_WIDGET_VOL,
3367 ALC_CTL_WIDGET_MUTE,
3368 ALC_CTL_BIND_MUTE,
3369};
3370static struct snd_kcontrol_new alc880_control_templates[] = {
3371 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3372 HDA_CODEC_MUTE(NULL, 0, 0, 0),
3373 HDA_BIND_MUTE(NULL, 0, 0, 0),
3374};
3375
3376/* add dynamic controls */
3377static int add_control(struct alc_spec *spec, int type, const char *name,
3378 unsigned long val)
3379{
3380 struct snd_kcontrol_new *knew;
3381
3382 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3383 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3384
3385 /* array + terminator */
3386 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3387 if (!knew)
3388 return -ENOMEM;
3389 if (spec->kctl_alloc) {
3390 memcpy(knew, spec->kctl_alloc,
3391 sizeof(*knew) * spec->num_kctl_alloc);
3392 kfree(spec->kctl_alloc);
3393 }
3394 spec->kctl_alloc = knew;
3395 spec->num_kctl_alloc = num;
3396 }
3397
3398 knew = &spec->kctl_alloc[spec->num_kctl_used];
3399 *knew = alc880_control_templates[type];
3400 knew->name = kstrdup(name, GFP_KERNEL);
3401 if (!knew->name)
3402 return -ENOMEM;
3403 knew->private_value = val;
3404 spec->num_kctl_used++;
3405 return 0;
3406}
3407
3408#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3409#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3410#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3411#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3412#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3413#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3414#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3415#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3416#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3417#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3418#define ALC880_PIN_CD_NID 0x1c
3419
3420/* fill in the dac_nids table from the parsed pin configuration */
3421static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3422 const struct auto_pin_cfg *cfg)
3423{
3424 hda_nid_t nid;
3425 int assigned[4];
3426 int i, j;
3427
3428 memset(assigned, 0, sizeof(assigned));
3429 spec->multiout.dac_nids = spec->private_dac_nids;
3430
3431 /* check the pins hardwired to audio widget */
3432 for (i = 0; i < cfg->line_outs; i++) {
3433 nid = cfg->line_out_pins[i];
3434 if (alc880_is_fixed_pin(nid)) {
3435 int idx = alc880_fixed_pin_idx(nid);
3436 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3437 assigned[idx] = 1;
3438 }
3439 }
3440 /* left pins can be connect to any audio widget */
3441 for (i = 0; i < cfg->line_outs; i++) {
3442 nid = cfg->line_out_pins[i];
3443 if (alc880_is_fixed_pin(nid))
3444 continue;
3445 /* search for an empty channel */
3446 for (j = 0; j < cfg->line_outs; j++) {
3447 if (!assigned[j]) {
3448 spec->multiout.dac_nids[i] =
3449 alc880_idx_to_dac(j);
3450 assigned[j] = 1;
3451 break;
3452 }
3453 }
3454 }
3455 spec->multiout.num_dacs = cfg->line_outs;
3456 return 0;
3457}
3458
3459/* add playback controls from the parsed DAC table */
3460static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3461 const struct auto_pin_cfg *cfg)
3462{
3463 char name[32];
3464 static const char *chname[4] = {
3465 "Front", "Surround", NULL /*CLFE*/, "Side"
3466 };
3467 hda_nid_t nid;
3468 int i, err;
3469
3470 for (i = 0; i < cfg->line_outs; i++) {
3471 if (!spec->multiout.dac_nids[i])
3472 continue;
3473 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3474 if (i == 2) {
3475 /* Center/LFE */
3476 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3477 "Center Playback Volume",
3478 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3479 HDA_OUTPUT));
3480 if (err < 0)
3481 return err;
3482 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3483 "LFE Playback Volume",
3484 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3485 HDA_OUTPUT));
3486 if (err < 0)
3487 return err;
3488 err = add_control(spec, ALC_CTL_BIND_MUTE,
3489 "Center Playback Switch",
3490 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3491 HDA_INPUT));
3492 if (err < 0)
3493 return err;
3494 err = add_control(spec, ALC_CTL_BIND_MUTE,
3495 "LFE Playback Switch",
3496 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3497 HDA_INPUT));
3498 if (err < 0)
3499 return err;
3500 } else {
3501 sprintf(name, "%s Playback Volume", chname[i]);
3502 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3503 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3504 HDA_OUTPUT));
3505 if (err < 0)
3506 return err;
3507 sprintf(name, "%s Playback Switch", chname[i]);
3508 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3509 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3510 HDA_INPUT));
3511 if (err < 0)
3512 return err;
3513 }
3514 }
3515 return 0;
3516}
3517
3518/* add playback controls for speaker and HP outputs */
3519static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3520 const char *pfx)
3521{
3522 hda_nid_t nid;
3523 int err;
3524 char name[32];
3525
3526 if (!pin)
3527 return 0;
3528
3529 if (alc880_is_fixed_pin(pin)) {
3530 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3531 /* specify the DAC as the extra output */
3532 if (!spec->multiout.hp_nid)
3533 spec->multiout.hp_nid = nid;
3534 else
3535 spec->multiout.extra_out_nid[0] = nid;
3536 /* control HP volume/switch on the output mixer amp */
3537 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3538 sprintf(name, "%s Playback Volume", pfx);
3539 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3540 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3541 if (err < 0)
3542 return err;
3543 sprintf(name, "%s Playback Switch", pfx);
3544 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3545 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3546 if (err < 0)
3547 return err;
3548 } else if (alc880_is_multi_pin(pin)) {
3549 /* set manual connection */
3550 /* we have only a switch on HP-out PIN */
3551 sprintf(name, "%s Playback Switch", pfx);
3552 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3553 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3554 if (err < 0)
3555 return err;
3556 }
3557 return 0;
3558}
3559
3560/* create input playback/capture controls for the given pin */
3561static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3562 const char *ctlname,
3563 int idx, hda_nid_t mix_nid)
3564{
3565 char name[32];
3566 int err;
3567
3568 sprintf(name, "%s Playback Volume", ctlname);
3569 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3570 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3571 if (err < 0)
3572 return err;
3573 sprintf(name, "%s Playback Switch", ctlname);
3574 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3575 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3576 if (err < 0)
3577 return err;
3578 return 0;
3579}
3580
3581/* create playback/capture controls for input pins */
3582static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3583 const struct auto_pin_cfg *cfg)
3584{
3585 struct hda_input_mux *imux = &spec->private_imux;
3586 int i, err, idx;
3587
3588 for (i = 0; i < AUTO_PIN_LAST; i++) {
3589 if (alc880_is_input_pin(cfg->input_pins[i])) {
3590 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3591 err = new_analog_input(spec, cfg->input_pins[i],
3592 auto_pin_cfg_labels[i],
3593 idx, 0x0b);
3594 if (err < 0)
3595 return err;
3596 imux->items[imux->num_items].label =
3597 auto_pin_cfg_labels[i];
3598 imux->items[imux->num_items].index =
3599 alc880_input_pin_idx(cfg->input_pins[i]);
3600 imux->num_items++;
3601 }
3602 }
3603 return 0;
3604}
3605
3606static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3607 unsigned int pin_type)
3608{
3609 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3610 pin_type);
3611 /* unmute pin */
3612 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3613 AMP_OUT_UNMUTE);
3614}
3615
3616static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3617 hda_nid_t nid, int pin_type,
3618 int dac_idx)
3619{
3620 alc_set_pin_output(codec, nid, pin_type);
3621 /* need the manual connection? */
3622 if (alc880_is_multi_pin(nid)) {
3623 struct alc_spec *spec = codec->spec;
3624 int idx = alc880_multi_pin_idx(nid);
3625 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3626 AC_VERB_SET_CONNECT_SEL,
3627 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3628 }
3629}
3630
3631static int get_pin_type(int line_out_type)
3632{
3633 if (line_out_type == AUTO_PIN_HP_OUT)
3634 return PIN_HP;
3635 else
3636 return PIN_OUT;
3637}
3638
3639static void alc880_auto_init_multi_out(struct hda_codec *codec)
3640{
3641 struct alc_spec *spec = codec->spec;
3642 int i;
3643
3644 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3645 for (i = 0; i < spec->autocfg.line_outs; i++) {
3646 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3647 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3648 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3649 }
3650}
3651
3652static void alc880_auto_init_extra_out(struct hda_codec *codec)
3653{
3654 struct alc_spec *spec = codec->spec;
3655 hda_nid_t pin;
3656
3657 pin = spec->autocfg.speaker_pins[0];
3658 if (pin) /* connect to front */
3659 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3660 pin = spec->autocfg.hp_pins[0];
3661 if (pin) /* connect to front */
3662 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3663}
3664
3665static void alc880_auto_init_analog_input(struct hda_codec *codec)
3666{
3667 struct alc_spec *spec = codec->spec;
3668 int i;
3669
3670 for (i = 0; i < AUTO_PIN_LAST; i++) {
3671 hda_nid_t nid = spec->autocfg.input_pins[i];
3672 if (alc880_is_input_pin(nid)) {
3673 snd_hda_codec_write(codec, nid, 0,
3674 AC_VERB_SET_PIN_WIDGET_CONTROL,
3675 i <= AUTO_PIN_FRONT_MIC ?
3676 PIN_VREF80 : PIN_IN);
3677 if (nid != ALC880_PIN_CD_NID)
3678 snd_hda_codec_write(codec, nid, 0,
3679 AC_VERB_SET_AMP_GAIN_MUTE,
3680 AMP_OUT_MUTE);
3681 }
3682 }
3683}
3684
3685/* parse the BIOS configuration and set up the alc_spec */
3686/* return 1 if successful, 0 if the proper config is not found,
3687 * or a negative error code
3688 */
3689static int alc880_parse_auto_config(struct hda_codec *codec)
3690{
3691 struct alc_spec *spec = codec->spec;
3692 int err;
3693 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3694
3695 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3696 alc880_ignore);
3697 if (err < 0)
3698 return err;
3699 if (!spec->autocfg.line_outs)
3700 return 0; /* can't find valid BIOS pin config */
3701
3702 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3703 if (err < 0)
3704 return err;
3705 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3706 if (err < 0)
3707 return err;
3708 err = alc880_auto_create_extra_out(spec,
3709 spec->autocfg.speaker_pins[0],
3710 "Speaker");
3711 if (err < 0)
3712 return err;
3713 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3714 "Headphone");
3715 if (err < 0)
3716 return err;
3717 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3718 if (err < 0)
3719 return err;
3720
3721 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3722
3723 if (spec->autocfg.dig_out_pin)
3724 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3725 if (spec->autocfg.dig_in_pin)
3726 spec->dig_in_nid = ALC880_DIGIN_NID;
3727
3728 if (spec->kctl_alloc)
3729 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3730
3731 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3732
3733 spec->num_mux_defs = 1;
3734 spec->input_mux = &spec->private_imux;
3735
3736 return 1;
3737}
3738
3739/* additional initialization for auto-configuration model */
3740static void alc880_auto_init(struct hda_codec *codec)
3741{
3742 struct alc_spec *spec = codec->spec;
3743 alc880_auto_init_multi_out(codec);
3744 alc880_auto_init_extra_out(codec);
3745 alc880_auto_init_analog_input(codec);
3746 if (spec->unsol_event)
3747 alc_sku_automute(codec);
3748}
3749
3750/*
3751 * OK, here we have finally the patch for ALC880
3752 */
3753
3754static int patch_alc880(struct hda_codec *codec)
3755{
3756 struct alc_spec *spec;
3757 int board_config;
3758 int err;
3759
3760 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3761 if (spec == NULL)
3762 return -ENOMEM;
3763
3764 codec->spec = spec;
3765
3766 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3767 alc880_models,
3768 alc880_cfg_tbl);
3769 if (board_config < 0) {
3770 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3771 "trying auto-probe from BIOS...\n");
3772 board_config = ALC880_AUTO;
3773 }
3774
3775 if (board_config == ALC880_AUTO) {
3776 /* automatic parse from the BIOS config */
3777 err = alc880_parse_auto_config(codec);
3778 if (err < 0) {
3779 alc_free(codec);
3780 return err;
3781 } else if (!err) {
3782 printk(KERN_INFO
3783 "hda_codec: Cannot set up configuration "
3784 "from BIOS. Using 3-stack mode...\n");
3785 board_config = ALC880_3ST;
3786 }
3787 }
3788
3789 if (board_config != ALC880_AUTO)
3790 setup_preset(spec, &alc880_presets[board_config]);
3791
3792 spec->stream_name_analog = "ALC880 Analog";
3793 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3794 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3795 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
3796
3797 spec->stream_name_digital = "ALC880 Digital";
3798 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3799 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3800
3801 if (!spec->adc_nids && spec->input_mux) {
3802 /* check whether NID 0x07 is valid */
3803 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3804 /* get type */
3805 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3806 if (wcap != AC_WID_AUD_IN) {
3807 spec->adc_nids = alc880_adc_nids_alt;
3808 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3809 spec->mixers[spec->num_mixers] =
3810 alc880_capture_alt_mixer;
3811 spec->num_mixers++;
3812 } else {
3813 spec->adc_nids = alc880_adc_nids;
3814 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3815 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3816 spec->num_mixers++;
3817 }
3818 }
3819
3820 spec->vmaster_nid = 0x0c;
3821
3822 codec->patch_ops = alc_patch_ops;
3823 if (board_config == ALC880_AUTO)
3824 spec->init_hook = alc880_auto_init;
3825#ifdef CONFIG_SND_HDA_POWER_SAVE
3826 if (!spec->loopback.amplist)
3827 spec->loopback.amplist = alc880_loopbacks;
3828#endif
3829
3830 return 0;
3831}
3832
3833
3834/*
3835 * ALC260 support
3836 */
3837
3838static hda_nid_t alc260_dac_nids[1] = {
3839 /* front */
3840 0x02,
3841};
3842
3843static hda_nid_t alc260_adc_nids[1] = {
3844 /* ADC0 */
3845 0x04,
3846};
3847
3848static hda_nid_t alc260_adc_nids_alt[1] = {
3849 /* ADC1 */
3850 0x05,
3851};
3852
3853static hda_nid_t alc260_hp_adc_nids[2] = {
3854 /* ADC1, 0 */
3855 0x05, 0x04
3856};
3857
3858/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3859 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3860 */
3861static hda_nid_t alc260_dual_adc_nids[2] = {
3862 /* ADC0, ADC1 */
3863 0x04, 0x05
3864};
3865
3866#define ALC260_DIGOUT_NID 0x03
3867#define ALC260_DIGIN_NID 0x06
3868
3869static struct hda_input_mux alc260_capture_source = {
3870 .num_items = 4,
3871 .items = {
3872 { "Mic", 0x0 },
3873 { "Front Mic", 0x1 },
3874 { "Line", 0x2 },
3875 { "CD", 0x4 },
3876 },
3877};
3878
3879/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3880 * headphone jack and the internal CD lines since these are the only pins at
3881 * which audio can appear. For flexibility, also allow the option of
3882 * recording the mixer output on the second ADC (ADC0 doesn't have a
3883 * connection to the mixer output).
3884 */
3885static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3886 {
3887 .num_items = 3,
3888 .items = {
3889 { "Mic/Line", 0x0 },
3890 { "CD", 0x4 },
3891 { "Headphone", 0x2 },
3892 },
3893 },
3894 {
3895 .num_items = 4,
3896 .items = {
3897 { "Mic/Line", 0x0 },
3898 { "CD", 0x4 },
3899 { "Headphone", 0x2 },
3900 { "Mixer", 0x5 },
3901 },
3902 },
3903
3904};
3905
3906/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3907 * the Fujitsu S702x, but jacks are marked differently.
3908 */
3909static struct hda_input_mux alc260_acer_capture_sources[2] = {
3910 {
3911 .num_items = 4,
3912 .items = {
3913 { "Mic", 0x0 },
3914 { "Line", 0x2 },
3915 { "CD", 0x4 },
3916 { "Headphone", 0x5 },
3917 },
3918 },
3919 {
3920 .num_items = 5,
3921 .items = {
3922 { "Mic", 0x0 },
3923 { "Line", 0x2 },
3924 { "CD", 0x4 },
3925 { "Headphone", 0x6 },
3926 { "Mixer", 0x5 },
3927 },
3928 },
3929};
3930/*
3931 * This is just place-holder, so there's something for alc_build_pcms to look
3932 * at when it calculates the maximum number of channels. ALC260 has no mixer
3933 * element which allows changing the channel mode, so the verb list is
3934 * never used.
3935 */
3936static struct hda_channel_mode alc260_modes[1] = {
3937 { 2, NULL },
3938};
3939
3940
3941/* Mixer combinations
3942 *
3943 * basic: base_output + input + pc_beep + capture
3944 * HP: base_output + input + capture_alt
3945 * HP_3013: hp_3013 + input + capture
3946 * fujitsu: fujitsu + capture
3947 * acer: acer + capture
3948 */
3949
3950static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3951 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3952 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3953 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3954 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3955 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3956 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3957 { } /* end */
3958};
3959
3960static struct snd_kcontrol_new alc260_input_mixer[] = {
3961 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3962 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3963 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3964 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3965 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3966 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3967 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3968 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3969 { } /* end */
3970};
3971
3972static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3973 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3974 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3975 { } /* end */
3976};
3977
3978/* update HP, line and mono out pins according to the master switch */
3979static void alc260_hp_master_update(struct hda_codec *codec,
3980 hda_nid_t hp, hda_nid_t line,
3981 hda_nid_t mono)
3982{
3983 struct alc_spec *spec = codec->spec;
3984 unsigned int val = spec->master_sw ? PIN_HP : 0;
3985 /* change HP and line-out pins */
3986 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3987 val);
3988 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3989 val);
3990 /* mono (speaker) depending on the HP jack sense */
3991 val = (val && !spec->jack_present) ? PIN_OUT : 0;
3992 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3993 val);
3994}
3995
3996static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
3997 struct snd_ctl_elem_value *ucontrol)
3998{
3999 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4000 struct alc_spec *spec = codec->spec;
4001 *ucontrol->value.integer.value = spec->master_sw;
4002 return 0;
4003}
4004
4005static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4006 struct snd_ctl_elem_value *ucontrol)
4007{
4008 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4009 struct alc_spec *spec = codec->spec;
4010 int val = !!*ucontrol->value.integer.value;
4011 hda_nid_t hp, line, mono;
4012
4013 if (val == spec->master_sw)
4014 return 0;
4015 spec->master_sw = val;
4016 hp = (kcontrol->private_value >> 16) & 0xff;
4017 line = (kcontrol->private_value >> 8) & 0xff;
4018 mono = kcontrol->private_value & 0xff;
4019 alc260_hp_master_update(codec, hp, line, mono);
4020 return 1;
4021}
4022
4023static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4024 {
4025 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4026 .name = "Master Playback Switch",
4027 .info = snd_ctl_boolean_mono_info,
4028 .get = alc260_hp_master_sw_get,
4029 .put = alc260_hp_master_sw_put,
4030 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4031 },
4032 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4033 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4034 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4035 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4036 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4037 HDA_OUTPUT),
4038 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4039 { } /* end */
4040};
4041
4042static struct hda_verb alc260_hp_unsol_verbs[] = {
4043 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4044 {},
4045};
4046
4047static void alc260_hp_automute(struct hda_codec *codec)
4048{
4049 struct alc_spec *spec = codec->spec;
4050 unsigned int present;
4051
4052 present = snd_hda_codec_read(codec, 0x10, 0,
4053 AC_VERB_GET_PIN_SENSE, 0);
4054 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4055 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4056}
4057
4058static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4059{
4060 if ((res >> 26) == ALC880_HP_EVENT)
4061 alc260_hp_automute(codec);
4062}
4063
4064static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
4065 {
4066 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4067 .name = "Master Playback Switch",
4068 .info = snd_ctl_boolean_mono_info,
4069 .get = alc260_hp_master_sw_get,
4070 .put = alc260_hp_master_sw_put,
4071 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4072 },
4073 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4074 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4075 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4076 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4077 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
4079 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4080 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
4081 { } /* end */
4082};
4083
4084static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4085 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4086 {},
4087};
4088
4089static void alc260_hp_3013_automute(struct hda_codec *codec)
4090{
4091 struct alc_spec *spec = codec->spec;
4092 unsigned int present;
4093
4094 present = snd_hda_codec_read(codec, 0x15, 0,
4095 AC_VERB_GET_PIN_SENSE, 0);
4096 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4097 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4098}
4099
4100static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4101 unsigned int res)
4102{
4103 if ((res >> 26) == ALC880_HP_EVENT)
4104 alc260_hp_3013_automute(codec);
4105}
4106
4107/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
4108 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4109 */
4110static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
4111 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4112 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
4113 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4114 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4115 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4116 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4117 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
4118 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
4119 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4120 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4121 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4122 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
4123 { } /* end */
4124};
4125
4126/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4127 * versions of the ALC260 don't act on requests to enable mic bias from NID
4128 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4129 * datasheet doesn't mention this restriction. At this stage it's not clear
4130 * whether this behaviour is intentional or is a hardware bug in chip
4131 * revisions available in early 2006. Therefore for now allow the
4132 * "Headphone Jack Mode" control to span all choices, but if it turns out
4133 * that the lack of mic bias for this NID is intentional we could change the
4134 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4135 *
4136 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4137 * don't appear to make the mic bias available from the "line" jack, even
4138 * though the NID used for this jack (0x14) can supply it. The theory is
4139 * that perhaps Acer have included blocking capacitors between the ALC260
4140 * and the output jack. If this turns out to be the case for all such
4141 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4142 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
4143 *
4144 * The C20x Tablet series have a mono internal speaker which is controlled
4145 * via the chip's Mono sum widget and pin complex, so include the necessary
4146 * controls for such models. On models without a "mono speaker" the control
4147 * won't do anything.
4148 */
4149static struct snd_kcontrol_new alc260_acer_mixer[] = {
4150 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4151 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4152 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4153 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4154 HDA_OUTPUT),
4155 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
4156 HDA_INPUT),
4157 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4158 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4159 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4160 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4161 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4162 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4163 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4164 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4165 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4166 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4167 { } /* end */
4168};
4169
4170/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4171 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4172 */
4173static struct snd_kcontrol_new alc260_will_mixer[] = {
4174 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4175 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4176 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4177 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4178 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4179 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4180 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4181 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4182 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4183 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4184 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4185 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4186 { } /* end */
4187};
4188
4189/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4190 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4191 */
4192static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4193 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4194 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4195 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4196 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4197 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4198 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4199 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4200 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4201 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4202 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4203 { } /* end */
4204};
4205
4206/* capture mixer elements */
4207static struct snd_kcontrol_new alc260_capture_mixer[] = {
4208 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4209 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
4210 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4211 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
4212 {
4213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4214 /* The multiple "Capture Source" controls confuse alsamixer
4215 * So call somewhat different..
4216 */
4217 /* .name = "Capture Source", */
4218 .name = "Input Source",
4219 .count = 2,
4220 .info = alc_mux_enum_info,
4221 .get = alc_mux_enum_get,
4222 .put = alc_mux_enum_put,
4223 },
4224 { } /* end */
4225};
4226
4227static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4228 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4229 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4230 {
4231 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4232 /* The multiple "Capture Source" controls confuse alsamixer
4233 * So call somewhat different..
4234 */
4235 /* .name = "Capture Source", */
4236 .name = "Input Source",
4237 .count = 1,
4238 .info = alc_mux_enum_info,
4239 .get = alc_mux_enum_get,
4240 .put = alc_mux_enum_put,
4241 },
4242 { } /* end */
4243};
4244
4245/*
4246 * initialization verbs
4247 */
4248static struct hda_verb alc260_init_verbs[] = {
4249 /* Line In pin widget for input */
4250 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4251 /* CD pin widget for input */
4252 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4253 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4254 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4255 /* Mic2 (front panel) pin widget for input and vref at 80% */
4256 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4257 /* LINE-2 is used for line-out in rear */
4258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4259 /* select line-out */
4260 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
4261 /* LINE-OUT pin */
4262 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4263 /* enable HP */
4264 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4265 /* enable Mono */
4266 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4267 /* mute capture amp left and right */
4268 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4269 /* set connection select to line in (default select for this ADC) */
4270 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4271 /* mute capture amp left and right */
4272 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4273 /* set connection select to line in (default select for this ADC) */
4274 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
4275 /* set vol=0 Line-Out mixer amp left and right */
4276 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4277 /* unmute pin widget amp left and right (no gain on this amp) */
4278 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4279 /* set vol=0 HP mixer amp left and right */
4280 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4281 /* unmute pin widget amp left and right (no gain on this amp) */
4282 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4283 /* set vol=0 Mono mixer amp left and right */
4284 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4285 /* unmute pin widget amp left and right (no gain on this amp) */
4286 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4287 /* unmute LINE-2 out pin */
4288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4289 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4290 * Line In 2 = 0x03
4291 */
4292 /* mute analog inputs */
4293 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4295 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4296 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4297 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4298 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4299 /* mute Front out path */
4300 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4301 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4302 /* mute Headphone out path */
4303 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4304 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4305 /* mute Mono out path */
4306 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4307 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4308 { }
4309};
4310
4311#if 0 /* should be identical with alc260_init_verbs? */
4312static struct hda_verb alc260_hp_init_verbs[] = {
4313 /* Headphone and output */
4314 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4315 /* mono output */
4316 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4317 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4318 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4319 /* Mic2 (front panel) pin widget for input and vref at 80% */
4320 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4321 /* Line In pin widget for input */
4322 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4323 /* Line-2 pin widget for output */
4324 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4325 /* CD pin widget for input */
4326 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4327 /* unmute amp left and right */
4328 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4329 /* set connection select to line in (default select for this ADC) */
4330 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4331 /* unmute Line-Out mixer amp left and right (volume = 0) */
4332 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4333 /* mute pin widget amp left and right (no gain on this amp) */
4334 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4335 /* unmute HP mixer amp left and right (volume = 0) */
4336 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4337 /* mute pin widget amp left and right (no gain on this amp) */
4338 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4339 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4340 * Line In 2 = 0x03
4341 */
4342 /* mute analog inputs */
4343 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4344 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4345 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4346 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4347 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4348 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4349 /* Unmute Front out path */
4350 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4351 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4352 /* Unmute Headphone out path */
4353 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4354 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4355 /* Unmute Mono out path */
4356 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4357 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4358 { }
4359};
4360#endif
4361
4362static struct hda_verb alc260_hp_3013_init_verbs[] = {
4363 /* Line out and output */
4364 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4365 /* mono output */
4366 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4367 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4368 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4369 /* Mic2 (front panel) pin widget for input and vref at 80% */
4370 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4371 /* Line In pin widget for input */
4372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4373 /* Headphone pin widget for output */
4374 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4375 /* CD pin widget for input */
4376 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4377 /* unmute amp left and right */
4378 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4379 /* set connection select to line in (default select for this ADC) */
4380 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4381 /* unmute Line-Out mixer amp left and right (volume = 0) */
4382 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4383 /* mute pin widget amp left and right (no gain on this amp) */
4384 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4385 /* unmute HP mixer amp left and right (volume = 0) */
4386 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4387 /* mute pin widget amp left and right (no gain on this amp) */
4388 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4389 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4390 * Line In 2 = 0x03
4391 */
4392 /* mute analog inputs */
4393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4398 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4399 /* Unmute Front out path */
4400 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4401 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4402 /* Unmute Headphone out path */
4403 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4404 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4405 /* Unmute Mono out path */
4406 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4407 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4408 { }
4409};
4410
4411/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
4412 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4413 * audio = 0x16, internal speaker = 0x10.
4414 */
4415static struct hda_verb alc260_fujitsu_init_verbs[] = {
4416 /* Disable all GPIOs */
4417 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4418 /* Internal speaker is connected to headphone pin */
4419 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4420 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4421 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4422 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4423 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4424 /* Ensure all other unused pins are disabled and muted. */
4425 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4426 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4427 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4428 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4429 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4430 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4431 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4432 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4433
4434 /* Disable digital (SPDIF) pins */
4435 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4436 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4437
4438 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4439 * when acting as an output.
4440 */
4441 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4442
4443 /* Start with output sum widgets muted and their output gains at min */
4444 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4445 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4447 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4448 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4449 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4450 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4451 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4452 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4453
4454 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4455 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4456 /* Unmute Line1 pin widget output buffer since it starts as an output.
4457 * If the pin mode is changed by the user the pin mode control will
4458 * take care of enabling the pin's input/output buffers as needed.
4459 * Therefore there's no need to enable the input buffer at this
4460 * stage.
4461 */
4462 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4463 /* Unmute input buffer of pin widget used for Line-in (no equiv
4464 * mixer ctrl)
4465 */
4466 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4467
4468 /* Mute capture amp left and right */
4469 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4470 /* Set ADC connection select to match default mixer setting - line
4471 * in (on mic1 pin)
4472 */
4473 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4474
4475 /* Do the same for the second ADC: mute capture input amp and
4476 * set ADC connection to line in (on mic1 pin)
4477 */
4478 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4479 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4480
4481 /* Mute all inputs to mixer widget (even unconnected ones) */
4482 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4483 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4485 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4490
4491 { }
4492};
4493
4494/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4495 * similar laptops (adapted from Fujitsu init verbs).
4496 */
4497static struct hda_verb alc260_acer_init_verbs[] = {
4498 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4499 * the headphone jack. Turn this on and rely on the standard mute
4500 * methods whenever the user wants to turn these outputs off.
4501 */
4502 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4503 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4504 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4505 /* Internal speaker/Headphone jack is connected to Line-out pin */
4506 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4507 /* Internal microphone/Mic jack is connected to Mic1 pin */
4508 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4509 /* Line In jack is connected to Line1 pin */
4510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4511 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4512 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4513 /* Ensure all other unused pins are disabled and muted. */
4514 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4515 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4516 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4517 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4518 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4519 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4520 /* Disable digital (SPDIF) pins */
4521 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4522 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4523
4524 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4525 * bus when acting as outputs.
4526 */
4527 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4528 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4529
4530 /* Start with output sum widgets muted and their output gains at min */
4531 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4532 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4534 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4537 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4538 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4539 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4540
4541 /* Unmute Line-out pin widget amp left and right
4542 * (no equiv mixer ctrl)
4543 */
4544 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4545 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4546 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4547 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4548 * inputs. If the pin mode is changed by the user the pin mode control
4549 * will take care of enabling the pin's input/output buffers as needed.
4550 * Therefore there's no need to enable the input buffer at this
4551 * stage.
4552 */
4553 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4554 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4555
4556 /* Mute capture amp left and right */
4557 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4558 /* Set ADC connection select to match default mixer setting - mic
4559 * (on mic1 pin)
4560 */
4561 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4562
4563 /* Do similar with the second ADC: mute capture input amp and
4564 * set ADC connection to mic to match ALSA's default state.
4565 */
4566 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4567 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4568
4569 /* Mute all inputs to mixer widget (even unconnected ones) */
4570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4571 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4572 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4574 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4578
4579 { }
4580};
4581
4582static struct hda_verb alc260_will_verbs[] = {
4583 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4584 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4585 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4586 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4587 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4588 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4589 {}
4590};
4591
4592static struct hda_verb alc260_replacer_672v_verbs[] = {
4593 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4594 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4595 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4596
4597 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4598 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4599 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4600
4601 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4602 {}
4603};
4604
4605/* toggle speaker-output according to the hp-jack state */
4606static void alc260_replacer_672v_automute(struct hda_codec *codec)
4607{
4608 unsigned int present;
4609
4610 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4611 present = snd_hda_codec_read(codec, 0x0f, 0,
4612 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4613 if (present) {
4614 snd_hda_codec_write_cache(codec, 0x01, 0,
4615 AC_VERB_SET_GPIO_DATA, 1);
4616 snd_hda_codec_write_cache(codec, 0x0f, 0,
4617 AC_VERB_SET_PIN_WIDGET_CONTROL,
4618 PIN_HP);
4619 } else {
4620 snd_hda_codec_write_cache(codec, 0x01, 0,
4621 AC_VERB_SET_GPIO_DATA, 0);
4622 snd_hda_codec_write_cache(codec, 0x0f, 0,
4623 AC_VERB_SET_PIN_WIDGET_CONTROL,
4624 PIN_OUT);
4625 }
4626}
4627
4628static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4629 unsigned int res)
4630{
4631 if ((res >> 26) == ALC880_HP_EVENT)
4632 alc260_replacer_672v_automute(codec);
4633}
4634
4635/* Test configuration for debugging, modelled after the ALC880 test
4636 * configuration.
4637 */
4638#ifdef CONFIG_SND_DEBUG
4639static hda_nid_t alc260_test_dac_nids[1] = {
4640 0x02,
4641};
4642static hda_nid_t alc260_test_adc_nids[2] = {
4643 0x04, 0x05,
4644};
4645/* For testing the ALC260, each input MUX needs its own definition since
4646 * the signal assignments are different. This assumes that the first ADC
4647 * is NID 0x04.
4648 */
4649static struct hda_input_mux alc260_test_capture_sources[2] = {
4650 {
4651 .num_items = 7,
4652 .items = {
4653 { "MIC1 pin", 0x0 },
4654 { "MIC2 pin", 0x1 },
4655 { "LINE1 pin", 0x2 },
4656 { "LINE2 pin", 0x3 },
4657 { "CD pin", 0x4 },
4658 { "LINE-OUT pin", 0x5 },
4659 { "HP-OUT pin", 0x6 },
4660 },
4661 },
4662 {
4663 .num_items = 8,
4664 .items = {
4665 { "MIC1 pin", 0x0 },
4666 { "MIC2 pin", 0x1 },
4667 { "LINE1 pin", 0x2 },
4668 { "LINE2 pin", 0x3 },
4669 { "CD pin", 0x4 },
4670 { "Mixer", 0x5 },
4671 { "LINE-OUT pin", 0x6 },
4672 { "HP-OUT pin", 0x7 },
4673 },
4674 },
4675};
4676static struct snd_kcontrol_new alc260_test_mixer[] = {
4677 /* Output driver widgets */
4678 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4679 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4680 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4681 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4682 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4683 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4684
4685 /* Modes for retasking pin widgets
4686 * Note: the ALC260 doesn't seem to act on requests to enable mic
4687 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4688 * mention this restriction. At this stage it's not clear whether
4689 * this behaviour is intentional or is a hardware bug in chip
4690 * revisions available at least up until early 2006. Therefore for
4691 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4692 * choices, but if it turns out that the lack of mic bias for these
4693 * NIDs is intentional we could change their modes from
4694 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4695 */
4696 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4697 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4698 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4699 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4700 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4701 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4702
4703 /* Loopback mixer controls */
4704 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4705 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4706 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4707 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4708 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4709 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4710 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4711 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4712 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4713 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4714 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4715 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4716 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4717 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4718 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4719 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4720
4721 /* Controls for GPIO pins, assuming they are configured as outputs */
4722 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4723 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4724 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4725 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4726
4727 /* Switches to allow the digital IO pins to be enabled. The datasheet
4728 * is ambigious as to which NID is which; testing on laptops which
4729 * make this output available should provide clarification.
4730 */
4731 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4732 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4733
4734 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4735 * this output to turn on an external amplifier.
4736 */
4737 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4738 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4739
4740 { } /* end */
4741};
4742static struct hda_verb alc260_test_init_verbs[] = {
4743 /* Enable all GPIOs as outputs with an initial value of 0 */
4744 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4745 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4746 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4747
4748 /* Enable retasking pins as output, initially without power amp */
4749 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4750 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4751 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4752 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4753 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4754 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4755
4756 /* Disable digital (SPDIF) pins initially, but users can enable
4757 * them via a mixer switch. In the case of SPDIF-out, this initverb
4758 * payload also sets the generation to 0, output to be in "consumer"
4759 * PCM format, copyright asserted, no pre-emphasis and no validity
4760 * control.
4761 */
4762 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4763 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4764
4765 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4766 * OUT1 sum bus when acting as an output.
4767 */
4768 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4769 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4770 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4771 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4772
4773 /* Start with output sum widgets muted and their output gains at min */
4774 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4775 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4776 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4777 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4778 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4779 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4780 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4781 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4782 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4783
4784 /* Unmute retasking pin widget output buffers since the default
4785 * state appears to be output. As the pin mode is changed by the
4786 * user the pin mode control will take care of enabling the pin's
4787 * input/output buffers as needed.
4788 */
4789 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4790 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4793 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4794 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4795 /* Also unmute the mono-out pin widget */
4796 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4797
4798 /* Mute capture amp left and right */
4799 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4800 /* Set ADC connection select to match default mixer setting (mic1
4801 * pin)
4802 */
4803 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4804
4805 /* Do the same for the second ADC: mute capture input amp and
4806 * set ADC connection to mic1 pin
4807 */
4808 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4809 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4810
4811 /* Mute all inputs to mixer widget (even unconnected ones) */
4812 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4813 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4814 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4815 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4816 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4817 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4819 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4820
4821 { }
4822};
4823#endif
4824
4825#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4826#define alc260_pcm_analog_capture alc880_pcm_analog_capture
4827
4828#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4829#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4830
4831/*
4832 * for BIOS auto-configuration
4833 */
4834
4835static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4836 const char *pfx)
4837{
4838 hda_nid_t nid_vol;
4839 unsigned long vol_val, sw_val;
4840 char name[32];
4841 int err;
4842
4843 if (nid >= 0x0f && nid < 0x11) {
4844 nid_vol = nid - 0x7;
4845 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4846 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4847 } else if (nid == 0x11) {
4848 nid_vol = nid - 0x7;
4849 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4850 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4851 } else if (nid >= 0x12 && nid <= 0x15) {
4852 nid_vol = 0x08;
4853 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4854 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4855 } else
4856 return 0; /* N/A */
4857
4858 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4859 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4860 if (err < 0)
4861 return err;
4862 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4863 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4864 if (err < 0)
4865 return err;
4866 return 1;
4867}
4868
4869/* add playback controls from the parsed DAC table */
4870static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4871 const struct auto_pin_cfg *cfg)
4872{
4873 hda_nid_t nid;
4874 int err;
4875
4876 spec->multiout.num_dacs = 1;
4877 spec->multiout.dac_nids = spec->private_dac_nids;
4878 spec->multiout.dac_nids[0] = 0x02;
4879
4880 nid = cfg->line_out_pins[0];
4881 if (nid) {
4882 err = alc260_add_playback_controls(spec, nid, "Front");
4883 if (err < 0)
4884 return err;
4885 }
4886
4887 nid = cfg->speaker_pins[0];
4888 if (nid) {
4889 err = alc260_add_playback_controls(spec, nid, "Speaker");
4890 if (err < 0)
4891 return err;
4892 }
4893
4894 nid = cfg->hp_pins[0];
4895 if (nid) {
4896 err = alc260_add_playback_controls(spec, nid, "Headphone");
4897 if (err < 0)
4898 return err;
4899 }
4900 return 0;
4901}
4902
4903/* create playback/capture controls for input pins */
4904static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4905 const struct auto_pin_cfg *cfg)
4906{
4907 struct hda_input_mux *imux = &spec->private_imux;
4908 int i, err, idx;
4909
4910 for (i = 0; i < AUTO_PIN_LAST; i++) {
4911 if (cfg->input_pins[i] >= 0x12) {
4912 idx = cfg->input_pins[i] - 0x12;
4913 err = new_analog_input(spec, cfg->input_pins[i],
4914 auto_pin_cfg_labels[i], idx,
4915 0x07);
4916 if (err < 0)
4917 return err;
4918 imux->items[imux->num_items].label =
4919 auto_pin_cfg_labels[i];
4920 imux->items[imux->num_items].index = idx;
4921 imux->num_items++;
4922 }
4923 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4924 idx = cfg->input_pins[i] - 0x09;
4925 err = new_analog_input(spec, cfg->input_pins[i],
4926 auto_pin_cfg_labels[i], idx,
4927 0x07);
4928 if (err < 0)
4929 return err;
4930 imux->items[imux->num_items].label =
4931 auto_pin_cfg_labels[i];
4932 imux->items[imux->num_items].index = idx;
4933 imux->num_items++;
4934 }
4935 }
4936 return 0;
4937}
4938
4939static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4940 hda_nid_t nid, int pin_type,
4941 int sel_idx)
4942{
4943 alc_set_pin_output(codec, nid, pin_type);
4944 /* need the manual connection? */
4945 if (nid >= 0x12) {
4946 int idx = nid - 0x12;
4947 snd_hda_codec_write(codec, idx + 0x0b, 0,
4948 AC_VERB_SET_CONNECT_SEL, sel_idx);
4949 }
4950}
4951
4952static void alc260_auto_init_multi_out(struct hda_codec *codec)
4953{
4954 struct alc_spec *spec = codec->spec;
4955 hda_nid_t nid;
4956
4957 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4958 nid = spec->autocfg.line_out_pins[0];
4959 if (nid) {
4960 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4961 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4962 }
4963
4964 nid = spec->autocfg.speaker_pins[0];
4965 if (nid)
4966 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4967
4968 nid = spec->autocfg.hp_pins[0];
4969 if (nid)
4970 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4971}
4972
4973#define ALC260_PIN_CD_NID 0x16
4974static void alc260_auto_init_analog_input(struct hda_codec *codec)
4975{
4976 struct alc_spec *spec = codec->spec;
4977 int i;
4978
4979 for (i = 0; i < AUTO_PIN_LAST; i++) {
4980 hda_nid_t nid = spec->autocfg.input_pins[i];
4981 if (nid >= 0x12) {
4982 snd_hda_codec_write(codec, nid, 0,
4983 AC_VERB_SET_PIN_WIDGET_CONTROL,
4984 i <= AUTO_PIN_FRONT_MIC ?
4985 PIN_VREF80 : PIN_IN);
4986 if (nid != ALC260_PIN_CD_NID)
4987 snd_hda_codec_write(codec, nid, 0,
4988 AC_VERB_SET_AMP_GAIN_MUTE,
4989 AMP_OUT_MUTE);
4990 }
4991 }
4992}
4993
4994/*
4995 * generic initialization of ADC, input mixers and output mixers
4996 */
4997static struct hda_verb alc260_volume_init_verbs[] = {
4998 /*
4999 * Unmute ADC0-1 and set the default input to mic-in
5000 */
5001 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5002 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5003 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5004 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5005
5006 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5007 * mixer widget
5008 * Note: PASD motherboards uses the Line In 2 as the input for
5009 * front panel mic (mic 2)
5010 */
5011 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5012 /* mute analog inputs */
5013 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5014 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5015 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5016 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5018
5019 /*
5020 * Set up output mixers (0x08 - 0x0a)
5021 */
5022 /* set vol=0 to output mixers */
5023 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5024 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5025 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5026 /* set up input amps for analog loopback */
5027 /* Amp Indices: DAC = 0, mixer = 1 */
5028 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5029 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5030 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5031 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5032 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5033 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5034
5035 { }
5036};
5037
5038static int alc260_parse_auto_config(struct hda_codec *codec)
5039{
5040 struct alc_spec *spec = codec->spec;
5041 unsigned int wcap;
5042 int err;
5043 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5044
5045 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5046 alc260_ignore);
5047 if (err < 0)
5048 return err;
5049 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5050 if (err < 0)
5051 return err;
5052 if (!spec->kctl_alloc)
5053 return 0; /* can't find valid BIOS pin config */
5054 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5055 if (err < 0)
5056 return err;
5057
5058 spec->multiout.max_channels = 2;
5059
5060 if (spec->autocfg.dig_out_pin)
5061 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5062 if (spec->kctl_alloc)
5063 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5064
5065 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5066
5067 spec->num_mux_defs = 1;
5068 spec->input_mux = &spec->private_imux;
5069
5070 /* check whether NID 0x04 is valid */
5071 wcap = get_wcaps(codec, 0x04);
5072 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
5073 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5074 spec->adc_nids = alc260_adc_nids_alt;
5075 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5076 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
5077 } else {
5078 spec->adc_nids = alc260_adc_nids;
5079 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5080 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
5081 }
5082 spec->num_mixers++;
5083
5084 return 1;
5085}
5086
5087/* additional initialization for auto-configuration model */
5088static void alc260_auto_init(struct hda_codec *codec)
5089{
5090 struct alc_spec *spec = codec->spec;
5091 alc260_auto_init_multi_out(codec);
5092 alc260_auto_init_analog_input(codec);
5093 if (spec->unsol_event)
5094 alc_sku_automute(codec);
5095}
5096
5097#ifdef CONFIG_SND_HDA_POWER_SAVE
5098static struct hda_amp_list alc260_loopbacks[] = {
5099 { 0x07, HDA_INPUT, 0 },
5100 { 0x07, HDA_INPUT, 1 },
5101 { 0x07, HDA_INPUT, 2 },
5102 { 0x07, HDA_INPUT, 3 },
5103 { 0x07, HDA_INPUT, 4 },
5104 { } /* end */
5105};
5106#endif
5107
5108/*
5109 * ALC260 configurations
5110 */
5111static const char *alc260_models[ALC260_MODEL_LAST] = {
5112 [ALC260_BASIC] = "basic",
5113 [ALC260_HP] = "hp",
5114 [ALC260_HP_3013] = "hp-3013",
5115 [ALC260_FUJITSU_S702X] = "fujitsu",
5116 [ALC260_ACER] = "acer",
5117 [ALC260_WILL] = "will",
5118 [ALC260_REPLACER_672V] = "replacer",
5119#ifdef CONFIG_SND_DEBUG
5120 [ALC260_TEST] = "test",
5121#endif
5122 [ALC260_AUTO] = "auto",
5123};
5124
5125static struct snd_pci_quirk alc260_cfg_tbl[] = {
5126 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
5127 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
5128 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
5129 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
5130 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
5131 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
5132 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
5133 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5134 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5135 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5136 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5137 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5138 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5139 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5140 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5141 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
5142 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
5143 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
5144 {}
5145};
5146
5147static struct alc_config_preset alc260_presets[] = {
5148 [ALC260_BASIC] = {
5149 .mixers = { alc260_base_output_mixer,
5150 alc260_input_mixer,
5151 alc260_pc_beep_mixer,
5152 alc260_capture_mixer },
5153 .init_verbs = { alc260_init_verbs },
5154 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5155 .dac_nids = alc260_dac_nids,
5156 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5157 .adc_nids = alc260_adc_nids,
5158 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5159 .channel_mode = alc260_modes,
5160 .input_mux = &alc260_capture_source,
5161 },
5162 [ALC260_HP] = {
5163 .mixers = { alc260_hp_output_mixer,
5164 alc260_input_mixer,
5165 alc260_capture_alt_mixer },
5166 .init_verbs = { alc260_init_verbs,
5167 alc260_hp_unsol_verbs },
5168 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5169 .dac_nids = alc260_dac_nids,
5170 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5171 .adc_nids = alc260_hp_adc_nids,
5172 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5173 .channel_mode = alc260_modes,
5174 .input_mux = &alc260_capture_source,
5175 .unsol_event = alc260_hp_unsol_event,
5176 .init_hook = alc260_hp_automute,
5177 },
5178 [ALC260_HP_3013] = {
5179 .mixers = { alc260_hp_3013_mixer,
5180 alc260_input_mixer,
5181 alc260_capture_alt_mixer },
5182 .init_verbs = { alc260_hp_3013_init_verbs,
5183 alc260_hp_3013_unsol_verbs },
5184 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5185 .dac_nids = alc260_dac_nids,
5186 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5187 .adc_nids = alc260_hp_adc_nids,
5188 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5189 .channel_mode = alc260_modes,
5190 .input_mux = &alc260_capture_source,
5191 .unsol_event = alc260_hp_3013_unsol_event,
5192 .init_hook = alc260_hp_3013_automute,
5193 },
5194 [ALC260_FUJITSU_S702X] = {
5195 .mixers = { alc260_fujitsu_mixer,
5196 alc260_capture_mixer },
5197 .init_verbs = { alc260_fujitsu_init_verbs },
5198 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5199 .dac_nids = alc260_dac_nids,
5200 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5201 .adc_nids = alc260_dual_adc_nids,
5202 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5203 .channel_mode = alc260_modes,
5204 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5205 .input_mux = alc260_fujitsu_capture_sources,
5206 },
5207 [ALC260_ACER] = {
5208 .mixers = { alc260_acer_mixer,
5209 alc260_capture_mixer },
5210 .init_verbs = { alc260_acer_init_verbs },
5211 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5212 .dac_nids = alc260_dac_nids,
5213 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5214 .adc_nids = alc260_dual_adc_nids,
5215 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5216 .channel_mode = alc260_modes,
5217 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5218 .input_mux = alc260_acer_capture_sources,
5219 },
5220 [ALC260_WILL] = {
5221 .mixers = { alc260_will_mixer,
5222 alc260_capture_mixer },
5223 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5224 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5225 .dac_nids = alc260_dac_nids,
5226 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5227 .adc_nids = alc260_adc_nids,
5228 .dig_out_nid = ALC260_DIGOUT_NID,
5229 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5230 .channel_mode = alc260_modes,
5231 .input_mux = &alc260_capture_source,
5232 },
5233 [ALC260_REPLACER_672V] = {
5234 .mixers = { alc260_replacer_672v_mixer,
5235 alc260_capture_mixer },
5236 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5237 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5238 .dac_nids = alc260_dac_nids,
5239 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5240 .adc_nids = alc260_adc_nids,
5241 .dig_out_nid = ALC260_DIGOUT_NID,
5242 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5243 .channel_mode = alc260_modes,
5244 .input_mux = &alc260_capture_source,
5245 .unsol_event = alc260_replacer_672v_unsol_event,
5246 .init_hook = alc260_replacer_672v_automute,
5247 },
5248#ifdef CONFIG_SND_DEBUG
5249 [ALC260_TEST] = {
5250 .mixers = { alc260_test_mixer,
5251 alc260_capture_mixer },
5252 .init_verbs = { alc260_test_init_verbs },
5253 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5254 .dac_nids = alc260_test_dac_nids,
5255 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5256 .adc_nids = alc260_test_adc_nids,
5257 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5258 .channel_mode = alc260_modes,
5259 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5260 .input_mux = alc260_test_capture_sources,
5261 },
5262#endif
5263};
5264
5265static int patch_alc260(struct hda_codec *codec)
5266{
5267 struct alc_spec *spec;
5268 int err, board_config;
5269
5270 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5271 if (spec == NULL)
5272 return -ENOMEM;
5273
5274 codec->spec = spec;
5275
5276 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5277 alc260_models,
5278 alc260_cfg_tbl);
5279 if (board_config < 0) {
5280 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5281 "trying auto-probe from BIOS...\n");
5282 board_config = ALC260_AUTO;
5283 }
5284
5285 if (board_config == ALC260_AUTO) {
5286 /* automatic parse from the BIOS config */
5287 err = alc260_parse_auto_config(codec);
5288 if (err < 0) {
5289 alc_free(codec);
5290 return err;
5291 } else if (!err) {
5292 printk(KERN_INFO
5293 "hda_codec: Cannot set up configuration "
5294 "from BIOS. Using base mode...\n");
5295 board_config = ALC260_BASIC;
5296 }
5297 }
5298
5299 if (board_config != ALC260_AUTO)
5300 setup_preset(spec, &alc260_presets[board_config]);
5301
5302 spec->stream_name_analog = "ALC260 Analog";
5303 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5304 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5305
5306 spec->stream_name_digital = "ALC260 Digital";
5307 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5308 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5309
5310 spec->vmaster_nid = 0x08;
5311
5312 codec->patch_ops = alc_patch_ops;
5313 if (board_config == ALC260_AUTO)
5314 spec->init_hook = alc260_auto_init;
5315#ifdef CONFIG_SND_HDA_POWER_SAVE
5316 if (!spec->loopback.amplist)
5317 spec->loopback.amplist = alc260_loopbacks;
5318#endif
5319
5320 return 0;
5321}
5322
5323
5324/*
5325 * ALC882 support
5326 *
5327 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5328 * configuration. Each pin widget can choose any input DACs and a mixer.
5329 * Each ADC is connected from a mixer of all inputs. This makes possible
5330 * 6-channel independent captures.
5331 *
5332 * In addition, an independent DAC for the multi-playback (not used in this
5333 * driver yet).
5334 */
5335#define ALC882_DIGOUT_NID 0x06
5336#define ALC882_DIGIN_NID 0x0a
5337
5338static struct hda_channel_mode alc882_ch_modes[1] = {
5339 { 8, NULL }
5340};
5341
5342static hda_nid_t alc882_dac_nids[4] = {
5343 /* front, rear, clfe, rear_surr */
5344 0x02, 0x03, 0x04, 0x05
5345};
5346
5347/* identical with ALC880 */
5348#define alc882_adc_nids alc880_adc_nids
5349#define alc882_adc_nids_alt alc880_adc_nids_alt
5350
5351static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5352static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5353
5354/* input MUX */
5355/* FIXME: should be a matrix-type input source selection */
5356
5357static struct hda_input_mux alc882_capture_source = {
5358 .num_items = 4,
5359 .items = {
5360 { "Mic", 0x0 },
5361 { "Front Mic", 0x1 },
5362 { "Line", 0x2 },
5363 { "CD", 0x4 },
5364 },
5365};
5366#define alc882_mux_enum_info alc_mux_enum_info
5367#define alc882_mux_enum_get alc_mux_enum_get
5368
5369static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5370 struct snd_ctl_elem_value *ucontrol)
5371{
5372 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5373 struct alc_spec *spec = codec->spec;
5374 const struct hda_input_mux *imux = spec->input_mux;
5375 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5376 hda_nid_t nid = spec->capsrc_nids ?
5377 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
5378 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5379 unsigned int i, idx;
5380
5381 idx = ucontrol->value.enumerated.item[0];
5382 if (idx >= imux->num_items)
5383 idx = imux->num_items - 1;
5384 if (*cur_val == idx)
5385 return 0;
5386 for (i = 0; i < imux->num_items; i++) {
5387 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5388 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
5389 imux->items[i].index,
5390 HDA_AMP_MUTE, v);
5391 }
5392 *cur_val = idx;
5393 return 1;
5394}
5395
5396/*
5397 * 2ch mode
5398 */
5399static struct hda_verb alc882_3ST_ch2_init[] = {
5400 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5401 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5402 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5403 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5404 { } /* end */
5405};
5406
5407/*
5408 * 6ch mode
5409 */
5410static struct hda_verb alc882_3ST_ch6_init[] = {
5411 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5412 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5413 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5414 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5415 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5416 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5417 { } /* end */
5418};
5419
5420static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5421 { 2, alc882_3ST_ch2_init },
5422 { 6, alc882_3ST_ch6_init },
5423};
5424
5425/*
5426 * 6ch mode
5427 */
5428static struct hda_verb alc882_sixstack_ch6_init[] = {
5429 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5430 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5431 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5432 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5433 { } /* end */
5434};
5435
5436/*
5437 * 8ch mode
5438 */
5439static struct hda_verb alc882_sixstack_ch8_init[] = {
5440 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5441 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5442 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5443 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5444 { } /* end */
5445};
5446
5447static struct hda_channel_mode alc882_sixstack_modes[2] = {
5448 { 6, alc882_sixstack_ch6_init },
5449 { 8, alc882_sixstack_ch8_init },
5450};
5451
5452/*
5453 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5454 */
5455
5456/*
5457 * 2ch mode
5458 */
5459static struct hda_verb alc885_mbp_ch2_init[] = {
5460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5461 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5462 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5463 { } /* end */
5464};
5465
5466/*
5467 * 6ch mode
5468 */
5469static struct hda_verb alc885_mbp_ch6_init[] = {
5470 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5471 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5472 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5473 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5474 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5475 { } /* end */
5476};
5477
5478static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5479 { 2, alc885_mbp_ch2_init },
5480 { 6, alc885_mbp_ch6_init },
5481};
5482
5483
5484/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5485 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5486 */
5487static struct snd_kcontrol_new alc882_base_mixer[] = {
5488 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5489 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5490 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5491 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5492 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5493 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5494 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5495 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5496 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5497 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5498 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5499 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5500 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5501 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5502 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5504 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5505 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5506 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5507 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5508 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5509 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5510 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5511 { } /* end */
5512};
5513
5514static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
5515 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5516 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5517 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5518 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5519 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5520 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5521 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5522 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
5523 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
5524 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5525 { } /* end */
5526};
5527static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5528 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5529 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5530 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5531 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5532 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5533 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5534 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5535 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5536 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5537 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5538 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5539 { } /* end */
5540};
5541
5542static struct snd_kcontrol_new alc882_targa_mixer[] = {
5543 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5544 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5545 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5546 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5547 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5548 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5549 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5552 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5553 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5554 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5555 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5556 { } /* end */
5557};
5558
5559/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5560 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5561 */
5562static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5563 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5564 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5565 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5566 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5567 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5568 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5569 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5570 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5571 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5572 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5573 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5574 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5575 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5576 { } /* end */
5577};
5578
5579static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5580 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5581 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5582 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5583 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5584 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5585 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5586 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5588 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5590 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5591 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5592 { } /* end */
5593};
5594
5595static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5596 {
5597 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5598 .name = "Channel Mode",
5599 .info = alc_ch_mode_info,
5600 .get = alc_ch_mode_get,
5601 .put = alc_ch_mode_put,
5602 },
5603 { } /* end */
5604};
5605
5606static struct hda_verb alc882_init_verbs[] = {
5607 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5608 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5609 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5610 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5611 /* Rear mixer */
5612 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5613 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5614 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5615 /* CLFE mixer */
5616 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5617 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5618 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5619 /* Side mixer */
5620 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5622 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5623
5624 /* Front Pin: output 0 (0x0c) */
5625 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5627 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5628 /* Rear Pin: output 1 (0x0d) */
5629 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5630 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5631 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5632 /* CLFE Pin: output 2 (0x0e) */
5633 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5634 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5635 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5636 /* Side Pin: output 3 (0x0f) */
5637 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5638 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5639 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5640 /* Mic (rear) pin: input vref at 80% */
5641 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5642 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5643 /* Front Mic pin: input vref at 80% */
5644 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5645 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5646 /* Line In pin: input */
5647 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5649 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5651 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5652 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5653 /* CD pin widget for input */
5654 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5655
5656 /* FIXME: use matrix-type input source selection */
5657 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5658 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5659 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5660 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5661 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5663 /* Input mixer2 */
5664 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5667 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5668 /* Input mixer3 */
5669 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5673 /* ADC1: mute amp left and right */
5674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5675 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5676 /* ADC2: mute amp left and right */
5677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5678 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5679 /* ADC3: mute amp left and right */
5680 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5681 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5682
5683 { }
5684};
5685
5686static struct hda_verb alc882_eapd_verbs[] = {
5687 /* change to EAPD mode */
5688 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5689 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5690 { }
5691};
5692
5693/* Mac Pro test */
5694static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5695 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5696 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5698 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5699 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5700 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5701 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5702 { } /* end */
5703};
5704
5705static struct hda_verb alc882_macpro_init_verbs[] = {
5706 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5709 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5710 /* Front Pin: output 0 (0x0c) */
5711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5713 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5714 /* Front Mic pin: input vref at 80% */
5715 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5716 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5717 /* Speaker: output */
5718 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5719 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5720 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5721 /* Headphone output (output 0 - 0x0c) */
5722 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5724 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5725
5726 /* FIXME: use matrix-type input source selection */
5727 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5728 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5729 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5730 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5731 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5732 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5733 /* Input mixer2 */
5734 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5735 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5736 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5737 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5738 /* Input mixer3 */
5739 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5740 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5741 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5742 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5743 /* ADC1: mute amp left and right */
5744 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5745 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5746 /* ADC2: mute amp left and right */
5747 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5748 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5749 /* ADC3: mute amp left and right */
5750 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5751 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5752
5753 { }
5754};
5755
5756/* Macbook Pro rev3 */
5757static struct hda_verb alc885_mbp3_init_verbs[] = {
5758 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5759 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5760 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5761 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5762 /* Rear mixer */
5763 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5764 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5766 /* Front Pin: output 0 (0x0c) */
5767 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5768 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5769 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5770 /* HP Pin: output 0 (0x0d) */
5771 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5772 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5773 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5774 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5775 /* Mic (rear) pin: input vref at 80% */
5776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5777 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5778 /* Front Mic pin: input vref at 80% */
5779 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5780 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5781 /* Line In pin: use output 1 when in LineOut mode */
5782 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5783 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5784 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5785
5786 /* FIXME: use matrix-type input source selection */
5787 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5788 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5789 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5792 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5793 /* Input mixer2 */
5794 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5795 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5798 /* Input mixer3 */
5799 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5800 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5803 /* ADC1: mute amp left and right */
5804 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5805 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5806 /* ADC2: mute amp left and right */
5807 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5808 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5809 /* ADC3: mute amp left and right */
5810 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5811 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5812
5813 { }
5814};
5815
5816/* iMac 24 mixer. */
5817static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5818 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5819 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5820 { } /* end */
5821};
5822
5823/* iMac 24 init verbs. */
5824static struct hda_verb alc885_imac24_init_verbs[] = {
5825 /* Internal speakers: output 0 (0x0c) */
5826 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5827 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5828 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5829 /* Internal speakers: output 0 (0x0c) */
5830 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5832 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5833 /* Headphone: output 0 (0x0c) */
5834 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5835 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5836 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5837 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5838 /* Front Mic: input vref at 80% */
5839 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5840 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5841 { }
5842};
5843
5844/* Toggle speaker-output according to the hp-jack state */
5845static void alc885_imac24_automute(struct hda_codec *codec)
5846{
5847 unsigned int present;
5848
5849 present = snd_hda_codec_read(codec, 0x14, 0,
5850 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5851 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5852 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5853 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5854 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5855}
5856
5857/* Processes unsolicited events. */
5858static void alc885_imac24_unsol_event(struct hda_codec *codec,
5859 unsigned int res)
5860{
5861 /* Headphone insertion or removal. */
5862 if ((res >> 26) == ALC880_HP_EVENT)
5863 alc885_imac24_automute(codec);
5864}
5865
5866static void alc885_mbp3_automute(struct hda_codec *codec)
5867{
5868 unsigned int present;
5869
5870 present = snd_hda_codec_read(codec, 0x15, 0,
5871 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5872 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5873 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5874 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5875 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5876
5877}
5878static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5879 unsigned int res)
5880{
5881 /* Headphone insertion or removal. */
5882 if ((res >> 26) == ALC880_HP_EVENT)
5883 alc885_mbp3_automute(codec);
5884}
5885
5886
5887static struct hda_verb alc882_targa_verbs[] = {
5888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5890
5891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5892 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5893
5894 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5895 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5896 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5897
5898 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5899 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5900 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5901 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5902 { } /* end */
5903};
5904
5905/* toggle speaker-output according to the hp-jack state */
5906static void alc882_targa_automute(struct hda_codec *codec)
5907{
5908 unsigned int present;
5909
5910 present = snd_hda_codec_read(codec, 0x14, 0,
5911 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5912 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5913 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5914 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5915 present ? 1 : 3);
5916}
5917
5918static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5919{
5920 /* Looks like the unsol event is incompatible with the standard
5921 * definition. 4bit tag is placed at 26 bit!
5922 */
5923 if (((res >> 26) == ALC880_HP_EVENT)) {
5924 alc882_targa_automute(codec);
5925 }
5926}
5927
5928static struct hda_verb alc882_asus_a7j_verbs[] = {
5929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5930 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5931
5932 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5933 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5934 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5935
5936 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5937 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5938 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5939
5940 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5941 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5942 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5943 { } /* end */
5944};
5945
5946static struct hda_verb alc882_asus_a7m_verbs[] = {
5947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5949
5950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5953
5954 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5955 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5956 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5957
5958 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5959 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5960 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5961 { } /* end */
5962};
5963
5964static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5965{
5966 unsigned int gpiostate, gpiomask, gpiodir;
5967
5968 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5969 AC_VERB_GET_GPIO_DATA, 0);
5970
5971 if (!muted)
5972 gpiostate |= (1 << pin);
5973 else
5974 gpiostate &= ~(1 << pin);
5975
5976 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5977 AC_VERB_GET_GPIO_MASK, 0);
5978 gpiomask |= (1 << pin);
5979
5980 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5981 AC_VERB_GET_GPIO_DIRECTION, 0);
5982 gpiodir |= (1 << pin);
5983
5984
5985 snd_hda_codec_write(codec, codec->afg, 0,
5986 AC_VERB_SET_GPIO_MASK, gpiomask);
5987 snd_hda_codec_write(codec, codec->afg, 0,
5988 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5989
5990 msleep(1);
5991
5992 snd_hda_codec_write(codec, codec->afg, 0,
5993 AC_VERB_SET_GPIO_DATA, gpiostate);
5994}
5995
5996/* set up GPIO at initialization */
5997static void alc885_macpro_init_hook(struct hda_codec *codec)
5998{
5999 alc882_gpio_mute(codec, 0, 0);
6000 alc882_gpio_mute(codec, 1, 0);
6001}
6002
6003/* set up GPIO and update auto-muting at initialization */
6004static void alc885_imac24_init_hook(struct hda_codec *codec)
6005{
6006 alc885_macpro_init_hook(codec);
6007 alc885_imac24_automute(codec);
6008}
6009
6010/*
6011 * generic initialization of ADC, input mixers and output mixers
6012 */
6013static struct hda_verb alc882_auto_init_verbs[] = {
6014 /*
6015 * Unmute ADC0-2 and set the default input to mic-in
6016 */
6017 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6019 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6020 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6021 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6022 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6023
6024 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6025 * mixer widget
6026 * Note: PASD motherboards uses the Line In 2 as the input for
6027 * front panel mic (mic 2)
6028 */
6029 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6030 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6031 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6032 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6033 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6034 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6035
6036 /*
6037 * Set up output mixers (0x0c - 0x0f)
6038 */
6039 /* set vol=0 to output mixers */
6040 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6042 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6043 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6044 /* set up input amps for analog loopback */
6045 /* Amp Indices: DAC = 0, mixer = 1 */
6046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6049 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6050 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6051 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6052 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6053 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6054 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6055 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6056
6057 /* FIXME: use matrix-type input source selection */
6058 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6059 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6064 /* Input mixer2 */
6065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6069 /* Input mixer3 */
6070 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6074
6075 { }
6076};
6077
6078/* capture mixer elements */
6079static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6080 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6081 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6082 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6083 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6084 {
6085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6086 /* The multiple "Capture Source" controls confuse alsamixer
6087 * So call somewhat different..
6088 */
6089 /* .name = "Capture Source", */
6090 .name = "Input Source",
6091 .count = 2,
6092 .info = alc882_mux_enum_info,
6093 .get = alc882_mux_enum_get,
6094 .put = alc882_mux_enum_put,
6095 },
6096 { } /* end */
6097};
6098
6099static struct snd_kcontrol_new alc882_capture_mixer[] = {
6100 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6101 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6102 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6103 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6104 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6105 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6106 {
6107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6108 /* The multiple "Capture Source" controls confuse alsamixer
6109 * So call somewhat different..
6110 */
6111 /* .name = "Capture Source", */
6112 .name = "Input Source",
6113 .count = 3,
6114 .info = alc882_mux_enum_info,
6115 .get = alc882_mux_enum_get,
6116 .put = alc882_mux_enum_put,
6117 },
6118 { } /* end */
6119};
6120
6121#ifdef CONFIG_SND_HDA_POWER_SAVE
6122#define alc882_loopbacks alc880_loopbacks
6123#endif
6124
6125/* pcm configuration: identiacal with ALC880 */
6126#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6127#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6128#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6129#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6130
6131/*
6132 * configuration and preset
6133 */
6134static const char *alc882_models[ALC882_MODEL_LAST] = {
6135 [ALC882_3ST_DIG] = "3stack-dig",
6136 [ALC882_6ST_DIG] = "6stack-dig",
6137 [ALC882_ARIMA] = "arima",
6138 [ALC882_W2JC] = "w2jc",
6139 [ALC882_TARGA] = "targa",
6140 [ALC882_ASUS_A7J] = "asus-a7j",
6141 [ALC882_ASUS_A7M] = "asus-a7m",
6142 [ALC885_MACPRO] = "macpro",
6143 [ALC885_MBP3] = "mbp3",
6144 [ALC885_IMAC24] = "imac24",
6145 [ALC882_AUTO] = "auto",
6146};
6147
6148static struct snd_pci_quirk alc882_cfg_tbl[] = {
6149 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
6150 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
6151 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
6152 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
6153 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
6154 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
6155 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
6156 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
6157 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
6158 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6159 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6160 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
6161 {}
6162};
6163
6164static struct alc_config_preset alc882_presets[] = {
6165 [ALC882_3ST_DIG] = {
6166 .mixers = { alc882_base_mixer },
6167 .init_verbs = { alc882_init_verbs },
6168 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6169 .dac_nids = alc882_dac_nids,
6170 .dig_out_nid = ALC882_DIGOUT_NID,
6171 .dig_in_nid = ALC882_DIGIN_NID,
6172 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6173 .channel_mode = alc882_ch_modes,
6174 .need_dac_fix = 1,
6175 .input_mux = &alc882_capture_source,
6176 },
6177 [ALC882_6ST_DIG] = {
6178 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6179 .init_verbs = { alc882_init_verbs },
6180 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6181 .dac_nids = alc882_dac_nids,
6182 .dig_out_nid = ALC882_DIGOUT_NID,
6183 .dig_in_nid = ALC882_DIGIN_NID,
6184 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6185 .channel_mode = alc882_sixstack_modes,
6186 .input_mux = &alc882_capture_source,
6187 },
6188 [ALC882_ARIMA] = {
6189 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6190 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6191 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6192 .dac_nids = alc882_dac_nids,
6193 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6194 .channel_mode = alc882_sixstack_modes,
6195 .input_mux = &alc882_capture_source,
6196 },
6197 [ALC882_W2JC] = {
6198 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6199 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6200 alc880_gpio1_init_verbs },
6201 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6202 .dac_nids = alc882_dac_nids,
6203 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6204 .channel_mode = alc880_threestack_modes,
6205 .need_dac_fix = 1,
6206 .input_mux = &alc882_capture_source,
6207 .dig_out_nid = ALC882_DIGOUT_NID,
6208 },
6209 [ALC885_MBP3] = {
6210 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6211 .init_verbs = { alc885_mbp3_init_verbs,
6212 alc880_gpio1_init_verbs },
6213 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6214 .dac_nids = alc882_dac_nids,
6215 .channel_mode = alc885_mbp_6ch_modes,
6216 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6217 .input_mux = &alc882_capture_source,
6218 .dig_out_nid = ALC882_DIGOUT_NID,
6219 .dig_in_nid = ALC882_DIGIN_NID,
6220 .unsol_event = alc885_mbp3_unsol_event,
6221 .init_hook = alc885_mbp3_automute,
6222 },
6223 [ALC885_MACPRO] = {
6224 .mixers = { alc882_macpro_mixer },
6225 .init_verbs = { alc882_macpro_init_verbs },
6226 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6227 .dac_nids = alc882_dac_nids,
6228 .dig_out_nid = ALC882_DIGOUT_NID,
6229 .dig_in_nid = ALC882_DIGIN_NID,
6230 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6231 .channel_mode = alc882_ch_modes,
6232 .input_mux = &alc882_capture_source,
6233 .init_hook = alc885_macpro_init_hook,
6234 },
6235 [ALC885_IMAC24] = {
6236 .mixers = { alc885_imac24_mixer },
6237 .init_verbs = { alc885_imac24_init_verbs },
6238 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6239 .dac_nids = alc882_dac_nids,
6240 .dig_out_nid = ALC882_DIGOUT_NID,
6241 .dig_in_nid = ALC882_DIGIN_NID,
6242 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6243 .channel_mode = alc882_ch_modes,
6244 .input_mux = &alc882_capture_source,
6245 .unsol_event = alc885_imac24_unsol_event,
6246 .init_hook = alc885_imac24_init_hook,
6247 },
6248 [ALC882_TARGA] = {
6249 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6250 alc882_capture_mixer },
6251 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6252 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6253 .dac_nids = alc882_dac_nids,
6254 .dig_out_nid = ALC882_DIGOUT_NID,
6255 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6256 .adc_nids = alc882_adc_nids,
6257 .capsrc_nids = alc882_capsrc_nids,
6258 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6259 .channel_mode = alc882_3ST_6ch_modes,
6260 .need_dac_fix = 1,
6261 .input_mux = &alc882_capture_source,
6262 .unsol_event = alc882_targa_unsol_event,
6263 .init_hook = alc882_targa_automute,
6264 },
6265 [ALC882_ASUS_A7J] = {
6266 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6267 alc882_capture_mixer },
6268 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6269 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6270 .dac_nids = alc882_dac_nids,
6271 .dig_out_nid = ALC882_DIGOUT_NID,
6272 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6273 .adc_nids = alc882_adc_nids,
6274 .capsrc_nids = alc882_capsrc_nids,
6275 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6276 .channel_mode = alc882_3ST_6ch_modes,
6277 .need_dac_fix = 1,
6278 .input_mux = &alc882_capture_source,
6279 },
6280 [ALC882_ASUS_A7M] = {
6281 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6282 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6283 alc880_gpio1_init_verbs,
6284 alc882_asus_a7m_verbs },
6285 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6286 .dac_nids = alc882_dac_nids,
6287 .dig_out_nid = ALC882_DIGOUT_NID,
6288 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6289 .channel_mode = alc880_threestack_modes,
6290 .need_dac_fix = 1,
6291 .input_mux = &alc882_capture_source,
6292 },
6293};
6294
6295
6296/*
6297 * Pin config fixes
6298 */
6299enum {
6300 PINFIX_ABIT_AW9D_MAX
6301};
6302
6303static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6304 { 0x15, 0x01080104 }, /* side */
6305 { 0x16, 0x01011012 }, /* rear */
6306 { 0x17, 0x01016011 }, /* clfe */
6307 { }
6308};
6309
6310static const struct alc_pincfg *alc882_pin_fixes[] = {
6311 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6312};
6313
6314static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6315 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6316 {}
6317};
6318
6319/*
6320 * BIOS auto configuration
6321 */
6322static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6323 hda_nid_t nid, int pin_type,
6324 int dac_idx)
6325{
6326 /* set as output */
6327 struct alc_spec *spec = codec->spec;
6328 int idx;
6329
6330 alc_set_pin_output(codec, nid, pin_type);
6331 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6332 idx = 4;
6333 else
6334 idx = spec->multiout.dac_nids[dac_idx] - 2;
6335 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6336
6337}
6338
6339static void alc882_auto_init_multi_out(struct hda_codec *codec)
6340{
6341 struct alc_spec *spec = codec->spec;
6342 int i;
6343
6344 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6345 for (i = 0; i <= HDA_SIDE; i++) {
6346 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6347 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6348 if (nid)
6349 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
6350 i);
6351 }
6352}
6353
6354static void alc882_auto_init_hp_out(struct hda_codec *codec)
6355{
6356 struct alc_spec *spec = codec->spec;
6357 hda_nid_t pin;
6358
6359 pin = spec->autocfg.hp_pins[0];
6360 if (pin) /* connect to front */
6361 /* use dac 0 */
6362 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6363 pin = spec->autocfg.speaker_pins[0];
6364 if (pin)
6365 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
6366}
6367
6368#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6369#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6370
6371static void alc882_auto_init_analog_input(struct hda_codec *codec)
6372{
6373 struct alc_spec *spec = codec->spec;
6374 int i;
6375
6376 for (i = 0; i < AUTO_PIN_LAST; i++) {
6377 hda_nid_t nid = spec->autocfg.input_pins[i];
6378 unsigned int vref;
6379 if (!nid)
6380 continue;
6381 vref = PIN_IN;
6382 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
6383 unsigned int pincap;
6384 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6385 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
6386 AC_PINCAP_VREF_80)
6387 vref = PIN_VREF80;
6388 }
6389 snd_hda_codec_write(codec, nid, 0,
6390 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6391 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6392 snd_hda_codec_write(codec, nid, 0,
6393 AC_VERB_SET_AMP_GAIN_MUTE,
6394 AMP_OUT_MUTE);
6395 }
6396}
6397
6398/* add mic boosts if needed */
6399static int alc_auto_add_mic_boost(struct hda_codec *codec)
6400{
6401 struct alc_spec *spec = codec->spec;
6402 int err;
6403 hda_nid_t nid;
6404
6405 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
6406 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6407 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6408 "Mic Boost",
6409 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6410 if (err < 0)
6411 return err;
6412 }
6413 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
6414 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6415 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6416 "Front Mic Boost",
6417 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6418 if (err < 0)
6419 return err;
6420 }
6421 return 0;
6422}
6423
6424/* almost identical with ALC880 parser... */
6425static int alc882_parse_auto_config(struct hda_codec *codec)
6426{
6427 struct alc_spec *spec = codec->spec;
6428 int err = alc880_parse_auto_config(codec);
6429
6430 if (err < 0)
6431 return err;
6432 else if (!err)
6433 return 0; /* no config found */
6434
6435 err = alc_auto_add_mic_boost(codec);
6436 if (err < 0)
6437 return err;
6438
6439 /* hack - override the init verbs */
6440 spec->init_verbs[0] = alc882_auto_init_verbs;
6441
6442 return 1; /* config found */
6443}
6444
6445/* additional initialization for auto-configuration model */
6446static void alc882_auto_init(struct hda_codec *codec)
6447{
6448 struct alc_spec *spec = codec->spec;
6449 alc882_auto_init_multi_out(codec);
6450 alc882_auto_init_hp_out(codec);
6451 alc882_auto_init_analog_input(codec);
6452 if (spec->unsol_event)
6453 alc_sku_automute(codec);
6454}
6455
6456static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6457
6458static int patch_alc882(struct hda_codec *codec)
6459{
6460 struct alc_spec *spec;
6461 int err, board_config;
6462
6463 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6464 if (spec == NULL)
6465 return -ENOMEM;
6466
6467 codec->spec = spec;
6468
6469 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6470 alc882_models,
6471 alc882_cfg_tbl);
6472
6473 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
6474 /* Pick up systems that don't supply PCI SSID */
6475 switch (codec->subsystem_id) {
6476 case 0x106b0c00: /* Mac Pro */
6477 board_config = ALC885_MACPRO;
6478 break;
6479 case 0x106b1000: /* iMac 24 */
6480 board_config = ALC885_IMAC24;
6481 break;
6482 case 0x106b00a1: /* Macbook */
6483 case 0x106b2c00: /* Macbook Pro rev3 */
6484 board_config = ALC885_MBP3;
6485 break;
6486 default:
6487 /* ALC889A is handled better as ALC888-compatible */
6488 if (codec->revision_id == 0x100103) {
6489 alc_free(codec);
6490 return patch_alc883(codec);
6491 }
6492 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6493 "trying auto-probe from BIOS...\n");
6494 board_config = ALC882_AUTO;
6495 }
6496 }
6497
6498 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6499
6500 if (board_config == ALC882_AUTO) {
6501 /* automatic parse from the BIOS config */
6502 err = alc882_parse_auto_config(codec);
6503 if (err < 0) {
6504 alc_free(codec);
6505 return err;
6506 } else if (!err) {
6507 printk(KERN_INFO
6508 "hda_codec: Cannot set up configuration "
6509 "from BIOS. Using base mode...\n");
6510 board_config = ALC882_3ST_DIG;
6511 }
6512 }
6513
6514 if (board_config != ALC882_AUTO)
6515 setup_preset(spec, &alc882_presets[board_config]);
6516
6517 if (codec->vendor_id == 0x10ec0885) {
6518 spec->stream_name_analog = "ALC885 Analog";
6519 spec->stream_name_digital = "ALC885 Digital";
6520 } else {
6521 spec->stream_name_analog = "ALC882 Analog";
6522 spec->stream_name_digital = "ALC882 Digital";
6523 }
6524
6525 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6526 spec->stream_analog_capture = &alc882_pcm_analog_capture;
6527 /* FIXME: setup DAC5 */
6528 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6529 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
6530
6531 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6532 spec->stream_digital_capture = &alc882_pcm_digital_capture;
6533
6534 if (!spec->adc_nids && spec->input_mux) {
6535 /* check whether NID 0x07 is valid */
6536 unsigned int wcap = get_wcaps(codec, 0x07);
6537 /* get type */
6538 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6539 if (wcap != AC_WID_AUD_IN) {
6540 spec->adc_nids = alc882_adc_nids_alt;
6541 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
6542 spec->capsrc_nids = alc882_capsrc_nids_alt;
6543 spec->mixers[spec->num_mixers] =
6544 alc882_capture_alt_mixer;
6545 spec->num_mixers++;
6546 } else {
6547 spec->adc_nids = alc882_adc_nids;
6548 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6549 spec->capsrc_nids = alc882_capsrc_nids;
6550 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6551 spec->num_mixers++;
6552 }
6553 }
6554
6555 spec->vmaster_nid = 0x0c;
6556
6557 codec->patch_ops = alc_patch_ops;
6558 if (board_config == ALC882_AUTO)
6559 spec->init_hook = alc882_auto_init;
6560#ifdef CONFIG_SND_HDA_POWER_SAVE
6561 if (!spec->loopback.amplist)
6562 spec->loopback.amplist = alc882_loopbacks;
6563#endif
6564
6565 return 0;
6566}
6567
6568/*
6569 * ALC883 support
6570 *
6571 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6572 * configuration. Each pin widget can choose any input DACs and a mixer.
6573 * Each ADC is connected from a mixer of all inputs. This makes possible
6574 * 6-channel independent captures.
6575 *
6576 * In addition, an independent DAC for the multi-playback (not used in this
6577 * driver yet).
6578 */
6579#define ALC883_DIGOUT_NID 0x06
6580#define ALC883_DIGIN_NID 0x0a
6581
6582static hda_nid_t alc883_dac_nids[4] = {
6583 /* front, rear, clfe, rear_surr */
6584 0x02, 0x03, 0x04, 0x05
6585};
6586
6587static hda_nid_t alc883_adc_nids[2] = {
6588 /* ADC1-2 */
6589 0x08, 0x09,
6590};
6591
6592static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6593
6594/* input MUX */
6595/* FIXME: should be a matrix-type input source selection */
6596
6597static struct hda_input_mux alc883_capture_source = {
6598 .num_items = 4,
6599 .items = {
6600 { "Mic", 0x0 },
6601 { "Front Mic", 0x1 },
6602 { "Line", 0x2 },
6603 { "CD", 0x4 },
6604 },
6605};
6606
6607static struct hda_input_mux alc883_3stack_6ch_intel = {
6608 .num_items = 4,
6609 .items = {
6610 { "Mic", 0x1 },
6611 { "Front Mic", 0x0 },
6612 { "Line", 0x2 },
6613 { "CD", 0x4 },
6614 },
6615};
6616
6617static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6618 .num_items = 2,
6619 .items = {
6620 { "Mic", 0x1 },
6621 { "Line", 0x2 },
6622 },
6623};
6624
6625static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6626 .num_items = 4,
6627 .items = {
6628 { "Mic", 0x0 },
6629 { "iMic", 0x1 },
6630 { "Line", 0x2 },
6631 { "CD", 0x4 },
6632 },
6633};
6634
6635static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6636 .num_items = 2,
6637 .items = {
6638 { "Mic", 0x0 },
6639 { "Int Mic", 0x1 },
6640 },
6641};
6642
6643#define alc883_mux_enum_info alc_mux_enum_info
6644#define alc883_mux_enum_get alc_mux_enum_get
6645/* ALC883 has the ALC882-type input selection */
6646#define alc883_mux_enum_put alc882_mux_enum_put
6647
6648/*
6649 * 2ch mode
6650 */
6651static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6652 { 2, NULL }
6653};
6654
6655/*
6656 * 2ch mode
6657 */
6658static struct hda_verb alc883_3ST_ch2_init[] = {
6659 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6660 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6661 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6662 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6663 { } /* end */
6664};
6665
6666/*
6667 * 4ch mode
6668 */
6669static struct hda_verb alc883_3ST_ch4_init[] = {
6670 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6671 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6672 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6673 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6674 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6675 { } /* end */
6676};
6677
6678/*
6679 * 6ch mode
6680 */
6681static struct hda_verb alc883_3ST_ch6_init[] = {
6682 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6683 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6684 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6685 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6686 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6687 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6688 { } /* end */
6689};
6690
6691static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
6692 { 2, alc883_3ST_ch2_init },
6693 { 4, alc883_3ST_ch4_init },
6694 { 6, alc883_3ST_ch6_init },
6695};
6696
6697/*
6698 * 2ch mode
6699 */
6700static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6701 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6702 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6703 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6704 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6705 { } /* end */
6706};
6707
6708/*
6709 * 4ch mode
6710 */
6711static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6712 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6713 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6714 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6715 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6716 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6717 { } /* end */
6718};
6719
6720/*
6721 * 6ch mode
6722 */
6723static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6724 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6725 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6726 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6727 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6728 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6729 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6730 { } /* end */
6731};
6732
6733static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6734 { 2, alc883_3ST_ch2_intel_init },
6735 { 4, alc883_3ST_ch4_intel_init },
6736 { 6, alc883_3ST_ch6_intel_init },
6737};
6738
6739/*
6740 * 6ch mode
6741 */
6742static struct hda_verb alc883_sixstack_ch6_init[] = {
6743 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6744 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6745 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6746 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6747 { } /* end */
6748};
6749
6750/*
6751 * 8ch mode
6752 */
6753static struct hda_verb alc883_sixstack_ch8_init[] = {
6754 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6755 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6756 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6757 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6758 { } /* end */
6759};
6760
6761static struct hda_channel_mode alc883_sixstack_modes[2] = {
6762 { 6, alc883_sixstack_ch6_init },
6763 { 8, alc883_sixstack_ch8_init },
6764};
6765
6766static struct hda_verb alc883_medion_eapd_verbs[] = {
6767 /* eanable EAPD on medion laptop */
6768 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6769 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6770 { }
6771};
6772
6773/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6774 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6775 */
6776
6777static struct snd_kcontrol_new alc883_base_mixer[] = {
6778 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6779 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6780 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6781 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6782 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6783 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6784 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6785 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6786 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6787 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6788 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6789 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6790 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6791 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6792 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6793 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6794 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6796 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6797 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6798 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6799 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6800 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6801 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6802 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6803 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6804 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6805 {
6806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6807 /* .name = "Capture Source", */
6808 .name = "Input Source",
6809 .count = 2,
6810 .info = alc883_mux_enum_info,
6811 .get = alc883_mux_enum_get,
6812 .put = alc883_mux_enum_put,
6813 },
6814 { } /* end */
6815};
6816
6817static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6818 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6819 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6820 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6821 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6822 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6823 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6824 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6826 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6828 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6829 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6830 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6831 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6832 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6833 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6834 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6835 {
6836 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6837 /* .name = "Capture Source", */
6838 .name = "Input Source",
6839 .count = 2,
6840 .info = alc883_mux_enum_info,
6841 .get = alc883_mux_enum_get,
6842 .put = alc883_mux_enum_put,
6843 },
6844 { } /* end */
6845};
6846
6847static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
6848 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6849 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6850 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6851 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6853 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6855 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6856 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6857 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6858 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6859 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6860 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6861 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6862 {
6863 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6864 /* .name = "Capture Source", */
6865 .name = "Input Source",
6866 .count = 2,
6867 .info = alc883_mux_enum_info,
6868 .get = alc883_mux_enum_get,
6869 .put = alc883_mux_enum_put,
6870 },
6871 { } /* end */
6872};
6873
6874static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
6875 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6876 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
6877 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6878 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
6879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6880 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6881 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6882 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6883 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
6884 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6885 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6886 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6887 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6888 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6889 {
6890 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6891 /* .name = "Capture Source", */
6892 .name = "Input Source",
6893 .count = 2,
6894 .info = alc883_mux_enum_info,
6895 .get = alc883_mux_enum_get,
6896 .put = alc883_mux_enum_put,
6897 },
6898 { } /* end */
6899};
6900
6901static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6902 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6903 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6905 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6906 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6907 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6908 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6909 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6910 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6911 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6912 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6913 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6914 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6915 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6916 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6917 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6918 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6919 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6920 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6921 {
6922 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6923 /* .name = "Capture Source", */
6924 .name = "Input Source",
6925 .count = 2,
6926 .info = alc883_mux_enum_info,
6927 .get = alc883_mux_enum_get,
6928 .put = alc883_mux_enum_put,
6929 },
6930 { } /* end */
6931};
6932
6933static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6934 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6935 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6936 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6937 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6938 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6939 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6940 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6941 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6943 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6944 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6945 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6946 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6947 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6948 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6950 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6951 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6952 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6953 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6954 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6955 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6956 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6957 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6958 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6959 {
6960 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6961 /* .name = "Capture Source", */
6962 .name = "Input Source",
6963 .count = 2,
6964 .info = alc883_mux_enum_info,
6965 .get = alc883_mux_enum_get,
6966 .put = alc883_mux_enum_put,
6967 },
6968 { } /* end */
6969};
6970
6971static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
6972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6973 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6974 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6975 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6976 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
6977 HDA_OUTPUT),
6978 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6979 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6980 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6984 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6985 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6987 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
6988 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6989 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6990 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
6991 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6992 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6993 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6994 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6995 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6996 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6997 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6998 {
6999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7000 /* .name = "Capture Source", */
7001 .name = "Input Source",
7002 .count = 2,
7003 .info = alc883_mux_enum_info,
7004 .get = alc883_mux_enum_get,
7005 .put = alc883_mux_enum_put,
7006 },
7007 { } /* end */
7008};
7009
7010static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
7011 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7012 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7013 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7014 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7015 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7016 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7017 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
7018 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7025 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7026 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7028 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7029 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7030 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7031 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7032 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7033 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7034
7035 {
7036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7037 /* .name = "Capture Source", */
7038 .name = "Input Source",
7039 .count = 1,
7040 .info = alc883_mux_enum_info,
7041 .get = alc883_mux_enum_get,
7042 .put = alc883_mux_enum_put,
7043 },
7044 { } /* end */
7045};
7046
7047static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7048 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7049 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7050 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7051 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7052 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7053 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7054 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7055 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7056 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7060 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7062 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7064 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7065 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7066 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7067 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7068 {
7069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7070 /* .name = "Capture Source", */
7071 .name = "Input Source",
7072 .count = 2,
7073 .info = alc883_mux_enum_info,
7074 .get = alc883_mux_enum_get,
7075 .put = alc883_mux_enum_put,
7076 },
7077 { } /* end */
7078};
7079
7080static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7081 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7082 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7083 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7084 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7085 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7086 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7087 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7088 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7089 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7090 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7091 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7092 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7093 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7094 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7095 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7096 {
7097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7098 /* .name = "Capture Source", */
7099 .name = "Input Source",
7100 .count = 2,
7101 .info = alc883_mux_enum_info,
7102 .get = alc883_mux_enum_get,
7103 .put = alc883_mux_enum_put,
7104 },
7105 { } /* end */
7106};
7107
7108static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7109 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7110 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7111 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7112 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7113 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7114 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7115 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7116 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7117 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7118 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7119 {
7120 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7121 /* .name = "Capture Source", */
7122 .name = "Input Source",
7123 .count = 1,
7124 .info = alc883_mux_enum_info,
7125 .get = alc883_mux_enum_get,
7126 .put = alc883_mux_enum_put,
7127 },
7128 { } /* end */
7129};
7130
7131static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7132 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7133 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7134 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7135 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7136 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7139 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7140 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7141 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7142 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7143 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7144 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7145 {
7146 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7147 /* .name = "Capture Source", */
7148 .name = "Input Source",
7149 .count = 2,
7150 .info = alc883_mux_enum_info,
7151 .get = alc883_mux_enum_get,
7152 .put = alc883_mux_enum_put,
7153 },
7154 { } /* end */
7155};
7156
7157static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7158 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7159 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7160 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7161 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7162 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7165 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7166 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7167 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7168 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7169 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7170 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7171 {
7172 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7173 /* .name = "Capture Source", */
7174 .name = "Input Source",
7175 .count = 2,
7176 .info = alc883_mux_enum_info,
7177 .get = alc883_mux_enum_get,
7178 .put = alc883_mux_enum_put,
7179 },
7180 { } /* end */
7181};
7182
7183static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
7184 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7185 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7186 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7187 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7188 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7189 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7190 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7192 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7193 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7194 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7195 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7196 {
7197 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7198 /* .name = "Capture Source", */
7199 .name = "Input Source",
7200 .count = 2,
7201 .info = alc883_mux_enum_info,
7202 .get = alc883_mux_enum_get,
7203 .put = alc883_mux_enum_put,
7204 },
7205 { } /* end */
7206};
7207
7208static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7209 {
7210 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7211 .name = "Channel Mode",
7212 .info = alc_ch_mode_info,
7213 .get = alc_ch_mode_get,
7214 .put = alc_ch_mode_put,
7215 },
7216 { } /* end */
7217};
7218
7219static struct hda_verb alc883_init_verbs[] = {
7220 /* ADC1: mute amp left and right */
7221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7222 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7223 /* ADC2: mute amp left and right */
7224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7225 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7226 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7230 /* Rear mixer */
7231 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7233 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7234 /* CLFE mixer */
7235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7236 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7237 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7238 /* Side mixer */
7239 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7240 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7241 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7242
7243 /* mute analog input loopbacks */
7244 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7247 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7249
7250 /* Front Pin: output 0 (0x0c) */
7251 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7252 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7253 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7254 /* Rear Pin: output 1 (0x0d) */
7255 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7257 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7258 /* CLFE Pin: output 2 (0x0e) */
7259 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7260 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7261 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7262 /* Side Pin: output 3 (0x0f) */
7263 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7265 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7266 /* Mic (rear) pin: input vref at 80% */
7267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7269 /* Front Mic pin: input vref at 80% */
7270 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7272 /* Line In pin: input */
7273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7275 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7276 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7277 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7278 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7279 /* CD pin widget for input */
7280 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7281
7282 /* FIXME: use matrix-type input source selection */
7283 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7284 /* Input mixer2 */
7285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7287 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7288 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7289 /* Input mixer3 */
7290 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7292 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7293 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7294 { }
7295};
7296
7297/* toggle speaker-output according to the hp-jack state */
7298static void alc883_mitac_hp_automute(struct hda_codec *codec)
7299{
7300 unsigned int present;
7301
7302 present = snd_hda_codec_read(codec, 0x15, 0,
7303 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7304 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7305 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7306 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7307 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7308}
7309
7310/* auto-toggle front mic */
7311/*
7312static void alc883_mitac_mic_automute(struct hda_codec *codec)
7313{
7314 unsigned int present;
7315 unsigned char bits;
7316
7317 present = snd_hda_codec_read(codec, 0x18, 0,
7318 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7319 bits = present ? HDA_AMP_MUTE : 0;
7320 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7321}
7322*/
7323
7324static void alc883_mitac_automute(struct hda_codec *codec)
7325{
7326 alc883_mitac_hp_automute(codec);
7327 /* alc883_mitac_mic_automute(codec); */
7328}
7329
7330static void alc883_mitac_unsol_event(struct hda_codec *codec,
7331 unsigned int res)
7332{
7333 switch (res >> 26) {
7334 case ALC880_HP_EVENT:
7335 alc883_mitac_hp_automute(codec);
7336 break;
7337 case ALC880_MIC_EVENT:
7338 /* alc883_mitac_mic_automute(codec); */
7339 break;
7340 }
7341}
7342
7343static struct hda_verb alc883_mitac_verbs[] = {
7344 /* HP */
7345 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7346 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7347 /* Subwoofer */
7348 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7349 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7350
7351 /* enable unsolicited event */
7352 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7353 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7354
7355 { } /* end */
7356};
7357
7358static struct hda_verb alc883_clevo_m720_verbs[] = {
7359 /* HP */
7360 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7361 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7362 /* Int speaker */
7363 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7365
7366 /* enable unsolicited event */
7367 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7368 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
7369
7370 { } /* end */
7371};
7372
7373static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7374 /* HP */
7375 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7377 /* Subwoofer */
7378 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7380
7381 /* enable unsolicited event */
7382 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7383
7384 { } /* end */
7385};
7386
7387static struct hda_verb alc883_tagra_verbs[] = {
7388 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7389 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7390
7391 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7392 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7393
7394 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7395 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7396 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7397
7398 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7399 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7400 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7401 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
7402
7403 { } /* end */
7404};
7405
7406static struct hda_verb alc883_lenovo_101e_verbs[] = {
7407 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7408 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7409 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7410 { } /* end */
7411};
7412
7413static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7414 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7415 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7416 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7417 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7418 { } /* end */
7419};
7420
7421static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7422 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7423 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7424 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7425 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7426 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7427 { } /* end */
7428};
7429
7430static struct hda_verb alc883_haier_w66_verbs[] = {
7431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7432 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7433
7434 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7435
7436 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7437 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7438 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7439 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7440 { } /* end */
7441};
7442
7443static struct hda_verb alc888_3st_hp_verbs[] = {
7444 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7445 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7446 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7447 { }
7448};
7449
7450static struct hda_verb alc888_6st_dell_verbs[] = {
7451 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7452 { }
7453};
7454
7455static struct hda_verb alc888_3st_hp_2ch_init[] = {
7456 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7457 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7458 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7459 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7460 { }
7461};
7462
7463static struct hda_verb alc888_3st_hp_6ch_init[] = {
7464 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7465 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7466 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7467 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7468 { }
7469};
7470
7471static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7472 { 2, alc888_3st_hp_2ch_init },
7473 { 6, alc888_3st_hp_6ch_init },
7474};
7475
7476/* toggle front-jack and RCA according to the hp-jack state */
7477static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7478{
7479 unsigned int present;
7480
7481 present = snd_hda_codec_read(codec, 0x1b, 0,
7482 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7483 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7484 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7485 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7486 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7487}
7488
7489/* toggle RCA according to the front-jack state */
7490static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7491{
7492 unsigned int present;
7493
7494 present = snd_hda_codec_read(codec, 0x14, 0,
7495 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7496 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7497 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7498}
7499
7500static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7501 unsigned int res)
7502{
7503 if ((res >> 26) == ALC880_HP_EVENT)
7504 alc888_lenovo_ms7195_front_automute(codec);
7505 if ((res >> 26) == ALC880_FRONT_EVENT)
7506 alc888_lenovo_ms7195_rca_automute(codec);
7507}
7508
7509static struct hda_verb alc883_medion_md2_verbs[] = {
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
7513 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7514
7515 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7516 { } /* end */
7517};
7518
7519/* toggle speaker-output according to the hp-jack state */
7520static void alc883_medion_md2_automute(struct hda_codec *codec)
7521{
7522 unsigned int present;
7523
7524 present = snd_hda_codec_read(codec, 0x14, 0,
7525 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7526 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7527 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7528}
7529
7530static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7531 unsigned int res)
7532{
7533 if ((res >> 26) == ALC880_HP_EVENT)
7534 alc883_medion_md2_automute(codec);
7535}
7536
7537/* toggle speaker-output according to the hp-jack state */
7538static void alc883_tagra_automute(struct hda_codec *codec)
7539{
7540 unsigned int present;
7541 unsigned char bits;
7542
7543 present = snd_hda_codec_read(codec, 0x14, 0,
7544 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7545 bits = present ? HDA_AMP_MUTE : 0;
7546 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7547 HDA_AMP_MUTE, bits);
7548 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7549 present ? 1 : 3);
7550}
7551
7552static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7553{
7554 if ((res >> 26) == ALC880_HP_EVENT)
7555 alc883_tagra_automute(codec);
7556}
7557
7558/* toggle speaker-output according to the hp-jack state */
7559static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
7560{
7561 unsigned int present;
7562 unsigned char bits;
7563
7564 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7565 & AC_PINSENSE_PRESENCE;
7566 bits = present ? HDA_AMP_MUTE : 0;
7567 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7568 HDA_AMP_MUTE, bits);
7569}
7570
7571static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7572{
7573 unsigned int present;
7574
7575 present = snd_hda_codec_read(codec, 0x18, 0,
7576 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7577 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7578 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7579}
7580
7581static void alc883_clevo_m720_automute(struct hda_codec *codec)
7582{
7583 alc883_clevo_m720_hp_automute(codec);
7584 alc883_clevo_m720_mic_automute(codec);
7585}
7586
7587static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
7588 unsigned int res)
7589{
7590 switch (res >> 26) {
7591 case ALC880_HP_EVENT:
7592 alc883_clevo_m720_hp_automute(codec);
7593 break;
7594 case ALC880_MIC_EVENT:
7595 alc883_clevo_m720_mic_automute(codec);
7596 break;
7597 }
7598}
7599
7600/* toggle speaker-output according to the hp-jack state */
7601static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7602{
7603 unsigned int present;
7604 unsigned char bits;
7605
7606 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7607 & AC_PINSENSE_PRESENCE;
7608 bits = present ? HDA_AMP_MUTE : 0;
7609 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7610 HDA_AMP_MUTE, bits);
7611}
7612
7613static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7614 unsigned int res)
7615{
7616 if ((res >> 26) == ALC880_HP_EVENT)
7617 alc883_2ch_fujitsu_pi2515_automute(codec);
7618}
7619
7620static void alc883_haier_w66_automute(struct hda_codec *codec)
7621{
7622 unsigned int present;
7623 unsigned char bits;
7624
7625 present = snd_hda_codec_read(codec, 0x1b, 0,
7626 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7627 bits = present ? 0x80 : 0;
7628 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7629 0x80, bits);
7630}
7631
7632static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7633 unsigned int res)
7634{
7635 if ((res >> 26) == ALC880_HP_EVENT)
7636 alc883_haier_w66_automute(codec);
7637}
7638
7639static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7640{
7641 unsigned int present;
7642 unsigned char bits;
7643
7644 present = snd_hda_codec_read(codec, 0x14, 0,
7645 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7646 bits = present ? HDA_AMP_MUTE : 0;
7647 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7648 HDA_AMP_MUTE, bits);
7649}
7650
7651static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7652{
7653 unsigned int present;
7654 unsigned char bits;
7655
7656 present = snd_hda_codec_read(codec, 0x1b, 0,
7657 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7658 bits = present ? HDA_AMP_MUTE : 0;
7659 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7660 HDA_AMP_MUTE, bits);
7661 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7662 HDA_AMP_MUTE, bits);
7663}
7664
7665static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7666 unsigned int res)
7667{
7668 if ((res >> 26) == ALC880_HP_EVENT)
7669 alc883_lenovo_101e_all_automute(codec);
7670 if ((res >> 26) == ALC880_FRONT_EVENT)
7671 alc883_lenovo_101e_ispeaker_automute(codec);
7672}
7673
7674/* toggle speaker-output according to the hp-jack state */
7675static void alc883_acer_aspire_automute(struct hda_codec *codec)
7676{
7677 unsigned int present;
7678
7679 present = snd_hda_codec_read(codec, 0x14, 0,
7680 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7681 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7682 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7683 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7684 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7685}
7686
7687static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7688 unsigned int res)
7689{
7690 if ((res >> 26) == ALC880_HP_EVENT)
7691 alc883_acer_aspire_automute(codec);
7692}
7693
7694static struct hda_verb alc883_acer_eapd_verbs[] = {
7695 /* HP Pin: output 0 (0x0c) */
7696 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7697 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7698 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7699 /* Front Pin: output 0 (0x0c) */
7700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7701 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7702 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7703 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7704 /* eanable EAPD on medion laptop */
7705 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7706 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7707 /* enable unsolicited event */
7708 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7709 { }
7710};
7711
7712static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7713{
7714 unsigned int present;
7715
7716 present = snd_hda_codec_read(codec, 0x1b, 0,
7717 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7718 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7719 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7720 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7721 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7722 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7723 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7724 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7725 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7726}
7727
7728static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7729 unsigned int res)
7730{
7731 switch (res >> 26) {
7732 case ALC880_HP_EVENT:
7733 printk("hp_event\n");
7734 alc888_6st_dell_front_automute(codec);
7735 break;
7736 }
7737}
7738
7739/*
7740 * generic initialization of ADC, input mixers and output mixers
7741 */
7742static struct hda_verb alc883_auto_init_verbs[] = {
7743 /*
7744 * Unmute ADC0-2 and set the default input to mic-in
7745 */
7746 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7747 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7748 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7749 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7750
7751 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7752 * mixer widget
7753 * Note: PASD motherboards uses the Line In 2 as the input for
7754 * front panel mic (mic 2)
7755 */
7756 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7757 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7758 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7759 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7762
7763 /*
7764 * Set up output mixers (0x0c - 0x0f)
7765 */
7766 /* set vol=0 to output mixers */
7767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7768 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7769 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7770 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7771 /* set up input amps for analog loopback */
7772 /* Amp Indices: DAC = 0, mixer = 1 */
7773 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7774 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7775 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7776 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7777 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7778 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7779 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7780 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7781 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7782 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7783
7784 /* FIXME: use matrix-type input source selection */
7785 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7786 /* Input mixer1 */
7787 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7788 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7789 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7790 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7791 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7792 /* Input mixer2 */
7793 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7794 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7795 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7796 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7797 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7798
7799 { }
7800};
7801
7802/* capture mixer elements */
7803static struct snd_kcontrol_new alc883_capture_mixer[] = {
7804 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7805 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7806 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7807 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7808 {
7809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7810 /* The multiple "Capture Source" controls confuse alsamixer
7811 * So call somewhat different..
7812 */
7813 /* .name = "Capture Source", */
7814 .name = "Input Source",
7815 .count = 2,
7816 .info = alc882_mux_enum_info,
7817 .get = alc882_mux_enum_get,
7818 .put = alc882_mux_enum_put,
7819 },
7820 { } /* end */
7821};
7822
7823#ifdef CONFIG_SND_HDA_POWER_SAVE
7824#define alc883_loopbacks alc880_loopbacks
7825#endif
7826
7827/* pcm configuration: identiacal with ALC880 */
7828#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7829#define alc883_pcm_analog_capture alc880_pcm_analog_capture
7830#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
7831#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7832#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7833
7834/*
7835 * configuration and preset
7836 */
7837static const char *alc883_models[ALC883_MODEL_LAST] = {
7838 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7839 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7840 [ALC883_3ST_6ch] = "3stack-6ch",
7841 [ALC883_6ST_DIG] = "6stack-dig",
7842 [ALC883_TARGA_DIG] = "targa-dig",
7843 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
7844 [ALC883_ACER] = "acer",
7845 [ALC883_ACER_ASPIRE] = "acer-aspire",
7846 [ALC883_MEDION] = "medion",
7847 [ALC883_MEDION_MD2] = "medion-md2",
7848 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
7849 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
7850 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7851 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
7852 [ALC883_HAIER_W66] = "haier-w66",
7853 [ALC888_3ST_HP] = "3stack-hp",
7854 [ALC888_6ST_DELL] = "6stack-dell",
7855 [ALC883_MITAC] = "mitac",
7856 [ALC883_CLEVO_M720] = "clevo-m720",
7857 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
7858 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
7859 [ALC883_AUTO] = "auto",
7860};
7861
7862static struct snd_pci_quirk alc883_cfg_tbl[] = {
7863 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
7864 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7865 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7866 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7867 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
7868 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
7869 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
7870 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7871 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7872 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
7873 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7874 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
7875 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
7876 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7877 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7878 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
7879 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
7880 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7881 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7882 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7883 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
7884 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7885 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
7886 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7887 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7888 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7889 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7890 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7891 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7892 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7893 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7894 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
7895 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7896 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7897 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7898 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
7899 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7900 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7901 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
7902 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7903 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
7904 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
7905 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7906 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
7907 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7908 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
7909 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7910 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7911 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7912 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7913 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
7914 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
7915 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
7916 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
7917 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
7918 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
7919 {}
7920};
7921
7922static struct alc_config_preset alc883_presets[] = {
7923 [ALC883_3ST_2ch_DIG] = {
7924 .mixers = { alc883_3ST_2ch_mixer },
7925 .init_verbs = { alc883_init_verbs },
7926 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7927 .dac_nids = alc883_dac_nids,
7928 .dig_out_nid = ALC883_DIGOUT_NID,
7929 .dig_in_nid = ALC883_DIGIN_NID,
7930 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7931 .channel_mode = alc883_3ST_2ch_modes,
7932 .input_mux = &alc883_capture_source,
7933 },
7934 [ALC883_3ST_6ch_DIG] = {
7935 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7936 .init_verbs = { alc883_init_verbs },
7937 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7938 .dac_nids = alc883_dac_nids,
7939 .dig_out_nid = ALC883_DIGOUT_NID,
7940 .dig_in_nid = ALC883_DIGIN_NID,
7941 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7942 .channel_mode = alc883_3ST_6ch_modes,
7943 .need_dac_fix = 1,
7944 .input_mux = &alc883_capture_source,
7945 },
7946 [ALC883_3ST_6ch] = {
7947 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7948 .init_verbs = { alc883_init_verbs },
7949 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7950 .dac_nids = alc883_dac_nids,
7951 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7952 .channel_mode = alc883_3ST_6ch_modes,
7953 .need_dac_fix = 1,
7954 .input_mux = &alc883_capture_source,
7955 },
7956 [ALC883_3ST_6ch_INTEL] = {
7957 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
7958 .init_verbs = { alc883_init_verbs },
7959 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7960 .dac_nids = alc883_dac_nids,
7961 .dig_out_nid = ALC883_DIGOUT_NID,
7962 .dig_in_nid = ALC883_DIGIN_NID,
7963 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
7964 .channel_mode = alc883_3ST_6ch_intel_modes,
7965 .need_dac_fix = 1,
7966 .input_mux = &alc883_3stack_6ch_intel,
7967 },
7968 [ALC883_6ST_DIG] = {
7969 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7970 .init_verbs = { alc883_init_verbs },
7971 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7972 .dac_nids = alc883_dac_nids,
7973 .dig_out_nid = ALC883_DIGOUT_NID,
7974 .dig_in_nid = ALC883_DIGIN_NID,
7975 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7976 .channel_mode = alc883_sixstack_modes,
7977 .input_mux = &alc883_capture_source,
7978 },
7979 [ALC883_TARGA_DIG] = {
7980 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7981 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7982 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7983 .dac_nids = alc883_dac_nids,
7984 .dig_out_nid = ALC883_DIGOUT_NID,
7985 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7986 .channel_mode = alc883_3ST_6ch_modes,
7987 .need_dac_fix = 1,
7988 .input_mux = &alc883_capture_source,
7989 .unsol_event = alc883_tagra_unsol_event,
7990 .init_hook = alc883_tagra_automute,
7991 },
7992 [ALC883_TARGA_2ch_DIG] = {
7993 .mixers = { alc883_tagra_2ch_mixer},
7994 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7995 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7996 .dac_nids = alc883_dac_nids,
7997 .dig_out_nid = ALC883_DIGOUT_NID,
7998 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7999 .channel_mode = alc883_3ST_2ch_modes,
8000 .input_mux = &alc883_capture_source,
8001 .unsol_event = alc883_tagra_unsol_event,
8002 .init_hook = alc883_tagra_automute,
8003 },
8004 [ALC883_ACER] = {
8005 .mixers = { alc883_base_mixer },
8006 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8007 * and the headphone jack. Turn this on and rely on the
8008 * standard mute methods whenever the user wants to turn
8009 * these outputs off.
8010 */
8011 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8012 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8013 .dac_nids = alc883_dac_nids,
8014 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8015 .channel_mode = alc883_3ST_2ch_modes,
8016 .input_mux = &alc883_capture_source,
8017 },
8018 [ALC883_ACER_ASPIRE] = {
8019 .mixers = { alc883_acer_aspire_mixer },
8020 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
8021 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8022 .dac_nids = alc883_dac_nids,
8023 .dig_out_nid = ALC883_DIGOUT_NID,
8024 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8025 .channel_mode = alc883_3ST_2ch_modes,
8026 .input_mux = &alc883_capture_source,
8027 .unsol_event = alc883_acer_aspire_unsol_event,
8028 .init_hook = alc883_acer_aspire_automute,
8029 },
8030 [ALC883_MEDION] = {
8031 .mixers = { alc883_fivestack_mixer,
8032 alc883_chmode_mixer },
8033 .init_verbs = { alc883_init_verbs,
8034 alc883_medion_eapd_verbs },
8035 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8036 .dac_nids = alc883_dac_nids,
8037 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8038 .channel_mode = alc883_sixstack_modes,
8039 .input_mux = &alc883_capture_source,
8040 },
8041 [ALC883_MEDION_MD2] = {
8042 .mixers = { alc883_medion_md2_mixer},
8043 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8044 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8045 .dac_nids = alc883_dac_nids,
8046 .dig_out_nid = ALC883_DIGOUT_NID,
8047 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8048 .channel_mode = alc883_3ST_2ch_modes,
8049 .input_mux = &alc883_capture_source,
8050 .unsol_event = alc883_medion_md2_unsol_event,
8051 .init_hook = alc883_medion_md2_automute,
8052 },
8053 [ALC883_LAPTOP_EAPD] = {
8054 .mixers = { alc883_base_mixer },
8055 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8056 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8057 .dac_nids = alc883_dac_nids,
8058 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8059 .channel_mode = alc883_3ST_2ch_modes,
8060 .input_mux = &alc883_capture_source,
8061 },
8062 [ALC883_CLEVO_M720] = {
8063 .mixers = { alc883_clevo_m720_mixer },
8064 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
8065 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8066 .dac_nids = alc883_dac_nids,
8067 .dig_out_nid = ALC883_DIGOUT_NID,
8068 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8069 .channel_mode = alc883_3ST_2ch_modes,
8070 .input_mux = &alc883_capture_source,
8071 .unsol_event = alc883_clevo_m720_unsol_event,
8072 .init_hook = alc883_clevo_m720_automute,
8073 },
8074 [ALC883_LENOVO_101E_2ch] = {
8075 .mixers = { alc883_lenovo_101e_2ch_mixer},
8076 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8077 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8078 .dac_nids = alc883_dac_nids,
8079 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8080 .channel_mode = alc883_3ST_2ch_modes,
8081 .input_mux = &alc883_lenovo_101e_capture_source,
8082 .unsol_event = alc883_lenovo_101e_unsol_event,
8083 .init_hook = alc883_lenovo_101e_all_automute,
8084 },
8085 [ALC883_LENOVO_NB0763] = {
8086 .mixers = { alc883_lenovo_nb0763_mixer },
8087 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8088 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8089 .dac_nids = alc883_dac_nids,
8090 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8091 .channel_mode = alc883_3ST_2ch_modes,
8092 .need_dac_fix = 1,
8093 .input_mux = &alc883_lenovo_nb0763_capture_source,
8094 .unsol_event = alc883_medion_md2_unsol_event,
8095 .init_hook = alc883_medion_md2_automute,
8096 },
8097 [ALC888_LENOVO_MS7195_DIG] = {
8098 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8099 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8100 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8101 .dac_nids = alc883_dac_nids,
8102 .dig_out_nid = ALC883_DIGOUT_NID,
8103 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8104 .channel_mode = alc883_3ST_6ch_modes,
8105 .need_dac_fix = 1,
8106 .input_mux = &alc883_capture_source,
8107 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8108 .init_hook = alc888_lenovo_ms7195_front_automute,
8109 },
8110 [ALC883_HAIER_W66] = {
8111 .mixers = { alc883_tagra_2ch_mixer},
8112 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8113 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8114 .dac_nids = alc883_dac_nids,
8115 .dig_out_nid = ALC883_DIGOUT_NID,
8116 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8117 .channel_mode = alc883_3ST_2ch_modes,
8118 .input_mux = &alc883_capture_source,
8119 .unsol_event = alc883_haier_w66_unsol_event,
8120 .init_hook = alc883_haier_w66_automute,
8121 },
8122 [ALC888_3ST_HP] = {
8123 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8124 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
8125 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8126 .dac_nids = alc883_dac_nids,
8127 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8128 .channel_mode = alc888_3st_hp_modes,
8129 .need_dac_fix = 1,
8130 .input_mux = &alc883_capture_source,
8131 },
8132 [ALC888_6ST_DELL] = {
8133 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8134 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8135 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8136 .dac_nids = alc883_dac_nids,
8137 .dig_out_nid = ALC883_DIGOUT_NID,
8138 .dig_in_nid = ALC883_DIGIN_NID,
8139 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8140 .channel_mode = alc883_sixstack_modes,
8141 .input_mux = &alc883_capture_source,
8142 .unsol_event = alc888_6st_dell_unsol_event,
8143 .init_hook = alc888_6st_dell_front_automute,
8144 },
8145 [ALC883_MITAC] = {
8146 .mixers = { alc883_mitac_mixer },
8147 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8148 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8149 .dac_nids = alc883_dac_nids,
8150 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8151 .channel_mode = alc883_3ST_2ch_modes,
8152 .input_mux = &alc883_capture_source,
8153 .unsol_event = alc883_mitac_unsol_event,
8154 .init_hook = alc883_mitac_automute,
8155 },
8156 [ALC883_FUJITSU_PI2515] = {
8157 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8158 .init_verbs = { alc883_init_verbs,
8159 alc883_2ch_fujitsu_pi2515_verbs},
8160 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8161 .dac_nids = alc883_dac_nids,
8162 .dig_out_nid = ALC883_DIGOUT_NID,
8163 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8164 .channel_mode = alc883_3ST_2ch_modes,
8165 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8166 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8167 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8168 },
8169};
8170
8171
8172/*
8173 * BIOS auto configuration
8174 */
8175static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8176 hda_nid_t nid, int pin_type,
8177 int dac_idx)
8178{
8179 /* set as output */
8180 struct alc_spec *spec = codec->spec;
8181 int idx;
8182
8183 alc_set_pin_output(codec, nid, pin_type);
8184 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8185 idx = 4;
8186 else
8187 idx = spec->multiout.dac_nids[dac_idx] - 2;
8188 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8189
8190}
8191
8192static void alc883_auto_init_multi_out(struct hda_codec *codec)
8193{
8194 struct alc_spec *spec = codec->spec;
8195 int i;
8196
8197 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
8198 for (i = 0; i <= HDA_SIDE; i++) {
8199 hda_nid_t nid = spec->autocfg.line_out_pins[i];
8200 int pin_type = get_pin_type(spec->autocfg.line_out_type);
8201 if (nid)
8202 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
8203 i);
8204 }
8205}
8206
8207static void alc883_auto_init_hp_out(struct hda_codec *codec)
8208{
8209 struct alc_spec *spec = codec->spec;
8210 hda_nid_t pin;
8211
8212 pin = spec->autocfg.hp_pins[0];
8213 if (pin) /* connect to front */
8214 /* use dac 0 */
8215 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
8216 pin = spec->autocfg.speaker_pins[0];
8217 if (pin)
8218 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
8219}
8220
8221#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8222#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8223
8224static void alc883_auto_init_analog_input(struct hda_codec *codec)
8225{
8226 struct alc_spec *spec = codec->spec;
8227 int i;
8228
8229 for (i = 0; i < AUTO_PIN_LAST; i++) {
8230 hda_nid_t nid = spec->autocfg.input_pins[i];
8231 if (alc883_is_input_pin(nid)) {
8232 snd_hda_codec_write(codec, nid, 0,
8233 AC_VERB_SET_PIN_WIDGET_CONTROL,
8234 (i <= AUTO_PIN_FRONT_MIC ?
8235 PIN_VREF80 : PIN_IN));
8236 if (nid != ALC883_PIN_CD_NID)
8237 snd_hda_codec_write(codec, nid, 0,
8238 AC_VERB_SET_AMP_GAIN_MUTE,
8239 AMP_OUT_MUTE);
8240 }
8241 }
8242}
8243
8244/* almost identical with ALC880 parser... */
8245static int alc883_parse_auto_config(struct hda_codec *codec)
8246{
8247 struct alc_spec *spec = codec->spec;
8248 int err = alc880_parse_auto_config(codec);
8249
8250 if (err < 0)
8251 return err;
8252 else if (!err)
8253 return 0; /* no config found */
8254
8255 err = alc_auto_add_mic_boost(codec);
8256 if (err < 0)
8257 return err;
8258
8259 /* hack - override the init verbs */
8260 spec->init_verbs[0] = alc883_auto_init_verbs;
8261 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8262 spec->num_mixers++;
8263
8264 return 1; /* config found */
8265}
8266
8267/* additional initialization for auto-configuration model */
8268static void alc883_auto_init(struct hda_codec *codec)
8269{
8270 struct alc_spec *spec = codec->spec;
8271 alc883_auto_init_multi_out(codec);
8272 alc883_auto_init_hp_out(codec);
8273 alc883_auto_init_analog_input(codec);
8274 if (spec->unsol_event)
8275 alc_sku_automute(codec);
8276}
8277
8278static int patch_alc883(struct hda_codec *codec)
8279{
8280 struct alc_spec *spec;
8281 int err, board_config;
8282
8283 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8284 if (spec == NULL)
8285 return -ENOMEM;
8286
8287 codec->spec = spec;
8288
8289 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8290 alc883_models,
8291 alc883_cfg_tbl);
8292 if (board_config < 0) {
8293 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8294 "trying auto-probe from BIOS...\n");
8295 board_config = ALC883_AUTO;
8296 }
8297
8298 if (board_config == ALC883_AUTO) {
8299 /* automatic parse from the BIOS config */
8300 err = alc883_parse_auto_config(codec);
8301 if (err < 0) {
8302 alc_free(codec);
8303 return err;
8304 } else if (!err) {
8305 printk(KERN_INFO
8306 "hda_codec: Cannot set up configuration "
8307 "from BIOS. Using base mode...\n");
8308 board_config = ALC883_3ST_2ch_DIG;
8309 }
8310 }
8311
8312 if (board_config != ALC883_AUTO)
8313 setup_preset(spec, &alc883_presets[board_config]);
8314
8315 switch (codec->vendor_id) {
8316 case 0x10ec0888:
8317 spec->stream_name_analog = "ALC888 Analog";
8318 spec->stream_name_digital = "ALC888 Digital";
8319 break;
8320 case 0x10ec0889:
8321 spec->stream_name_analog = "ALC889 Analog";
8322 spec->stream_name_digital = "ALC889 Digital";
8323 break;
8324 default:
8325 spec->stream_name_analog = "ALC883 Analog";
8326 spec->stream_name_digital = "ALC883 Digital";
8327 break;
8328 }
8329
8330 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8331 spec->stream_analog_capture = &alc883_pcm_analog_capture;
8332 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
8333
8334 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8335 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8336
8337 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8338 spec->adc_nids = alc883_adc_nids;
8339 spec->capsrc_nids = alc883_capsrc_nids;
8340
8341 spec->vmaster_nid = 0x0c;
8342
8343 codec->patch_ops = alc_patch_ops;
8344 if (board_config == ALC883_AUTO)
8345 spec->init_hook = alc883_auto_init;
8346 else if (codec->vendor_id == 0x10ec0888)
8347 spec->init_hook = alc888_coef_init;
8348
8349#ifdef CONFIG_SND_HDA_POWER_SAVE
8350 if (!spec->loopback.amplist)
8351 spec->loopback.amplist = alc883_loopbacks;
8352#endif
8353
8354 return 0;
8355}
8356
8357/*
8358 * ALC262 support
8359 */
8360
8361#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8362#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8363
8364#define alc262_dac_nids alc260_dac_nids
8365#define alc262_adc_nids alc882_adc_nids
8366#define alc262_adc_nids_alt alc882_adc_nids_alt
8367#define alc262_capsrc_nids alc882_capsrc_nids
8368#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
8369
8370#define alc262_modes alc260_modes
8371#define alc262_capture_source alc882_capture_source
8372
8373static struct snd_kcontrol_new alc262_base_mixer[] = {
8374 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8375 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8376 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8377 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8378 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8379 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8382 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8383 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8384 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8385 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8386 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8387 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8388 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8389 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8390 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8391 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8392 { } /* end */
8393};
8394
8395static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8396 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8397 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8398 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8399 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8400 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8401 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8402 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8403 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8404 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8405 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8406 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8407 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8408 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8409 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8410 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8411 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8412 { } /* end */
8413};
8414
8415/* update HP, line and mono-out pins according to the master switch */
8416static void alc262_hp_master_update(struct hda_codec *codec)
8417{
8418 struct alc_spec *spec = codec->spec;
8419 int val = spec->master_sw;
8420
8421 /* HP & line-out */
8422 snd_hda_codec_write_cache(codec, 0x1b, 0,
8423 AC_VERB_SET_PIN_WIDGET_CONTROL,
8424 val ? PIN_HP : 0);
8425 snd_hda_codec_write_cache(codec, 0x15, 0,
8426 AC_VERB_SET_PIN_WIDGET_CONTROL,
8427 val ? PIN_HP : 0);
8428 /* mono (speaker) depending on the HP jack sense */
8429 val = val && !spec->jack_present;
8430 snd_hda_codec_write_cache(codec, 0x16, 0,
8431 AC_VERB_SET_PIN_WIDGET_CONTROL,
8432 val ? PIN_OUT : 0);
8433}
8434
8435static void alc262_hp_bpc_automute(struct hda_codec *codec)
8436{
8437 struct alc_spec *spec = codec->spec;
8438 unsigned int presence;
8439 presence = snd_hda_codec_read(codec, 0x1b, 0,
8440 AC_VERB_GET_PIN_SENSE, 0);
8441 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8442 alc262_hp_master_update(codec);
8443}
8444
8445static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8446{
8447 if ((res >> 26) != ALC880_HP_EVENT)
8448 return;
8449 alc262_hp_bpc_automute(codec);
8450}
8451
8452static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8453{
8454 struct alc_spec *spec = codec->spec;
8455 unsigned int presence;
8456 presence = snd_hda_codec_read(codec, 0x15, 0,
8457 AC_VERB_GET_PIN_SENSE, 0);
8458 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8459 alc262_hp_master_update(codec);
8460}
8461
8462static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8463 unsigned int res)
8464{
8465 if ((res >> 26) != ALC880_HP_EVENT)
8466 return;
8467 alc262_hp_wildwest_automute(codec);
8468}
8469
8470static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8471 struct snd_ctl_elem_value *ucontrol)
8472{
8473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8474 struct alc_spec *spec = codec->spec;
8475 *ucontrol->value.integer.value = spec->master_sw;
8476 return 0;
8477}
8478
8479static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8480 struct snd_ctl_elem_value *ucontrol)
8481{
8482 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8483 struct alc_spec *spec = codec->spec;
8484 int val = !!*ucontrol->value.integer.value;
8485
8486 if (val == spec->master_sw)
8487 return 0;
8488 spec->master_sw = val;
8489 alc262_hp_master_update(codec);
8490 return 1;
8491}
8492
8493static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
8494 {
8495 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8496 .name = "Master Playback Switch",
8497 .info = snd_ctl_boolean_mono_info,
8498 .get = alc262_hp_master_sw_get,
8499 .put = alc262_hp_master_sw_put,
8500 },
8501 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8502 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8503 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8504 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8505 HDA_OUTPUT),
8506 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8507 HDA_OUTPUT),
8508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8509 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8510 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8511 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8512 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8513 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8514 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8515 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8516 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8517 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8518 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8519 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8520 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8521 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8522 { } /* end */
8523};
8524
8525static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8526 {
8527 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8528 .name = "Master Playback Switch",
8529 .info = snd_ctl_boolean_mono_info,
8530 .get = alc262_hp_master_sw_get,
8531 .put = alc262_hp_master_sw_put,
8532 },
8533 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8534 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8535 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8536 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8537 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8538 HDA_OUTPUT),
8539 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8540 HDA_OUTPUT),
8541 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8542 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
8543 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
8544 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8545 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8546 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8547 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8548 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8549 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8550 { } /* end */
8551};
8552
8553static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8554 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8555 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8556 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
8557 { } /* end */
8558};
8559
8560/* mute/unmute internal speaker according to the hp jack and mute state */
8561static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8562{
8563 struct alc_spec *spec = codec->spec;
8564
8565 if (force || !spec->sense_updated) {
8566 unsigned int present;
8567 present = snd_hda_codec_read(codec, 0x15, 0,
8568 AC_VERB_GET_PIN_SENSE, 0);
8569 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
8570 spec->sense_updated = 1;
8571 }
8572 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8573 spec->jack_present ? HDA_AMP_MUTE : 0);
8574}
8575
8576static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8577 unsigned int res)
8578{
8579 if ((res >> 26) != ALC880_HP_EVENT)
8580 return;
8581 alc262_hp_t5735_automute(codec, 1);
8582}
8583
8584static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8585{
8586 alc262_hp_t5735_automute(codec, 1);
8587}
8588
8589static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
8590 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8591 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8592 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8593 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8594 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8595 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8596 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8597 { } /* end */
8598};
8599
8600static struct hda_verb alc262_hp_t5735_verbs[] = {
8601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8602 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8603
8604 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8605 { }
8606};
8607
8608static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
8609 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8610 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8611 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8612 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8613 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8614 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8615 { } /* end */
8616};
8617
8618static struct hda_verb alc262_hp_rp5700_verbs[] = {
8619 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8620 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8621 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8623 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8624 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8626 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8627 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8628 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8629 {}
8630};
8631
8632static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8633 .num_items = 1,
8634 .items = {
8635 { "Line", 0x1 },
8636 },
8637};
8638
8639/* bind hp and internal speaker mute (with plug check) */
8640static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8641 struct snd_ctl_elem_value *ucontrol)
8642{
8643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8644 long *valp = ucontrol->value.integer.value;
8645 int change;
8646
8647 /* change hp mute */
8648 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8649 HDA_AMP_MUTE,
8650 valp[0] ? 0 : HDA_AMP_MUTE);
8651 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8652 HDA_AMP_MUTE,
8653 valp[1] ? 0 : HDA_AMP_MUTE);
8654 if (change) {
8655 /* change speaker according to HP jack state */
8656 struct alc_spec *spec = codec->spec;
8657 unsigned int mute;
8658 if (spec->jack_present)
8659 mute = HDA_AMP_MUTE;
8660 else
8661 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8662 HDA_OUTPUT, 0);
8663 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8664 HDA_AMP_MUTE, mute);
8665 }
8666 return change;
8667}
8668
8669static struct snd_kcontrol_new alc262_sony_mixer[] = {
8670 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8671 {
8672 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8673 .name = "Master Playback Switch",
8674 .info = snd_hda_mixer_amp_switch_info,
8675 .get = snd_hda_mixer_amp_switch_get,
8676 .put = alc262_sony_master_sw_put,
8677 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8678 },
8679 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8680 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8681 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8682 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8683 { } /* end */
8684};
8685
8686static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8687 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8688 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8689 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8690 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8691 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8692 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8693 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8694 { } /* end */
8695};
8696
8697#define alc262_capture_mixer alc882_capture_mixer
8698#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8699
8700/*
8701 * generic initialization of ADC, input mixers and output mixers
8702 */
8703static struct hda_verb alc262_init_verbs[] = {
8704 /*
8705 * Unmute ADC0-2 and set the default input to mic-in
8706 */
8707 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8708 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8709 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8710 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8711 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8712 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8713
8714 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8715 * mixer widget
8716 * Note: PASD motherboards uses the Line In 2 as the input for
8717 * front panel mic (mic 2)
8718 */
8719 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8721 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8725
8726 /*
8727 * Set up output mixers (0x0c - 0x0e)
8728 */
8729 /* set vol=0 to output mixers */
8730 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8731 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8732 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8733 /* set up input amps for analog loopback */
8734 /* Amp Indices: DAC = 0, mixer = 1 */
8735 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8736 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8737 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8738 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8739 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8740 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8741
8742 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8743 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8744 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8745 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8746 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8747 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8748
8749 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8750 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8751 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8752 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8753 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8754
8755 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8756 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8757
8758 /* FIXME: use matrix-type input source selection */
8759 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8760 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8761 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8762 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8763 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8764 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8765 /* Input mixer2 */
8766 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8767 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8768 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8769 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8770 /* Input mixer3 */
8771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8772 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8773 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8774 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8775
8776 { }
8777};
8778
8779static struct hda_verb alc262_hippo_unsol_verbs[] = {
8780 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8781 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8782 {}
8783};
8784
8785static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8786 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8787 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8788 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8789
8790 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8791 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8792 {}
8793};
8794
8795static struct hda_verb alc262_sony_unsol_verbs[] = {
8796 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8797 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8798 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8799
8800 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8801 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8802 {}
8803};
8804
8805/* mute/unmute internal speaker according to the hp jack and mute state */
8806static void alc262_hippo_automute(struct hda_codec *codec)
8807{
8808 struct alc_spec *spec = codec->spec;
8809 unsigned int mute;
8810 unsigned int present;
8811
8812 /* need to execute and sync at first */
8813 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8814 present = snd_hda_codec_read(codec, 0x15, 0,
8815 AC_VERB_GET_PIN_SENSE, 0);
8816 spec->jack_present = (present & 0x80000000) != 0;
8817 if (spec->jack_present) {
8818 /* mute internal speaker */
8819 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8820 HDA_AMP_MUTE, HDA_AMP_MUTE);
8821 } else {
8822 /* unmute internal speaker if necessary */
8823 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8824 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8825 HDA_AMP_MUTE, mute);
8826 }
8827}
8828
8829/* unsolicited event for HP jack sensing */
8830static void alc262_hippo_unsol_event(struct hda_codec *codec,
8831 unsigned int res)
8832{
8833 if ((res >> 26) != ALC880_HP_EVENT)
8834 return;
8835 alc262_hippo_automute(codec);
8836}
8837
8838static void alc262_hippo1_automute(struct hda_codec *codec)
8839{
8840 unsigned int mute;
8841 unsigned int present;
8842
8843 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8844 present = snd_hda_codec_read(codec, 0x1b, 0,
8845 AC_VERB_GET_PIN_SENSE, 0);
8846 present = (present & 0x80000000) != 0;
8847 if (present) {
8848 /* mute internal speaker */
8849 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8850 HDA_AMP_MUTE, HDA_AMP_MUTE);
8851 } else {
8852 /* unmute internal speaker if necessary */
8853 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8854 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8855 HDA_AMP_MUTE, mute);
8856 }
8857}
8858
8859/* unsolicited event for HP jack sensing */
8860static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8861 unsigned int res)
8862{
8863 if ((res >> 26) != ALC880_HP_EVENT)
8864 return;
8865 alc262_hippo1_automute(codec);
8866}
8867
8868/*
8869 * fujitsu model
8870 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
8871 * 0x1b = port replicator headphone out
8872 */
8873
8874#define ALC_HP_EVENT 0x37
8875
8876static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8877 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8878 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8879 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8880 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8881 {}
8882};
8883
8884static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
8885 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8886 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8887 {}
8888};
8889
8890static struct hda_input_mux alc262_fujitsu_capture_source = {
8891 .num_items = 3,
8892 .items = {
8893 { "Mic", 0x0 },
8894 { "Int Mic", 0x1 },
8895 { "CD", 0x4 },
8896 },
8897};
8898
8899static struct hda_input_mux alc262_HP_capture_source = {
8900 .num_items = 5,
8901 .items = {
8902 { "Mic", 0x0 },
8903 { "Front Mic", 0x1 },
8904 { "Line", 0x2 },
8905 { "CD", 0x4 },
8906 { "AUX IN", 0x6 },
8907 },
8908};
8909
8910static struct hda_input_mux alc262_HP_D7000_capture_source = {
8911 .num_items = 4,
8912 .items = {
8913 { "Mic", 0x0 },
8914 { "Front Mic", 0x2 },
8915 { "Line", 0x1 },
8916 { "CD", 0x4 },
8917 },
8918};
8919
8920/* mute/unmute internal speaker according to the hp jacks and mute state */
8921static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8922{
8923 struct alc_spec *spec = codec->spec;
8924 unsigned int mute;
8925
8926 if (force || !spec->sense_updated) {
8927 unsigned int present;
8928 /* need to execute and sync at first */
8929 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8930 /* check laptop HP jack */
8931 present = snd_hda_codec_read(codec, 0x14, 0,
8932 AC_VERB_GET_PIN_SENSE, 0);
8933 /* need to execute and sync at first */
8934 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8935 /* check docking HP jack */
8936 present |= snd_hda_codec_read(codec, 0x1b, 0,
8937 AC_VERB_GET_PIN_SENSE, 0);
8938 if (present & AC_PINSENSE_PRESENCE)
8939 spec->jack_present = 1;
8940 else
8941 spec->jack_present = 0;
8942 spec->sense_updated = 1;
8943 }
8944 /* unmute internal speaker only if both HPs are unplugged and
8945 * master switch is on
8946 */
8947 if (spec->jack_present)
8948 mute = HDA_AMP_MUTE;
8949 else
8950 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
8951 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8952 HDA_AMP_MUTE, mute);
8953}
8954
8955/* unsolicited event for HP jack sensing */
8956static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8957 unsigned int res)
8958{
8959 if ((res >> 26) != ALC_HP_EVENT)
8960 return;
8961 alc262_fujitsu_automute(codec, 1);
8962}
8963
8964static void alc262_fujitsu_init_hook(struct hda_codec *codec)
8965{
8966 alc262_fujitsu_automute(codec, 1);
8967}
8968
8969/* bind volumes of both NID 0x0c and 0x0d */
8970static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8971 .ops = &snd_hda_bind_vol,
8972 .values = {
8973 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8974 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8975 0
8976 },
8977};
8978
8979/* mute/unmute internal speaker according to the hp jack and mute state */
8980static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
8981{
8982 struct alc_spec *spec = codec->spec;
8983 unsigned int mute;
8984
8985 if (force || !spec->sense_updated) {
8986 unsigned int present_int_hp;
8987 /* need to execute and sync at first */
8988 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8989 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
8990 AC_VERB_GET_PIN_SENSE, 0);
8991 spec->jack_present = (present_int_hp & 0x80000000) != 0;
8992 spec->sense_updated = 1;
8993 }
8994 if (spec->jack_present) {
8995 /* mute internal speaker */
8996 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8997 HDA_AMP_MUTE, HDA_AMP_MUTE);
8998 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8999 HDA_AMP_MUTE, HDA_AMP_MUTE);
9000 } else {
9001 /* unmute internal speaker if necessary */
9002 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9003 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9004 HDA_AMP_MUTE, mute);
9005 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9006 HDA_AMP_MUTE, mute);
9007 }
9008}
9009
9010/* unsolicited event for HP jack sensing */
9011static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9012 unsigned int res)
9013{
9014 if ((res >> 26) != ALC_HP_EVENT)
9015 return;
9016 alc262_lenovo_3000_automute(codec, 1);
9017}
9018
9019/* bind hp and internal speaker mute (with plug check) */
9020static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9021 struct snd_ctl_elem_value *ucontrol)
9022{
9023 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9024 long *valp = ucontrol->value.integer.value;
9025 int change;
9026
9027 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9028 HDA_AMP_MUTE,
9029 valp ? 0 : HDA_AMP_MUTE);
9030 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9031 HDA_AMP_MUTE,
9032 valp ? 0 : HDA_AMP_MUTE);
9033
9034 if (change)
9035 alc262_fujitsu_automute(codec, 0);
9036 return change;
9037}
9038
9039static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
9040 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9041 {
9042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9043 .name = "Master Playback Switch",
9044 .info = snd_hda_mixer_amp_switch_info,
9045 .get = snd_hda_mixer_amp_switch_get,
9046 .put = alc262_fujitsu_master_sw_put,
9047 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9048 },
9049 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9050 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9051 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9052 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
9053 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9054 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9055 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9056 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9057 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9058 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9059 { } /* end */
9060};
9061
9062/* bind hp and internal speaker mute (with plug check) */
9063static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9064 struct snd_ctl_elem_value *ucontrol)
9065{
9066 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9067 long *valp = ucontrol->value.integer.value;
9068 int change;
9069
9070 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9071 HDA_AMP_MUTE,
9072 valp ? 0 : HDA_AMP_MUTE);
9073
9074 if (change)
9075 alc262_lenovo_3000_automute(codec, 0);
9076 return change;
9077}
9078
9079static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9080 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9081 {
9082 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9083 .name = "Master Playback Switch",
9084 .info = snd_hda_mixer_amp_switch_info,
9085 .get = snd_hda_mixer_amp_switch_get,
9086 .put = alc262_lenovo_3000_master_sw_put,
9087 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9088 },
9089 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9090 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9091 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9092 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9093 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9094 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9095 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9096 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9097 { } /* end */
9098};
9099
9100/* additional init verbs for Benq laptops */
9101static struct hda_verb alc262_EAPD_verbs[] = {
9102 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9103 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9104 {}
9105};
9106
9107static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9108 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9109 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9110
9111 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9112 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9113 {}
9114};
9115
9116/* Samsung Q1 Ultra Vista model setup */
9117static struct snd_kcontrol_new alc262_ultra_mixer[] = {
9118 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9119 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9120 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9121 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9122 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9123 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
9124 { } /* end */
9125};
9126
9127static struct hda_verb alc262_ultra_verbs[] = {
9128 /* output mixer */
9129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9132 /* speaker */
9133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9134 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9135 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9136 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9137 /* HP */
9138 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9139 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9140 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9141 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9142 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9143 /* internal mic */
9144 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9145 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9146 /* ADC, choose mic */
9147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9148 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9149 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9150 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9151 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9152 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9153 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9154 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9155 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
9157 {}
9158};
9159
9160/* mute/unmute internal speaker according to the hp jack and mute state */
9161static void alc262_ultra_automute(struct hda_codec *codec)
9162{
9163 struct alc_spec *spec = codec->spec;
9164 unsigned int mute;
9165
9166 mute = 0;
9167 /* auto-mute only when HP is used as HP */
9168 if (!spec->cur_mux[0]) {
9169 unsigned int present;
9170 /* need to execute and sync at first */
9171 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9172 present = snd_hda_codec_read(codec, 0x15, 0,
9173 AC_VERB_GET_PIN_SENSE, 0);
9174 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9175 if (spec->jack_present)
9176 mute = HDA_AMP_MUTE;
9177 }
9178 /* mute/unmute internal speaker */
9179 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9180 HDA_AMP_MUTE, mute);
9181 /* mute/unmute HP */
9182 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9183 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
9184}
9185
9186/* unsolicited event for HP jack sensing */
9187static void alc262_ultra_unsol_event(struct hda_codec *codec,
9188 unsigned int res)
9189{
9190 if ((res >> 26) != ALC880_HP_EVENT)
9191 return;
9192 alc262_ultra_automute(codec);
9193}
9194
9195static struct hda_input_mux alc262_ultra_capture_source = {
9196 .num_items = 2,
9197 .items = {
9198 { "Mic", 0x1 },
9199 { "Headphone", 0x7 },
9200 },
9201};
9202
9203static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9204 struct snd_ctl_elem_value *ucontrol)
9205{
9206 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9207 struct alc_spec *spec = codec->spec;
9208 int ret;
9209
9210 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9211 if (!ret)
9212 return 0;
9213 /* reprogram the HP pin as mic or HP according to the input source */
9214 snd_hda_codec_write_cache(codec, 0x15, 0,
9215 AC_VERB_SET_PIN_WIDGET_CONTROL,
9216 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9217 alc262_ultra_automute(codec); /* mute/unmute HP */
9218 return ret;
9219}
9220
9221static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9222 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9223 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9224 {
9225 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9226 .name = "Capture Source",
9227 .info = alc882_mux_enum_info,
9228 .get = alc882_mux_enum_get,
9229 .put = alc262_ultra_mux_enum_put,
9230 },
9231 { } /* end */
9232};
9233
9234/* add playback controls from the parsed DAC table */
9235static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9236 const struct auto_pin_cfg *cfg)
9237{
9238 hda_nid_t nid;
9239 int err;
9240
9241 spec->multiout.num_dacs = 1; /* only use one dac */
9242 spec->multiout.dac_nids = spec->private_dac_nids;
9243 spec->multiout.dac_nids[0] = 2;
9244
9245 nid = cfg->line_out_pins[0];
9246 if (nid) {
9247 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9248 "Front Playback Volume",
9249 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9250 if (err < 0)
9251 return err;
9252 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9253 "Front Playback Switch",
9254 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9255 if (err < 0)
9256 return err;
9257 }
9258
9259 nid = cfg->speaker_pins[0];
9260 if (nid) {
9261 if (nid == 0x16) {
9262 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9263 "Speaker Playback Volume",
9264 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9265 HDA_OUTPUT));
9266 if (err < 0)
9267 return err;
9268 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9269 "Speaker Playback Switch",
9270 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9271 HDA_OUTPUT));
9272 if (err < 0)
9273 return err;
9274 } else {
9275 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9276 "Speaker Playback Switch",
9277 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9278 HDA_OUTPUT));
9279 if (err < 0)
9280 return err;
9281 }
9282 }
9283 nid = cfg->hp_pins[0];
9284 if (nid) {
9285 /* spec->multiout.hp_nid = 2; */
9286 if (nid == 0x16) {
9287 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9288 "Headphone Playback Volume",
9289 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9290 HDA_OUTPUT));
9291 if (err < 0)
9292 return err;
9293 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9294 "Headphone Playback Switch",
9295 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9296 HDA_OUTPUT));
9297 if (err < 0)
9298 return err;
9299 } else {
9300 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9301 "Headphone Playback Switch",
9302 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9303 HDA_OUTPUT));
9304 if (err < 0)
9305 return err;
9306 }
9307 }
9308 return 0;
9309}
9310
9311/* identical with ALC880 */
9312#define alc262_auto_create_analog_input_ctls \
9313 alc880_auto_create_analog_input_ctls
9314
9315/*
9316 * generic initialization of ADC, input mixers and output mixers
9317 */
9318static struct hda_verb alc262_volume_init_verbs[] = {
9319 /*
9320 * Unmute ADC0-2 and set the default input to mic-in
9321 */
9322 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9324 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9325 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9326 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9327 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9328
9329 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9330 * mixer widget
9331 * Note: PASD motherboards uses the Line In 2 as the input for
9332 * front panel mic (mic 2)
9333 */
9334 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9335 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9336 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9340
9341 /*
9342 * Set up output mixers (0x0c - 0x0f)
9343 */
9344 /* set vol=0 to output mixers */
9345 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9348
9349 /* set up input amps for analog loopback */
9350 /* Amp Indices: DAC = 0, mixer = 1 */
9351 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9352 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9353 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9354 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9355 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9356 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9357
9358 /* FIXME: use matrix-type input source selection */
9359 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9360 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9362 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9364 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9365 /* Input mixer2 */
9366 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9367 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9368 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9369 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9370 /* Input mixer3 */
9371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9373 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9374 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9375
9376 { }
9377};
9378
9379static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9380 /*
9381 * Unmute ADC0-2 and set the default input to mic-in
9382 */
9383 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9385 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9387 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9388 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9389
9390 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9391 * mixer widget
9392 * Note: PASD motherboards uses the Line In 2 as the input for
9393 * front panel mic (mic 2)
9394 */
9395 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9396 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9397 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9398 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9399 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9400 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9401 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9403
9404 /*
9405 * Set up output mixers (0x0c - 0x0e)
9406 */
9407 /* set vol=0 to output mixers */
9408 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9410 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9411
9412 /* set up input amps for analog loopback */
9413 /* Amp Indices: DAC = 0, mixer = 1 */
9414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9415 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9416 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9417 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9418 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9419 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9420
9421 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9422 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9423 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9424
9425 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9427
9428 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9429 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9430
9431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9433 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9434 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9435 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9436
9437 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9438 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9441 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9442 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9443
9444
9445 /* FIXME: use matrix-type input source selection */
9446 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9447 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9452 /* Input mixer2 */
9453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9456 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9457 /* Input mixer3 */
9458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9461 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9462
9463 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9464
9465 { }
9466};
9467
9468static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9469 /*
9470 * Unmute ADC0-2 and set the default input to mic-in
9471 */
9472 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9473 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9474 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9475 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9476 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9477 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9478
9479 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
9480 * mixer widget
9481 * Note: PASD motherboards uses the Line In 2 as the input for front
9482 * panel mic (mic 2)
9483 */
9484 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
9485 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9486 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9487 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9488 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9489 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9490 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9491 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9492 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9493 /*
9494 * Set up output mixers (0x0c - 0x0e)
9495 */
9496 /* set vol=0 to output mixers */
9497 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9498 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9499 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9500
9501 /* set up input amps for analog loopback */
9502 /* Amp Indices: DAC = 0, mixer = 1 */
9503 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9504 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9505 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9508 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9509
9510
9511 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9512 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9513 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9514 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9515 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9516 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9517 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9518
9519 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9521
9522 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9523 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9524
9525 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9526 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9527 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9528 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9529 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9530 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9531
9532 /* FIXME: use matrix-type input source selection */
9533 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9534 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9535 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9536 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9537 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9538 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9539 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9540 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9541 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9542 /* Input mixer2 */
9543 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9544 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9545 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9546 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9547 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9548 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9549 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9550 /* Input mixer3 */
9551 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9552 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9553 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9556 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9557 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9558
9559 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9560
9561 { }
9562};
9563
9564#ifdef CONFIG_SND_HDA_POWER_SAVE
9565#define alc262_loopbacks alc880_loopbacks
9566#endif
9567
9568/* pcm configuration: identiacal with ALC880 */
9569#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9570#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9571#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9572#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9573
9574/*
9575 * BIOS auto configuration
9576 */
9577static int alc262_parse_auto_config(struct hda_codec *codec)
9578{
9579 struct alc_spec *spec = codec->spec;
9580 int err;
9581 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9582
9583 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9584 alc262_ignore);
9585 if (err < 0)
9586 return err;
9587 if (!spec->autocfg.line_outs)
9588 return 0; /* can't find valid BIOS pin config */
9589 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9590 if (err < 0)
9591 return err;
9592 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9593 if (err < 0)
9594 return err;
9595
9596 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9597
9598 if (spec->autocfg.dig_out_pin)
9599 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9600 if (spec->autocfg.dig_in_pin)
9601 spec->dig_in_nid = ALC262_DIGIN_NID;
9602
9603 if (spec->kctl_alloc)
9604 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9605
9606 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
9607 spec->num_mux_defs = 1;
9608 spec->input_mux = &spec->private_imux;
9609
9610 err = alc_auto_add_mic_boost(codec);
9611 if (err < 0)
9612 return err;
9613
9614 return 1;
9615}
9616
9617#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9618#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9619#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9620
9621
9622/* init callback for auto-configuration model -- overriding the default init */
9623static void alc262_auto_init(struct hda_codec *codec)
9624{
9625 struct alc_spec *spec = codec->spec;
9626 alc262_auto_init_multi_out(codec);
9627 alc262_auto_init_hp_out(codec);
9628 alc262_auto_init_analog_input(codec);
9629 if (spec->unsol_event)
9630 alc_sku_automute(codec);
9631}
9632
9633/*
9634 * configuration and preset
9635 */
9636static const char *alc262_models[ALC262_MODEL_LAST] = {
9637 [ALC262_BASIC] = "basic",
9638 [ALC262_HIPPO] = "hippo",
9639 [ALC262_HIPPO_1] = "hippo_1",
9640 [ALC262_FUJITSU] = "fujitsu",
9641 [ALC262_HP_BPC] = "hp-bpc",
9642 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
9643 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
9644 [ALC262_HP_RP5700] = "hp-rp5700",
9645 [ALC262_BENQ_ED8] = "benq",
9646 [ALC262_BENQ_T31] = "benq-t31",
9647 [ALC262_SONY_ASSAMD] = "sony-assamd",
9648 [ALC262_ULTRA] = "ultra",
9649 [ALC262_LENOVO_3000] = "lenovo-3000",
9650 [ALC262_AUTO] = "auto",
9651};
9652
9653static struct snd_pci_quirk alc262_cfg_tbl[] = {
9654 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9655 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
9656 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
9657 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9658 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
9659 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
9660 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
9661 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
9662 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
9663 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
9664 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
9665 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
9666 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
9667 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
9668 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
9669 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
9670 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
9671 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9672 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9673 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
9674 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9675 ALC262_HP_TC_T5735),
9676 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
9677 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9678 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
9679 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9680 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9681 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
9682 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
9683 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
9684 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
9685 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
9686 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
9687 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
9688 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
9689 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
9690 {}
9691};
9692
9693static struct alc_config_preset alc262_presets[] = {
9694 [ALC262_BASIC] = {
9695 .mixers = { alc262_base_mixer },
9696 .init_verbs = { alc262_init_verbs },
9697 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9698 .dac_nids = alc262_dac_nids,
9699 .hp_nid = 0x03,
9700 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9701 .channel_mode = alc262_modes,
9702 .input_mux = &alc262_capture_source,
9703 },
9704 [ALC262_HIPPO] = {
9705 .mixers = { alc262_base_mixer },
9706 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9707 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9708 .dac_nids = alc262_dac_nids,
9709 .hp_nid = 0x03,
9710 .dig_out_nid = ALC262_DIGOUT_NID,
9711 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9712 .channel_mode = alc262_modes,
9713 .input_mux = &alc262_capture_source,
9714 .unsol_event = alc262_hippo_unsol_event,
9715 .init_hook = alc262_hippo_automute,
9716 },
9717 [ALC262_HIPPO_1] = {
9718 .mixers = { alc262_hippo1_mixer },
9719 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9720 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9721 .dac_nids = alc262_dac_nids,
9722 .hp_nid = 0x02,
9723 .dig_out_nid = ALC262_DIGOUT_NID,
9724 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9725 .channel_mode = alc262_modes,
9726 .input_mux = &alc262_capture_source,
9727 .unsol_event = alc262_hippo1_unsol_event,
9728 .init_hook = alc262_hippo1_automute,
9729 },
9730 [ALC262_FUJITSU] = {
9731 .mixers = { alc262_fujitsu_mixer },
9732 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9733 alc262_fujitsu_unsol_verbs },
9734 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9735 .dac_nids = alc262_dac_nids,
9736 .hp_nid = 0x03,
9737 .dig_out_nid = ALC262_DIGOUT_NID,
9738 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9739 .channel_mode = alc262_modes,
9740 .input_mux = &alc262_fujitsu_capture_source,
9741 .unsol_event = alc262_fujitsu_unsol_event,
9742 .init_hook = alc262_fujitsu_init_hook,
9743 },
9744 [ALC262_HP_BPC] = {
9745 .mixers = { alc262_HP_BPC_mixer },
9746 .init_verbs = { alc262_HP_BPC_init_verbs },
9747 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9748 .dac_nids = alc262_dac_nids,
9749 .hp_nid = 0x03,
9750 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9751 .channel_mode = alc262_modes,
9752 .input_mux = &alc262_HP_capture_source,
9753 .unsol_event = alc262_hp_bpc_unsol_event,
9754 .init_hook = alc262_hp_bpc_automute,
9755 },
9756 [ALC262_HP_BPC_D7000_WF] = {
9757 .mixers = { alc262_HP_BPC_WildWest_mixer },
9758 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9759 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9760 .dac_nids = alc262_dac_nids,
9761 .hp_nid = 0x03,
9762 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9763 .channel_mode = alc262_modes,
9764 .input_mux = &alc262_HP_D7000_capture_source,
9765 .unsol_event = alc262_hp_wildwest_unsol_event,
9766 .init_hook = alc262_hp_wildwest_automute,
9767 },
9768 [ALC262_HP_BPC_D7000_WL] = {
9769 .mixers = { alc262_HP_BPC_WildWest_mixer,
9770 alc262_HP_BPC_WildWest_option_mixer },
9771 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9772 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9773 .dac_nids = alc262_dac_nids,
9774 .hp_nid = 0x03,
9775 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9776 .channel_mode = alc262_modes,
9777 .input_mux = &alc262_HP_D7000_capture_source,
9778 .unsol_event = alc262_hp_wildwest_unsol_event,
9779 .init_hook = alc262_hp_wildwest_automute,
9780 },
9781 [ALC262_HP_TC_T5735] = {
9782 .mixers = { alc262_hp_t5735_mixer },
9783 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9784 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9785 .dac_nids = alc262_dac_nids,
9786 .hp_nid = 0x03,
9787 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9788 .channel_mode = alc262_modes,
9789 .input_mux = &alc262_capture_source,
9790 .unsol_event = alc262_hp_t5735_unsol_event,
9791 .init_hook = alc262_hp_t5735_init_hook,
9792 },
9793 [ALC262_HP_RP5700] = {
9794 .mixers = { alc262_hp_rp5700_mixer },
9795 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9796 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9797 .dac_nids = alc262_dac_nids,
9798 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9799 .channel_mode = alc262_modes,
9800 .input_mux = &alc262_hp_rp5700_capture_source,
9801 },
9802 [ALC262_BENQ_ED8] = {
9803 .mixers = { alc262_base_mixer },
9804 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9805 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9806 .dac_nids = alc262_dac_nids,
9807 .hp_nid = 0x03,
9808 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9809 .channel_mode = alc262_modes,
9810 .input_mux = &alc262_capture_source,
9811 },
9812 [ALC262_SONY_ASSAMD] = {
9813 .mixers = { alc262_sony_mixer },
9814 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9815 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9816 .dac_nids = alc262_dac_nids,
9817 .hp_nid = 0x02,
9818 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9819 .channel_mode = alc262_modes,
9820 .input_mux = &alc262_capture_source,
9821 .unsol_event = alc262_hippo_unsol_event,
9822 .init_hook = alc262_hippo_automute,
9823 },
9824 [ALC262_BENQ_T31] = {
9825 .mixers = { alc262_benq_t31_mixer },
9826 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9827 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9828 .dac_nids = alc262_dac_nids,
9829 .hp_nid = 0x03,
9830 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9831 .channel_mode = alc262_modes,
9832 .input_mux = &alc262_capture_source,
9833 .unsol_event = alc262_hippo_unsol_event,
9834 .init_hook = alc262_hippo_automute,
9835 },
9836 [ALC262_ULTRA] = {
9837 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
9838 .init_verbs = { alc262_ultra_verbs },
9839 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9840 .dac_nids = alc262_dac_nids,
9841 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9842 .channel_mode = alc262_modes,
9843 .input_mux = &alc262_ultra_capture_source,
9844 .adc_nids = alc262_adc_nids, /* ADC0 */
9845 .capsrc_nids = alc262_capsrc_nids,
9846 .num_adc_nids = 1, /* single ADC */
9847 .unsol_event = alc262_ultra_unsol_event,
9848 .init_hook = alc262_ultra_automute,
9849 },
9850 [ALC262_LENOVO_3000] = {
9851 .mixers = { alc262_lenovo_3000_mixer },
9852 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9853 alc262_lenovo_3000_unsol_verbs },
9854 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9855 .dac_nids = alc262_dac_nids,
9856 .hp_nid = 0x03,
9857 .dig_out_nid = ALC262_DIGOUT_NID,
9858 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9859 .channel_mode = alc262_modes,
9860 .input_mux = &alc262_fujitsu_capture_source,
9861 .unsol_event = alc262_lenovo_3000_unsol_event,
9862 },
9863};
9864
9865static int patch_alc262(struct hda_codec *codec)
9866{
9867 struct alc_spec *spec;
9868 int board_config;
9869 int err;
9870
9871 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9872 if (spec == NULL)
9873 return -ENOMEM;
9874
9875 codec->spec = spec;
9876#if 0
9877 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9878 * under-run
9879 */
9880 {
9881 int tmp;
9882 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9883 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9884 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9885 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9886 }
9887#endif
9888
9889 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9890 alc262_models,
9891 alc262_cfg_tbl);
9892
9893 if (board_config < 0) {
9894 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9895 "trying auto-probe from BIOS...\n");
9896 board_config = ALC262_AUTO;
9897 }
9898
9899 if (board_config == ALC262_AUTO) {
9900 /* automatic parse from the BIOS config */
9901 err = alc262_parse_auto_config(codec);
9902 if (err < 0) {
9903 alc_free(codec);
9904 return err;
9905 } else if (!err) {
9906 printk(KERN_INFO
9907 "hda_codec: Cannot set up configuration "
9908 "from BIOS. Using base mode...\n");
9909 board_config = ALC262_BASIC;
9910 }
9911 }
9912
9913 if (board_config != ALC262_AUTO)
9914 setup_preset(spec, &alc262_presets[board_config]);
9915
9916 spec->stream_name_analog = "ALC262 Analog";
9917 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9918 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9919
9920 spec->stream_name_digital = "ALC262 Digital";
9921 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9922 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9923
9924 if (!spec->adc_nids && spec->input_mux) {
9925 /* check whether NID 0x07 is valid */
9926 unsigned int wcap = get_wcaps(codec, 0x07);
9927
9928 /* get type */
9929 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9930 if (wcap != AC_WID_AUD_IN) {
9931 spec->adc_nids = alc262_adc_nids_alt;
9932 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
9933 spec->capsrc_nids = alc262_capsrc_nids_alt;
9934 spec->mixers[spec->num_mixers] =
9935 alc262_capture_alt_mixer;
9936 spec->num_mixers++;
9937 } else {
9938 spec->adc_nids = alc262_adc_nids;
9939 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9940 spec->capsrc_nids = alc262_capsrc_nids;
9941 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9942 spec->num_mixers++;
9943 }
9944 }
9945
9946 spec->vmaster_nid = 0x0c;
9947
9948 codec->patch_ops = alc_patch_ops;
9949 if (board_config == ALC262_AUTO)
9950 spec->init_hook = alc262_auto_init;
9951#ifdef CONFIG_SND_HDA_POWER_SAVE
9952 if (!spec->loopback.amplist)
9953 spec->loopback.amplist = alc262_loopbacks;
9954#endif
9955
9956 return 0;
9957}
9958
9959/*
9960 * ALC268 channel source setting (2 channel)
9961 */
9962#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9963#define alc268_modes alc260_modes
9964
9965static hda_nid_t alc268_dac_nids[2] = {
9966 /* front, hp */
9967 0x02, 0x03
9968};
9969
9970static hda_nid_t alc268_adc_nids[2] = {
9971 /* ADC0-1 */
9972 0x08, 0x07
9973};
9974
9975static hda_nid_t alc268_adc_nids_alt[1] = {
9976 /* ADC0 */
9977 0x08
9978};
9979
9980static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
9981
9982static struct snd_kcontrol_new alc268_base_mixer[] = {
9983 /* output mixer control */
9984 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9985 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9986 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9988 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9989 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9990 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
9991 { }
9992};
9993
9994/* bind Beep switches of both NID 0x0f and 0x10 */
9995static struct hda_bind_ctls alc268_bind_beep_sw = {
9996 .ops = &snd_hda_bind_sw,
9997 .values = {
9998 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
9999 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10000 0
10001 },
10002};
10003
10004static struct snd_kcontrol_new alc268_beep_mixer[] = {
10005 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10006 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10007 { }
10008};
10009
10010static struct hda_verb alc268_eapd_verbs[] = {
10011 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10012 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10013 { }
10014};
10015
10016/* Toshiba specific */
10017#define alc268_toshiba_automute alc262_hippo_automute
10018
10019static struct hda_verb alc268_toshiba_verbs[] = {
10020 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10021 { } /* end */
10022};
10023
10024/* Acer specific */
10025/* bind volumes of both NID 0x02 and 0x03 */
10026static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10027 .ops = &snd_hda_bind_vol,
10028 .values = {
10029 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10030 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10031 0
10032 },
10033};
10034
10035/* mute/unmute internal speaker according to the hp jack and mute state */
10036static void alc268_acer_automute(struct hda_codec *codec, int force)
10037{
10038 struct alc_spec *spec = codec->spec;
10039 unsigned int mute;
10040
10041 if (force || !spec->sense_updated) {
10042 unsigned int present;
10043 present = snd_hda_codec_read(codec, 0x14, 0,
10044 AC_VERB_GET_PIN_SENSE, 0);
10045 spec->jack_present = (present & 0x80000000) != 0;
10046 spec->sense_updated = 1;
10047 }
10048 if (spec->jack_present)
10049 mute = HDA_AMP_MUTE; /* mute internal speaker */
10050 else /* unmute internal speaker if necessary */
10051 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10052 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10053 HDA_AMP_MUTE, mute);
10054}
10055
10056
10057/* bind hp and internal speaker mute (with plug check) */
10058static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10059 struct snd_ctl_elem_value *ucontrol)
10060{
10061 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10062 long *valp = ucontrol->value.integer.value;
10063 int change;
10064
10065 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10066 HDA_AMP_MUTE,
10067 valp[0] ? 0 : HDA_AMP_MUTE);
10068 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10069 HDA_AMP_MUTE,
10070 valp[1] ? 0 : HDA_AMP_MUTE);
10071 if (change)
10072 alc268_acer_automute(codec, 0);
10073 return change;
10074}
10075
10076static struct snd_kcontrol_new alc268_acer_mixer[] = {
10077 /* output mixer control */
10078 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10079 {
10080 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10081 .name = "Master Playback Switch",
10082 .info = snd_hda_mixer_amp_switch_info,
10083 .get = snd_hda_mixer_amp_switch_get,
10084 .put = alc268_acer_master_sw_put,
10085 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10086 },
10087 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10088 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10089 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
10090 { }
10091};
10092
10093static struct hda_verb alc268_acer_verbs[] = {
10094 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10095 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10096 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10097 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10098 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10099 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10100
10101 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10102 { }
10103};
10104
10105/* unsolicited event for HP jack sensing */
10106static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10107 unsigned int res)
10108{
10109 if ((res >> 26) != ALC880_HP_EVENT)
10110 return;
10111 alc268_toshiba_automute(codec);
10112}
10113
10114static void alc268_acer_unsol_event(struct hda_codec *codec,
10115 unsigned int res)
10116{
10117 if ((res >> 26) != ALC880_HP_EVENT)
10118 return;
10119 alc268_acer_automute(codec, 1);
10120}
10121
10122static void alc268_acer_init_hook(struct hda_codec *codec)
10123{
10124 alc268_acer_automute(codec, 1);
10125}
10126
10127static struct snd_kcontrol_new alc268_dell_mixer[] = {
10128 /* output mixer control */
10129 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10130 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10131 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10132 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10133 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10134 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10135 { }
10136};
10137
10138static struct hda_verb alc268_dell_verbs[] = {
10139 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10140 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10141 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10142 { }
10143};
10144
10145/* mute/unmute internal speaker according to the hp jack and mute state */
10146static void alc268_dell_automute(struct hda_codec *codec)
10147{
10148 unsigned int present;
10149 unsigned int mute;
10150
10151 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10152 if (present & 0x80000000)
10153 mute = HDA_AMP_MUTE;
10154 else
10155 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10156 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10157 HDA_AMP_MUTE, mute);
10158}
10159
10160static void alc268_dell_unsol_event(struct hda_codec *codec,
10161 unsigned int res)
10162{
10163 if ((res >> 26) != ALC880_HP_EVENT)
10164 return;
10165 alc268_dell_automute(codec);
10166}
10167
10168#define alc268_dell_init_hook alc268_dell_automute
10169
10170static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10171 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10172 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10173 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10174 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10175 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10176 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10177 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10178 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10179 { }
10180};
10181
10182static struct hda_verb alc267_quanta_il1_verbs[] = {
10183 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10184 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10185 { }
10186};
10187
10188static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10189{
10190 unsigned int present;
10191
10192 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10193 & AC_PINSENSE_PRESENCE;
10194 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10195 present ? 0 : PIN_OUT);
10196}
10197
10198static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10199{
10200 unsigned int present;
10201
10202 present = snd_hda_codec_read(codec, 0x18, 0,
10203 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10204 snd_hda_codec_write(codec, 0x23, 0,
10205 AC_VERB_SET_CONNECT_SEL,
10206 present ? 0x00 : 0x01);
10207}
10208
10209static void alc267_quanta_il1_automute(struct hda_codec *codec)
10210{
10211 alc267_quanta_il1_hp_automute(codec);
10212 alc267_quanta_il1_mic_automute(codec);
10213}
10214
10215static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10216 unsigned int res)
10217{
10218 switch (res >> 26) {
10219 case ALC880_HP_EVENT:
10220 alc267_quanta_il1_hp_automute(codec);
10221 break;
10222 case ALC880_MIC_EVENT:
10223 alc267_quanta_il1_mic_automute(codec);
10224 break;
10225 }
10226}
10227
10228/*
10229 * generic initialization of ADC, input mixers and output mixers
10230 */
10231static struct hda_verb alc268_base_init_verbs[] = {
10232 /* Unmute DAC0-1 and set vol = 0 */
10233 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10234 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10235 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10236 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10237 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10238 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10239
10240 /*
10241 * Set up output mixers (0x0c - 0x0e)
10242 */
10243 /* set vol=0 to output mixers */
10244 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10245 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10246 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10247 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10248
10249 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10250 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10251
10252 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10253 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10254 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10255 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10256 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10257 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10258 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10259 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10260
10261 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10262 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10263 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10264 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10267 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10268
10269 /* set PCBEEP vol = 0, mute connections */
10270 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10271 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10272 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10273
10274 /* Unmute Selector 23h,24h and set the default input to mic-in */
10275
10276 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10278 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10280
10281 { }
10282};
10283
10284/*
10285 * generic initialization of ADC, input mixers and output mixers
10286 */
10287static struct hda_verb alc268_volume_init_verbs[] = {
10288 /* set output DAC */
10289 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10290 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10291 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10292 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10293
10294 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10295 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10296 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10297 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10298 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10299
10300 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10302 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10303 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10304 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10305
10306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10307 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10308 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10309 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10310
10311 /* set PCBEEP vol = 0, mute connections */
10312 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10313 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10314 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10315
10316 { }
10317};
10318
10319#define alc268_mux_enum_info alc_mux_enum_info
10320#define alc268_mux_enum_get alc_mux_enum_get
10321#define alc268_mux_enum_put alc_mux_enum_put
10322
10323static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10324 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10325 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10326 {
10327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10328 /* The multiple "Capture Source" controls confuse alsamixer
10329 * So call somewhat different..
10330 */
10331 /* .name = "Capture Source", */
10332 .name = "Input Source",
10333 .count = 1,
10334 .info = alc268_mux_enum_info,
10335 .get = alc268_mux_enum_get,
10336 .put = alc268_mux_enum_put,
10337 },
10338 { } /* end */
10339};
10340
10341static struct snd_kcontrol_new alc268_capture_mixer[] = {
10342 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10343 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10344 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10345 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10346 {
10347 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10348 /* The multiple "Capture Source" controls confuse alsamixer
10349 * So call somewhat different..
10350 */
10351 /* .name = "Capture Source", */
10352 .name = "Input Source",
10353 .count = 2,
10354 .info = alc268_mux_enum_info,
10355 .get = alc268_mux_enum_get,
10356 .put = alc268_mux_enum_put,
10357 },
10358 { } /* end */
10359};
10360
10361static struct hda_input_mux alc268_capture_source = {
10362 .num_items = 4,
10363 .items = {
10364 { "Mic", 0x0 },
10365 { "Front Mic", 0x1 },
10366 { "Line", 0x2 },
10367 { "CD", 0x3 },
10368 },
10369};
10370
10371static struct hda_input_mux alc268_acer_capture_source = {
10372 .num_items = 3,
10373 .items = {
10374 { "Mic", 0x0 },
10375 { "Internal Mic", 0x6 },
10376 { "Line", 0x2 },
10377 },
10378};
10379
10380#ifdef CONFIG_SND_DEBUG
10381static struct snd_kcontrol_new alc268_test_mixer[] = {
10382 /* Volume widgets */
10383 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10384 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10385 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10386 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10387 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10388 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10389 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10390 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10391 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10392 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10393 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10394 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10395 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
10396 /* The below appears problematic on some hardwares */
10397 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
10398 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10399 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10400 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10401 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10402
10403 /* Modes for retasking pin widgets */
10404 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10405 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10406 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10407 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10408
10409 /* Controls for GPIO pins, assuming they are configured as outputs */
10410 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10411 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10412 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10413 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10414
10415 /* Switches to allow the digital SPDIF output pin to be enabled.
10416 * The ALC268 does not have an SPDIF input.
10417 */
10418 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10419
10420 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10421 * this output to turn on an external amplifier.
10422 */
10423 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10424 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10425
10426 { } /* end */
10427};
10428#endif
10429
10430/* create input playback/capture controls for the given pin */
10431static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10432 const char *ctlname, int idx)
10433{
10434 char name[32];
10435 int err;
10436
10437 sprintf(name, "%s Playback Volume", ctlname);
10438 if (nid == 0x14) {
10439 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10440 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10441 HDA_OUTPUT));
10442 if (err < 0)
10443 return err;
10444 } else if (nid == 0x15) {
10445 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10446 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10447 HDA_OUTPUT));
10448 if (err < 0)
10449 return err;
10450 } else
10451 return -1;
10452 sprintf(name, "%s Playback Switch", ctlname);
10453 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10454 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10455 if (err < 0)
10456 return err;
10457 return 0;
10458}
10459
10460/* add playback controls from the parsed DAC table */
10461static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10462 const struct auto_pin_cfg *cfg)
10463{
10464 hda_nid_t nid;
10465 int err;
10466
10467 spec->multiout.num_dacs = 2; /* only use one dac */
10468 spec->multiout.dac_nids = spec->private_dac_nids;
10469 spec->multiout.dac_nids[0] = 2;
10470 spec->multiout.dac_nids[1] = 3;
10471
10472 nid = cfg->line_out_pins[0];
10473 if (nid)
10474 alc268_new_analog_output(spec, nid, "Front", 0);
10475
10476 nid = cfg->speaker_pins[0];
10477 if (nid == 0x1d) {
10478 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10479 "Speaker Playback Volume",
10480 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10481 if (err < 0)
10482 return err;
10483 }
10484 nid = cfg->hp_pins[0];
10485 if (nid)
10486 alc268_new_analog_output(spec, nid, "Headphone", 0);
10487
10488 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10489 if (nid == 0x16) {
10490 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10491 "Mono Playback Switch",
10492 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10493 if (err < 0)
10494 return err;
10495 }
10496 return 0;
10497}
10498
10499/* create playback/capture controls for input pins */
10500static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10501 const struct auto_pin_cfg *cfg)
10502{
10503 struct hda_input_mux *imux = &spec->private_imux;
10504 int i, idx1;
10505
10506 for (i = 0; i < AUTO_PIN_LAST; i++) {
10507 switch(cfg->input_pins[i]) {
10508 case 0x18:
10509 idx1 = 0; /* Mic 1 */
10510 break;
10511 case 0x19:
10512 idx1 = 1; /* Mic 2 */
10513 break;
10514 case 0x1a:
10515 idx1 = 2; /* Line In */
10516 break;
10517 case 0x1c:
10518 idx1 = 3; /* CD */
10519 break;
10520 case 0x12:
10521 case 0x13:
10522 idx1 = 6; /* digital mics */
10523 break;
10524 default:
10525 continue;
10526 }
10527 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10528 imux->items[imux->num_items].index = idx1;
10529 imux->num_items++;
10530 }
10531 return 0;
10532}
10533
10534static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10535{
10536 struct alc_spec *spec = codec->spec;
10537 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10538 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10539 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10540 unsigned int dac_vol1, dac_vol2;
10541
10542 if (speaker_nid) {
10543 snd_hda_codec_write(codec, speaker_nid, 0,
10544 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10545 snd_hda_codec_write(codec, 0x0f, 0,
10546 AC_VERB_SET_AMP_GAIN_MUTE,
10547 AMP_IN_UNMUTE(1));
10548 snd_hda_codec_write(codec, 0x10, 0,
10549 AC_VERB_SET_AMP_GAIN_MUTE,
10550 AMP_IN_UNMUTE(1));
10551 } else {
10552 snd_hda_codec_write(codec, 0x0f, 0,
10553 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10554 snd_hda_codec_write(codec, 0x10, 0,
10555 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10556 }
10557
10558 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
10559 if (line_nid == 0x14)
10560 dac_vol2 = AMP_OUT_ZERO;
10561 else if (line_nid == 0x15)
10562 dac_vol1 = AMP_OUT_ZERO;
10563 if (hp_nid == 0x14)
10564 dac_vol2 = AMP_OUT_ZERO;
10565 else if (hp_nid == 0x15)
10566 dac_vol1 = AMP_OUT_ZERO;
10567 if (line_nid != 0x16 || hp_nid != 0x16 ||
10568 spec->autocfg.line_out_pins[1] != 0x16 ||
10569 spec->autocfg.line_out_pins[2] != 0x16)
10570 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10571
10572 snd_hda_codec_write(codec, 0x02, 0,
10573 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10574 snd_hda_codec_write(codec, 0x03, 0,
10575 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10576}
10577
10578/* pcm configuration: identiacal with ALC880 */
10579#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10580#define alc268_pcm_analog_capture alc880_pcm_analog_capture
10581#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
10582#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10583
10584/*
10585 * BIOS auto configuration
10586 */
10587static int alc268_parse_auto_config(struct hda_codec *codec)
10588{
10589 struct alc_spec *spec = codec->spec;
10590 int err;
10591 static hda_nid_t alc268_ignore[] = { 0 };
10592
10593 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10594 alc268_ignore);
10595 if (err < 0)
10596 return err;
10597 if (!spec->autocfg.line_outs)
10598 return 0; /* can't find valid BIOS pin config */
10599
10600 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
10601 if (err < 0)
10602 return err;
10603 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
10604 if (err < 0)
10605 return err;
10606
10607 spec->multiout.max_channels = 2;
10608
10609 /* digital only support output */
10610 if (spec->autocfg.dig_out_pin)
10611 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
10612
10613 if (spec->kctl_alloc)
10614 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10615
10616 if (spec->autocfg.speaker_pins[0] != 0x1d)
10617 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
10618
10619 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
10620 spec->num_mux_defs = 1;
10621 spec->input_mux = &spec->private_imux;
10622
10623 err = alc_auto_add_mic_boost(codec);
10624 if (err < 0)
10625 return err;
10626
10627 return 1;
10628}
10629
10630#define alc268_auto_init_multi_out alc882_auto_init_multi_out
10631#define alc268_auto_init_hp_out alc882_auto_init_hp_out
10632#define alc268_auto_init_analog_input alc882_auto_init_analog_input
10633
10634/* init callback for auto-configuration model -- overriding the default init */
10635static void alc268_auto_init(struct hda_codec *codec)
10636{
10637 struct alc_spec *spec = codec->spec;
10638 alc268_auto_init_multi_out(codec);
10639 alc268_auto_init_hp_out(codec);
10640 alc268_auto_init_mono_speaker_out(codec);
10641 alc268_auto_init_analog_input(codec);
10642 if (spec->unsol_event)
10643 alc_sku_automute(codec);
10644}
10645
10646/*
10647 * configuration and preset
10648 */
10649static const char *alc268_models[ALC268_MODEL_LAST] = {
10650 [ALC267_QUANTA_IL1] = "quanta-il1",
10651 [ALC268_3ST] = "3stack",
10652 [ALC268_TOSHIBA] = "toshiba",
10653 [ALC268_ACER] = "acer",
10654 [ALC268_DELL] = "dell",
10655 [ALC268_ZEPTO] = "zepto",
10656#ifdef CONFIG_SND_DEBUG
10657 [ALC268_TEST] = "test",
10658#endif
10659 [ALC268_AUTO] = "auto",
10660};
10661
10662static struct snd_pci_quirk alc268_cfg_tbl[] = {
10663 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
10664 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
10665 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
10666 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
10667 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
10668 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
10669 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
10670 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
10671 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
10672 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
10673 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
10674 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
10675 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
10676 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
10677 {}
10678};
10679
10680static struct alc_config_preset alc268_presets[] = {
10681 [ALC267_QUANTA_IL1] = {
10682 .mixers = { alc267_quanta_il1_mixer },
10683 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10684 alc267_quanta_il1_verbs },
10685 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10686 .dac_nids = alc268_dac_nids,
10687 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10688 .adc_nids = alc268_adc_nids_alt,
10689 .hp_nid = 0x03,
10690 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10691 .channel_mode = alc268_modes,
10692 .input_mux = &alc268_capture_source,
10693 .unsol_event = alc267_quanta_il1_unsol_event,
10694 .init_hook = alc267_quanta_il1_automute,
10695 },
10696 [ALC268_3ST] = {
10697 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10698 alc268_beep_mixer },
10699 .init_verbs = { alc268_base_init_verbs },
10700 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10701 .dac_nids = alc268_dac_nids,
10702 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10703 .adc_nids = alc268_adc_nids_alt,
10704 .capsrc_nids = alc268_capsrc_nids,
10705 .hp_nid = 0x03,
10706 .dig_out_nid = ALC268_DIGOUT_NID,
10707 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10708 .channel_mode = alc268_modes,
10709 .input_mux = &alc268_capture_source,
10710 },
10711 [ALC268_TOSHIBA] = {
10712 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10713 alc268_beep_mixer },
10714 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10715 alc268_toshiba_verbs },
10716 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10717 .dac_nids = alc268_dac_nids,
10718 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10719 .adc_nids = alc268_adc_nids_alt,
10720 .capsrc_nids = alc268_capsrc_nids,
10721 .hp_nid = 0x03,
10722 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10723 .channel_mode = alc268_modes,
10724 .input_mux = &alc268_capture_source,
10725 .unsol_event = alc268_toshiba_unsol_event,
10726 .init_hook = alc268_toshiba_automute,
10727 },
10728 [ALC268_ACER] = {
10729 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
10730 alc268_beep_mixer },
10731 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10732 alc268_acer_verbs },
10733 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10734 .dac_nids = alc268_dac_nids,
10735 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10736 .adc_nids = alc268_adc_nids_alt,
10737 .capsrc_nids = alc268_capsrc_nids,
10738 .hp_nid = 0x02,
10739 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10740 .channel_mode = alc268_modes,
10741 .input_mux = &alc268_acer_capture_source,
10742 .unsol_event = alc268_acer_unsol_event,
10743 .init_hook = alc268_acer_init_hook,
10744 },
10745 [ALC268_DELL] = {
10746 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
10747 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10748 alc268_dell_verbs },
10749 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10750 .dac_nids = alc268_dac_nids,
10751 .hp_nid = 0x02,
10752 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10753 .channel_mode = alc268_modes,
10754 .unsol_event = alc268_dell_unsol_event,
10755 .init_hook = alc268_dell_init_hook,
10756 .input_mux = &alc268_capture_source,
10757 },
10758 [ALC268_ZEPTO] = {
10759 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
10760 alc268_beep_mixer },
10761 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10762 alc268_toshiba_verbs },
10763 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10764 .dac_nids = alc268_dac_nids,
10765 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10766 .adc_nids = alc268_adc_nids_alt,
10767 .capsrc_nids = alc268_capsrc_nids,
10768 .hp_nid = 0x03,
10769 .dig_out_nid = ALC268_DIGOUT_NID,
10770 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10771 .channel_mode = alc268_modes,
10772 .input_mux = &alc268_capture_source,
10773 .unsol_event = alc268_toshiba_unsol_event,
10774 .init_hook = alc268_toshiba_automute
10775 },
10776#ifdef CONFIG_SND_DEBUG
10777 [ALC268_TEST] = {
10778 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10779 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10780 alc268_volume_init_verbs },
10781 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10782 .dac_nids = alc268_dac_nids,
10783 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10784 .adc_nids = alc268_adc_nids_alt,
10785 .capsrc_nids = alc268_capsrc_nids,
10786 .hp_nid = 0x03,
10787 .dig_out_nid = ALC268_DIGOUT_NID,
10788 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10789 .channel_mode = alc268_modes,
10790 .input_mux = &alc268_capture_source,
10791 },
10792#endif
10793};
10794
10795static int patch_alc268(struct hda_codec *codec)
10796{
10797 struct alc_spec *spec;
10798 int board_config;
10799 int err;
10800
10801 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10802 if (spec == NULL)
10803 return -ENOMEM;
10804
10805 codec->spec = spec;
10806
10807 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10808 alc268_models,
10809 alc268_cfg_tbl);
10810
10811 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10812 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10813 "trying auto-probe from BIOS...\n");
10814 board_config = ALC268_AUTO;
10815 }
10816
10817 if (board_config == ALC268_AUTO) {
10818 /* automatic parse from the BIOS config */
10819 err = alc268_parse_auto_config(codec);
10820 if (err < 0) {
10821 alc_free(codec);
10822 return err;
10823 } else if (!err) {
10824 printk(KERN_INFO
10825 "hda_codec: Cannot set up configuration "
10826 "from BIOS. Using base mode...\n");
10827 board_config = ALC268_3ST;
10828 }
10829 }
10830
10831 if (board_config != ALC268_AUTO)
10832 setup_preset(spec, &alc268_presets[board_config]);
10833
10834 if (codec->vendor_id == 0x10ec0267) {
10835 spec->stream_name_analog = "ALC267 Analog";
10836 spec->stream_name_digital = "ALC267 Digital";
10837 } else {
10838 spec->stream_name_analog = "ALC268 Analog";
10839 spec->stream_name_digital = "ALC268 Digital";
10840 }
10841
10842 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10843 spec->stream_analog_capture = &alc268_pcm_analog_capture;
10844 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
10845
10846 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10847
10848 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
10849 /* override the amp caps for beep generator */
10850 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
10851 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
10852 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
10853 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
10854 (0 << AC_AMPCAP_MUTE_SHIFT));
10855
10856 if (!spec->adc_nids && spec->input_mux) {
10857 /* check whether NID 0x07 is valid */
10858 unsigned int wcap = get_wcaps(codec, 0x07);
10859 int i;
10860
10861 /* get type */
10862 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10863 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
10864 spec->adc_nids = alc268_adc_nids_alt;
10865 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10866 spec->mixers[spec->num_mixers] =
10867 alc268_capture_alt_mixer;
10868 spec->num_mixers++;
10869 } else {
10870 spec->adc_nids = alc268_adc_nids;
10871 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10872 spec->mixers[spec->num_mixers] =
10873 alc268_capture_mixer;
10874 spec->num_mixers++;
10875 }
10876 spec->capsrc_nids = alc268_capsrc_nids;
10877 /* set default input source */
10878 for (i = 0; i < spec->num_adc_nids; i++)
10879 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
10880 0, AC_VERB_SET_CONNECT_SEL,
10881 spec->input_mux->items[0].index);
10882 }
10883
10884 spec->vmaster_nid = 0x02;
10885
10886 codec->patch_ops = alc_patch_ops;
10887 if (board_config == ALC268_AUTO)
10888 spec->init_hook = alc268_auto_init;
10889
10890 return 0;
10891}
10892
10893/*
10894 * ALC269 channel source setting (2 channel)
10895 */
10896#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10897
10898#define alc269_dac_nids alc260_dac_nids
10899
10900static hda_nid_t alc269_adc_nids[1] = {
10901 /* ADC1 */
10902 0x07,
10903};
10904
10905#define alc269_modes alc260_modes
10906#define alc269_capture_source alc880_lg_lw_capture_source
10907
10908static struct snd_kcontrol_new alc269_base_mixer[] = {
10909 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10910 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10915 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10916 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10917 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10918 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10919 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10920 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10921 { } /* end */
10922};
10923
10924/* capture mixer elements */
10925static struct snd_kcontrol_new alc269_capture_mixer[] = {
10926 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10927 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10928 {
10929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10930 /* The multiple "Capture Source" controls confuse alsamixer
10931 * So call somewhat different..
10932 */
10933 /* .name = "Capture Source", */
10934 .name = "Input Source",
10935 .count = 1,
10936 .info = alc_mux_enum_info,
10937 .get = alc_mux_enum_get,
10938 .put = alc_mux_enum_put,
10939 },
10940 { } /* end */
10941};
10942
10943/*
10944 * generic initialization of ADC, input mixers and output mixers
10945 */
10946static struct hda_verb alc269_init_verbs[] = {
10947 /*
10948 * Unmute ADC0 and set the default input to mic-in
10949 */
10950 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10951
10952 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10953 * analog-loopback mixer widget
10954 * Note: PASD motherboards uses the Line In 2 as the input for
10955 * front panel mic (mic 2)
10956 */
10957 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10958 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10959 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10960 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10961 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10962 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10963
10964 /*
10965 * Set up output mixers (0x0c - 0x0e)
10966 */
10967 /* set vol=0 to output mixers */
10968 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10969 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10970
10971 /* set up input amps for analog loopback */
10972 /* Amp Indices: DAC = 0, mixer = 1 */
10973 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10974 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10975 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10976 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10977 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10978 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10979
10980 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10981 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10982 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10983 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10984 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10985 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10986 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10987
10988 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10989 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10990 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10991 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10992 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10993 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10994 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10995
10996 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10997 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10998
10999 /* FIXME: use matrix-type input source selection */
11000 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11001 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11002 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11003 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11004 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11005 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11006
11007 /* set EAPD */
11008 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11009 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11010 { }
11011};
11012
11013/* add playback controls from the parsed DAC table */
11014static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11015 const struct auto_pin_cfg *cfg)
11016{
11017 hda_nid_t nid;
11018 int err;
11019
11020 spec->multiout.num_dacs = 1; /* only use one dac */
11021 spec->multiout.dac_nids = spec->private_dac_nids;
11022 spec->multiout.dac_nids[0] = 2;
11023
11024 nid = cfg->line_out_pins[0];
11025 if (nid) {
11026 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11027 "Front Playback Volume",
11028 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11029 if (err < 0)
11030 return err;
11031 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11032 "Front Playback Switch",
11033 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11034 if (err < 0)
11035 return err;
11036 }
11037
11038 nid = cfg->speaker_pins[0];
11039 if (nid) {
11040 if (!cfg->line_out_pins[0]) {
11041 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11042 "Speaker Playback Volume",
11043 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11044 HDA_OUTPUT));
11045 if (err < 0)
11046 return err;
11047 }
11048 if (nid == 0x16) {
11049 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11050 "Speaker Playback Switch",
11051 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11052 HDA_OUTPUT));
11053 if (err < 0)
11054 return err;
11055 } else {
11056 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11057 "Speaker Playback Switch",
11058 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11059 HDA_OUTPUT));
11060 if (err < 0)
11061 return err;
11062 }
11063 }
11064 nid = cfg->hp_pins[0];
11065 if (nid) {
11066 /* spec->multiout.hp_nid = 2; */
11067 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11068 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11069 "Headphone Playback Volume",
11070 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11071 HDA_OUTPUT));
11072 if (err < 0)
11073 return err;
11074 }
11075 if (nid == 0x16) {
11076 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11077 "Headphone Playback Switch",
11078 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11079 HDA_OUTPUT));
11080 if (err < 0)
11081 return err;
11082 } else {
11083 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11084 "Headphone Playback Switch",
11085 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11086 HDA_OUTPUT));
11087 if (err < 0)
11088 return err;
11089 }
11090 }
11091 return 0;
11092}
11093
11094#define alc269_auto_create_analog_input_ctls \
11095 alc880_auto_create_analog_input_ctls
11096
11097#ifdef CONFIG_SND_HDA_POWER_SAVE
11098#define alc269_loopbacks alc880_loopbacks
11099#endif
11100
11101/* pcm configuration: identiacal with ALC880 */
11102#define alc269_pcm_analog_playback alc880_pcm_analog_playback
11103#define alc269_pcm_analog_capture alc880_pcm_analog_capture
11104#define alc269_pcm_digital_playback alc880_pcm_digital_playback
11105#define alc269_pcm_digital_capture alc880_pcm_digital_capture
11106
11107/*
11108 * BIOS auto configuration
11109 */
11110static int alc269_parse_auto_config(struct hda_codec *codec)
11111{
11112 struct alc_spec *spec = codec->spec;
11113 int err;
11114 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
11115
11116 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11117 alc269_ignore);
11118 if (err < 0)
11119 return err;
11120
11121 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
11122 if (err < 0)
11123 return err;
11124 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
11125 if (err < 0)
11126 return err;
11127
11128 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11129
11130 if (spec->autocfg.dig_out_pin)
11131 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
11132
11133 if (spec->kctl_alloc)
11134 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11135
11136 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
11137 spec->num_mux_defs = 1;
11138 spec->input_mux = &spec->private_imux;
11139
11140 err = alc_auto_add_mic_boost(codec);
11141 if (err < 0)
11142 return err;
11143
11144 return 1;
11145}
11146
11147#define alc269_auto_init_multi_out alc882_auto_init_multi_out
11148#define alc269_auto_init_hp_out alc882_auto_init_hp_out
11149#define alc269_auto_init_analog_input alc882_auto_init_analog_input
11150
11151
11152/* init callback for auto-configuration model -- overriding the default init */
11153static void alc269_auto_init(struct hda_codec *codec)
11154{
11155 struct alc_spec *spec = codec->spec;
11156 alc269_auto_init_multi_out(codec);
11157 alc269_auto_init_hp_out(codec);
11158 alc269_auto_init_analog_input(codec);
11159 if (spec->unsol_event)
11160 alc_sku_automute(codec);
11161}
11162
11163/*
11164 * configuration and preset
11165 */
11166static const char *alc269_models[ALC269_MODEL_LAST] = {
11167 [ALC269_BASIC] = "basic",
11168};
11169
11170static struct snd_pci_quirk alc269_cfg_tbl[] = {
11171 {}
11172};
11173
11174static struct alc_config_preset alc269_presets[] = {
11175 [ALC269_BASIC] = {
11176 .mixers = { alc269_base_mixer },
11177 .init_verbs = { alc269_init_verbs },
11178 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11179 .dac_nids = alc269_dac_nids,
11180 .hp_nid = 0x03,
11181 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11182 .channel_mode = alc269_modes,
11183 .input_mux = &alc269_capture_source,
11184 },
11185};
11186
11187static int patch_alc269(struct hda_codec *codec)
11188{
11189 struct alc_spec *spec;
11190 int board_config;
11191 int err;
11192
11193 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11194 if (spec == NULL)
11195 return -ENOMEM;
11196
11197 codec->spec = spec;
11198
11199 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
11200 alc269_models,
11201 alc269_cfg_tbl);
11202
11203 if (board_config < 0) {
11204 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
11205 "trying auto-probe from BIOS...\n");
11206 board_config = ALC269_AUTO;
11207 }
11208
11209 if (board_config == ALC269_AUTO) {
11210 /* automatic parse from the BIOS config */
11211 err = alc269_parse_auto_config(codec);
11212 if (err < 0) {
11213 alc_free(codec);
11214 return err;
11215 } else if (!err) {
11216 printk(KERN_INFO
11217 "hda_codec: Cannot set up configuration "
11218 "from BIOS. Using base mode...\n");
11219 board_config = ALC269_BASIC;
11220 }
11221 }
11222
11223 if (board_config != ALC269_AUTO)
11224 setup_preset(spec, &alc269_presets[board_config]);
11225
11226 spec->stream_name_analog = "ALC269 Analog";
11227 spec->stream_analog_playback = &alc269_pcm_analog_playback;
11228 spec->stream_analog_capture = &alc269_pcm_analog_capture;
11229
11230 spec->stream_name_digital = "ALC269 Digital";
11231 spec->stream_digital_playback = &alc269_pcm_digital_playback;
11232 spec->stream_digital_capture = &alc269_pcm_digital_capture;
11233
11234 spec->adc_nids = alc269_adc_nids;
11235 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
11236 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11237 spec->num_mixers++;
11238
11239 codec->patch_ops = alc_patch_ops;
11240 if (board_config == ALC269_AUTO)
11241 spec->init_hook = alc269_auto_init;
11242#ifdef CONFIG_SND_HDA_POWER_SAVE
11243 if (!spec->loopback.amplist)
11244 spec->loopback.amplist = alc269_loopbacks;
11245#endif
11246
11247 return 0;
11248}
11249
11250/*
11251 * ALC861 channel source setting (2/6 channel selection for 3-stack)
11252 */
11253
11254/*
11255 * set the path ways for 2 channel output
11256 * need to set the codec line out and mic 1 pin widgets to inputs
11257 */
11258static struct hda_verb alc861_threestack_ch2_init[] = {
11259 /* set pin widget 1Ah (line in) for input */
11260 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11261 /* set pin widget 18h (mic1/2) for input, for mic also enable
11262 * the vref
11263 */
11264 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11265
11266 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11267#if 0
11268 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11269 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11270#endif
11271 { } /* end */
11272};
11273/*
11274 * 6ch mode
11275 * need to set the codec line out and mic 1 pin widgets to outputs
11276 */
11277static struct hda_verb alc861_threestack_ch6_init[] = {
11278 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11279 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11280 /* set pin widget 18h (mic1) for output (CLFE)*/
11281 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11282
11283 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11284 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11285
11286 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11287#if 0
11288 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11289 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11290#endif
11291 { } /* end */
11292};
11293
11294static struct hda_channel_mode alc861_threestack_modes[2] = {
11295 { 2, alc861_threestack_ch2_init },
11296 { 6, alc861_threestack_ch6_init },
11297};
11298/* Set mic1 as input and unmute the mixer */
11299static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
11300 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11301 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11302 { } /* end */
11303};
11304/* Set mic1 as output and mute mixer */
11305static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
11306 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11307 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11308 { } /* end */
11309};
11310
11311static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
11312 { 2, alc861_uniwill_m31_ch2_init },
11313 { 4, alc861_uniwill_m31_ch4_init },
11314};
11315
11316/* Set mic1 and line-in as input and unmute the mixer */
11317static struct hda_verb alc861_asus_ch2_init[] = {
11318 /* set pin widget 1Ah (line in) for input */
11319 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11320 /* set pin widget 18h (mic1/2) for input, for mic also enable
11321 * the vref
11322 */
11323 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11324
11325 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11326#if 0
11327 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11328 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11329#endif
11330 { } /* end */
11331};
11332/* Set mic1 nad line-in as output and mute mixer */
11333static struct hda_verb alc861_asus_ch6_init[] = {
11334 /* set pin widget 1Ah (line in) for output (Back Surround)*/
11335 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11336 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11337 /* set pin widget 18h (mic1) for output (CLFE)*/
11338 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11339 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
11340 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
11341 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
11342
11343 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
11344#if 0
11345 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
11346 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
11347#endif
11348 { } /* end */
11349};
11350
11351static struct hda_channel_mode alc861_asus_modes[2] = {
11352 { 2, alc861_asus_ch2_init },
11353 { 6, alc861_asus_ch6_init },
11354};
11355
11356/* patch-ALC861 */
11357
11358static struct snd_kcontrol_new alc861_base_mixer[] = {
11359 /* output mixer control */
11360 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11361 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11362 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11363 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11364 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11365
11366 /*Input mixer control */
11367 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11368 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11369 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11370 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11371 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11372 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11373 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11374 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11375 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11376 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
11377
11378 /* Capture mixer control */
11379 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11380 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11381 {
11382 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11383 .name = "Capture Source",
11384 .count = 1,
11385 .info = alc_mux_enum_info,
11386 .get = alc_mux_enum_get,
11387 .put = alc_mux_enum_put,
11388 },
11389 { } /* end */
11390};
11391
11392static struct snd_kcontrol_new alc861_3ST_mixer[] = {
11393 /* output mixer control */
11394 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11395 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11396 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11397 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11398 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11399
11400 /* Input mixer control */
11401 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11402 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11403 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11404 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11405 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11406 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11408 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11409 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11410 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
11411
11412 /* Capture mixer control */
11413 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11414 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11415 {
11416 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11417 .name = "Capture Source",
11418 .count = 1,
11419 .info = alc_mux_enum_info,
11420 .get = alc_mux_enum_get,
11421 .put = alc_mux_enum_put,
11422 },
11423 {
11424 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11425 .name = "Channel Mode",
11426 .info = alc_ch_mode_info,
11427 .get = alc_ch_mode_get,
11428 .put = alc_ch_mode_put,
11429 .private_value = ARRAY_SIZE(alc861_threestack_modes),
11430 },
11431 { } /* end */
11432};
11433
11434static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
11435 /* output mixer control */
11436 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11438 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11439
11440 /*Capture mixer control */
11441 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11442 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11443 {
11444 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11445 .name = "Capture Source",
11446 .count = 1,
11447 .info = alc_mux_enum_info,
11448 .get = alc_mux_enum_get,
11449 .put = alc_mux_enum_put,
11450 },
11451
11452 { } /* end */
11453};
11454
11455static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
11456 /* output mixer control */
11457 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11458 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11459 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11460 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11461 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
11462
11463 /* Input mixer control */
11464 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11465 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
11466 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11467 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11468 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11469 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11470 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11471 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11472 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11473 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
11474
11475 /* Capture mixer control */
11476 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11477 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11478 {
11479 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11480 .name = "Capture Source",
11481 .count = 1,
11482 .info = alc_mux_enum_info,
11483 .get = alc_mux_enum_get,
11484 .put = alc_mux_enum_put,
11485 },
11486 {
11487 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11488 .name = "Channel Mode",
11489 .info = alc_ch_mode_info,
11490 .get = alc_ch_mode_get,
11491 .put = alc_ch_mode_put,
11492 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
11493 },
11494 { } /* end */
11495};
11496
11497static struct snd_kcontrol_new alc861_asus_mixer[] = {
11498 /* output mixer control */
11499 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
11500 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
11501 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
11502 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
11503 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
11504
11505 /* Input mixer control */
11506 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
11507 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11508 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11509 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11510 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
11511 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
11512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
11513 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
11514 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
11515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
11516
11517 /* Capture mixer control */
11518 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11519 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11520 {
11521 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11522 .name = "Capture Source",
11523 .count = 1,
11524 .info = alc_mux_enum_info,
11525 .get = alc_mux_enum_get,
11526 .put = alc_mux_enum_put,
11527 },
11528 {
11529 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11530 .name = "Channel Mode",
11531 .info = alc_ch_mode_info,
11532 .get = alc_ch_mode_get,
11533 .put = alc_ch_mode_put,
11534 .private_value = ARRAY_SIZE(alc861_asus_modes),
11535 },
11536 { }
11537};
11538
11539/* additional mixer */
11540static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
11541 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
11542 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
11543 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
11544 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
11545 { }
11546};
11547
11548/*
11549 * generic initialization of ADC, input mixers and output mixers
11550 */
11551static struct hda_verb alc861_base_init_verbs[] = {
11552 /*
11553 * Unmute ADC0 and set the default input to mic-in
11554 */
11555 /* port-A for surround (rear panel) */
11556 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11557 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
11558 /* port-B for mic-in (rear panel) with vref */
11559 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11560 /* port-C for line-in (rear panel) */
11561 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11562 /* port-D for Front */
11563 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11564 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11565 /* port-E for HP out (front panel) */
11566 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11567 /* route front PCM to HP */
11568 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11569 /* port-F for mic-in (front panel) with vref */
11570 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11571 /* port-G for CLFE (rear panel) */
11572 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11573 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11574 /* port-H for side (rear panel) */
11575 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11576 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
11577 /* CD-in */
11578 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11579 /* route front mic to ADC1*/
11580 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11581 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11582
11583 /* Unmute DAC0~3 & spdif out*/
11584 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11585 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11586 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11587 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11589
11590 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11591 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11592 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11593 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11594 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11595
11596 /* Unmute Stereo Mixer 15 */
11597 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11598 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11599 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11600 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11601
11602 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11603 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11604 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11605 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11606 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11607 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11608 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11609 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11610 /* hp used DAC 3 (Front) */
11611 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11612 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11613
11614 { }
11615};
11616
11617static struct hda_verb alc861_threestack_init_verbs[] = {
11618 /*
11619 * Unmute ADC0 and set the default input to mic-in
11620 */
11621 /* port-A for surround (rear panel) */
11622 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11623 /* port-B for mic-in (rear panel) with vref */
11624 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11625 /* port-C for line-in (rear panel) */
11626 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11627 /* port-D for Front */
11628 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11629 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11630 /* port-E for HP out (front panel) */
11631 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
11632 /* route front PCM to HP */
11633 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11634 /* port-F for mic-in (front panel) with vref */
11635 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11636 /* port-G for CLFE (rear panel) */
11637 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11638 /* port-H for side (rear panel) */
11639 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11640 /* CD-in */
11641 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11642 /* route front mic to ADC1*/
11643 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11644 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11645 /* Unmute DAC0~3 & spdif out*/
11646 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11647 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11648 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11649 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11651
11652 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11653 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11654 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11655 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11656 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11657
11658 /* Unmute Stereo Mixer 15 */
11659 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11663
11664 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11665 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11666 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11667 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11668 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11669 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11670 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11671 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11672 /* hp used DAC 3 (Front) */
11673 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11674 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11675 { }
11676};
11677
11678static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
11679 /*
11680 * Unmute ADC0 and set the default input to mic-in
11681 */
11682 /* port-A for surround (rear panel) */
11683 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11684 /* port-B for mic-in (rear panel) with vref */
11685 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11686 /* port-C for line-in (rear panel) */
11687 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11688 /* port-D for Front */
11689 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11690 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11691 /* port-E for HP out (front panel) */
11692 /* this has to be set to VREF80 */
11693 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11694 /* route front PCM to HP */
11695 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11696 /* port-F for mic-in (front panel) with vref */
11697 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11698 /* port-G for CLFE (rear panel) */
11699 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11700 /* port-H for side (rear panel) */
11701 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11702 /* CD-in */
11703 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11704 /* route front mic to ADC1*/
11705 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11706 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11707 /* Unmute DAC0~3 & spdif out*/
11708 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11709 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11710 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11711 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11713
11714 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11715 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11716 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11717 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11718 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11719
11720 /* Unmute Stereo Mixer 15 */
11721 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11722 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11723 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11725
11726 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11727 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11728 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11729 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11730 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11731 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11732 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11734 /* hp used DAC 3 (Front) */
11735 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11736 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11737 { }
11738};
11739
11740static struct hda_verb alc861_asus_init_verbs[] = {
11741 /*
11742 * Unmute ADC0 and set the default input to mic-in
11743 */
11744 /* port-A for surround (rear panel)
11745 * according to codec#0 this is the HP jack
11746 */
11747 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
11748 /* route front PCM to HP */
11749 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
11750 /* port-B for mic-in (rear panel) with vref */
11751 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11752 /* port-C for line-in (rear panel) */
11753 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11754 /* port-D for Front */
11755 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11756 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
11757 /* port-E for HP out (front panel) */
11758 /* this has to be set to VREF80 */
11759 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11760 /* route front PCM to HP */
11761 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
11762 /* port-F for mic-in (front panel) with vref */
11763 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11764 /* port-G for CLFE (rear panel) */
11765 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11766 /* port-H for side (rear panel) */
11767 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
11768 /* CD-in */
11769 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
11770 /* route front mic to ADC1*/
11771 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11772 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11773 /* Unmute DAC0~3 & spdif out*/
11774 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11775 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11776 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11777 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11778 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11779 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11780 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11781 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11782 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11783 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11784
11785 /* Unmute Stereo Mixer 15 */
11786 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11787 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11789 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
11790
11791 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11792 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11793 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11794 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11795 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11796 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11797 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11798 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11799 /* hp used DAC 3 (Front) */
11800 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11801 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11802 { }
11803};
11804
11805/* additional init verbs for ASUS laptops */
11806static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11807 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11808 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11809 { }
11810};
11811
11812/*
11813 * generic initialization of ADC, input mixers and output mixers
11814 */
11815static struct hda_verb alc861_auto_init_verbs[] = {
11816 /*
11817 * Unmute ADC0 and set the default input to mic-in
11818 */
11819 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
11820 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11821
11822 /* Unmute DAC0~3 & spdif out*/
11823 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11824 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11825 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11826 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11828
11829 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11830 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11831 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11832 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11833 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11834
11835 /* Unmute Stereo Mixer 15 */
11836 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11839 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11840
11841 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11842 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11843 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11844 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11845 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11846 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11847 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11848 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11849
11850 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11851 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11852 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11853 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11854 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11855 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11856 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11857 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11858
11859 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
11860
11861 { }
11862};
11863
11864static struct hda_verb alc861_toshiba_init_verbs[] = {
11865 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11866
11867 { }
11868};
11869
11870/* toggle speaker-output according to the hp-jack state */
11871static void alc861_toshiba_automute(struct hda_codec *codec)
11872{
11873 unsigned int present;
11874
11875 present = snd_hda_codec_read(codec, 0x0f, 0,
11876 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11877 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11878 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11879 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11880 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
11881}
11882
11883static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11884 unsigned int res)
11885{
11886 if ((res >> 26) == ALC880_HP_EVENT)
11887 alc861_toshiba_automute(codec);
11888}
11889
11890/* pcm configuration: identiacal with ALC880 */
11891#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11892#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11893#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11894#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11895
11896
11897#define ALC861_DIGOUT_NID 0x07
11898
11899static struct hda_channel_mode alc861_8ch_modes[1] = {
11900 { 8, NULL }
11901};
11902
11903static hda_nid_t alc861_dac_nids[4] = {
11904 /* front, surround, clfe, side */
11905 0x03, 0x06, 0x05, 0x04
11906};
11907
11908static hda_nid_t alc660_dac_nids[3] = {
11909 /* front, clfe, surround */
11910 0x03, 0x05, 0x06
11911};
11912
11913static hda_nid_t alc861_adc_nids[1] = {
11914 /* ADC0-2 */
11915 0x08,
11916};
11917
11918static struct hda_input_mux alc861_capture_source = {
11919 .num_items = 5,
11920 .items = {
11921 { "Mic", 0x0 },
11922 { "Front Mic", 0x3 },
11923 { "Line", 0x1 },
11924 { "CD", 0x4 },
11925 { "Mixer", 0x5 },
11926 },
11927};
11928
11929/* fill in the dac_nids table from the parsed pin configuration */
11930static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11931 const struct auto_pin_cfg *cfg)
11932{
11933 int i;
11934 hda_nid_t nid;
11935
11936 spec->multiout.dac_nids = spec->private_dac_nids;
11937 for (i = 0; i < cfg->line_outs; i++) {
11938 nid = cfg->line_out_pins[i];
11939 if (nid) {
11940 if (i >= ARRAY_SIZE(alc861_dac_nids))
11941 continue;
11942 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11943 }
11944 }
11945 spec->multiout.num_dacs = cfg->line_outs;
11946 return 0;
11947}
11948
11949/* add playback controls from the parsed DAC table */
11950static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11951 const struct auto_pin_cfg *cfg)
11952{
11953 char name[32];
11954 static const char *chname[4] = {
11955 "Front", "Surround", NULL /*CLFE*/, "Side"
11956 };
11957 hda_nid_t nid;
11958 int i, idx, err;
11959
11960 for (i = 0; i < cfg->line_outs; i++) {
11961 nid = spec->multiout.dac_nids[i];
11962 if (!nid)
11963 continue;
11964 if (nid == 0x05) {
11965 /* Center/LFE */
11966 err = add_control(spec, ALC_CTL_BIND_MUTE,
11967 "Center Playback Switch",
11968 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11969 HDA_OUTPUT));
11970 if (err < 0)
11971 return err;
11972 err = add_control(spec, ALC_CTL_BIND_MUTE,
11973 "LFE Playback Switch",
11974 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11975 HDA_OUTPUT));
11976 if (err < 0)
11977 return err;
11978 } else {
11979 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11980 idx++)
11981 if (nid == alc861_dac_nids[idx])
11982 break;
11983 sprintf(name, "%s Playback Switch", chname[idx]);
11984 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11985 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11986 HDA_OUTPUT));
11987 if (err < 0)
11988 return err;
11989 }
11990 }
11991 return 0;
11992}
11993
11994static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11995{
11996 int err;
11997 hda_nid_t nid;
11998
11999 if (!pin)
12000 return 0;
12001
12002 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12003 nid = 0x03;
12004 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12005 "Headphone Playback Switch",
12006 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12007 if (err < 0)
12008 return err;
12009 spec->multiout.hp_nid = nid;
12010 }
12011 return 0;
12012}
12013
12014/* create playback/capture controls for input pins */
12015static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12016 const struct auto_pin_cfg *cfg)
12017{
12018 struct hda_input_mux *imux = &spec->private_imux;
12019 int i, err, idx, idx1;
12020
12021 for (i = 0; i < AUTO_PIN_LAST; i++) {
12022 switch (cfg->input_pins[i]) {
12023 case 0x0c:
12024 idx1 = 1;
12025 idx = 2; /* Line In */
12026 break;
12027 case 0x0f:
12028 idx1 = 2;
12029 idx = 2; /* Line In */
12030 break;
12031 case 0x0d:
12032 idx1 = 0;
12033 idx = 1; /* Mic In */
12034 break;
12035 case 0x10:
12036 idx1 = 3;
12037 idx = 1; /* Mic In */
12038 break;
12039 case 0x11:
12040 idx1 = 4;
12041 idx = 0; /* CD */
12042 break;
12043 default:
12044 continue;
12045 }
12046
12047 err = new_analog_input(spec, cfg->input_pins[i],
12048 auto_pin_cfg_labels[i], idx, 0x15);
12049 if (err < 0)
12050 return err;
12051
12052 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12053 imux->items[imux->num_items].index = idx1;
12054 imux->num_items++;
12055 }
12056 return 0;
12057}
12058
12059static struct snd_kcontrol_new alc861_capture_mixer[] = {
12060 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12061 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12062
12063 {
12064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12065 /* The multiple "Capture Source" controls confuse alsamixer
12066 * So call somewhat different..
12067 */
12068 /* .name = "Capture Source", */
12069 .name = "Input Source",
12070 .count = 1,
12071 .info = alc_mux_enum_info,
12072 .get = alc_mux_enum_get,
12073 .put = alc_mux_enum_put,
12074 },
12075 { } /* end */
12076};
12077
12078static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
12079 hda_nid_t nid,
12080 int pin_type, int dac_idx)
12081{
12082 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
12083 pin_type);
12084 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12085 AMP_OUT_UNMUTE);
12086}
12087
12088static void alc861_auto_init_multi_out(struct hda_codec *codec)
12089{
12090 struct alc_spec *spec = codec->spec;
12091 int i;
12092
12093 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
12094 for (i = 0; i < spec->autocfg.line_outs; i++) {
12095 hda_nid_t nid = spec->autocfg.line_out_pins[i];
12096 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12097 if (nid)
12098 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
12099 spec->multiout.dac_nids[i]);
12100 }
12101}
12102
12103static void alc861_auto_init_hp_out(struct hda_codec *codec)
12104{
12105 struct alc_spec *spec = codec->spec;
12106 hda_nid_t pin;
12107
12108 pin = spec->autocfg.hp_pins[0];
12109 if (pin) /* connect to front */
12110 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
12111 spec->multiout.dac_nids[0]);
12112 pin = spec->autocfg.speaker_pins[0];
12113 if (pin)
12114 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
12115}
12116
12117static void alc861_auto_init_analog_input(struct hda_codec *codec)
12118{
12119 struct alc_spec *spec = codec->spec;
12120 int i;
12121
12122 for (i = 0; i < AUTO_PIN_LAST; i++) {
12123 hda_nid_t nid = spec->autocfg.input_pins[i];
12124 if (nid >= 0x0c && nid <= 0x11) {
12125 snd_hda_codec_write(codec, nid, 0,
12126 AC_VERB_SET_PIN_WIDGET_CONTROL,
12127 i <= AUTO_PIN_FRONT_MIC ?
12128 PIN_VREF80 : PIN_IN);
12129 }
12130 }
12131}
12132
12133/* parse the BIOS configuration and set up the alc_spec */
12134/* return 1 if successful, 0 if the proper config is not found,
12135 * or a negative error code
12136 */
12137static int alc861_parse_auto_config(struct hda_codec *codec)
12138{
12139 struct alc_spec *spec = codec->spec;
12140 int err;
12141 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
12142
12143 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12144 alc861_ignore);
12145 if (err < 0)
12146 return err;
12147 if (!spec->autocfg.line_outs)
12148 return 0; /* can't find valid BIOS pin config */
12149
12150 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
12151 if (err < 0)
12152 return err;
12153 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
12154 if (err < 0)
12155 return err;
12156 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
12157 if (err < 0)
12158 return err;
12159 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
12160 if (err < 0)
12161 return err;
12162
12163 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12164
12165 if (spec->autocfg.dig_out_pin)
12166 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
12167
12168 if (spec->kctl_alloc)
12169 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12170
12171 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
12172
12173 spec->num_mux_defs = 1;
12174 spec->input_mux = &spec->private_imux;
12175
12176 spec->adc_nids = alc861_adc_nids;
12177 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
12178 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
12179 spec->num_mixers++;
12180
12181 return 1;
12182}
12183
12184/* additional initialization for auto-configuration model */
12185static void alc861_auto_init(struct hda_codec *codec)
12186{
12187 struct alc_spec *spec = codec->spec;
12188 alc861_auto_init_multi_out(codec);
12189 alc861_auto_init_hp_out(codec);
12190 alc861_auto_init_analog_input(codec);
12191 if (spec->unsol_event)
12192 alc_sku_automute(codec);
12193}
12194
12195#ifdef CONFIG_SND_HDA_POWER_SAVE
12196static struct hda_amp_list alc861_loopbacks[] = {
12197 { 0x15, HDA_INPUT, 0 },
12198 { 0x15, HDA_INPUT, 1 },
12199 { 0x15, HDA_INPUT, 2 },
12200 { 0x15, HDA_INPUT, 3 },
12201 { } /* end */
12202};
12203#endif
12204
12205
12206/*
12207 * configuration and preset
12208 */
12209static const char *alc861_models[ALC861_MODEL_LAST] = {
12210 [ALC861_3ST] = "3stack",
12211 [ALC660_3ST] = "3stack-660",
12212 [ALC861_3ST_DIG] = "3stack-dig",
12213 [ALC861_6ST_DIG] = "6stack-dig",
12214 [ALC861_UNIWILL_M31] = "uniwill-m31",
12215 [ALC861_TOSHIBA] = "toshiba",
12216 [ALC861_ASUS] = "asus",
12217 [ALC861_ASUS_LAPTOP] = "asus-laptop",
12218 [ALC861_AUTO] = "auto",
12219};
12220
12221static struct snd_pci_quirk alc861_cfg_tbl[] = {
12222 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
12223 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12224 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12225 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
12226 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
12227 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
12228 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
12229 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
12230 * Any other models that need this preset?
12231 */
12232 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
12233 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
12234 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
12235 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
12236 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
12237 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
12238 /* FIXME: the below seems conflict */
12239 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
12240 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
12241 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
12242 {}
12243};
12244
12245static struct alc_config_preset alc861_presets[] = {
12246 [ALC861_3ST] = {
12247 .mixers = { alc861_3ST_mixer },
12248 .init_verbs = { alc861_threestack_init_verbs },
12249 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12250 .dac_nids = alc861_dac_nids,
12251 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12252 .channel_mode = alc861_threestack_modes,
12253 .need_dac_fix = 1,
12254 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12255 .adc_nids = alc861_adc_nids,
12256 .input_mux = &alc861_capture_source,
12257 },
12258 [ALC861_3ST_DIG] = {
12259 .mixers = { alc861_base_mixer },
12260 .init_verbs = { alc861_threestack_init_verbs },
12261 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12262 .dac_nids = alc861_dac_nids,
12263 .dig_out_nid = ALC861_DIGOUT_NID,
12264 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12265 .channel_mode = alc861_threestack_modes,
12266 .need_dac_fix = 1,
12267 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12268 .adc_nids = alc861_adc_nids,
12269 .input_mux = &alc861_capture_source,
12270 },
12271 [ALC861_6ST_DIG] = {
12272 .mixers = { alc861_base_mixer },
12273 .init_verbs = { alc861_base_init_verbs },
12274 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12275 .dac_nids = alc861_dac_nids,
12276 .dig_out_nid = ALC861_DIGOUT_NID,
12277 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
12278 .channel_mode = alc861_8ch_modes,
12279 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12280 .adc_nids = alc861_adc_nids,
12281 .input_mux = &alc861_capture_source,
12282 },
12283 [ALC660_3ST] = {
12284 .mixers = { alc861_3ST_mixer },
12285 .init_verbs = { alc861_threestack_init_verbs },
12286 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
12287 .dac_nids = alc660_dac_nids,
12288 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12289 .channel_mode = alc861_threestack_modes,
12290 .need_dac_fix = 1,
12291 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12292 .adc_nids = alc861_adc_nids,
12293 .input_mux = &alc861_capture_source,
12294 },
12295 [ALC861_UNIWILL_M31] = {
12296 .mixers = { alc861_uniwill_m31_mixer },
12297 .init_verbs = { alc861_uniwill_m31_init_verbs },
12298 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12299 .dac_nids = alc861_dac_nids,
12300 .dig_out_nid = ALC861_DIGOUT_NID,
12301 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
12302 .channel_mode = alc861_uniwill_m31_modes,
12303 .need_dac_fix = 1,
12304 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12305 .adc_nids = alc861_adc_nids,
12306 .input_mux = &alc861_capture_source,
12307 },
12308 [ALC861_TOSHIBA] = {
12309 .mixers = { alc861_toshiba_mixer },
12310 .init_verbs = { alc861_base_init_verbs,
12311 alc861_toshiba_init_verbs },
12312 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12313 .dac_nids = alc861_dac_nids,
12314 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12315 .channel_mode = alc883_3ST_2ch_modes,
12316 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12317 .adc_nids = alc861_adc_nids,
12318 .input_mux = &alc861_capture_source,
12319 .unsol_event = alc861_toshiba_unsol_event,
12320 .init_hook = alc861_toshiba_automute,
12321 },
12322 [ALC861_ASUS] = {
12323 .mixers = { alc861_asus_mixer },
12324 .init_verbs = { alc861_asus_init_verbs },
12325 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12326 .dac_nids = alc861_dac_nids,
12327 .dig_out_nid = ALC861_DIGOUT_NID,
12328 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
12329 .channel_mode = alc861_asus_modes,
12330 .need_dac_fix = 1,
12331 .hp_nid = 0x06,
12332 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12333 .adc_nids = alc861_adc_nids,
12334 .input_mux = &alc861_capture_source,
12335 },
12336 [ALC861_ASUS_LAPTOP] = {
12337 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
12338 .init_verbs = { alc861_asus_init_verbs,
12339 alc861_asus_laptop_init_verbs },
12340 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12341 .dac_nids = alc861_dac_nids,
12342 .dig_out_nid = ALC861_DIGOUT_NID,
12343 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
12344 .channel_mode = alc883_3ST_2ch_modes,
12345 .need_dac_fix = 1,
12346 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12347 .adc_nids = alc861_adc_nids,
12348 .input_mux = &alc861_capture_source,
12349 },
12350};
12351
12352
12353static int patch_alc861(struct hda_codec *codec)
12354{
12355 struct alc_spec *spec;
12356 int board_config;
12357 int err;
12358
12359 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12360 if (spec == NULL)
12361 return -ENOMEM;
12362
12363 codec->spec = spec;
12364
12365 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
12366 alc861_models,
12367 alc861_cfg_tbl);
12368
12369 if (board_config < 0) {
12370 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
12371 "trying auto-probe from BIOS...\n");
12372 board_config = ALC861_AUTO;
12373 }
12374
12375 if (board_config == ALC861_AUTO) {
12376 /* automatic parse from the BIOS config */
12377 err = alc861_parse_auto_config(codec);
12378 if (err < 0) {
12379 alc_free(codec);
12380 return err;
12381 } else if (!err) {
12382 printk(KERN_INFO
12383 "hda_codec: Cannot set up configuration "
12384 "from BIOS. Using base mode...\n");
12385 board_config = ALC861_3ST_DIG;
12386 }
12387 }
12388
12389 if (board_config != ALC861_AUTO)
12390 setup_preset(spec, &alc861_presets[board_config]);
12391
12392 spec->stream_name_analog = "ALC861 Analog";
12393 spec->stream_analog_playback = &alc861_pcm_analog_playback;
12394 spec->stream_analog_capture = &alc861_pcm_analog_capture;
12395
12396 spec->stream_name_digital = "ALC861 Digital";
12397 spec->stream_digital_playback = &alc861_pcm_digital_playback;
12398 spec->stream_digital_capture = &alc861_pcm_digital_capture;
12399
12400 spec->vmaster_nid = 0x03;
12401
12402 codec->patch_ops = alc_patch_ops;
12403 if (board_config == ALC861_AUTO)
12404 spec->init_hook = alc861_auto_init;
12405#ifdef CONFIG_SND_HDA_POWER_SAVE
12406 if (!spec->loopback.amplist)
12407 spec->loopback.amplist = alc861_loopbacks;
12408#endif
12409
12410 return 0;
12411}
12412
12413/*
12414 * ALC861-VD support
12415 *
12416 * Based on ALC882
12417 *
12418 * In addition, an independent DAC
12419 */
12420#define ALC861VD_DIGOUT_NID 0x06
12421
12422static hda_nid_t alc861vd_dac_nids[4] = {
12423 /* front, surr, clfe, side surr */
12424 0x02, 0x03, 0x04, 0x05
12425};
12426
12427/* dac_nids for ALC660vd are in a different order - according to
12428 * Realtek's driver.
12429 * This should probably tesult in a different mixer for 6stack models
12430 * of ALC660vd codecs, but for now there is only 3stack mixer
12431 * - and it is the same as in 861vd.
12432 * adc_nids in ALC660vd are (is) the same as in 861vd
12433 */
12434static hda_nid_t alc660vd_dac_nids[3] = {
12435 /* front, rear, clfe, rear_surr */
12436 0x02, 0x04, 0x03
12437};
12438
12439static hda_nid_t alc861vd_adc_nids[1] = {
12440 /* ADC0 */
12441 0x09,
12442};
12443
12444static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
12445
12446/* input MUX */
12447/* FIXME: should be a matrix-type input source selection */
12448static struct hda_input_mux alc861vd_capture_source = {
12449 .num_items = 4,
12450 .items = {
12451 { "Mic", 0x0 },
12452 { "Front Mic", 0x1 },
12453 { "Line", 0x2 },
12454 { "CD", 0x4 },
12455 },
12456};
12457
12458static struct hda_input_mux alc861vd_dallas_capture_source = {
12459 .num_items = 2,
12460 .items = {
12461 { "Ext Mic", 0x0 },
12462 { "Int Mic", 0x1 },
12463 },
12464};
12465
12466static struct hda_input_mux alc861vd_hp_capture_source = {
12467 .num_items = 2,
12468 .items = {
12469 { "Front Mic", 0x0 },
12470 { "ATAPI Mic", 0x1 },
12471 },
12472};
12473
12474#define alc861vd_mux_enum_info alc_mux_enum_info
12475#define alc861vd_mux_enum_get alc_mux_enum_get
12476/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
12477#define alc861vd_mux_enum_put alc882_mux_enum_put
12478
12479/*
12480 * 2ch mode
12481 */
12482static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
12483 { 2, NULL }
12484};
12485
12486/*
12487 * 6ch mode
12488 */
12489static struct hda_verb alc861vd_6stack_ch6_init[] = {
12490 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12491 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12492 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12493 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12494 { } /* end */
12495};
12496
12497/*
12498 * 8ch mode
12499 */
12500static struct hda_verb alc861vd_6stack_ch8_init[] = {
12501 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12502 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12503 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12504 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12505 { } /* end */
12506};
12507
12508static struct hda_channel_mode alc861vd_6stack_modes[2] = {
12509 { 6, alc861vd_6stack_ch6_init },
12510 { 8, alc861vd_6stack_ch8_init },
12511};
12512
12513static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
12514 {
12515 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12516 .name = "Channel Mode",
12517 .info = alc_ch_mode_info,
12518 .get = alc_ch_mode_get,
12519 .put = alc_ch_mode_put,
12520 },
12521 { } /* end */
12522};
12523
12524static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
12525 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12526 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12527
12528 {
12529 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12530 /* The multiple "Capture Source" controls confuse alsamixer
12531 * So call somewhat different..
12532 */
12533 /* .name = "Capture Source", */
12534 .name = "Input Source",
12535 .count = 1,
12536 .info = alc861vd_mux_enum_info,
12537 .get = alc861vd_mux_enum_get,
12538 .put = alc861vd_mux_enum_put,
12539 },
12540 { } /* end */
12541};
12542
12543/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12544 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12545 */
12546static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
12547 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12548 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12549
12550 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12551 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
12552
12553 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
12554 HDA_OUTPUT),
12555 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
12556 HDA_OUTPUT),
12557 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12558 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
12559
12560 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
12561 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
12562
12563 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12564
12565 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12567 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12568
12569 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12570 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12571 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12572
12573 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12574 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12575
12576 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12577 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12578
12579 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12580 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12581
12582 { } /* end */
12583};
12584
12585static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
12586 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12587 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12588
12589 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12590
12591 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12592 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12593 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12594
12595 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12596 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12597 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12598
12599 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12600 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12601
12602 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12603 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12604
12605 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12606 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12607
12608 { } /* end */
12609};
12610
12611static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
12612 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12613 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
12614 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12615
12616 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12617
12618 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12621
12622 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12623 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12624 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12625
12626 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12627 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12628
12629 { } /* end */
12630};
12631
12632/* Pin assignment: Speaker=0x14, HP = 0x15,
12633 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
12634 */
12635static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
12636 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12637 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
12638 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12639 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12640 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12641 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12642 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12643 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12644 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12645 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12646 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
12647 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
12648 { } /* end */
12649};
12650
12651/* Pin assignment: Speaker=0x14, Line-out = 0x15,
12652 * Front Mic=0x18, ATAPI Mic = 0x19,
12653 */
12654static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
12655 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12656 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
12657 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12658 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
12659 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12660 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12661 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12662 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12663
12664 { } /* end */
12665};
12666
12667/*
12668 * generic initialization of ADC, input mixers and output mixers
12669 */
12670static struct hda_verb alc861vd_volume_init_verbs[] = {
12671 /*
12672 * Unmute ADC0 and set the default input to mic-in
12673 */
12674 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12675 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12676
12677 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
12678 * the analog-loopback mixer widget
12679 */
12680 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12686
12687 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
12688 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12689 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12690 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12691 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
12692
12693 /*
12694 * Set up output mixers (0x02 - 0x05)
12695 */
12696 /* set vol=0 to output mixers */
12697 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12698 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12699 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12700 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12701
12702 /* set up input amps for analog loopback */
12703 /* Amp Indices: DAC = 0, mixer = 1 */
12704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12705 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12706 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12707 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12708 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12709 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12710 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12711 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12712
12713 { }
12714};
12715
12716/*
12717 * 3-stack pin configuration:
12718 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
12719 */
12720static struct hda_verb alc861vd_3stack_init_verbs[] = {
12721 /*
12722 * Set pin mode and muting
12723 */
12724 /* set front pin widgets 0x14 for output */
12725 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12726 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12727 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12728
12729 /* Mic (rear) pin: input vref at 80% */
12730 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12731 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12732 /* Front Mic pin: input vref at 80% */
12733 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12734 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12735 /* Line In pin: input */
12736 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12737 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12738 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12739 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12740 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12741 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12742 /* CD pin widget for input */
12743 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12744
12745 { }
12746};
12747
12748/*
12749 * 6-stack pin configuration:
12750 */
12751static struct hda_verb alc861vd_6stack_init_verbs[] = {
12752 /*
12753 * Set pin mode and muting
12754 */
12755 /* set front pin widgets 0x14 for output */
12756 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12757 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12758 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12759
12760 /* Rear Pin: output 1 (0x0d) */
12761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12763 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12764 /* CLFE Pin: output 2 (0x0e) */
12765 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12766 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12767 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
12768 /* Side Pin: output 3 (0x0f) */
12769 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12770 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12771 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
12772
12773 /* Mic (rear) pin: input vref at 80% */
12774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12776 /* Front Mic pin: input vref at 80% */
12777 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12778 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12779 /* Line In pin: input */
12780 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12781 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12782 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12783 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12784 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12785 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12786 /* CD pin widget for input */
12787 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12788
12789 { }
12790};
12791
12792static struct hda_verb alc861vd_eapd_verbs[] = {
12793 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12794 { }
12795};
12796
12797static struct hda_verb alc660vd_eapd_verbs[] = {
12798 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12799 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12800 { }
12801};
12802
12803static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12806 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12807 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12808 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12809 {}
12810};
12811
12812/* toggle speaker-output according to the hp-jack state */
12813static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12814{
12815 unsigned int present;
12816 unsigned char bits;
12817
12818 present = snd_hda_codec_read(codec, 0x1b, 0,
12819 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12820 bits = present ? HDA_AMP_MUTE : 0;
12821 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12822 HDA_AMP_MUTE, bits);
12823}
12824
12825static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12826{
12827 unsigned int present;
12828 unsigned char bits;
12829
12830 present = snd_hda_codec_read(codec, 0x18, 0,
12831 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12832 bits = present ? HDA_AMP_MUTE : 0;
12833 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12834 HDA_AMP_MUTE, bits);
12835}
12836
12837static void alc861vd_lenovo_automute(struct hda_codec *codec)
12838{
12839 alc861vd_lenovo_hp_automute(codec);
12840 alc861vd_lenovo_mic_automute(codec);
12841}
12842
12843static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12844 unsigned int res)
12845{
12846 switch (res >> 26) {
12847 case ALC880_HP_EVENT:
12848 alc861vd_lenovo_hp_automute(codec);
12849 break;
12850 case ALC880_MIC_EVENT:
12851 alc861vd_lenovo_mic_automute(codec);
12852 break;
12853 }
12854}
12855
12856static struct hda_verb alc861vd_dallas_verbs[] = {
12857 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12858 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12859 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12860 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12861
12862 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12864 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12865 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12866 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12867 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12868 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12869 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12870
12871 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12872 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12875 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12876 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12877 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12878 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12879
12880 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12881 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12882 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12883 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12884 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12885 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12886 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12887 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12888
12889 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12890 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12891 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12892 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12893
12894 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12895 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12896 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12897
12898 { } /* end */
12899};
12900
12901/* toggle speaker-output according to the hp-jack state */
12902static void alc861vd_dallas_automute(struct hda_codec *codec)
12903{
12904 unsigned int present;
12905
12906 present = snd_hda_codec_read(codec, 0x15, 0,
12907 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12908 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12909 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12910}
12911
12912static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12913{
12914 if ((res >> 26) == ALC880_HP_EVENT)
12915 alc861vd_dallas_automute(codec);
12916}
12917
12918#ifdef CONFIG_SND_HDA_POWER_SAVE
12919#define alc861vd_loopbacks alc880_loopbacks
12920#endif
12921
12922/* pcm configuration: identiacal with ALC880 */
12923#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12924#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12925#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12926#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12927
12928/*
12929 * configuration and preset
12930 */
12931static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12932 [ALC660VD_3ST] = "3stack-660",
12933 [ALC660VD_3ST_DIG] = "3stack-660-digout",
12934 [ALC861VD_3ST] = "3stack",
12935 [ALC861VD_3ST_DIG] = "3stack-digout",
12936 [ALC861VD_6ST_DIG] = "6stack-digout",
12937 [ALC861VD_LENOVO] = "lenovo",
12938 [ALC861VD_DALLAS] = "dallas",
12939 [ALC861VD_HP] = "hp",
12940 [ALC861VD_AUTO] = "auto",
12941};
12942
12943static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
12944 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12945 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
12946 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
12947 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
12948 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
12949 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
12950 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
12951 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
12952 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
12953 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
12954 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
12955 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
12956 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12957 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
12958 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
12959 {}
12960};
12961
12962static struct alc_config_preset alc861vd_presets[] = {
12963 [ALC660VD_3ST] = {
12964 .mixers = { alc861vd_3st_mixer },
12965 .init_verbs = { alc861vd_volume_init_verbs,
12966 alc861vd_3stack_init_verbs },
12967 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12968 .dac_nids = alc660vd_dac_nids,
12969 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12970 .channel_mode = alc861vd_3stack_2ch_modes,
12971 .input_mux = &alc861vd_capture_source,
12972 },
12973 [ALC660VD_3ST_DIG] = {
12974 .mixers = { alc861vd_3st_mixer },
12975 .init_verbs = { alc861vd_volume_init_verbs,
12976 alc861vd_3stack_init_verbs },
12977 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12978 .dac_nids = alc660vd_dac_nids,
12979 .dig_out_nid = ALC861VD_DIGOUT_NID,
12980 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12981 .channel_mode = alc861vd_3stack_2ch_modes,
12982 .input_mux = &alc861vd_capture_source,
12983 },
12984 [ALC861VD_3ST] = {
12985 .mixers = { alc861vd_3st_mixer },
12986 .init_verbs = { alc861vd_volume_init_verbs,
12987 alc861vd_3stack_init_verbs },
12988 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12989 .dac_nids = alc861vd_dac_nids,
12990 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12991 .channel_mode = alc861vd_3stack_2ch_modes,
12992 .input_mux = &alc861vd_capture_source,
12993 },
12994 [ALC861VD_3ST_DIG] = {
12995 .mixers = { alc861vd_3st_mixer },
12996 .init_verbs = { alc861vd_volume_init_verbs,
12997 alc861vd_3stack_init_verbs },
12998 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12999 .dac_nids = alc861vd_dac_nids,
13000 .dig_out_nid = ALC861VD_DIGOUT_NID,
13001 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13002 .channel_mode = alc861vd_3stack_2ch_modes,
13003 .input_mux = &alc861vd_capture_source,
13004 },
13005 [ALC861VD_6ST_DIG] = {
13006 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13007 .init_verbs = { alc861vd_volume_init_verbs,
13008 alc861vd_6stack_init_verbs },
13009 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13010 .dac_nids = alc861vd_dac_nids,
13011 .dig_out_nid = ALC861VD_DIGOUT_NID,
13012 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13013 .channel_mode = alc861vd_6stack_modes,
13014 .input_mux = &alc861vd_capture_source,
13015 },
13016 [ALC861VD_LENOVO] = {
13017 .mixers = { alc861vd_lenovo_mixer },
13018 .init_verbs = { alc861vd_volume_init_verbs,
13019 alc861vd_3stack_init_verbs,
13020 alc861vd_eapd_verbs,
13021 alc861vd_lenovo_unsol_verbs },
13022 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13023 .dac_nids = alc660vd_dac_nids,
13024 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13025 .channel_mode = alc861vd_3stack_2ch_modes,
13026 .input_mux = &alc861vd_capture_source,
13027 .unsol_event = alc861vd_lenovo_unsol_event,
13028 .init_hook = alc861vd_lenovo_automute,
13029 },
13030 [ALC861VD_DALLAS] = {
13031 .mixers = { alc861vd_dallas_mixer },
13032 .init_verbs = { alc861vd_dallas_verbs },
13033 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13034 .dac_nids = alc861vd_dac_nids,
13035 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13036 .channel_mode = alc861vd_3stack_2ch_modes,
13037 .input_mux = &alc861vd_dallas_capture_source,
13038 .unsol_event = alc861vd_dallas_unsol_event,
13039 .init_hook = alc861vd_dallas_automute,
13040 },
13041 [ALC861VD_HP] = {
13042 .mixers = { alc861vd_hp_mixer },
13043 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13044 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13045 .dac_nids = alc861vd_dac_nids,
13046 .dig_out_nid = ALC861VD_DIGOUT_NID,
13047 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13048 .channel_mode = alc861vd_3stack_2ch_modes,
13049 .input_mux = &alc861vd_hp_capture_source,
13050 .unsol_event = alc861vd_dallas_unsol_event,
13051 .init_hook = alc861vd_dallas_automute,
13052 },
13053};
13054
13055/*
13056 * BIOS auto configuration
13057 */
13058static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13059 hda_nid_t nid, int pin_type, int dac_idx)
13060{
13061 alc_set_pin_output(codec, nid, pin_type);
13062}
13063
13064static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13065{
13066 struct alc_spec *spec = codec->spec;
13067 int i;
13068
13069 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
13070 for (i = 0; i <= HDA_SIDE; i++) {
13071 hda_nid_t nid = spec->autocfg.line_out_pins[i];
13072 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13073 if (nid)
13074 alc861vd_auto_set_output_and_unmute(codec, nid,
13075 pin_type, i);
13076 }
13077}
13078
13079
13080static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
13081{
13082 struct alc_spec *spec = codec->spec;
13083 hda_nid_t pin;
13084
13085 pin = spec->autocfg.hp_pins[0];
13086 if (pin) /* connect to front and use dac 0 */
13087 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13088 pin = spec->autocfg.speaker_pins[0];
13089 if (pin)
13090 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
13091}
13092
13093#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
13094#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
13095
13096static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
13097{
13098 struct alc_spec *spec = codec->spec;
13099 int i;
13100
13101 for (i = 0; i < AUTO_PIN_LAST; i++) {
13102 hda_nid_t nid = spec->autocfg.input_pins[i];
13103 if (alc861vd_is_input_pin(nid)) {
13104 snd_hda_codec_write(codec, nid, 0,
13105 AC_VERB_SET_PIN_WIDGET_CONTROL,
13106 i <= AUTO_PIN_FRONT_MIC ?
13107 PIN_VREF80 : PIN_IN);
13108 if (nid != ALC861VD_PIN_CD_NID)
13109 snd_hda_codec_write(codec, nid, 0,
13110 AC_VERB_SET_AMP_GAIN_MUTE,
13111 AMP_OUT_MUTE);
13112 }
13113 }
13114}
13115
13116#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
13117#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
13118
13119/* add playback controls from the parsed DAC table */
13120/* Based on ALC880 version. But ALC861VD has separate,
13121 * different NIDs for mute/unmute switch and volume control */
13122static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
13123 const struct auto_pin_cfg *cfg)
13124{
13125 char name[32];
13126 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
13127 hda_nid_t nid_v, nid_s;
13128 int i, err;
13129
13130 for (i = 0; i < cfg->line_outs; i++) {
13131 if (!spec->multiout.dac_nids[i])
13132 continue;
13133 nid_v = alc861vd_idx_to_mixer_vol(
13134 alc880_dac_to_idx(
13135 spec->multiout.dac_nids[i]));
13136 nid_s = alc861vd_idx_to_mixer_switch(
13137 alc880_dac_to_idx(
13138 spec->multiout.dac_nids[i]));
13139
13140 if (i == 2) {
13141 /* Center/LFE */
13142 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13143 "Center Playback Volume",
13144 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
13145 HDA_OUTPUT));
13146 if (err < 0)
13147 return err;
13148 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13149 "LFE Playback Volume",
13150 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
13151 HDA_OUTPUT));
13152 if (err < 0)
13153 return err;
13154 err = add_control(spec, ALC_CTL_BIND_MUTE,
13155 "Center Playback Switch",
13156 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
13157 HDA_INPUT));
13158 if (err < 0)
13159 return err;
13160 err = add_control(spec, ALC_CTL_BIND_MUTE,
13161 "LFE Playback Switch",
13162 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
13163 HDA_INPUT));
13164 if (err < 0)
13165 return err;
13166 } else {
13167 sprintf(name, "%s Playback Volume", chname[i]);
13168 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13169 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
13170 HDA_OUTPUT));
13171 if (err < 0)
13172 return err;
13173 sprintf(name, "%s Playback Switch", chname[i]);
13174 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13175 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
13176 HDA_INPUT));
13177 if (err < 0)
13178 return err;
13179 }
13180 }
13181 return 0;
13182}
13183
13184/* add playback controls for speaker and HP outputs */
13185/* Based on ALC880 version. But ALC861VD has separate,
13186 * different NIDs for mute/unmute switch and volume control */
13187static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
13188 hda_nid_t pin, const char *pfx)
13189{
13190 hda_nid_t nid_v, nid_s;
13191 int err;
13192 char name[32];
13193
13194 if (!pin)
13195 return 0;
13196
13197 if (alc880_is_fixed_pin(pin)) {
13198 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13199 /* specify the DAC as the extra output */
13200 if (!spec->multiout.hp_nid)
13201 spec->multiout.hp_nid = nid_v;
13202 else
13203 spec->multiout.extra_out_nid[0] = nid_v;
13204 /* control HP volume/switch on the output mixer amp */
13205 nid_v = alc861vd_idx_to_mixer_vol(
13206 alc880_fixed_pin_idx(pin));
13207 nid_s = alc861vd_idx_to_mixer_switch(
13208 alc880_fixed_pin_idx(pin));
13209
13210 sprintf(name, "%s Playback Volume", pfx);
13211 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13212 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
13213 if (err < 0)
13214 return err;
13215 sprintf(name, "%s Playback Switch", pfx);
13216 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13217 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
13218 if (err < 0)
13219 return err;
13220 } else if (alc880_is_multi_pin(pin)) {
13221 /* set manual connection */
13222 /* we have only a switch on HP-out PIN */
13223 sprintf(name, "%s Playback Switch", pfx);
13224 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13225 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13226 if (err < 0)
13227 return err;
13228 }
13229 return 0;
13230}
13231
13232/* parse the BIOS configuration and set up the alc_spec
13233 * return 1 if successful, 0 if the proper config is not found,
13234 * or a negative error code
13235 * Based on ALC880 version - had to change it to override
13236 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
13237static int alc861vd_parse_auto_config(struct hda_codec *codec)
13238{
13239 struct alc_spec *spec = codec->spec;
13240 int err;
13241 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
13242
13243 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13244 alc861vd_ignore);
13245 if (err < 0)
13246 return err;
13247 if (!spec->autocfg.line_outs)
13248 return 0; /* can't find valid BIOS pin config */
13249
13250 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13251 if (err < 0)
13252 return err;
13253 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
13254 if (err < 0)
13255 return err;
13256 err = alc861vd_auto_create_extra_out(spec,
13257 spec->autocfg.speaker_pins[0],
13258 "Speaker");
13259 if (err < 0)
13260 return err;
13261 err = alc861vd_auto_create_extra_out(spec,
13262 spec->autocfg.hp_pins[0],
13263 "Headphone");
13264 if (err < 0)
13265 return err;
13266 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
13267 if (err < 0)
13268 return err;
13269
13270 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13271
13272 if (spec->autocfg.dig_out_pin)
13273 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
13274
13275 if (spec->kctl_alloc)
13276 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13277
13278 spec->init_verbs[spec->num_init_verbs++]
13279 = alc861vd_volume_init_verbs;
13280
13281 spec->num_mux_defs = 1;
13282 spec->input_mux = &spec->private_imux;
13283
13284 err = alc_auto_add_mic_boost(codec);
13285 if (err < 0)
13286 return err;
13287
13288 return 1;
13289}
13290
13291/* additional initialization for auto-configuration model */
13292static void alc861vd_auto_init(struct hda_codec *codec)
13293{
13294 struct alc_spec *spec = codec->spec;
13295 alc861vd_auto_init_multi_out(codec);
13296 alc861vd_auto_init_hp_out(codec);
13297 alc861vd_auto_init_analog_input(codec);
13298 if (spec->unsol_event)
13299 alc_sku_automute(codec);
13300}
13301
13302static int patch_alc861vd(struct hda_codec *codec)
13303{
13304 struct alc_spec *spec;
13305 int err, board_config;
13306
13307 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13308 if (spec == NULL)
13309 return -ENOMEM;
13310
13311 codec->spec = spec;
13312
13313 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
13314 alc861vd_models,
13315 alc861vd_cfg_tbl);
13316
13317 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
13318 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
13319 "ALC861VD, trying auto-probe from BIOS...\n");
13320 board_config = ALC861VD_AUTO;
13321 }
13322
13323 if (board_config == ALC861VD_AUTO) {
13324 /* automatic parse from the BIOS config */
13325 err = alc861vd_parse_auto_config(codec);
13326 if (err < 0) {
13327 alc_free(codec);
13328 return err;
13329 } else if (!err) {
13330 printk(KERN_INFO
13331 "hda_codec: Cannot set up configuration "
13332 "from BIOS. Using base mode...\n");
13333 board_config = ALC861VD_3ST;
13334 }
13335 }
13336
13337 if (board_config != ALC861VD_AUTO)
13338 setup_preset(spec, &alc861vd_presets[board_config]);
13339
13340 if (codec->vendor_id == 0x10ec0660) {
13341 spec->stream_name_analog = "ALC660-VD Analog";
13342 spec->stream_name_digital = "ALC660-VD Digital";
13343 /* always turn on EAPD */
13344 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
13345 } else {
13346 spec->stream_name_analog = "ALC861VD Analog";
13347 spec->stream_name_digital = "ALC861VD Digital";
13348 }
13349
13350 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
13351 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
13352
13353 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
13354 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
13355
13356 spec->adc_nids = alc861vd_adc_nids;
13357 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
13358 spec->capsrc_nids = alc861vd_capsrc_nids;
13359
13360 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
13361 spec->num_mixers++;
13362
13363 spec->vmaster_nid = 0x02;
13364
13365 codec->patch_ops = alc_patch_ops;
13366
13367 if (board_config == ALC861VD_AUTO)
13368 spec->init_hook = alc861vd_auto_init;
13369#ifdef CONFIG_SND_HDA_POWER_SAVE
13370 if (!spec->loopback.amplist)
13371 spec->loopback.amplist = alc861vd_loopbacks;
13372#endif
13373
13374 return 0;
13375}
13376
13377/*
13378 * ALC662 support
13379 *
13380 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
13381 * configuration. Each pin widget can choose any input DACs and a mixer.
13382 * Each ADC is connected from a mixer of all inputs. This makes possible
13383 * 6-channel independent captures.
13384 *
13385 * In addition, an independent DAC for the multi-playback (not used in this
13386 * driver yet).
13387 */
13388#define ALC662_DIGOUT_NID 0x06
13389#define ALC662_DIGIN_NID 0x0a
13390
13391static hda_nid_t alc662_dac_nids[4] = {
13392 /* front, rear, clfe, rear_surr */
13393 0x02, 0x03, 0x04
13394};
13395
13396static hda_nid_t alc662_adc_nids[1] = {
13397 /* ADC1-2 */
13398 0x09,
13399};
13400
13401static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
13402
13403/* input MUX */
13404/* FIXME: should be a matrix-type input source selection */
13405static struct hda_input_mux alc662_capture_source = {
13406 .num_items = 4,
13407 .items = {
13408 { "Mic", 0x0 },
13409 { "Front Mic", 0x1 },
13410 { "Line", 0x2 },
13411 { "CD", 0x4 },
13412 },
13413};
13414
13415static struct hda_input_mux alc662_lenovo_101e_capture_source = {
13416 .num_items = 2,
13417 .items = {
13418 { "Mic", 0x1 },
13419 { "Line", 0x2 },
13420 },
13421};
13422
13423static struct hda_input_mux alc662_eeepc_capture_source = {
13424 .num_items = 2,
13425 .items = {
13426 { "i-Mic", 0x1 },
13427 { "e-Mic", 0x0 },
13428 },
13429};
13430
13431static struct hda_input_mux alc663_capture_source = {
13432 .num_items = 3,
13433 .items = {
13434 { "Mic", 0x0 },
13435 { "Front Mic", 0x1 },
13436 { "Line", 0x2 },
13437 },
13438};
13439
13440static struct hda_input_mux alc663_m51va_capture_source = {
13441 .num_items = 2,
13442 .items = {
13443 { "Ext-Mic", 0x0 },
13444 { "D-Mic", 0x9 },
13445 },
13446};
13447
13448#define alc662_mux_enum_info alc_mux_enum_info
13449#define alc662_mux_enum_get alc_mux_enum_get
13450#define alc662_mux_enum_put alc882_mux_enum_put
13451
13452/*
13453 * 2ch mode
13454 */
13455static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
13456 { 2, NULL }
13457};
13458
13459/*
13460 * 2ch mode
13461 */
13462static struct hda_verb alc662_3ST_ch2_init[] = {
13463 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
13464 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13465 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
13466 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
13467 { } /* end */
13468};
13469
13470/*
13471 * 6ch mode
13472 */
13473static struct hda_verb alc662_3ST_ch6_init[] = {
13474 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13475 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13476 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
13477 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13478 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
13479 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
13480 { } /* end */
13481};
13482
13483static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
13484 { 2, alc662_3ST_ch2_init },
13485 { 6, alc662_3ST_ch6_init },
13486};
13487
13488/*
13489 * 2ch mode
13490 */
13491static struct hda_verb alc662_sixstack_ch6_init[] = {
13492 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13493 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13494 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13495 { } /* end */
13496};
13497
13498/*
13499 * 6ch mode
13500 */
13501static struct hda_verb alc662_sixstack_ch8_init[] = {
13502 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13503 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13504 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13505 { } /* end */
13506};
13507
13508static struct hda_channel_mode alc662_5stack_modes[2] = {
13509 { 2, alc662_sixstack_ch6_init },
13510 { 6, alc662_sixstack_ch8_init },
13511};
13512
13513/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13514 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13515 */
13516
13517static struct snd_kcontrol_new alc662_base_mixer[] = {
13518 /* output mixer control */
13519 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13520 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
13521 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13522 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
13523 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13524 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13525 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13526 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
13527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13528
13529 /*Input mixer control */
13530 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
13531 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
13532 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
13533 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
13534 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
13535 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
13536 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
13537 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
13538 { } /* end */
13539};
13540
13541static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
13542 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13543 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
13544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13545 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13546 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13547 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13548 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13551 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13552 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13553 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13554 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13555 { } /* end */
13556};
13557
13558static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
13559 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13560 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
13561 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13562 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
13563 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13564 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13565 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
13566 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
13567 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13568 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13569 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13570 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13571 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13574 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13575 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13576 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13577 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13578 { } /* end */
13579};
13580
13581static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
13582 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13583 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
13584 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13585 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
13586 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13587 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13588 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13591 { } /* end */
13592};
13593
13594static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
13595 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13596
13597 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13598 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13599
13600 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
13601 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13602 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13603
13604 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
13605 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13606 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13607 { } /* end */
13608};
13609
13610static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
13611 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13612 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13613 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13614 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
13615 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
13616 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
13617 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
13618 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
13619 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13620 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
13621 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13622 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13623 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13624 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13625 { } /* end */
13626};
13627
13628static struct snd_kcontrol_new alc663_m51va_mixer[] = {
13629 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13630 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13631 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13633 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13634 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
13635 { } /* end */
13636};
13637
13638static struct snd_kcontrol_new alc663_g71v_mixer[] = {
13639 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13640 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13641 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13642 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13644
13645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13647 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13648 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13649 { } /* end */
13650};
13651
13652static struct snd_kcontrol_new alc663_g50v_mixer[] = {
13653 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13654 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13656
13657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13659 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13660 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13661 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13662 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13663 { } /* end */
13664};
13665
13666static struct snd_kcontrol_new alc662_chmode_mixer[] = {
13667 {
13668 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13669 .name = "Channel Mode",
13670 .info = alc_ch_mode_info,
13671 .get = alc_ch_mode_get,
13672 .put = alc_ch_mode_put,
13673 },
13674 { } /* end */
13675};
13676
13677static struct hda_verb alc662_init_verbs[] = {
13678 /* ADC: mute amp left and right */
13679 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13680 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13681 /* Front mixer: unmute input/output amp left and right (volume = 0) */
13682
13683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13686 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13687 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13688
13689 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13690 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13691 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13692 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13693 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13694 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13695
13696 /* Front Pin: output 0 (0x0c) */
13697 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13698 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13699
13700 /* Rear Pin: output 1 (0x0d) */
13701 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13702 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13703
13704 /* CLFE Pin: output 2 (0x0e) */
13705 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13706 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13707
13708 /* Mic (rear) pin: input vref at 80% */
13709 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13710 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13711 /* Front Mic pin: input vref at 80% */
13712 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13713 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13714 /* Line In pin: input */
13715 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13716 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13717 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13718 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13719 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13720 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13721 /* CD pin widget for input */
13722 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13723
13724 /* FIXME: use matrix-type input source selection */
13725 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13726 /* Input mixer */
13727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
13731
13732 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13733 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13734 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13735 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
13736
13737 /* always trun on EAPD */
13738 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13739 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13740
13741 { }
13742};
13743
13744static struct hda_verb alc662_sue_init_verbs[] = {
13745 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13746 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
13747 {}
13748};
13749
13750static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
13751 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13752 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13753 {}
13754};
13755
13756/* Set Unsolicited Event*/
13757static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
13758 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13759 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13760 {}
13761};
13762
13763/*
13764 * generic initialization of ADC, input mixers and output mixers
13765 */
13766static struct hda_verb alc662_auto_init_verbs[] = {
13767 /*
13768 * Unmute ADC and set the default input to mic-in
13769 */
13770 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13771 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13772
13773 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
13774 * mixer widget
13775 * Note: PASD motherboards uses the Line In 2 as the input for front
13776 * panel mic (mic 2)
13777 */
13778 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13779 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13780 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13781 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13782 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13783 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13784
13785 /*
13786 * Set up output mixers (0x0c - 0x0f)
13787 */
13788 /* set vol=0 to output mixers */
13789 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13790 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13791 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13792
13793 /* set up input amps for analog loopback */
13794 /* Amp Indices: DAC = 0, mixer = 1 */
13795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13796 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13797 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13798 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13799 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13800 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13801
13802
13803 /* FIXME: use matrix-type input source selection */
13804 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
13805 /* Input mixer */
13806 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13807 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13808 { }
13809};
13810
13811static struct hda_verb alc663_m51va_init_verbs[] = {
13812 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13813 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13814 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13815
13816 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
13817
13818 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13819 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13820 {}
13821};
13822
13823static struct hda_verb alc663_g71v_init_verbs[] = {
13824 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13825 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
13826 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
13827
13828 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13829 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13830 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13831
13832 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
13833 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
13834 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
13835 {}
13836};
13837
13838static struct hda_verb alc663_g50v_init_verbs[] = {
13839 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13840 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13841 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
13842
13843 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13844 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13845 {}
13846};
13847
13848/* capture mixer elements */
13849static struct snd_kcontrol_new alc662_capture_mixer[] = {
13850 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13851 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13852 {
13853 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13854 /* The multiple "Capture Source" controls confuse alsamixer
13855 * So call somewhat different..
13856 */
13857 /* .name = "Capture Source", */
13858 .name = "Input Source",
13859 .count = 1,
13860 .info = alc662_mux_enum_info,
13861 .get = alc662_mux_enum_get,
13862 .put = alc662_mux_enum_put,
13863 },
13864 { } /* end */
13865};
13866
13867static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13868{
13869 unsigned int present;
13870 unsigned char bits;
13871
13872 present = snd_hda_codec_read(codec, 0x14, 0,
13873 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13874 bits = present ? HDA_AMP_MUTE : 0;
13875 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13876 HDA_AMP_MUTE, bits);
13877}
13878
13879static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13880{
13881 unsigned int present;
13882 unsigned char bits;
13883
13884 present = snd_hda_codec_read(codec, 0x1b, 0,
13885 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13886 bits = present ? HDA_AMP_MUTE : 0;
13887 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13888 HDA_AMP_MUTE, bits);
13889 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13890 HDA_AMP_MUTE, bits);
13891}
13892
13893static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13894 unsigned int res)
13895{
13896 if ((res >> 26) == ALC880_HP_EVENT)
13897 alc662_lenovo_101e_all_automute(codec);
13898 if ((res >> 26) == ALC880_FRONT_EVENT)
13899 alc662_lenovo_101e_ispeaker_automute(codec);
13900}
13901
13902static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13903{
13904 unsigned int present;
13905
13906 present = snd_hda_codec_read(codec, 0x18, 0,
13907 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13908 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13909 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13910 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13911 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13912 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13913 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13914 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13915 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13916}
13917
13918/* unsolicited event for HP jack sensing */
13919static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13920 unsigned int res)
13921{
13922 if ((res >> 26) == ALC880_HP_EVENT)
13923 alc262_hippo1_automute( codec );
13924
13925 if ((res >> 26) == ALC880_MIC_EVENT)
13926 alc662_eeepc_mic_automute(codec);
13927}
13928
13929static void alc662_eeepc_inithook(struct hda_codec *codec)
13930{
13931 alc262_hippo1_automute( codec );
13932 alc662_eeepc_mic_automute(codec);
13933}
13934
13935static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13936{
13937 unsigned int mute;
13938 unsigned int present;
13939
13940 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13941 present = snd_hda_codec_read(codec, 0x14, 0,
13942 AC_VERB_GET_PIN_SENSE, 0);
13943 present = (present & 0x80000000) != 0;
13944 if (present) {
13945 /* mute internal speaker */
13946 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13947 HDA_AMP_MUTE, HDA_AMP_MUTE);
13948 } else {
13949 /* unmute internal speaker if necessary */
13950 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13951 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13952 HDA_AMP_MUTE, mute);
13953 }
13954}
13955
13956/* unsolicited event for HP jack sensing */
13957static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13958 unsigned int res)
13959{
13960 if ((res >> 26) == ALC880_HP_EVENT)
13961 alc662_eeepc_ep20_automute(codec);
13962}
13963
13964static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13965{
13966 alc662_eeepc_ep20_automute(codec);
13967}
13968
13969static void alc663_m51va_speaker_automute(struct hda_codec *codec)
13970{
13971 unsigned int present;
13972 unsigned char bits;
13973
13974 present = snd_hda_codec_read(codec, 0x21, 0,
13975 AC_VERB_GET_PIN_SENSE, 0)
13976 & AC_PINSENSE_PRESENCE;
13977 bits = present ? HDA_AMP_MUTE : 0;
13978 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13979 HDA_AMP_MUTE, bits);
13980}
13981
13982static void alc663_m51va_mic_automute(struct hda_codec *codec)
13983{
13984 unsigned int present;
13985
13986 present = snd_hda_codec_read(codec, 0x18, 0,
13987 AC_VERB_GET_PIN_SENSE, 0)
13988 & AC_PINSENSE_PRESENCE;
13989 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13990 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13991 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13992 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13993 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13994 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
13995 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13996 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
13997}
13998
13999static void alc663_m51va_unsol_event(struct hda_codec *codec,
14000 unsigned int res)
14001{
14002 switch (res >> 26) {
14003 case ALC880_HP_EVENT:
14004 alc663_m51va_speaker_automute(codec);
14005 break;
14006 case ALC880_MIC_EVENT:
14007 alc663_m51va_mic_automute(codec);
14008 break;
14009 }
14010}
14011
14012static void alc663_m51va_inithook(struct hda_codec *codec)
14013{
14014 alc663_m51va_speaker_automute(codec);
14015 alc663_m51va_mic_automute(codec);
14016}
14017
14018static void alc663_g71v_hp_automute(struct hda_codec *codec)
14019{
14020 unsigned int present;
14021 unsigned char bits;
14022
14023 present = snd_hda_codec_read(codec, 0x21, 0,
14024 AC_VERB_GET_PIN_SENSE, 0)
14025 & AC_PINSENSE_PRESENCE;
14026 bits = present ? HDA_AMP_MUTE : 0;
14027 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14028 HDA_AMP_MUTE, bits);
14029 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14030 HDA_AMP_MUTE, bits);
14031}
14032
14033static void alc663_g71v_front_automute(struct hda_codec *codec)
14034{
14035 unsigned int present;
14036 unsigned char bits;
14037
14038 present = snd_hda_codec_read(codec, 0x15, 0,
14039 AC_VERB_GET_PIN_SENSE, 0)
14040 & AC_PINSENSE_PRESENCE;
14041 bits = present ? HDA_AMP_MUTE : 0;
14042 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14043 HDA_AMP_MUTE, bits);
14044}
14045
14046static void alc663_g71v_unsol_event(struct hda_codec *codec,
14047 unsigned int res)
14048{
14049 switch (res >> 26) {
14050 case ALC880_HP_EVENT:
14051 alc663_g71v_hp_automute(codec);
14052 break;
14053 case ALC880_FRONT_EVENT:
14054 alc663_g71v_front_automute(codec);
14055 break;
14056 case ALC880_MIC_EVENT:
14057 alc662_eeepc_mic_automute(codec);
14058 break;
14059 }
14060}
14061
14062static void alc663_g71v_inithook(struct hda_codec *codec)
14063{
14064 alc663_g71v_front_automute(codec);
14065 alc663_g71v_hp_automute(codec);
14066 alc662_eeepc_mic_automute(codec);
14067}
14068
14069static void alc663_g50v_unsol_event(struct hda_codec *codec,
14070 unsigned int res)
14071{
14072 switch (res >> 26) {
14073 case ALC880_HP_EVENT:
14074 alc663_m51va_speaker_automute(codec);
14075 break;
14076 case ALC880_MIC_EVENT:
14077 alc662_eeepc_mic_automute(codec);
14078 break;
14079 }
14080}
14081
14082static void alc663_g50v_inithook(struct hda_codec *codec)
14083{
14084 alc663_m51va_speaker_automute(codec);
14085 alc662_eeepc_mic_automute(codec);
14086}
14087
14088#ifdef CONFIG_SND_HDA_POWER_SAVE
14089#define alc662_loopbacks alc880_loopbacks
14090#endif
14091
14092
14093/* pcm configuration: identiacal with ALC880 */
14094#define alc662_pcm_analog_playback alc880_pcm_analog_playback
14095#define alc662_pcm_analog_capture alc880_pcm_analog_capture
14096#define alc662_pcm_digital_playback alc880_pcm_digital_playback
14097#define alc662_pcm_digital_capture alc880_pcm_digital_capture
14098
14099/*
14100 * configuration and preset
14101 */
14102static const char *alc662_models[ALC662_MODEL_LAST] = {
14103 [ALC662_3ST_2ch_DIG] = "3stack-dig",
14104 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
14105 [ALC662_3ST_6ch] = "3stack-6ch",
14106 [ALC662_5ST_DIG] = "6stack-dig",
14107 [ALC662_LENOVO_101E] = "lenovo-101e",
14108 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
14109 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
14110 [ALC663_ASUS_M51VA] = "m51va",
14111 [ALC663_ASUS_G71V] = "g71v",
14112 [ALC663_ASUS_H13] = "h13",
14113 [ALC663_ASUS_G50V] = "g50v",
14114 [ALC662_AUTO] = "auto",
14115};
14116
14117static struct snd_pci_quirk alc662_cfg_tbl[] = {
14118 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
14119 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
14120 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
14121 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
14122 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
14123 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
14124 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
14125 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
14126 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
14127 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
14128 {}
14129};
14130
14131static struct alc_config_preset alc662_presets[] = {
14132 [ALC662_3ST_2ch_DIG] = {
14133 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
14134 .init_verbs = { alc662_init_verbs },
14135 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14136 .dac_nids = alc662_dac_nids,
14137 .dig_out_nid = ALC662_DIGOUT_NID,
14138 .dig_in_nid = ALC662_DIGIN_NID,
14139 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14140 .channel_mode = alc662_3ST_2ch_modes,
14141 .input_mux = &alc662_capture_source,
14142 },
14143 [ALC662_3ST_6ch_DIG] = {
14144 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14145 alc662_capture_mixer },
14146 .init_verbs = { alc662_init_verbs },
14147 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14148 .dac_nids = alc662_dac_nids,
14149 .dig_out_nid = ALC662_DIGOUT_NID,
14150 .dig_in_nid = ALC662_DIGIN_NID,
14151 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14152 .channel_mode = alc662_3ST_6ch_modes,
14153 .need_dac_fix = 1,
14154 .input_mux = &alc662_capture_source,
14155 },
14156 [ALC662_3ST_6ch] = {
14157 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14158 alc662_capture_mixer },
14159 .init_verbs = { alc662_init_verbs },
14160 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14161 .dac_nids = alc662_dac_nids,
14162 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14163 .channel_mode = alc662_3ST_6ch_modes,
14164 .need_dac_fix = 1,
14165 .input_mux = &alc662_capture_source,
14166 },
14167 [ALC662_5ST_DIG] = {
14168 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
14169 alc662_capture_mixer },
14170 .init_verbs = { alc662_init_verbs },
14171 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14172 .dac_nids = alc662_dac_nids,
14173 .dig_out_nid = ALC662_DIGOUT_NID,
14174 .dig_in_nid = ALC662_DIGIN_NID,
14175 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
14176 .channel_mode = alc662_5stack_modes,
14177 .input_mux = &alc662_capture_source,
14178 },
14179 [ALC662_LENOVO_101E] = {
14180 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
14181 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
14182 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14183 .dac_nids = alc662_dac_nids,
14184 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14185 .channel_mode = alc662_3ST_2ch_modes,
14186 .input_mux = &alc662_lenovo_101e_capture_source,
14187 .unsol_event = alc662_lenovo_101e_unsol_event,
14188 .init_hook = alc662_lenovo_101e_all_automute,
14189 },
14190 [ALC662_ASUS_EEEPC_P701] = {
14191 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
14192 .init_verbs = { alc662_init_verbs,
14193 alc662_eeepc_sue_init_verbs },
14194 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14195 .dac_nids = alc662_dac_nids,
14196 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14197 .channel_mode = alc662_3ST_2ch_modes,
14198 .input_mux = &alc662_eeepc_capture_source,
14199 .unsol_event = alc662_eeepc_unsol_event,
14200 .init_hook = alc662_eeepc_inithook,
14201 },
14202 [ALC662_ASUS_EEEPC_EP20] = {
14203 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
14204 alc662_chmode_mixer },
14205 .init_verbs = { alc662_init_verbs,
14206 alc662_eeepc_ep20_sue_init_verbs },
14207 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14208 .dac_nids = alc662_dac_nids,
14209 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14210 .channel_mode = alc662_3ST_6ch_modes,
14211 .input_mux = &alc662_lenovo_101e_capture_source,
14212 .unsol_event = alc662_eeepc_ep20_unsol_event,
14213 .init_hook = alc662_eeepc_ep20_inithook,
14214 },
14215 [ALC663_ASUS_M51VA] = {
14216 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14217 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14218 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14219 .dac_nids = alc662_dac_nids,
14220 .dig_out_nid = ALC662_DIGOUT_NID,
14221 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14222 .channel_mode = alc662_3ST_2ch_modes,
14223 .input_mux = &alc663_m51va_capture_source,
14224 .unsol_event = alc663_m51va_unsol_event,
14225 .init_hook = alc663_m51va_inithook,
14226 },
14227 [ALC663_ASUS_G71V] = {
14228 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
14229 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
14230 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14231 .dac_nids = alc662_dac_nids,
14232 .dig_out_nid = ALC662_DIGOUT_NID,
14233 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14234 .channel_mode = alc662_3ST_2ch_modes,
14235 .input_mux = &alc662_eeepc_capture_source,
14236 .unsol_event = alc663_g71v_unsol_event,
14237 .init_hook = alc663_g71v_inithook,
14238 },
14239 [ALC663_ASUS_H13] = {
14240 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14241 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14242 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14243 .dac_nids = alc662_dac_nids,
14244 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14245 .channel_mode = alc662_3ST_2ch_modes,
14246 .input_mux = &alc663_m51va_capture_source,
14247 .unsol_event = alc663_m51va_unsol_event,
14248 .init_hook = alc663_m51va_inithook,
14249 },
14250 [ALC663_ASUS_G50V] = {
14251 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
14252 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
14253 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14254 .dac_nids = alc662_dac_nids,
14255 .dig_out_nid = ALC662_DIGOUT_NID,
14256 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14257 .channel_mode = alc662_3ST_6ch_modes,
14258 .input_mux = &alc663_capture_source,
14259 .unsol_event = alc663_g50v_unsol_event,
14260 .init_hook = alc663_g50v_inithook,
14261 },
14262};
14263
14264
14265/*
14266 * BIOS auto configuration
14267 */
14268
14269/* add playback controls from the parsed DAC table */
14270static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
14271 const struct auto_pin_cfg *cfg)
14272{
14273 char name[32];
14274 static const char *chname[4] = {
14275 "Front", "Surround", NULL /*CLFE*/, "Side"
14276 };
14277 hda_nid_t nid;
14278 int i, err;
14279
14280 for (i = 0; i < cfg->line_outs; i++) {
14281 if (!spec->multiout.dac_nids[i])
14282 continue;
14283 nid = alc880_idx_to_dac(i);
14284 if (i == 2) {
14285 /* Center/LFE */
14286 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14287 "Center Playback Volume",
14288 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
14289 HDA_OUTPUT));
14290 if (err < 0)
14291 return err;
14292 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14293 "LFE Playback Volume",
14294 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
14295 HDA_OUTPUT));
14296 if (err < 0)
14297 return err;
14298 err = add_control(spec, ALC_CTL_BIND_MUTE,
14299 "Center Playback Switch",
14300 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
14301 HDA_INPUT));
14302 if (err < 0)
14303 return err;
14304 err = add_control(spec, ALC_CTL_BIND_MUTE,
14305 "LFE Playback Switch",
14306 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
14307 HDA_INPUT));
14308 if (err < 0)
14309 return err;
14310 } else {
14311 sprintf(name, "%s Playback Volume", chname[i]);
14312 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14313 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
14314 HDA_OUTPUT));
14315 if (err < 0)
14316 return err;
14317 sprintf(name, "%s Playback Switch", chname[i]);
14318 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14319 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
14320 HDA_INPUT));
14321 if (err < 0)
14322 return err;
14323 }
14324 }
14325 return 0;
14326}
14327
14328/* add playback controls for speaker and HP outputs */
14329static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
14330 const char *pfx)
14331{
14332 hda_nid_t nid;
14333 int err;
14334 char name[32];
14335
14336 if (!pin)
14337 return 0;
14338
14339 if (alc880_is_fixed_pin(pin)) {
14340 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14341 /* printk("DAC nid=%x\n",nid); */
14342 /* specify the DAC as the extra output */
14343 if (!spec->multiout.hp_nid)
14344 spec->multiout.hp_nid = nid;
14345 else
14346 spec->multiout.extra_out_nid[0] = nid;
14347 /* control HP volume/switch on the output mixer amp */
14348 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14349 sprintf(name, "%s Playback Volume", pfx);
14350 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14351 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
14352 if (err < 0)
14353 return err;
14354 sprintf(name, "%s Playback Switch", pfx);
14355 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14356 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
14357 if (err < 0)
14358 return err;
14359 } else if (alc880_is_multi_pin(pin)) {
14360 /* set manual connection */
14361 /* we have only a switch on HP-out PIN */
14362 sprintf(name, "%s Playback Switch", pfx);
14363 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14364 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14365 if (err < 0)
14366 return err;
14367 }
14368 return 0;
14369}
14370
14371/* create playback/capture controls for input pins */
14372static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
14373 const struct auto_pin_cfg *cfg)
14374{
14375 struct hda_input_mux *imux = &spec->private_imux;
14376 int i, err, idx;
14377
14378 for (i = 0; i < AUTO_PIN_LAST; i++) {
14379 if (alc880_is_input_pin(cfg->input_pins[i])) {
14380 idx = alc880_input_pin_idx(cfg->input_pins[i]);
14381 err = new_analog_input(spec, cfg->input_pins[i],
14382 auto_pin_cfg_labels[i],
14383 idx, 0x0b);
14384 if (err < 0)
14385 return err;
14386 imux->items[imux->num_items].label =
14387 auto_pin_cfg_labels[i];
14388 imux->items[imux->num_items].index =
14389 alc880_input_pin_idx(cfg->input_pins[i]);
14390 imux->num_items++;
14391 }
14392 }
14393 return 0;
14394}
14395
14396static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
14397 hda_nid_t nid, int pin_type,
14398 int dac_idx)
14399{
14400 alc_set_pin_output(codec, nid, pin_type);
14401 /* need the manual connection? */
14402 if (alc880_is_multi_pin(nid)) {
14403 struct alc_spec *spec = codec->spec;
14404 int idx = alc880_multi_pin_idx(nid);
14405 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
14406 AC_VERB_SET_CONNECT_SEL,
14407 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
14408 }
14409}
14410
14411static void alc662_auto_init_multi_out(struct hda_codec *codec)
14412{
14413 struct alc_spec *spec = codec->spec;
14414 int i;
14415
14416 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
14417 for (i = 0; i <= HDA_SIDE; i++) {
14418 hda_nid_t nid = spec->autocfg.line_out_pins[i];
14419 int pin_type = get_pin_type(spec->autocfg.line_out_type);
14420 if (nid)
14421 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
14422 i);
14423 }
14424}
14425
14426static void alc662_auto_init_hp_out(struct hda_codec *codec)
14427{
14428 struct alc_spec *spec = codec->spec;
14429 hda_nid_t pin;
14430
14431 pin = spec->autocfg.hp_pins[0];
14432 if (pin) /* connect to front */
14433 /* use dac 0 */
14434 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
14435 pin = spec->autocfg.speaker_pins[0];
14436 if (pin)
14437 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
14438}
14439
14440#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
14441#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
14442
14443static void alc662_auto_init_analog_input(struct hda_codec *codec)
14444{
14445 struct alc_spec *spec = codec->spec;
14446 int i;
14447
14448 for (i = 0; i < AUTO_PIN_LAST; i++) {
14449 hda_nid_t nid = spec->autocfg.input_pins[i];
14450 if (alc662_is_input_pin(nid)) {
14451 snd_hda_codec_write(codec, nid, 0,
14452 AC_VERB_SET_PIN_WIDGET_CONTROL,
14453 (i <= AUTO_PIN_FRONT_MIC ?
14454 PIN_VREF80 : PIN_IN));
14455 if (nid != ALC662_PIN_CD_NID)
14456 snd_hda_codec_write(codec, nid, 0,
14457 AC_VERB_SET_AMP_GAIN_MUTE,
14458 AMP_OUT_MUTE);
14459 }
14460 }
14461}
14462
14463static int alc662_parse_auto_config(struct hda_codec *codec)
14464{
14465 struct alc_spec *spec = codec->spec;
14466 int err;
14467 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
14468
14469 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14470 alc662_ignore);
14471 if (err < 0)
14472 return err;
14473 if (!spec->autocfg.line_outs)
14474 return 0; /* can't find valid BIOS pin config */
14475
14476 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14477 if (err < 0)
14478 return err;
14479 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
14480 if (err < 0)
14481 return err;
14482 err = alc662_auto_create_extra_out(spec,
14483 spec->autocfg.speaker_pins[0],
14484 "Speaker");
14485 if (err < 0)
14486 return err;
14487 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
14488 "Headphone");
14489 if (err < 0)
14490 return err;
14491 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
14492 if (err < 0)
14493 return err;
14494
14495 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14496
14497 if (spec->autocfg.dig_out_pin)
14498 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
14499
14500 if (spec->kctl_alloc)
14501 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14502
14503 spec->num_mux_defs = 1;
14504 spec->input_mux = &spec->private_imux;
14505
14506 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
14507 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
14508 spec->num_mixers++;
14509 return 1;
14510}
14511
14512/* additional initialization for auto-configuration model */
14513static void alc662_auto_init(struct hda_codec *codec)
14514{
14515 struct alc_spec *spec = codec->spec;
14516 alc662_auto_init_multi_out(codec);
14517 alc662_auto_init_hp_out(codec);
14518 alc662_auto_init_analog_input(codec);
14519 if (spec->unsol_event)
14520 alc_sku_automute(codec);
14521}
14522
14523static int patch_alc662(struct hda_codec *codec)
14524{
14525 struct alc_spec *spec;
14526 int err, board_config;
14527
14528 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14529 if (!spec)
14530 return -ENOMEM;
14531
14532 codec->spec = spec;
14533
14534 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
14535 alc662_models,
14536 alc662_cfg_tbl);
14537 if (board_config < 0) {
14538 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
14539 "trying auto-probe from BIOS...\n");
14540 board_config = ALC662_AUTO;
14541 }
14542
14543 if (board_config == ALC662_AUTO) {
14544 /* automatic parse from the BIOS config */
14545 err = alc662_parse_auto_config(codec);
14546 if (err < 0) {
14547 alc_free(codec);
14548 return err;
14549 } else if (!err) {
14550 printk(KERN_INFO
14551 "hda_codec: Cannot set up configuration "
14552 "from BIOS. Using base mode...\n");
14553 board_config = ALC662_3ST_2ch_DIG;
14554 }
14555 }
14556
14557 if (board_config != ALC662_AUTO)
14558 setup_preset(spec, &alc662_presets[board_config]);
14559
14560 if (codec->vendor_id == 0x10ec0663) {
14561 spec->stream_name_analog = "ALC663 Analog";
14562 spec->stream_name_digital = "ALC663 Digital";
14563 } else {
14564 spec->stream_name_analog = "ALC662 Analog";
14565 spec->stream_name_digital = "ALC662 Digital";
14566 }
14567
14568 spec->stream_analog_playback = &alc662_pcm_analog_playback;
14569 spec->stream_analog_capture = &alc662_pcm_analog_capture;
14570
14571 spec->stream_digital_playback = &alc662_pcm_digital_playback;
14572 spec->stream_digital_capture = &alc662_pcm_digital_capture;
14573
14574 spec->adc_nids = alc662_adc_nids;
14575 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
14576 spec->capsrc_nids = alc662_capsrc_nids;
14577
14578 spec->vmaster_nid = 0x02;
14579
14580 codec->patch_ops = alc_patch_ops;
14581 if (board_config == ALC662_AUTO)
14582 spec->init_hook = alc662_auto_init;
14583#ifdef CONFIG_SND_HDA_POWER_SAVE
14584 if (!spec->loopback.amplist)
14585 spec->loopback.amplist = alc662_loopbacks;
14586#endif
14587
14588 return 0;
14589}
14590
14591/*
14592 * patch entries
14593 */
14594struct hda_codec_preset snd_hda_preset_realtek[] = {
14595 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
14596 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
14597 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
14598 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
14599 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
14600 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
14601 .patch = patch_alc861 },
14602 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
14603 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
14604 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
14605 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
14606 .patch = patch_alc883 },
14607 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
14608 .patch = patch_alc662 },
14609 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
14610 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
14611 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
14612 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
14613 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
14614 .patch = patch_alc882 }, /* should be patch_alc883() in future */
14615 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
14616 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
14617 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
14618 {} /* terminator */
14619};