]> git.ipfire.org Git - thirdparty/linux.git/blame_incremental - sound/pci/hda/patch_realtek.c
[ALSA] hda-codec - Add SPDIF output support to AD1986a laptop-eapd model
[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
34#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02
36#define ALC880_HP_EVENT 0x04
37#define ALC880_MIC_EVENT 0x08
38
39/* ALC880 board config type */
40enum {
41 ALC880_3ST,
42 ALC880_3ST_DIG,
43 ALC880_5ST,
44 ALC880_5ST_DIG,
45 ALC880_W810,
46 ALC880_Z71V,
47 ALC880_6ST,
48 ALC880_6ST_DIG,
49 ALC880_F1734,
50 ALC880_ASUS,
51 ALC880_ASUS_DIG,
52 ALC880_ASUS_W1V,
53 ALC880_ASUS_DIG2,
54 ALC880_FUJITSU,
55 ALC880_UNIWILL_DIG,
56 ALC880_UNIWILL,
57 ALC880_UNIWILL_P53,
58 ALC880_CLEVO,
59 ALC880_TCL_S700,
60 ALC880_LG,
61 ALC880_LG_LW,
62#ifdef CONFIG_SND_DEBUG
63 ALC880_TEST,
64#endif
65 ALC880_AUTO,
66 ALC880_MODEL_LAST /* last tag */
67};
68
69/* ALC260 models */
70enum {
71 ALC260_BASIC,
72 ALC260_HP,
73 ALC260_HP_3013,
74 ALC260_FUJITSU_S702X,
75 ALC260_ACER,
76 ALC260_WILL,
77 ALC260_REPLACER_672V,
78#ifdef CONFIG_SND_DEBUG
79 ALC260_TEST,
80#endif
81 ALC260_AUTO,
82 ALC260_MODEL_LAST /* last tag */
83};
84
85/* ALC262 models */
86enum {
87 ALC262_BASIC,
88 ALC262_HIPPO,
89 ALC262_HIPPO_1,
90 ALC262_FUJITSU,
91 ALC262_HP_BPC,
92 ALC262_HP_BPC_D7000_WL,
93 ALC262_HP_BPC_D7000_WF,
94 ALC262_HP_TC_T5735,
95 ALC262_HP_RP5700,
96 ALC262_BENQ_ED8,
97 ALC262_SONY_ASSAMD,
98 ALC262_BENQ_T31,
99 ALC262_ULTRA,
100 ALC262_AUTO,
101 ALC262_MODEL_LAST /* last tag */
102};
103
104/* ALC268 models */
105enum {
106 ALC268_3ST,
107 ALC268_TOSHIBA,
108 ALC268_ACER,
109 ALC268_DELL,
110#ifdef CONFIG_SND_DEBUG
111 ALC268_TEST,
112#endif
113 ALC268_AUTO,
114 ALC268_MODEL_LAST /* last tag */
115};
116
117/* ALC269 models */
118enum {
119 ALC269_BASIC,
120 ALC269_AUTO,
121 ALC269_MODEL_LAST /* last tag */
122};
123
124/* ALC861 models */
125enum {
126 ALC861_3ST,
127 ALC660_3ST,
128 ALC861_3ST_DIG,
129 ALC861_6ST_DIG,
130 ALC861_UNIWILL_M31,
131 ALC861_TOSHIBA,
132 ALC861_ASUS,
133 ALC861_ASUS_LAPTOP,
134 ALC861_AUTO,
135 ALC861_MODEL_LAST,
136};
137
138/* ALC861-VD models */
139enum {
140 ALC660VD_3ST,
141 ALC660VD_3ST_DIG,
142 ALC861VD_3ST,
143 ALC861VD_3ST_DIG,
144 ALC861VD_6ST_DIG,
145 ALC861VD_LENOVO,
146 ALC861VD_DALLAS,
147 ALC861VD_HP,
148 ALC861VD_AUTO,
149 ALC861VD_MODEL_LAST,
150};
151
152/* ALC662 models */
153enum {
154 ALC662_3ST_2ch_DIG,
155 ALC662_3ST_6ch_DIG,
156 ALC662_3ST_6ch,
157 ALC662_5ST_DIG,
158 ALC662_LENOVO_101E,
159 ALC662_ASUS_EEEPC_P701,
160 ALC662_ASUS_EEEPC_EP20,
161 ALC662_AUTO,
162 ALC662_MODEL_LAST,
163};
164
165/* ALC882 models */
166enum {
167 ALC882_3ST_DIG,
168 ALC882_6ST_DIG,
169 ALC882_ARIMA,
170 ALC882_W2JC,
171 ALC882_TARGA,
172 ALC882_ASUS_A7J,
173 ALC882_ASUS_A7M,
174 ALC885_MACPRO,
175 ALC885_MBP3,
176 ALC885_IMAC24,
177 ALC882_AUTO,
178 ALC882_MODEL_LAST,
179};
180
181/* ALC883 models */
182enum {
183 ALC883_3ST_2ch_DIG,
184 ALC883_3ST_6ch_DIG,
185 ALC883_3ST_6ch,
186 ALC883_6ST_DIG,
187 ALC883_TARGA_DIG,
188 ALC883_TARGA_2ch_DIG,
189 ALC883_ACER,
190 ALC883_ACER_ASPIRE,
191 ALC883_MEDION,
192 ALC883_MEDION_MD2,
193 ALC883_LAPTOP_EAPD,
194 ALC883_LENOVO_101E_2ch,
195 ALC883_LENOVO_NB0763,
196 ALC888_LENOVO_MS7195_DIG,
197 ALC883_HAIER_W66,
198 ALC888_6ST_HP,
199 ALC888_3ST_HP,
200 ALC888_6ST_DELL,
201 ALC883_MITAC,
202 ALC883_AUTO,
203 ALC883_MODEL_LAST,
204};
205
206/* for GPIO Poll */
207#define GPIO_MASK 0x03
208
209struct alc_spec {
210 /* codec parameterization */
211 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
212 unsigned int num_mixers;
213
214 const struct hda_verb *init_verbs[5]; /* initialization verbs
215 * don't forget NULL
216 * termination!
217 */
218 unsigned int num_init_verbs;
219
220 char *stream_name_analog; /* analog PCM stream */
221 struct hda_pcm_stream *stream_analog_playback;
222 struct hda_pcm_stream *stream_analog_capture;
223 struct hda_pcm_stream *stream_analog_alt_playback;
224 struct hda_pcm_stream *stream_analog_alt_capture;
225
226 char *stream_name_digital; /* digital PCM stream */
227 struct hda_pcm_stream *stream_digital_playback;
228 struct hda_pcm_stream *stream_digital_capture;
229
230 /* playback */
231 struct hda_multi_out multiout; /* playback set-up
232 * max_channels, dacs must be set
233 * dig_out_nid and hp_nid are optional
234 */
235 hda_nid_t alt_dac_nid;
236
237 /* capture */
238 unsigned int num_adc_nids;
239 hda_nid_t *adc_nids;
240 hda_nid_t dig_in_nid; /* digital-in NID; optional */
241
242 /* capture source */
243 unsigned int num_mux_defs;
244 const struct hda_input_mux *input_mux;
245 unsigned int cur_mux[3];
246
247 /* channel model */
248 const struct hda_channel_mode *channel_mode;
249 int num_channel_mode;
250 int need_dac_fix;
251
252 /* PCM information */
253 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
254
255 /* dynamic controls, init_verbs and input_mux */
256 struct auto_pin_cfg autocfg;
257 unsigned int num_kctl_alloc, num_kctl_used;
258 struct snd_kcontrol_new *kctl_alloc;
259 struct hda_input_mux private_imux;
260 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
261
262 /* hooks */
263 void (*init_hook)(struct hda_codec *codec);
264 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
265
266 /* for pin sensing */
267 unsigned int sense_updated: 1;
268 unsigned int jack_present: 1;
269
270 /* for virtual master */
271 hda_nid_t vmaster_nid;
272 u32 vmaster_tlv[4];
273#ifdef CONFIG_SND_HDA_POWER_SAVE
274 struct hda_loopback_check loopback;
275#endif
276};
277
278/*
279 * configuration template - to be copied to the spec instance
280 */
281struct alc_config_preset {
282 struct snd_kcontrol_new *mixers[5]; /* should be identical size
283 * with spec
284 */
285 const struct hda_verb *init_verbs[5];
286 unsigned int num_dacs;
287 hda_nid_t *dac_nids;
288 hda_nid_t dig_out_nid; /* optional */
289 hda_nid_t hp_nid; /* optional */
290 unsigned int num_adc_nids;
291 hda_nid_t *adc_nids;
292 hda_nid_t dig_in_nid;
293 unsigned int num_channel_mode;
294 const struct hda_channel_mode *channel_mode;
295 int need_dac_fix;
296 unsigned int num_mux_defs;
297 const struct hda_input_mux *input_mux;
298 void (*unsol_event)(struct hda_codec *, unsigned int);
299 void (*init_hook)(struct hda_codec *);
300#ifdef CONFIG_SND_HDA_POWER_SAVE
301 struct hda_amp_list *loopbacks;
302#endif
303};
304
305
306/*
307 * input MUX handling
308 */
309static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
310 struct snd_ctl_elem_info *uinfo)
311{
312 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
313 struct alc_spec *spec = codec->spec;
314 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
315 if (mux_idx >= spec->num_mux_defs)
316 mux_idx = 0;
317 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
318}
319
320static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
321 struct snd_ctl_elem_value *ucontrol)
322{
323 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
324 struct alc_spec *spec = codec->spec;
325 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
326
327 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
328 return 0;
329}
330
331static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
332 struct snd_ctl_elem_value *ucontrol)
333{
334 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
335 struct alc_spec *spec = codec->spec;
336 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
337 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
338 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
339 spec->adc_nids[adc_idx],
340 &spec->cur_mux[adc_idx]);
341}
342
343
344/*
345 * channel mode setting
346 */
347static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
348 struct snd_ctl_elem_info *uinfo)
349{
350 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
351 struct alc_spec *spec = codec->spec;
352 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
353 spec->num_channel_mode);
354}
355
356static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
357 struct snd_ctl_elem_value *ucontrol)
358{
359 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
360 struct alc_spec *spec = codec->spec;
361 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
362 spec->num_channel_mode,
363 spec->multiout.max_channels);
364}
365
366static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
367 struct snd_ctl_elem_value *ucontrol)
368{
369 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
370 struct alc_spec *spec = codec->spec;
371 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
372 spec->num_channel_mode,
373 &spec->multiout.max_channels);
374 if (err >= 0 && spec->need_dac_fix)
375 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
376 return err;
377}
378
379/*
380 * Control the mode of pin widget settings via the mixer. "pc" is used
381 * instead of "%" to avoid consequences of accidently treating the % as
382 * being part of a format specifier. Maximum allowed length of a value is
383 * 63 characters plus NULL terminator.
384 *
385 * Note: some retasking pin complexes seem to ignore requests for input
386 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
387 * are requested. Therefore order this list so that this behaviour will not
388 * cause problems when mixer clients move through the enum sequentially.
389 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
390 * March 2006.
391 */
392static char *alc_pin_mode_names[] = {
393 "Mic 50pc bias", "Mic 80pc bias",
394 "Line in", "Line out", "Headphone out",
395};
396static unsigned char alc_pin_mode_values[] = {
397 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
398};
399/* The control can present all 5 options, or it can limit the options based
400 * in the pin being assumed to be exclusively an input or an output pin. In
401 * addition, "input" pins may or may not process the mic bias option
402 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
403 * accept requests for bias as of chip versions up to March 2006) and/or
404 * wiring in the computer.
405 */
406#define ALC_PIN_DIR_IN 0x00
407#define ALC_PIN_DIR_OUT 0x01
408#define ALC_PIN_DIR_INOUT 0x02
409#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
410#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
411
412/* Info about the pin modes supported by the different pin direction modes.
413 * For each direction the minimum and maximum values are given.
414 */
415static signed char alc_pin_mode_dir_info[5][2] = {
416 { 0, 2 }, /* ALC_PIN_DIR_IN */
417 { 3, 4 }, /* ALC_PIN_DIR_OUT */
418 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
419 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
420 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
421};
422#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
423#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
424#define alc_pin_mode_n_items(_dir) \
425 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
426
427static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
428 struct snd_ctl_elem_info *uinfo)
429{
430 unsigned int item_num = uinfo->value.enumerated.item;
431 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
432
433 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
434 uinfo->count = 1;
435 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
436
437 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
438 item_num = alc_pin_mode_min(dir);
439 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
440 return 0;
441}
442
443static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
444 struct snd_ctl_elem_value *ucontrol)
445{
446 unsigned int i;
447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
448 hda_nid_t nid = kcontrol->private_value & 0xffff;
449 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
450 long *valp = ucontrol->value.integer.value;
451 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
452 AC_VERB_GET_PIN_WIDGET_CONTROL,
453 0x00);
454
455 /* Find enumerated value for current pinctl setting */
456 i = alc_pin_mode_min(dir);
457 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
458 i++;
459 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
460 return 0;
461}
462
463static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
464 struct snd_ctl_elem_value *ucontrol)
465{
466 signed int change;
467 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
468 hda_nid_t nid = kcontrol->private_value & 0xffff;
469 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
470 long val = *ucontrol->value.integer.value;
471 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
472 AC_VERB_GET_PIN_WIDGET_CONTROL,
473 0x00);
474
475 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
476 val = alc_pin_mode_min(dir);
477
478 change = pinctl != alc_pin_mode_values[val];
479 if (change) {
480 /* Set pin mode to that requested */
481 snd_hda_codec_write_cache(codec, nid, 0,
482 AC_VERB_SET_PIN_WIDGET_CONTROL,
483 alc_pin_mode_values[val]);
484
485 /* Also enable the retasking pin's input/output as required
486 * for the requested pin mode. Enum values of 2 or less are
487 * input modes.
488 *
489 * Dynamically switching the input/output buffers probably
490 * reduces noise slightly (particularly on input) so we'll
491 * do it. However, having both input and output buffers
492 * enabled simultaneously doesn't seem to be problematic if
493 * this turns out to be necessary in the future.
494 */
495 if (val <= 2) {
496 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
497 HDA_AMP_MUTE, HDA_AMP_MUTE);
498 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
499 HDA_AMP_MUTE, 0);
500 } else {
501 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
502 HDA_AMP_MUTE, HDA_AMP_MUTE);
503 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
504 HDA_AMP_MUTE, 0);
505 }
506 }
507 return change;
508}
509
510#define ALC_PIN_MODE(xname, nid, dir) \
511 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
512 .info = alc_pin_mode_info, \
513 .get = alc_pin_mode_get, \
514 .put = alc_pin_mode_put, \
515 .private_value = nid | (dir<<16) }
516
517/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
518 * together using a mask with more than one bit set. This control is
519 * currently used only by the ALC260 test model. At this stage they are not
520 * needed for any "production" models.
521 */
522#ifdef CONFIG_SND_DEBUG
523#define alc_gpio_data_info snd_ctl_boolean_mono_info
524
525static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
527{
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 hda_nid_t nid = kcontrol->private_value & 0xffff;
530 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
531 long *valp = ucontrol->value.integer.value;
532 unsigned int val = snd_hda_codec_read(codec, nid, 0,
533 AC_VERB_GET_GPIO_DATA, 0x00);
534
535 *valp = (val & mask) != 0;
536 return 0;
537}
538static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
539 struct snd_ctl_elem_value *ucontrol)
540{
541 signed int change;
542 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
543 hda_nid_t nid = kcontrol->private_value & 0xffff;
544 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
545 long val = *ucontrol->value.integer.value;
546 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
547 AC_VERB_GET_GPIO_DATA,
548 0x00);
549
550 /* Set/unset the masked GPIO bit(s) as needed */
551 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
552 if (val == 0)
553 gpio_data &= ~mask;
554 else
555 gpio_data |= mask;
556 snd_hda_codec_write_cache(codec, nid, 0,
557 AC_VERB_SET_GPIO_DATA, gpio_data);
558
559 return change;
560}
561#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
562 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
563 .info = alc_gpio_data_info, \
564 .get = alc_gpio_data_get, \
565 .put = alc_gpio_data_put, \
566 .private_value = nid | (mask<<16) }
567#endif /* CONFIG_SND_DEBUG */
568
569/* A switch control to allow the enabling of the digital IO pins on the
570 * ALC260. This is incredibly simplistic; the intention of this control is
571 * to provide something in the test model allowing digital outputs to be
572 * identified if present. If models are found which can utilise these
573 * outputs a more complete mixer control can be devised for those models if
574 * necessary.
575 */
576#ifdef CONFIG_SND_DEBUG
577#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
578
579static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
580 struct snd_ctl_elem_value *ucontrol)
581{
582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
583 hda_nid_t nid = kcontrol->private_value & 0xffff;
584 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
585 long *valp = ucontrol->value.integer.value;
586 unsigned int val = snd_hda_codec_read(codec, nid, 0,
587 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
588
589 *valp = (val & mask) != 0;
590 return 0;
591}
592static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
593 struct snd_ctl_elem_value *ucontrol)
594{
595 signed int change;
596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
597 hda_nid_t nid = kcontrol->private_value & 0xffff;
598 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
599 long val = *ucontrol->value.integer.value;
600 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
601 AC_VERB_GET_DIGI_CONVERT_1,
602 0x00);
603
604 /* Set/unset the masked control bit(s) as needed */
605 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
606 if (val==0)
607 ctrl_data &= ~mask;
608 else
609 ctrl_data |= mask;
610 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
611 ctrl_data);
612
613 return change;
614}
615#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
616 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
617 .info = alc_spdif_ctrl_info, \
618 .get = alc_spdif_ctrl_get, \
619 .put = alc_spdif_ctrl_put, \
620 .private_value = nid | (mask<<16) }
621#endif /* CONFIG_SND_DEBUG */
622
623/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
624 * Again, this is only used in the ALC26x test models to help identify when
625 * the EAPD line must be asserted for features to work.
626 */
627#ifdef CONFIG_SND_DEBUG
628#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
629
630static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
632{
633 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
634 hda_nid_t nid = kcontrol->private_value & 0xffff;
635 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
636 long *valp = ucontrol->value.integer.value;
637 unsigned int val = snd_hda_codec_read(codec, nid, 0,
638 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
639
640 *valp = (val & mask) != 0;
641 return 0;
642}
643
644static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
645 struct snd_ctl_elem_value *ucontrol)
646{
647 int change;
648 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
649 hda_nid_t nid = kcontrol->private_value & 0xffff;
650 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
651 long val = *ucontrol->value.integer.value;
652 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
653 AC_VERB_GET_EAPD_BTLENABLE,
654 0x00);
655
656 /* Set/unset the masked control bit(s) as needed */
657 change = (!val ? 0 : mask) != (ctrl_data & mask);
658 if (!val)
659 ctrl_data &= ~mask;
660 else
661 ctrl_data |= mask;
662 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
663 ctrl_data);
664
665 return change;
666}
667
668#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
669 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
670 .info = alc_eapd_ctrl_info, \
671 .get = alc_eapd_ctrl_get, \
672 .put = alc_eapd_ctrl_put, \
673 .private_value = nid | (mask<<16) }
674#endif /* CONFIG_SND_DEBUG */
675
676/*
677 * set up from the preset table
678 */
679static void setup_preset(struct alc_spec *spec,
680 const struct alc_config_preset *preset)
681{
682 int i;
683
684 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
685 spec->mixers[spec->num_mixers++] = preset->mixers[i];
686 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
687 i++)
688 spec->init_verbs[spec->num_init_verbs++] =
689 preset->init_verbs[i];
690
691 spec->channel_mode = preset->channel_mode;
692 spec->num_channel_mode = preset->num_channel_mode;
693 spec->need_dac_fix = preset->need_dac_fix;
694
695 spec->multiout.max_channels = spec->channel_mode[0].channels;
696
697 spec->multiout.num_dacs = preset->num_dacs;
698 spec->multiout.dac_nids = preset->dac_nids;
699 spec->multiout.dig_out_nid = preset->dig_out_nid;
700 spec->multiout.hp_nid = preset->hp_nid;
701
702 spec->num_mux_defs = preset->num_mux_defs;
703 if (!spec->num_mux_defs)
704 spec->num_mux_defs = 1;
705 spec->input_mux = preset->input_mux;
706
707 spec->num_adc_nids = preset->num_adc_nids;
708 spec->adc_nids = preset->adc_nids;
709 spec->dig_in_nid = preset->dig_in_nid;
710
711 spec->unsol_event = preset->unsol_event;
712 spec->init_hook = preset->init_hook;
713#ifdef CONFIG_SND_HDA_POWER_SAVE
714 spec->loopback.amplist = preset->loopbacks;
715#endif
716}
717
718/* Enable GPIO mask and set output */
719static struct hda_verb alc_gpio1_init_verbs[] = {
720 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
721 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
722 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
723 { }
724};
725
726static struct hda_verb alc_gpio2_init_verbs[] = {
727 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
728 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
729 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
730 { }
731};
732
733static struct hda_verb alc_gpio3_init_verbs[] = {
734 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
735 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
736 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
737 { }
738};
739
740static void alc_sku_automute(struct hda_codec *codec)
741{
742 struct alc_spec *spec = codec->spec;
743 unsigned int mute;
744 unsigned int present;
745 unsigned int hp_nid = spec->autocfg.hp_pins[0];
746 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
747
748 /* need to execute and sync at first */
749 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
750 present = snd_hda_codec_read(codec, hp_nid, 0,
751 AC_VERB_GET_PIN_SENSE, 0);
752 spec->jack_present = (present & 0x80000000) != 0;
753 if (spec->jack_present) {
754 /* mute internal speaker */
755 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
756 HDA_AMP_MUTE, HDA_AMP_MUTE);
757 } else {
758 /* unmute internal speaker if necessary */
759 mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
760 snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
761 HDA_AMP_MUTE, mute);
762 }
763}
764
765/* unsolicited event for HP jack sensing */
766static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
767{
768 if (codec->vendor_id == 0x10ec0880)
769 res >>= 28;
770 else
771 res >>= 26;
772 if (res != ALC880_HP_EVENT)
773 return;
774
775 alc_sku_automute(codec);
776}
777
778/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
779 * 31 ~ 16 : Manufacture ID
780 * 15 ~ 8 : SKU ID
781 * 7 ~ 0 : Assembly ID
782 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
783 */
784static void alc_subsystem_id(struct hda_codec *codec,
785 unsigned int porta, unsigned int porte,
786 unsigned int portd)
787{
788 unsigned int ass, tmp, i;
789 unsigned nid;
790 struct alc_spec *spec = codec->spec;
791
792 ass = codec->subsystem_id & 0xffff;
793 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
794 goto do_sku;
795
796 /*
797 * 31~30 : port conetcivity
798 * 29~21 : reserve
799 * 20 : PCBEEP input
800 * 19~16 : Check sum (15:1)
801 * 15~1 : Custom
802 * 0 : override
803 */
804 nid = 0x1d;
805 if (codec->vendor_id == 0x10ec0260)
806 nid = 0x17;
807 ass = snd_hda_codec_read(codec, nid, 0,
808 AC_VERB_GET_CONFIG_DEFAULT, 0);
809 if (!(ass & 1) && !(ass & 0x100000))
810 return;
811 if ((ass >> 30) != 1) /* no physical connection */
812 return;
813
814 /* check sum */
815 tmp = 0;
816 for (i = 1; i < 16; i++) {
817 if ((ass >> i) & 1)
818 tmp++;
819 }
820 if (((ass >> 16) & 0xf) != tmp)
821 return;
822do_sku:
823 /*
824 * 0 : override
825 * 1 : Swap Jack
826 * 2 : 0 --> Desktop, 1 --> Laptop
827 * 3~5 : External Amplifier control
828 * 7~6 : Reserved
829 */
830 tmp = (ass & 0x38) >> 3; /* external Amp control */
831 switch (tmp) {
832 case 1:
833 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
834 break;
835 case 3:
836 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
837 break;
838 case 7:
839 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
840 break;
841 case 5: /* set EAPD output high */
842 switch (codec->vendor_id) {
843 case 0x10ec0260:
844 snd_hda_codec_write(codec, 0x0f, 0,
845 AC_VERB_SET_EAPD_BTLENABLE, 2);
846 snd_hda_codec_write(codec, 0x10, 0,
847 AC_VERB_SET_EAPD_BTLENABLE, 2);
848 break;
849 case 0x10ec0262:
850 case 0x10ec0267:
851 case 0x10ec0268:
852 case 0x10ec0269:
853 case 0x10ec0862:
854 case 0x10ec0662:
855 snd_hda_codec_write(codec, 0x14, 0,
856 AC_VERB_SET_EAPD_BTLENABLE, 2);
857 snd_hda_codec_write(codec, 0x15, 0,
858 AC_VERB_SET_EAPD_BTLENABLE, 2);
859 break;
860 }
861 switch (codec->vendor_id) {
862 case 0x10ec0260:
863 snd_hda_codec_write(codec, 0x1a, 0,
864 AC_VERB_SET_COEF_INDEX, 7);
865 tmp = snd_hda_codec_read(codec, 0x1a, 0,
866 AC_VERB_GET_PROC_COEF, 0);
867 snd_hda_codec_write(codec, 0x1a, 0,
868 AC_VERB_SET_COEF_INDEX, 7);
869 snd_hda_codec_write(codec, 0x1a, 0,
870 AC_VERB_SET_PROC_COEF,
871 tmp | 0x2010);
872 break;
873 case 0x10ec0262:
874 case 0x10ec0880:
875 case 0x10ec0882:
876 case 0x10ec0883:
877 case 0x10ec0885:
878 case 0x10ec0888:
879 snd_hda_codec_write(codec, 0x20, 0,
880 AC_VERB_SET_COEF_INDEX, 7);
881 tmp = snd_hda_codec_read(codec, 0x20, 0,
882 AC_VERB_GET_PROC_COEF, 0);
883 snd_hda_codec_write(codec, 0x20, 0,
884 AC_VERB_SET_COEF_INDEX, 7);
885 snd_hda_codec_write(codec, 0x20, 0,
886 AC_VERB_SET_PROC_COEF,
887 tmp | 0x2010);
888 break;
889 case 0x10ec0267:
890 case 0x10ec0268:
891 snd_hda_codec_write(codec, 0x20, 0,
892 AC_VERB_SET_COEF_INDEX, 7);
893 tmp = snd_hda_codec_read(codec, 0x20, 0,
894 AC_VERB_GET_PROC_COEF, 0);
895 snd_hda_codec_write(codec, 0x20, 0,
896 AC_VERB_SET_COEF_INDEX, 7);
897 snd_hda_codec_write(codec, 0x20, 0,
898 AC_VERB_SET_PROC_COEF,
899 tmp | 0x3000);
900 break;
901 }
902 default:
903 break;
904 }
905
906 /* is laptop or Desktop and enable the function "Mute internal speaker
907 * when the external headphone out jack is plugged"
908 */
909 if (!(ass & 0x8000))
910 return;
911 /*
912 * 10~8 : Jack location
913 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
914 * 14~13: Resvered
915 * 15 : 1 --> enable the function "Mute internal speaker
916 * when the external headphone out jack is plugged"
917 */
918 if (!spec->autocfg.speaker_pins[0]) {
919 if (spec->autocfg.line_out_pins[0])
920 spec->autocfg.speaker_pins[0] =
921 spec->autocfg.line_out_pins[0];
922 else
923 return;
924 }
925
926 if (!spec->autocfg.hp_pins[0]) {
927 tmp = (ass >> 11) & 0x3; /* HP to chassis */
928 if (tmp == 0)
929 spec->autocfg.hp_pins[0] = porta;
930 else if (tmp == 1)
931 spec->autocfg.hp_pins[0] = porte;
932 else if (tmp == 2)
933 spec->autocfg.hp_pins[0] = portd;
934 else
935 return;
936 }
937
938 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
939 AC_VERB_SET_UNSOLICITED_ENABLE,
940 AC_USRSP_EN | ALC880_HP_EVENT);
941 spec->unsol_event = alc_sku_unsol_event;
942 spec->init_hook = alc_sku_automute;
943}
944
945/*
946 * Fix-up pin default configurations
947 */
948
949struct alc_pincfg {
950 hda_nid_t nid;
951 u32 val;
952};
953
954static void alc_fix_pincfg(struct hda_codec *codec,
955 const struct snd_pci_quirk *quirk,
956 const struct alc_pincfg **pinfix)
957{
958 const struct alc_pincfg *cfg;
959
960 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
961 if (!quirk)
962 return;
963
964 cfg = pinfix[quirk->value];
965 for (; cfg->nid; cfg++) {
966 int i;
967 u32 val = cfg->val;
968 for (i = 0; i < 4; i++) {
969 snd_hda_codec_write(codec, cfg->nid, 0,
970 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
971 val & 0xff);
972 val >>= 8;
973 }
974 }
975}
976
977/*
978 * ALC880 3-stack model
979 *
980 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
981 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
982 * F-Mic = 0x1b, HP = 0x19
983 */
984
985static hda_nid_t alc880_dac_nids[4] = {
986 /* front, rear, clfe, rear_surr */
987 0x02, 0x05, 0x04, 0x03
988};
989
990static hda_nid_t alc880_adc_nids[3] = {
991 /* ADC0-2 */
992 0x07, 0x08, 0x09,
993};
994
995/* The datasheet says the node 0x07 is connected from inputs,
996 * but it shows zero connection in the real implementation on some devices.
997 * Note: this is a 915GAV bug, fixed on 915GLV
998 */
999static hda_nid_t alc880_adc_nids_alt[2] = {
1000 /* ADC1-2 */
1001 0x08, 0x09,
1002};
1003
1004#define ALC880_DIGOUT_NID 0x06
1005#define ALC880_DIGIN_NID 0x0a
1006
1007static struct hda_input_mux alc880_capture_source = {
1008 .num_items = 4,
1009 .items = {
1010 { "Mic", 0x0 },
1011 { "Front Mic", 0x3 },
1012 { "Line", 0x2 },
1013 { "CD", 0x4 },
1014 },
1015};
1016
1017/* channel source setting (2/6 channel selection for 3-stack) */
1018/* 2ch mode */
1019static struct hda_verb alc880_threestack_ch2_init[] = {
1020 /* set line-in to input, mute it */
1021 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1022 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1023 /* set mic-in to input vref 80%, mute it */
1024 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1025 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1026 { } /* end */
1027};
1028
1029/* 6ch mode */
1030static struct hda_verb alc880_threestack_ch6_init[] = {
1031 /* set line-in to output, unmute it */
1032 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1033 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1034 /* set mic-in to output, unmute it */
1035 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1036 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1037 { } /* end */
1038};
1039
1040static struct hda_channel_mode alc880_threestack_modes[2] = {
1041 { 2, alc880_threestack_ch2_init },
1042 { 6, alc880_threestack_ch6_init },
1043};
1044
1045static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1046 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1047 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1048 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1049 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1050 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1051 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1052 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1053 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1060 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1061 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1062 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1063 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1064 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1065 {
1066 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1067 .name = "Channel Mode",
1068 .info = alc_ch_mode_info,
1069 .get = alc_ch_mode_get,
1070 .put = alc_ch_mode_put,
1071 },
1072 { } /* end */
1073};
1074
1075/* capture mixer elements */
1076static struct snd_kcontrol_new alc880_capture_mixer[] = {
1077 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1078 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1079 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1080 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1081 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1082 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1083 {
1084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1085 /* The multiple "Capture Source" controls confuse alsamixer
1086 * So call somewhat different..
1087 */
1088 /* .name = "Capture Source", */
1089 .name = "Input Source",
1090 .count = 3,
1091 .info = alc_mux_enum_info,
1092 .get = alc_mux_enum_get,
1093 .put = alc_mux_enum_put,
1094 },
1095 { } /* end */
1096};
1097
1098/* capture mixer elements (in case NID 0x07 not available) */
1099static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
1100 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1101 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1102 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1103 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
1104 {
1105 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1106 /* The multiple "Capture Source" controls confuse alsamixer
1107 * So call somewhat different..
1108 */
1109 /* .name = "Capture Source", */
1110 .name = "Input Source",
1111 .count = 2,
1112 .info = alc_mux_enum_info,
1113 .get = alc_mux_enum_get,
1114 .put = alc_mux_enum_put,
1115 },
1116 { } /* end */
1117};
1118
1119
1120
1121/*
1122 * ALC880 5-stack model
1123 *
1124 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1125 * Side = 0x02 (0xd)
1126 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1127 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1128 */
1129
1130/* additional mixers to alc880_three_stack_mixer */
1131static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
1132 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1133 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
1134 { } /* end */
1135};
1136
1137/* channel source setting (6/8 channel selection for 5-stack) */
1138/* 6ch mode */
1139static struct hda_verb alc880_fivestack_ch6_init[] = {
1140 /* set line-in to input, mute it */
1141 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1142 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1143 { } /* end */
1144};
1145
1146/* 8ch mode */
1147static struct hda_verb alc880_fivestack_ch8_init[] = {
1148 /* set line-in to output, unmute it */
1149 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1150 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1151 { } /* end */
1152};
1153
1154static struct hda_channel_mode alc880_fivestack_modes[2] = {
1155 { 6, alc880_fivestack_ch6_init },
1156 { 8, alc880_fivestack_ch8_init },
1157};
1158
1159
1160/*
1161 * ALC880 6-stack model
1162 *
1163 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1164 * Side = 0x05 (0x0f)
1165 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1166 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1167 */
1168
1169static hda_nid_t alc880_6st_dac_nids[4] = {
1170 /* front, rear, clfe, rear_surr */
1171 0x02, 0x03, 0x04, 0x05
1172};
1173
1174static struct hda_input_mux alc880_6stack_capture_source = {
1175 .num_items = 4,
1176 .items = {
1177 { "Mic", 0x0 },
1178 { "Front Mic", 0x1 },
1179 { "Line", 0x2 },
1180 { "CD", 0x4 },
1181 },
1182};
1183
1184/* fixed 8-channels */
1185static struct hda_channel_mode alc880_sixstack_modes[1] = {
1186 { 8, NULL },
1187};
1188
1189static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1190 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1191 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1192 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1193 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1194 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1195 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1196 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1197 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1198 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1199 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1200 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1201 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1202 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1203 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1205 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1206 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1207 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1208 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1209 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1210 {
1211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1212 .name = "Channel Mode",
1213 .info = alc_ch_mode_info,
1214 .get = alc_ch_mode_get,
1215 .put = alc_ch_mode_put,
1216 },
1217 { } /* end */
1218};
1219
1220
1221/*
1222 * ALC880 W810 model
1223 *
1224 * W810 has rear IO for:
1225 * Front (DAC 02)
1226 * Surround (DAC 03)
1227 * Center/LFE (DAC 04)
1228 * Digital out (06)
1229 *
1230 * The system also has a pair of internal speakers, and a headphone jack.
1231 * These are both connected to Line2 on the codec, hence to DAC 02.
1232 *
1233 * There is a variable resistor to control the speaker or headphone
1234 * volume. This is a hardware-only device without a software API.
1235 *
1236 * Plugging headphones in will disable the internal speakers. This is
1237 * implemented in hardware, not via the driver using jack sense. In
1238 * a similar fashion, plugging into the rear socket marked "front" will
1239 * disable both the speakers and headphones.
1240 *
1241 * For input, there's a microphone jack, and an "audio in" jack.
1242 * These may not do anything useful with this driver yet, because I
1243 * haven't setup any initialization verbs for these yet...
1244 */
1245
1246static hda_nid_t alc880_w810_dac_nids[3] = {
1247 /* front, rear/surround, clfe */
1248 0x02, 0x03, 0x04
1249};
1250
1251/* fixed 6 channels */
1252static struct hda_channel_mode alc880_w810_modes[1] = {
1253 { 6, NULL }
1254};
1255
1256/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
1257static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
1258 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1259 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1260 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1261 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1262 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1263 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1264 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1265 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1266 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1267 { } /* end */
1268};
1269
1270
1271/*
1272 * Z710V model
1273 *
1274 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
1275 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1276 * Line = 0x1a
1277 */
1278
1279static hda_nid_t alc880_z71v_dac_nids[1] = {
1280 0x02
1281};
1282#define ALC880_Z71V_HP_DAC 0x03
1283
1284/* fixed 2 channels */
1285static struct hda_channel_mode alc880_2_jack_modes[1] = {
1286 { 2, NULL }
1287};
1288
1289static struct snd_kcontrol_new alc880_z71v_mixer[] = {
1290 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1291 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1292 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1293 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
1294 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1295 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1298 { } /* end */
1299};
1300
1301
1302/*
1303 * ALC880 F1734 model
1304 *
1305 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1306 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1307 */
1308
1309static hda_nid_t alc880_f1734_dac_nids[1] = {
1310 0x03
1311};
1312#define ALC880_F1734_HP_DAC 0x02
1313
1314static struct snd_kcontrol_new alc880_f1734_mixer[] = {
1315 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1316 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1317 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1318 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1319 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1320 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1321 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1322 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1323 { } /* end */
1324};
1325
1326
1327/*
1328 * ALC880 ASUS model
1329 *
1330 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1331 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1332 * Mic = 0x18, Line = 0x1a
1333 */
1334
1335#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1336#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1337
1338static struct snd_kcontrol_new alc880_asus_mixer[] = {
1339 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1340 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1341 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1342 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1343 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1344 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1345 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1346 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1348 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1353 {
1354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1355 .name = "Channel Mode",
1356 .info = alc_ch_mode_info,
1357 .get = alc_ch_mode_get,
1358 .put = alc_ch_mode_put,
1359 },
1360 { } /* end */
1361};
1362
1363/*
1364 * ALC880 ASUS W1V model
1365 *
1366 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1367 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1368 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1369 */
1370
1371/* additional mixers to alc880_asus_mixer */
1372static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1373 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1374 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
1375 { } /* end */
1376};
1377
1378/* additional mixers to alc880_asus_mixer */
1379static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1380 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1381 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1382 { } /* end */
1383};
1384
1385/* TCL S700 */
1386static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1387 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1388 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1389 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1390 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1391 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1393 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1394 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1395 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1396 {
1397 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1398 /* The multiple "Capture Source" controls confuse alsamixer
1399 * So call somewhat different..
1400 */
1401 /* .name = "Capture Source", */
1402 .name = "Input Source",
1403 .count = 1,
1404 .info = alc_mux_enum_info,
1405 .get = alc_mux_enum_get,
1406 .put = alc_mux_enum_put,
1407 },
1408 { } /* end */
1409};
1410
1411/* Uniwill */
1412static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1413 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1414 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1415 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1416 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1417 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1418 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1419 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1420 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1421 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1422 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1423 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1424 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1425 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1426 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1427 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1428 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1429 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1430 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1431 {
1432 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1433 .name = "Channel Mode",
1434 .info = alc_ch_mode_info,
1435 .get = alc_ch_mode_get,
1436 .put = alc_ch_mode_put,
1437 },
1438 { } /* end */
1439};
1440
1441static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1442 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1443 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1444 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1445 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1446 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1447 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1448 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1449 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1450 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1451 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1452 { } /* end */
1453};
1454
1455static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
1456 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1457 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1458 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1459 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1462 { } /* end */
1463};
1464
1465/*
1466 * virtual master controls
1467 */
1468
1469/*
1470 * slave controls for virtual master
1471 */
1472static const char *alc_slave_vols[] = {
1473 "Front Playback Volume",
1474 "Surround Playback Volume",
1475 "Center Playback Volume",
1476 "LFE Playback Volume",
1477 "Side Playback Volume",
1478 "Headphone Playback Volume",
1479 "Speaker Playback Volume",
1480 "Mono Playback Volume",
1481 "iSpeaker Playback Volume",
1482 "Line-Out Playback Volume",
1483 NULL,
1484};
1485
1486static const char *alc_slave_sws[] = {
1487 "Front Playback Switch",
1488 "Surround Playback Switch",
1489 "Center Playback Switch",
1490 "LFE Playback Switch",
1491 "Side Playback Switch",
1492 "Headphone Playback Switch",
1493 "Speaker Playback Switch",
1494 "Mono Playback Switch",
1495 "iSpeaker Playback Switch",
1496 NULL,
1497};
1498
1499/*
1500 * build control elements
1501 */
1502static int alc_build_controls(struct hda_codec *codec)
1503{
1504 struct alc_spec *spec = codec->spec;
1505 int err;
1506 int i;
1507
1508 for (i = 0; i < spec->num_mixers; i++) {
1509 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1510 if (err < 0)
1511 return err;
1512 }
1513
1514 if (spec->multiout.dig_out_nid) {
1515 err = snd_hda_create_spdif_out_ctls(codec,
1516 spec->multiout.dig_out_nid);
1517 if (err < 0)
1518 return err;
1519 }
1520 if (spec->dig_in_nid) {
1521 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1522 if (err < 0)
1523 return err;
1524 }
1525
1526 /* if we have no master control, let's create it */
1527 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1528 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
1529 HDA_OUTPUT, spec->vmaster_tlv);
1530 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1531 spec->vmaster_tlv, alc_slave_vols);
1532 if (err < 0)
1533 return err;
1534 }
1535 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1536 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1537 NULL, alc_slave_sws);
1538 if (err < 0)
1539 return err;
1540 }
1541
1542 return 0;
1543}
1544
1545
1546/*
1547 * initialize the codec volumes, etc
1548 */
1549
1550/*
1551 * generic initialization of ADC, input mixers and output mixers
1552 */
1553static struct hda_verb alc880_volume_init_verbs[] = {
1554 /*
1555 * Unmute ADC0-2 and set the default input to mic-in
1556 */
1557 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
1558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1559 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
1560 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1561 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
1562 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1563
1564 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1565 * mixer widget
1566 * Note: PASD motherboards uses the Line In 2 as the input for front
1567 * panel mic (mic 2)
1568 */
1569 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
1570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1575 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1576 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
1577
1578 /*
1579 * Set up output mixers (0x0c - 0x0f)
1580 */
1581 /* set vol=0 to output mixers */
1582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1584 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1585 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1586 /* set up input amps for analog loopback */
1587 /* Amp Indices: DAC = 0, mixer = 1 */
1588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1591 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1592 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1593 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1595 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1596
1597 { }
1598};
1599
1600/*
1601 * 3-stack pin configuration:
1602 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1603 */
1604static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1605 /*
1606 * preset connection lists of input pins
1607 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1608 */
1609 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1610 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1611 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1612
1613 /*
1614 * Set pin mode and muting
1615 */
1616 /* set front pin widgets 0x14 for output */
1617 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1618 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1619 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1622 /* Mic2 (as headphone out) for HP output */
1623 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1624 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625 /* Line In pin widget for input */
1626 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1628 /* Line2 (as front mic) pin widget for input and vref at 80% */
1629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1631 /* CD pin widget for input */
1632 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1633
1634 { }
1635};
1636
1637/*
1638 * 5-stack pin configuration:
1639 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1640 * line-in/side = 0x1a, f-mic = 0x1b
1641 */
1642static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1643 /*
1644 * preset connection lists of input pins
1645 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1646 */
1647 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1648 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1649
1650 /*
1651 * Set pin mode and muting
1652 */
1653 /* set pin widgets 0x14-0x17 for output */
1654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1655 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1656 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1657 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1658 /* unmute pins for output (no gain on this amp) */
1659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1661 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1662 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1663
1664 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1665 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1666 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1667 /* Mic2 (as headphone out) for HP output */
1668 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1669 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1670 /* Line In pin widget for input */
1671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1673 /* Line2 (as front mic) pin widget for input and vref at 80% */
1674 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1675 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1676 /* CD pin widget for input */
1677 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1678
1679 { }
1680};
1681
1682/*
1683 * W810 pin configuration:
1684 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1685 */
1686static struct hda_verb alc880_pin_w810_init_verbs[] = {
1687 /* hphone/speaker input selector: front DAC */
1688 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1689
1690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1695 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1696
1697 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1698 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1699
1700 { }
1701};
1702
1703/*
1704 * Z71V pin configuration:
1705 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1706 */
1707static struct hda_verb alc880_pin_z71v_init_verbs[] = {
1708 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1712
1713 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1714 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1716 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1717
1718 { }
1719};
1720
1721/*
1722 * 6-stack pin configuration:
1723 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1724 * f-mic = 0x19, line = 0x1a, HP = 0x1b
1725 */
1726static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1727 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1728
1729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1730 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1733 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1734 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1735 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1736 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1737
1738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1744 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1745 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1746 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1747
1748 { }
1749};
1750
1751/*
1752 * Uniwill pin configuration:
1753 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1754 * line = 0x1a
1755 */
1756static struct hda_verb alc880_uniwill_init_verbs[] = {
1757 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1758
1759 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1762 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1763 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1764 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1765 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1766 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1767 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1768 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1769 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1770 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1771 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1773
1774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1776 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1777 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1780 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1781 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1782 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1783
1784 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1785 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1786
1787 { }
1788};
1789
1790/*
1791* Uniwill P53
1792* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
1793 */
1794static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1795 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1796
1797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1798 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1801 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1802 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1803 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1804 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1805 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1806 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1807 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1808 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1809
1810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1812 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1813 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1814 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1815 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1816
1817 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1818 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1819
1820 { }
1821};
1822
1823static struct hda_verb alc880_beep_init_verbs[] = {
1824 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1825 { }
1826};
1827
1828/* toggle speaker-output according to the hp-jack state */
1829static void alc880_uniwill_hp_automute(struct hda_codec *codec)
1830{
1831 unsigned int present;
1832 unsigned char bits;
1833
1834 present = snd_hda_codec_read(codec, 0x14, 0,
1835 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1836 bits = present ? HDA_AMP_MUTE : 0;
1837 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1838 HDA_AMP_MUTE, bits);
1839 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1840 HDA_AMP_MUTE, bits);
1841}
1842
1843/* auto-toggle front mic */
1844static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1845{
1846 unsigned int present;
1847 unsigned char bits;
1848
1849 present = snd_hda_codec_read(codec, 0x18, 0,
1850 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1851 bits = present ? HDA_AMP_MUTE : 0;
1852 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
1853}
1854
1855static void alc880_uniwill_automute(struct hda_codec *codec)
1856{
1857 alc880_uniwill_hp_automute(codec);
1858 alc880_uniwill_mic_automute(codec);
1859}
1860
1861static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1862 unsigned int res)
1863{
1864 /* Looks like the unsol event is incompatible with the standard
1865 * definition. 4bit tag is placed at 28 bit!
1866 */
1867 switch (res >> 28) {
1868 case ALC880_HP_EVENT:
1869 alc880_uniwill_hp_automute(codec);
1870 break;
1871 case ALC880_MIC_EVENT:
1872 alc880_uniwill_mic_automute(codec);
1873 break;
1874 }
1875}
1876
1877static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1878{
1879 unsigned int present;
1880 unsigned char bits;
1881
1882 present = snd_hda_codec_read(codec, 0x14, 0,
1883 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1884 bits = present ? HDA_AMP_MUTE : 0;
1885 snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
1886}
1887
1888static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1889{
1890 unsigned int present;
1891
1892 present = snd_hda_codec_read(codec, 0x21, 0,
1893 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1894 present &= HDA_AMP_VOLMASK;
1895 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1896 HDA_AMP_VOLMASK, present);
1897 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1898 HDA_AMP_VOLMASK, present);
1899}
1900
1901static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1902 unsigned int res)
1903{
1904 /* Looks like the unsol event is incompatible with the standard
1905 * definition. 4bit tag is placed at 28 bit!
1906 */
1907 if ((res >> 28) == ALC880_HP_EVENT)
1908 alc880_uniwill_p53_hp_automute(codec);
1909 if ((res >> 28) == ALC880_DCVOL_EVENT)
1910 alc880_uniwill_p53_dcvol_automute(codec);
1911}
1912
1913/*
1914 * F1734 pin configuration:
1915 * HP = 0x14, speaker-out = 0x15, mic = 0x18
1916 */
1917static struct hda_verb alc880_pin_f1734_init_verbs[] = {
1918 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1919 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1920 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1921 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1922
1923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1924 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1927
1928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1935 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1937
1938 { }
1939};
1940
1941/*
1942 * ASUS pin configuration:
1943 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
1944 */
1945static struct hda_verb alc880_pin_asus_init_verbs[] = {
1946 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
1947 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
1948 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
1949 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
1950
1951 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1952 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1953 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1956 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1957 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1958 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1959
1960 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1961 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1962 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1964 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1965 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1966 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1969
1970 { }
1971};
1972
1973/* Enable GPIO mask and set output */
1974#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
1975#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
1976
1977/* Clevo m520g init */
1978static struct hda_verb alc880_pin_clevo_init_verbs[] = {
1979 /* headphone output */
1980 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
1981 /* line-out */
1982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1984 /* Line-in */
1985 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1986 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1987 /* CD */
1988 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1989 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1990 /* Mic1 (rear panel) */
1991 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1993 /* Mic2 (front panel) */
1994 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1995 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1996 /* headphone */
1997 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1998 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1999 /* change to EAPD mode */
2000 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2001 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2002
2003 { }
2004};
2005
2006static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2007 /* change to EAPD mode */
2008 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2009 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2010
2011 /* Headphone output */
2012 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2013 /* Front output*/
2014 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2015 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2016
2017 /* Line In pin widget for input */
2018 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2019 /* CD pin widget for input */
2020 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2021 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2022 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2023
2024 /* change to EAPD mode */
2025 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2026 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2027
2028 { }
2029};
2030
2031/*
2032 * LG m1 express dual
2033 *
2034 * Pin assignment:
2035 * Rear Line-In/Out (blue): 0x14
2036 * Build-in Mic-In: 0x15
2037 * Speaker-out: 0x17
2038 * HP-Out (green): 0x1b
2039 * Mic-In/Out (red): 0x19
2040 * SPDIF-Out: 0x1e
2041 */
2042
2043/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2044static hda_nid_t alc880_lg_dac_nids[3] = {
2045 0x05, 0x02, 0x03
2046};
2047
2048/* seems analog CD is not working */
2049static struct hda_input_mux alc880_lg_capture_source = {
2050 .num_items = 3,
2051 .items = {
2052 { "Mic", 0x1 },
2053 { "Line", 0x5 },
2054 { "Internal Mic", 0x6 },
2055 },
2056};
2057
2058/* 2,4,6 channel modes */
2059static struct hda_verb alc880_lg_ch2_init[] = {
2060 /* set line-in and mic-in to input */
2061 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2062 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2063 { }
2064};
2065
2066static struct hda_verb alc880_lg_ch4_init[] = {
2067 /* set line-in to out and mic-in to input */
2068 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2069 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2070 { }
2071};
2072
2073static struct hda_verb alc880_lg_ch6_init[] = {
2074 /* set line-in and mic-in to output */
2075 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2076 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2077 { }
2078};
2079
2080static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2081 { 2, alc880_lg_ch2_init },
2082 { 4, alc880_lg_ch4_init },
2083 { 6, alc880_lg_ch6_init },
2084};
2085
2086static struct snd_kcontrol_new alc880_lg_mixer[] = {
2087 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2088 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
2089 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2090 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2091 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2092 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2093 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2094 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2096 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2099 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2100 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2101 {
2102 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2103 .name = "Channel Mode",
2104 .info = alc_ch_mode_info,
2105 .get = alc_ch_mode_get,
2106 .put = alc_ch_mode_put,
2107 },
2108 { } /* end */
2109};
2110
2111static struct hda_verb alc880_lg_init_verbs[] = {
2112 /* set capture source to mic-in */
2113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2115 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2116 /* mute all amp mixer inputs */
2117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
2118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2120 /* line-in to input */
2121 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2122 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2123 /* built-in mic */
2124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2126 /* speaker-out */
2127 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2128 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2129 /* mic-in to input */
2130 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2131 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2132 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2133 /* HP-out */
2134 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2135 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2136 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2137 /* jack sense */
2138 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2139 { }
2140};
2141
2142/* toggle speaker-output according to the hp-jack state */
2143static void alc880_lg_automute(struct hda_codec *codec)
2144{
2145 unsigned int present;
2146 unsigned char bits;
2147
2148 present = snd_hda_codec_read(codec, 0x1b, 0,
2149 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2150 bits = present ? HDA_AMP_MUTE : 0;
2151 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2152 HDA_AMP_MUTE, bits);
2153}
2154
2155static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2156{
2157 /* Looks like the unsol event is incompatible with the standard
2158 * definition. 4bit tag is placed at 28 bit!
2159 */
2160 if ((res >> 28) == 0x01)
2161 alc880_lg_automute(codec);
2162}
2163
2164/*
2165 * LG LW20
2166 *
2167 * Pin assignment:
2168 * Speaker-out: 0x14
2169 * Mic-In: 0x18
2170 * Built-in Mic-In: 0x19
2171 * Line-In: 0x1b
2172 * HP-Out: 0x1a
2173 * SPDIF-Out: 0x1e
2174 */
2175
2176static struct hda_input_mux alc880_lg_lw_capture_source = {
2177 .num_items = 3,
2178 .items = {
2179 { "Mic", 0x0 },
2180 { "Internal Mic", 0x1 },
2181 { "Line In", 0x2 },
2182 },
2183};
2184
2185#define alc880_lg_lw_modes alc880_threestack_modes
2186
2187static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
2188 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2189 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2190 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2191 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2192 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2193 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2194 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2195 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2196 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2197 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2201 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
2202 {
2203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2204 .name = "Channel Mode",
2205 .info = alc_ch_mode_info,
2206 .get = alc_ch_mode_get,
2207 .put = alc_ch_mode_put,
2208 },
2209 { } /* end */
2210};
2211
2212static struct hda_verb alc880_lg_lw_init_verbs[] = {
2213 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2214 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2215 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2216
2217 /* set capture source to mic-in */
2218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2219 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2220 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2222 /* speaker-out */
2223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2224 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2225 /* HP-out */
2226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2227 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2228 /* mic-in to input */
2229 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2231 /* built-in mic */
2232 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2233 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2234 /* jack sense */
2235 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2236 { }
2237};
2238
2239/* toggle speaker-output according to the hp-jack state */
2240static void alc880_lg_lw_automute(struct hda_codec *codec)
2241{
2242 unsigned int present;
2243 unsigned char bits;
2244
2245 present = snd_hda_codec_read(codec, 0x1b, 0,
2246 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2247 bits = present ? HDA_AMP_MUTE : 0;
2248 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2249 HDA_AMP_MUTE, bits);
2250}
2251
2252static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2253{
2254 /* Looks like the unsol event is incompatible with the standard
2255 * definition. 4bit tag is placed at 28 bit!
2256 */
2257 if ((res >> 28) == 0x01)
2258 alc880_lg_lw_automute(codec);
2259}
2260
2261#ifdef CONFIG_SND_HDA_POWER_SAVE
2262static struct hda_amp_list alc880_loopbacks[] = {
2263 { 0x0b, HDA_INPUT, 0 },
2264 { 0x0b, HDA_INPUT, 1 },
2265 { 0x0b, HDA_INPUT, 2 },
2266 { 0x0b, HDA_INPUT, 3 },
2267 { 0x0b, HDA_INPUT, 4 },
2268 { } /* end */
2269};
2270
2271static struct hda_amp_list alc880_lg_loopbacks[] = {
2272 { 0x0b, HDA_INPUT, 1 },
2273 { 0x0b, HDA_INPUT, 6 },
2274 { 0x0b, HDA_INPUT, 7 },
2275 { } /* end */
2276};
2277#endif
2278
2279/*
2280 * Common callbacks
2281 */
2282
2283static int alc_init(struct hda_codec *codec)
2284{
2285 struct alc_spec *spec = codec->spec;
2286 unsigned int i;
2287
2288 for (i = 0; i < spec->num_init_verbs; i++)
2289 snd_hda_sequence_write(codec, spec->init_verbs[i]);
2290
2291 if (spec->init_hook)
2292 spec->init_hook(codec);
2293
2294 return 0;
2295}
2296
2297static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2298{
2299 struct alc_spec *spec = codec->spec;
2300
2301 if (spec->unsol_event)
2302 spec->unsol_event(codec, res);
2303}
2304
2305#ifdef CONFIG_SND_HDA_POWER_SAVE
2306static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2307{
2308 struct alc_spec *spec = codec->spec;
2309 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2310}
2311#endif
2312
2313/*
2314 * Analog playback callbacks
2315 */
2316static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2317 struct hda_codec *codec,
2318 struct snd_pcm_substream *substream)
2319{
2320 struct alc_spec *spec = codec->spec;
2321 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
2322}
2323
2324static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2325 struct hda_codec *codec,
2326 unsigned int stream_tag,
2327 unsigned int format,
2328 struct snd_pcm_substream *substream)
2329{
2330 struct alc_spec *spec = codec->spec;
2331 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2332 stream_tag, format, substream);
2333}
2334
2335static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2336 struct hda_codec *codec,
2337 struct snd_pcm_substream *substream)
2338{
2339 struct alc_spec *spec = codec->spec;
2340 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2341}
2342
2343/*
2344 * Digital out
2345 */
2346static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2347 struct hda_codec *codec,
2348 struct snd_pcm_substream *substream)
2349{
2350 struct alc_spec *spec = codec->spec;
2351 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2352}
2353
2354static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2355 struct hda_codec *codec,
2356 unsigned int stream_tag,
2357 unsigned int format,
2358 struct snd_pcm_substream *substream)
2359{
2360 struct alc_spec *spec = codec->spec;
2361 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2362 stream_tag, format, substream);
2363}
2364
2365static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2366 struct hda_codec *codec,
2367 struct snd_pcm_substream *substream)
2368{
2369 struct alc_spec *spec = codec->spec;
2370 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2371}
2372
2373/*
2374 * Analog capture
2375 */
2376static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2377 struct hda_codec *codec,
2378 unsigned int stream_tag,
2379 unsigned int format,
2380 struct snd_pcm_substream *substream)
2381{
2382 struct alc_spec *spec = codec->spec;
2383
2384 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2385 stream_tag, 0, format);
2386 return 0;
2387}
2388
2389static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2390 struct hda_codec *codec,
2391 struct snd_pcm_substream *substream)
2392{
2393 struct alc_spec *spec = codec->spec;
2394
2395 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
2396 0, 0, 0);
2397 return 0;
2398}
2399
2400
2401/*
2402 */
2403static struct hda_pcm_stream alc880_pcm_analog_playback = {
2404 .substreams = 1,
2405 .channels_min = 2,
2406 .channels_max = 8,
2407 /* NID is set in alc_build_pcms */
2408 .ops = {
2409 .open = alc880_playback_pcm_open,
2410 .prepare = alc880_playback_pcm_prepare,
2411 .cleanup = alc880_playback_pcm_cleanup
2412 },
2413};
2414
2415static struct hda_pcm_stream alc880_pcm_analog_capture = {
2416 .substreams = 1,
2417 .channels_min = 2,
2418 .channels_max = 2,
2419 /* NID is set in alc_build_pcms */
2420};
2421
2422static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2423 .substreams = 1,
2424 .channels_min = 2,
2425 .channels_max = 2,
2426 /* NID is set in alc_build_pcms */
2427};
2428
2429static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2430 .substreams = 2, /* can be overridden */
2431 .channels_min = 2,
2432 .channels_max = 2,
2433 /* NID is set in alc_build_pcms */
2434 .ops = {
2435 .prepare = alc880_alt_capture_pcm_prepare,
2436 .cleanup = alc880_alt_capture_pcm_cleanup
2437 },
2438};
2439
2440static struct hda_pcm_stream alc880_pcm_digital_playback = {
2441 .substreams = 1,
2442 .channels_min = 2,
2443 .channels_max = 2,
2444 /* NID is set in alc_build_pcms */
2445 .ops = {
2446 .open = alc880_dig_playback_pcm_open,
2447 .close = alc880_dig_playback_pcm_close,
2448 .prepare = alc880_dig_playback_pcm_prepare
2449 },
2450};
2451
2452static struct hda_pcm_stream alc880_pcm_digital_capture = {
2453 .substreams = 1,
2454 .channels_min = 2,
2455 .channels_max = 2,
2456 /* NID is set in alc_build_pcms */
2457};
2458
2459/* Used by alc_build_pcms to flag that a PCM has no playback stream */
2460static struct hda_pcm_stream alc_pcm_null_stream = {
2461 .substreams = 0,
2462 .channels_min = 0,
2463 .channels_max = 0,
2464};
2465
2466static int alc_build_pcms(struct hda_codec *codec)
2467{
2468 struct alc_spec *spec = codec->spec;
2469 struct hda_pcm *info = spec->pcm_rec;
2470 int i;
2471
2472 codec->num_pcms = 1;
2473 codec->pcm_info = info;
2474
2475 info->name = spec->stream_name_analog;
2476 if (spec->stream_analog_playback) {
2477 snd_assert(spec->multiout.dac_nids, return -EINVAL);
2478 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2479 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2480 }
2481 if (spec->stream_analog_capture) {
2482 snd_assert(spec->adc_nids, return -EINVAL);
2483 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2484 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2485 }
2486
2487 if (spec->channel_mode) {
2488 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2489 for (i = 0; i < spec->num_channel_mode; i++) {
2490 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2491 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2492 }
2493 }
2494 }
2495
2496 /* SPDIF for stream index #1 */
2497 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2498 codec->num_pcms = 2;
2499 info = spec->pcm_rec + 1;
2500 info->name = spec->stream_name_digital;
2501 if (spec->multiout.dig_out_nid &&
2502 spec->stream_digital_playback) {
2503 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2505 }
2506 if (spec->dig_in_nid &&
2507 spec->stream_digital_capture) {
2508 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2509 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2510 }
2511 }
2512
2513 /* If the use of more than one ADC is requested for the current
2514 * model, configure a second analog capture-only PCM.
2515 */
2516 /* Additional Analaog capture for index #2 */
2517 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2518 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
2519 codec->num_pcms = 3;
2520 info = spec->pcm_rec + 2;
2521 info->name = spec->stream_name_analog;
2522 if (spec->alt_dac_nid) {
2523 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2524 *spec->stream_analog_alt_playback;
2525 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2526 spec->alt_dac_nid;
2527 } else {
2528 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2529 alc_pcm_null_stream;
2530 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2531 }
2532 if (spec->num_adc_nids > 1) {
2533 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2534 *spec->stream_analog_alt_capture;
2535 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2536 spec->adc_nids[1];
2537 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2538 spec->num_adc_nids - 1;
2539 } else {
2540 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2541 alc_pcm_null_stream;
2542 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
2543 }
2544 }
2545
2546 return 0;
2547}
2548
2549static void alc_free(struct hda_codec *codec)
2550{
2551 struct alc_spec *spec = codec->spec;
2552 unsigned int i;
2553
2554 if (!spec)
2555 return;
2556
2557 if (spec->kctl_alloc) {
2558 for (i = 0; i < spec->num_kctl_used; i++)
2559 kfree(spec->kctl_alloc[i].name);
2560 kfree(spec->kctl_alloc);
2561 }
2562 kfree(spec);
2563}
2564
2565/*
2566 */
2567static struct hda_codec_ops alc_patch_ops = {
2568 .build_controls = alc_build_controls,
2569 .build_pcms = alc_build_pcms,
2570 .init = alc_init,
2571 .free = alc_free,
2572 .unsol_event = alc_unsol_event,
2573#ifdef CONFIG_SND_HDA_POWER_SAVE
2574 .check_power_status = alc_check_power_status,
2575#endif
2576};
2577
2578
2579/*
2580 * Test configuration for debugging
2581 *
2582 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2583 * enum controls.
2584 */
2585#ifdef CONFIG_SND_DEBUG
2586static hda_nid_t alc880_test_dac_nids[4] = {
2587 0x02, 0x03, 0x04, 0x05
2588};
2589
2590static struct hda_input_mux alc880_test_capture_source = {
2591 .num_items = 7,
2592 .items = {
2593 { "In-1", 0x0 },
2594 { "In-2", 0x1 },
2595 { "In-3", 0x2 },
2596 { "In-4", 0x3 },
2597 { "CD", 0x4 },
2598 { "Front", 0x5 },
2599 { "Surround", 0x6 },
2600 },
2601};
2602
2603static struct hda_channel_mode alc880_test_modes[4] = {
2604 { 2, NULL },
2605 { 4, NULL },
2606 { 6, NULL },
2607 { 8, NULL },
2608};
2609
2610static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2611 struct snd_ctl_elem_info *uinfo)
2612{
2613 static char *texts[] = {
2614 "N/A", "Line Out", "HP Out",
2615 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2616 };
2617 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2618 uinfo->count = 1;
2619 uinfo->value.enumerated.items = 8;
2620 if (uinfo->value.enumerated.item >= 8)
2621 uinfo->value.enumerated.item = 7;
2622 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2623 return 0;
2624}
2625
2626static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2627 struct snd_ctl_elem_value *ucontrol)
2628{
2629 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2630 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2631 unsigned int pin_ctl, item = 0;
2632
2633 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2634 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2635 if (pin_ctl & AC_PINCTL_OUT_EN) {
2636 if (pin_ctl & AC_PINCTL_HP_EN)
2637 item = 2;
2638 else
2639 item = 1;
2640 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2641 switch (pin_ctl & AC_PINCTL_VREFEN) {
2642 case AC_PINCTL_VREF_HIZ: item = 3; break;
2643 case AC_PINCTL_VREF_50: item = 4; break;
2644 case AC_PINCTL_VREF_GRD: item = 5; break;
2645 case AC_PINCTL_VREF_80: item = 6; break;
2646 case AC_PINCTL_VREF_100: item = 7; break;
2647 }
2648 }
2649 ucontrol->value.enumerated.item[0] = item;
2650 return 0;
2651}
2652
2653static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2654 struct snd_ctl_elem_value *ucontrol)
2655{
2656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2657 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2658 static unsigned int ctls[] = {
2659 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2660 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2661 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2662 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2663 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2664 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2665 };
2666 unsigned int old_ctl, new_ctl;
2667
2668 old_ctl = snd_hda_codec_read(codec, nid, 0,
2669 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2670 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2671 if (old_ctl != new_ctl) {
2672 int val;
2673 snd_hda_codec_write_cache(codec, nid, 0,
2674 AC_VERB_SET_PIN_WIDGET_CONTROL,
2675 new_ctl);
2676 val = ucontrol->value.enumerated.item[0] >= 3 ?
2677 HDA_AMP_MUTE : 0;
2678 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2679 HDA_AMP_MUTE, val);
2680 return 1;
2681 }
2682 return 0;
2683}
2684
2685static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2686 struct snd_ctl_elem_info *uinfo)
2687{
2688 static char *texts[] = {
2689 "Front", "Surround", "CLFE", "Side"
2690 };
2691 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2692 uinfo->count = 1;
2693 uinfo->value.enumerated.items = 4;
2694 if (uinfo->value.enumerated.item >= 4)
2695 uinfo->value.enumerated.item = 3;
2696 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2697 return 0;
2698}
2699
2700static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2701 struct snd_ctl_elem_value *ucontrol)
2702{
2703 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2704 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2705 unsigned int sel;
2706
2707 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2708 ucontrol->value.enumerated.item[0] = sel & 3;
2709 return 0;
2710}
2711
2712static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2713 struct snd_ctl_elem_value *ucontrol)
2714{
2715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2716 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2717 unsigned int sel;
2718
2719 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2720 if (ucontrol->value.enumerated.item[0] != sel) {
2721 sel = ucontrol->value.enumerated.item[0] & 3;
2722 snd_hda_codec_write_cache(codec, nid, 0,
2723 AC_VERB_SET_CONNECT_SEL, sel);
2724 return 1;
2725 }
2726 return 0;
2727}
2728
2729#define PIN_CTL_TEST(xname,nid) { \
2730 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2731 .name = xname, \
2732 .info = alc_test_pin_ctl_info, \
2733 .get = alc_test_pin_ctl_get, \
2734 .put = alc_test_pin_ctl_put, \
2735 .private_value = nid \
2736 }
2737
2738#define PIN_SRC_TEST(xname,nid) { \
2739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2740 .name = xname, \
2741 .info = alc_test_pin_src_info, \
2742 .get = alc_test_pin_src_get, \
2743 .put = alc_test_pin_src_put, \
2744 .private_value = nid \
2745 }
2746
2747static struct snd_kcontrol_new alc880_test_mixer[] = {
2748 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2749 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2750 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2751 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2752 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2753 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2754 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2755 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2756 PIN_CTL_TEST("Front Pin Mode", 0x14),
2757 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2758 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2759 PIN_CTL_TEST("Side Pin Mode", 0x17),
2760 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2761 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2762 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2763 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2764 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2765 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2766 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2767 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2768 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2769 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2770 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2771 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2772 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2773 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2774 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2775 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2776 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2777 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
2778 {
2779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2780 .name = "Channel Mode",
2781 .info = alc_ch_mode_info,
2782 .get = alc_ch_mode_get,
2783 .put = alc_ch_mode_put,
2784 },
2785 { } /* end */
2786};
2787
2788static struct hda_verb alc880_test_init_verbs[] = {
2789 /* Unmute inputs of 0x0c - 0x0f */
2790 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2792 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2794 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2795 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2796 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2797 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2798 /* Vol output for 0x0c-0x0f */
2799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2800 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2801 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2802 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2803 /* Set output pins 0x14-0x17 */
2804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2805 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2806 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2807 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2808 /* Unmute output pins 0x14-0x17 */
2809 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2811 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2812 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2813 /* Set input pins 0x18-0x1c */
2814 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2815 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2816 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2817 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2818 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2819 /* Mute input pins 0x18-0x1b */
2820 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2821 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2822 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2824 /* ADC set up */
2825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2826 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2827 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2828 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2829 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2830 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2831 /* Analog input/passthru */
2832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2837 { }
2838};
2839#endif
2840
2841/*
2842 */
2843
2844static const char *alc880_models[ALC880_MODEL_LAST] = {
2845 [ALC880_3ST] = "3stack",
2846 [ALC880_TCL_S700] = "tcl",
2847 [ALC880_3ST_DIG] = "3stack-digout",
2848 [ALC880_CLEVO] = "clevo",
2849 [ALC880_5ST] = "5stack",
2850 [ALC880_5ST_DIG] = "5stack-digout",
2851 [ALC880_W810] = "w810",
2852 [ALC880_Z71V] = "z71v",
2853 [ALC880_6ST] = "6stack",
2854 [ALC880_6ST_DIG] = "6stack-digout",
2855 [ALC880_ASUS] = "asus",
2856 [ALC880_ASUS_W1V] = "asus-w1v",
2857 [ALC880_ASUS_DIG] = "asus-dig",
2858 [ALC880_ASUS_DIG2] = "asus-dig2",
2859 [ALC880_UNIWILL_DIG] = "uniwill",
2860 [ALC880_UNIWILL_P53] = "uniwill-p53",
2861 [ALC880_FUJITSU] = "fujitsu",
2862 [ALC880_F1734] = "F1734",
2863 [ALC880_LG] = "lg",
2864 [ALC880_LG_LW] = "lg-lw",
2865#ifdef CONFIG_SND_DEBUG
2866 [ALC880_TEST] = "test",
2867#endif
2868 [ALC880_AUTO] = "auto",
2869};
2870
2871static struct snd_pci_quirk alc880_cfg_tbl[] = {
2872 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
2873 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
2874 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
2875 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
2876 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
2877 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
2878 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
2879 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
2880 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
2881 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
2882 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
2883 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
2884 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
2885 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
2886 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
2887 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
2888 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
2889 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
2890 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
2891 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
2892 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
2893 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
2894 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
2895 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
2896 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
2897 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
2898 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
2899 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
2900 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
2901 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
2902 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
2903 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
2904 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
2905 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
2906 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
2907 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
2908 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
2909 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
2910 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
2911 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
2912 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
2913 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
2914 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
2915 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
2916 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
2917 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
2918 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
2919 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
2920 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
2921 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
2922 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
2923 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
2924 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
2925 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
2926 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
2927 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
2928 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
2929 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
2930 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
2931 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
2932 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
2933 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
2934 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
2935 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
2936 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
2937 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
2938 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
2939 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
2940 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
2941 {}
2942};
2943
2944/*
2945 * ALC880 codec presets
2946 */
2947static struct alc_config_preset alc880_presets[] = {
2948 [ALC880_3ST] = {
2949 .mixers = { alc880_three_stack_mixer },
2950 .init_verbs = { alc880_volume_init_verbs,
2951 alc880_pin_3stack_init_verbs },
2952 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2953 .dac_nids = alc880_dac_nids,
2954 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2955 .channel_mode = alc880_threestack_modes,
2956 .need_dac_fix = 1,
2957 .input_mux = &alc880_capture_source,
2958 },
2959 [ALC880_3ST_DIG] = {
2960 .mixers = { alc880_three_stack_mixer },
2961 .init_verbs = { alc880_volume_init_verbs,
2962 alc880_pin_3stack_init_verbs },
2963 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2964 .dac_nids = alc880_dac_nids,
2965 .dig_out_nid = ALC880_DIGOUT_NID,
2966 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
2967 .channel_mode = alc880_threestack_modes,
2968 .need_dac_fix = 1,
2969 .input_mux = &alc880_capture_source,
2970 },
2971 [ALC880_TCL_S700] = {
2972 .mixers = { alc880_tcl_s700_mixer },
2973 .init_verbs = { alc880_volume_init_verbs,
2974 alc880_pin_tcl_S700_init_verbs,
2975 alc880_gpio2_init_verbs },
2976 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2977 .dac_nids = alc880_dac_nids,
2978 .hp_nid = 0x03,
2979 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
2980 .channel_mode = alc880_2_jack_modes,
2981 .input_mux = &alc880_capture_source,
2982 },
2983 [ALC880_5ST] = {
2984 .mixers = { alc880_three_stack_mixer,
2985 alc880_five_stack_mixer},
2986 .init_verbs = { alc880_volume_init_verbs,
2987 alc880_pin_5stack_init_verbs },
2988 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
2989 .dac_nids = alc880_dac_nids,
2990 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
2991 .channel_mode = alc880_fivestack_modes,
2992 .input_mux = &alc880_capture_source,
2993 },
2994 [ALC880_5ST_DIG] = {
2995 .mixers = { alc880_three_stack_mixer,
2996 alc880_five_stack_mixer },
2997 .init_verbs = { alc880_volume_init_verbs,
2998 alc880_pin_5stack_init_verbs },
2999 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3000 .dac_nids = alc880_dac_nids,
3001 .dig_out_nid = ALC880_DIGOUT_NID,
3002 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3003 .channel_mode = alc880_fivestack_modes,
3004 .input_mux = &alc880_capture_source,
3005 },
3006 [ALC880_6ST] = {
3007 .mixers = { alc880_six_stack_mixer },
3008 .init_verbs = { alc880_volume_init_verbs,
3009 alc880_pin_6stack_init_verbs },
3010 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3011 .dac_nids = alc880_6st_dac_nids,
3012 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3013 .channel_mode = alc880_sixstack_modes,
3014 .input_mux = &alc880_6stack_capture_source,
3015 },
3016 [ALC880_6ST_DIG] = {
3017 .mixers = { alc880_six_stack_mixer },
3018 .init_verbs = { alc880_volume_init_verbs,
3019 alc880_pin_6stack_init_verbs },
3020 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3021 .dac_nids = alc880_6st_dac_nids,
3022 .dig_out_nid = ALC880_DIGOUT_NID,
3023 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3024 .channel_mode = alc880_sixstack_modes,
3025 .input_mux = &alc880_6stack_capture_source,
3026 },
3027 [ALC880_W810] = {
3028 .mixers = { alc880_w810_base_mixer },
3029 .init_verbs = { alc880_volume_init_verbs,
3030 alc880_pin_w810_init_verbs,
3031 alc880_gpio2_init_verbs },
3032 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3033 .dac_nids = alc880_w810_dac_nids,
3034 .dig_out_nid = ALC880_DIGOUT_NID,
3035 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3036 .channel_mode = alc880_w810_modes,
3037 .input_mux = &alc880_capture_source,
3038 },
3039 [ALC880_Z71V] = {
3040 .mixers = { alc880_z71v_mixer },
3041 .init_verbs = { alc880_volume_init_verbs,
3042 alc880_pin_z71v_init_verbs },
3043 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3044 .dac_nids = alc880_z71v_dac_nids,
3045 .dig_out_nid = ALC880_DIGOUT_NID,
3046 .hp_nid = 0x03,
3047 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3048 .channel_mode = alc880_2_jack_modes,
3049 .input_mux = &alc880_capture_source,
3050 },
3051 [ALC880_F1734] = {
3052 .mixers = { alc880_f1734_mixer },
3053 .init_verbs = { alc880_volume_init_verbs,
3054 alc880_pin_f1734_init_verbs },
3055 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3056 .dac_nids = alc880_f1734_dac_nids,
3057 .hp_nid = 0x02,
3058 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3059 .channel_mode = alc880_2_jack_modes,
3060 .input_mux = &alc880_capture_source,
3061 },
3062 [ALC880_ASUS] = {
3063 .mixers = { alc880_asus_mixer },
3064 .init_verbs = { alc880_volume_init_verbs,
3065 alc880_pin_asus_init_verbs,
3066 alc880_gpio1_init_verbs },
3067 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3068 .dac_nids = alc880_asus_dac_nids,
3069 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3070 .channel_mode = alc880_asus_modes,
3071 .need_dac_fix = 1,
3072 .input_mux = &alc880_capture_source,
3073 },
3074 [ALC880_ASUS_DIG] = {
3075 .mixers = { alc880_asus_mixer },
3076 .init_verbs = { alc880_volume_init_verbs,
3077 alc880_pin_asus_init_verbs,
3078 alc880_gpio1_init_verbs },
3079 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3080 .dac_nids = alc880_asus_dac_nids,
3081 .dig_out_nid = ALC880_DIGOUT_NID,
3082 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3083 .channel_mode = alc880_asus_modes,
3084 .need_dac_fix = 1,
3085 .input_mux = &alc880_capture_source,
3086 },
3087 [ALC880_ASUS_DIG2] = {
3088 .mixers = { alc880_asus_mixer },
3089 .init_verbs = { alc880_volume_init_verbs,
3090 alc880_pin_asus_init_verbs,
3091 alc880_gpio2_init_verbs }, /* use GPIO2 */
3092 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3093 .dac_nids = alc880_asus_dac_nids,
3094 .dig_out_nid = ALC880_DIGOUT_NID,
3095 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3096 .channel_mode = alc880_asus_modes,
3097 .need_dac_fix = 1,
3098 .input_mux = &alc880_capture_source,
3099 },
3100 [ALC880_ASUS_W1V] = {
3101 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
3102 .init_verbs = { alc880_volume_init_verbs,
3103 alc880_pin_asus_init_verbs,
3104 alc880_gpio1_init_verbs },
3105 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3106 .dac_nids = alc880_asus_dac_nids,
3107 .dig_out_nid = ALC880_DIGOUT_NID,
3108 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3109 .channel_mode = alc880_asus_modes,
3110 .need_dac_fix = 1,
3111 .input_mux = &alc880_capture_source,
3112 },
3113 [ALC880_UNIWILL_DIG] = {
3114 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
3115 .init_verbs = { alc880_volume_init_verbs,
3116 alc880_pin_asus_init_verbs },
3117 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3118 .dac_nids = alc880_asus_dac_nids,
3119 .dig_out_nid = ALC880_DIGOUT_NID,
3120 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3121 .channel_mode = alc880_asus_modes,
3122 .need_dac_fix = 1,
3123 .input_mux = &alc880_capture_source,
3124 },
3125 [ALC880_UNIWILL] = {
3126 .mixers = { alc880_uniwill_mixer },
3127 .init_verbs = { alc880_volume_init_verbs,
3128 alc880_uniwill_init_verbs },
3129 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3130 .dac_nids = alc880_asus_dac_nids,
3131 .dig_out_nid = ALC880_DIGOUT_NID,
3132 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3133 .channel_mode = alc880_threestack_modes,
3134 .need_dac_fix = 1,
3135 .input_mux = &alc880_capture_source,
3136 .unsol_event = alc880_uniwill_unsol_event,
3137 .init_hook = alc880_uniwill_automute,
3138 },
3139 [ALC880_UNIWILL_P53] = {
3140 .mixers = { alc880_uniwill_p53_mixer },
3141 .init_verbs = { alc880_volume_init_verbs,
3142 alc880_uniwill_p53_init_verbs },
3143 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3144 .dac_nids = alc880_asus_dac_nids,
3145 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3146 .channel_mode = alc880_threestack_modes,
3147 .input_mux = &alc880_capture_source,
3148 .unsol_event = alc880_uniwill_p53_unsol_event,
3149 .init_hook = alc880_uniwill_p53_hp_automute,
3150 },
3151 [ALC880_FUJITSU] = {
3152 .mixers = { alc880_fujitsu_mixer,
3153 alc880_pcbeep_mixer, },
3154 .init_verbs = { alc880_volume_init_verbs,
3155 alc880_uniwill_p53_init_verbs,
3156 alc880_beep_init_verbs },
3157 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3158 .dac_nids = alc880_dac_nids,
3159 .dig_out_nid = ALC880_DIGOUT_NID,
3160 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3161 .channel_mode = alc880_2_jack_modes,
3162 .input_mux = &alc880_capture_source,
3163 .unsol_event = alc880_uniwill_p53_unsol_event,
3164 .init_hook = alc880_uniwill_p53_hp_automute,
3165 },
3166 [ALC880_CLEVO] = {
3167 .mixers = { alc880_three_stack_mixer },
3168 .init_verbs = { alc880_volume_init_verbs,
3169 alc880_pin_clevo_init_verbs },
3170 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3171 .dac_nids = alc880_dac_nids,
3172 .hp_nid = 0x03,
3173 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3174 .channel_mode = alc880_threestack_modes,
3175 .need_dac_fix = 1,
3176 .input_mux = &alc880_capture_source,
3177 },
3178 [ALC880_LG] = {
3179 .mixers = { alc880_lg_mixer },
3180 .init_verbs = { alc880_volume_init_verbs,
3181 alc880_lg_init_verbs },
3182 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3183 .dac_nids = alc880_lg_dac_nids,
3184 .dig_out_nid = ALC880_DIGOUT_NID,
3185 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3186 .channel_mode = alc880_lg_ch_modes,
3187 .need_dac_fix = 1,
3188 .input_mux = &alc880_lg_capture_source,
3189 .unsol_event = alc880_lg_unsol_event,
3190 .init_hook = alc880_lg_automute,
3191#ifdef CONFIG_SND_HDA_POWER_SAVE
3192 .loopbacks = alc880_lg_loopbacks,
3193#endif
3194 },
3195 [ALC880_LG_LW] = {
3196 .mixers = { alc880_lg_lw_mixer },
3197 .init_verbs = { alc880_volume_init_verbs,
3198 alc880_lg_lw_init_verbs },
3199 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3200 .dac_nids = alc880_dac_nids,
3201 .dig_out_nid = ALC880_DIGOUT_NID,
3202 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3203 .channel_mode = alc880_lg_lw_modes,
3204 .input_mux = &alc880_lg_lw_capture_source,
3205 .unsol_event = alc880_lg_lw_unsol_event,
3206 .init_hook = alc880_lg_lw_automute,
3207 },
3208#ifdef CONFIG_SND_DEBUG
3209 [ALC880_TEST] = {
3210 .mixers = { alc880_test_mixer },
3211 .init_verbs = { alc880_test_init_verbs },
3212 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3213 .dac_nids = alc880_test_dac_nids,
3214 .dig_out_nid = ALC880_DIGOUT_NID,
3215 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3216 .channel_mode = alc880_test_modes,
3217 .input_mux = &alc880_test_capture_source,
3218 },
3219#endif
3220};
3221
3222/*
3223 * Automatic parse of I/O pins from the BIOS configuration
3224 */
3225
3226#define NUM_CONTROL_ALLOC 32
3227#define NUM_VERB_ALLOC 32
3228
3229enum {
3230 ALC_CTL_WIDGET_VOL,
3231 ALC_CTL_WIDGET_MUTE,
3232 ALC_CTL_BIND_MUTE,
3233};
3234static struct snd_kcontrol_new alc880_control_templates[] = {
3235 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3236 HDA_CODEC_MUTE(NULL, 0, 0, 0),
3237 HDA_BIND_MUTE(NULL, 0, 0, 0),
3238};
3239
3240/* add dynamic controls */
3241static int add_control(struct alc_spec *spec, int type, const char *name,
3242 unsigned long val)
3243{
3244 struct snd_kcontrol_new *knew;
3245
3246 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3247 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3248
3249 /* array + terminator */
3250 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3251 if (!knew)
3252 return -ENOMEM;
3253 if (spec->kctl_alloc) {
3254 memcpy(knew, spec->kctl_alloc,
3255 sizeof(*knew) * spec->num_kctl_alloc);
3256 kfree(spec->kctl_alloc);
3257 }
3258 spec->kctl_alloc = knew;
3259 spec->num_kctl_alloc = num;
3260 }
3261
3262 knew = &spec->kctl_alloc[spec->num_kctl_used];
3263 *knew = alc880_control_templates[type];
3264 knew->name = kstrdup(name, GFP_KERNEL);
3265 if (!knew->name)
3266 return -ENOMEM;
3267 knew->private_value = val;
3268 spec->num_kctl_used++;
3269 return 0;
3270}
3271
3272#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3273#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3274#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3275#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3276#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3277#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3278#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3279#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3280#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3281#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3282#define ALC880_PIN_CD_NID 0x1c
3283
3284/* fill in the dac_nids table from the parsed pin configuration */
3285static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3286 const struct auto_pin_cfg *cfg)
3287{
3288 hda_nid_t nid;
3289 int assigned[4];
3290 int i, j;
3291
3292 memset(assigned, 0, sizeof(assigned));
3293 spec->multiout.dac_nids = spec->private_dac_nids;
3294
3295 /* check the pins hardwired to audio widget */
3296 for (i = 0; i < cfg->line_outs; i++) {
3297 nid = cfg->line_out_pins[i];
3298 if (alc880_is_fixed_pin(nid)) {
3299 int idx = alc880_fixed_pin_idx(nid);
3300 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
3301 assigned[idx] = 1;
3302 }
3303 }
3304 /* left pins can be connect to any audio widget */
3305 for (i = 0; i < cfg->line_outs; i++) {
3306 nid = cfg->line_out_pins[i];
3307 if (alc880_is_fixed_pin(nid))
3308 continue;
3309 /* search for an empty channel */
3310 for (j = 0; j < cfg->line_outs; j++) {
3311 if (!assigned[j]) {
3312 spec->multiout.dac_nids[i] =
3313 alc880_idx_to_dac(j);
3314 assigned[j] = 1;
3315 break;
3316 }
3317 }
3318 }
3319 spec->multiout.num_dacs = cfg->line_outs;
3320 return 0;
3321}
3322
3323/* add playback controls from the parsed DAC table */
3324static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3325 const struct auto_pin_cfg *cfg)
3326{
3327 char name[32];
3328 static const char *chname[4] = {
3329 "Front", "Surround", NULL /*CLFE*/, "Side"
3330 };
3331 hda_nid_t nid;
3332 int i, err;
3333
3334 for (i = 0; i < cfg->line_outs; i++) {
3335 if (!spec->multiout.dac_nids[i])
3336 continue;
3337 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3338 if (i == 2) {
3339 /* Center/LFE */
3340 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3341 "Center Playback Volume",
3342 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3343 HDA_OUTPUT));
3344 if (err < 0)
3345 return err;
3346 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3347 "LFE Playback Volume",
3348 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3349 HDA_OUTPUT));
3350 if (err < 0)
3351 return err;
3352 err = add_control(spec, ALC_CTL_BIND_MUTE,
3353 "Center Playback Switch",
3354 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3355 HDA_INPUT));
3356 if (err < 0)
3357 return err;
3358 err = add_control(spec, ALC_CTL_BIND_MUTE,
3359 "LFE Playback Switch",
3360 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3361 HDA_INPUT));
3362 if (err < 0)
3363 return err;
3364 } else {
3365 sprintf(name, "%s Playback Volume", chname[i]);
3366 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3367 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3368 HDA_OUTPUT));
3369 if (err < 0)
3370 return err;
3371 sprintf(name, "%s Playback Switch", chname[i]);
3372 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3373 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3374 HDA_INPUT));
3375 if (err < 0)
3376 return err;
3377 }
3378 }
3379 return 0;
3380}
3381
3382/* add playback controls for speaker and HP outputs */
3383static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3384 const char *pfx)
3385{
3386 hda_nid_t nid;
3387 int err;
3388 char name[32];
3389
3390 if (!pin)
3391 return 0;
3392
3393 if (alc880_is_fixed_pin(pin)) {
3394 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
3395 /* specify the DAC as the extra output */
3396 if (!spec->multiout.hp_nid)
3397 spec->multiout.hp_nid = nid;
3398 else
3399 spec->multiout.extra_out_nid[0] = nid;
3400 /* control HP volume/switch on the output mixer amp */
3401 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
3402 sprintf(name, "%s Playback Volume", pfx);
3403 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3404 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3405 if (err < 0)
3406 return err;
3407 sprintf(name, "%s Playback Switch", pfx);
3408 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3409 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3410 if (err < 0)
3411 return err;
3412 } else if (alc880_is_multi_pin(pin)) {
3413 /* set manual connection */
3414 /* we have only a switch on HP-out PIN */
3415 sprintf(name, "%s Playback Switch", pfx);
3416 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3417 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3418 if (err < 0)
3419 return err;
3420 }
3421 return 0;
3422}
3423
3424/* create input playback/capture controls for the given pin */
3425static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3426 const char *ctlname,
3427 int idx, hda_nid_t mix_nid)
3428{
3429 char name[32];
3430 int err;
3431
3432 sprintf(name, "%s Playback Volume", ctlname);
3433 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3434 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3435 if (err < 0)
3436 return err;
3437 sprintf(name, "%s Playback Switch", ctlname);
3438 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3439 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3440 if (err < 0)
3441 return err;
3442 return 0;
3443}
3444
3445/* create playback/capture controls for input pins */
3446static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3447 const struct auto_pin_cfg *cfg)
3448{
3449 struct hda_input_mux *imux = &spec->private_imux;
3450 int i, err, idx;
3451
3452 for (i = 0; i < AUTO_PIN_LAST; i++) {
3453 if (alc880_is_input_pin(cfg->input_pins[i])) {
3454 idx = alc880_input_pin_idx(cfg->input_pins[i]);
3455 err = new_analog_input(spec, cfg->input_pins[i],
3456 auto_pin_cfg_labels[i],
3457 idx, 0x0b);
3458 if (err < 0)
3459 return err;
3460 imux->items[imux->num_items].label =
3461 auto_pin_cfg_labels[i];
3462 imux->items[imux->num_items].index =
3463 alc880_input_pin_idx(cfg->input_pins[i]);
3464 imux->num_items++;
3465 }
3466 }
3467 return 0;
3468}
3469
3470static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3471 hda_nid_t nid, int pin_type,
3472 int dac_idx)
3473{
3474 /* set as output */
3475 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3476 pin_type);
3477 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3478 AMP_OUT_UNMUTE);
3479 /* need the manual connection? */
3480 if (alc880_is_multi_pin(nid)) {
3481 struct alc_spec *spec = codec->spec;
3482 int idx = alc880_multi_pin_idx(nid);
3483 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3484 AC_VERB_SET_CONNECT_SEL,
3485 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3486 }
3487}
3488
3489static int get_pin_type(int line_out_type)
3490{
3491 if (line_out_type == AUTO_PIN_HP_OUT)
3492 return PIN_HP;
3493 else
3494 return PIN_OUT;
3495}
3496
3497static void alc880_auto_init_multi_out(struct hda_codec *codec)
3498{
3499 struct alc_spec *spec = codec->spec;
3500 int i;
3501
3502 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
3503 for (i = 0; i < spec->autocfg.line_outs; i++) {
3504 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3505 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3506 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
3507 }
3508}
3509
3510static void alc880_auto_init_extra_out(struct hda_codec *codec)
3511{
3512 struct alc_spec *spec = codec->spec;
3513 hda_nid_t pin;
3514
3515 pin = spec->autocfg.speaker_pins[0];
3516 if (pin) /* connect to front */
3517 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
3518 pin = spec->autocfg.hp_pins[0];
3519 if (pin) /* connect to front */
3520 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3521}
3522
3523static void alc880_auto_init_analog_input(struct hda_codec *codec)
3524{
3525 struct alc_spec *spec = codec->spec;
3526 int i;
3527
3528 for (i = 0; i < AUTO_PIN_LAST; i++) {
3529 hda_nid_t nid = spec->autocfg.input_pins[i];
3530 if (alc880_is_input_pin(nid)) {
3531 snd_hda_codec_write(codec, nid, 0,
3532 AC_VERB_SET_PIN_WIDGET_CONTROL,
3533 i <= AUTO_PIN_FRONT_MIC ?
3534 PIN_VREF80 : PIN_IN);
3535 if (nid != ALC880_PIN_CD_NID)
3536 snd_hda_codec_write(codec, nid, 0,
3537 AC_VERB_SET_AMP_GAIN_MUTE,
3538 AMP_OUT_MUTE);
3539 }
3540 }
3541}
3542
3543/* parse the BIOS configuration and set up the alc_spec */
3544/* return 1 if successful, 0 if the proper config is not found,
3545 * or a negative error code
3546 */
3547static int alc880_parse_auto_config(struct hda_codec *codec)
3548{
3549 struct alc_spec *spec = codec->spec;
3550 int err;
3551 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
3552
3553 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3554 alc880_ignore);
3555 if (err < 0)
3556 return err;
3557 if (!spec->autocfg.line_outs)
3558 return 0; /* can't find valid BIOS pin config */
3559
3560 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3561 if (err < 0)
3562 return err;
3563 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3564 if (err < 0)
3565 return err;
3566 err = alc880_auto_create_extra_out(spec,
3567 spec->autocfg.speaker_pins[0],
3568 "Speaker");
3569 if (err < 0)
3570 return err;
3571 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3572 "Headphone");
3573 if (err < 0)
3574 return err;
3575 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3576 if (err < 0)
3577 return err;
3578
3579 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3580
3581 if (spec->autocfg.dig_out_pin)
3582 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3583 if (spec->autocfg.dig_in_pin)
3584 spec->dig_in_nid = ALC880_DIGIN_NID;
3585
3586 if (spec->kctl_alloc)
3587 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3588
3589 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3590
3591 spec->num_mux_defs = 1;
3592 spec->input_mux = &spec->private_imux;
3593
3594 return 1;
3595}
3596
3597/* additional initialization for auto-configuration model */
3598static void alc880_auto_init(struct hda_codec *codec)
3599{
3600 alc880_auto_init_multi_out(codec);
3601 alc880_auto_init_extra_out(codec);
3602 alc880_auto_init_analog_input(codec);
3603}
3604
3605/*
3606 * OK, here we have finally the patch for ALC880
3607 */
3608
3609static int patch_alc880(struct hda_codec *codec)
3610{
3611 struct alc_spec *spec;
3612 int board_config;
3613 int err;
3614
3615 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3616 if (spec == NULL)
3617 return -ENOMEM;
3618
3619 codec->spec = spec;
3620
3621 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3622 alc880_models,
3623 alc880_cfg_tbl);
3624 if (board_config < 0) {
3625 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3626 "trying auto-probe from BIOS...\n");
3627 board_config = ALC880_AUTO;
3628 }
3629
3630 if (board_config == ALC880_AUTO) {
3631 /* automatic parse from the BIOS config */
3632 err = alc880_parse_auto_config(codec);
3633 if (err < 0) {
3634 alc_free(codec);
3635 return err;
3636 } else if (!err) {
3637 printk(KERN_INFO
3638 "hda_codec: Cannot set up configuration "
3639 "from BIOS. Using 3-stack mode...\n");
3640 board_config = ALC880_3ST;
3641 }
3642 }
3643
3644 if (board_config != ALC880_AUTO)
3645 setup_preset(spec, &alc880_presets[board_config]);
3646
3647 spec->stream_name_analog = "ALC880 Analog";
3648 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3649 spec->stream_analog_capture = &alc880_pcm_analog_capture;
3650 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
3651
3652 spec->stream_name_digital = "ALC880 Digital";
3653 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3654 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3655
3656 if (!spec->adc_nids && spec->input_mux) {
3657 /* check whether NID 0x07 is valid */
3658 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
3659 /* get type */
3660 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3661 if (wcap != AC_WID_AUD_IN) {
3662 spec->adc_nids = alc880_adc_nids_alt;
3663 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
3664 spec->mixers[spec->num_mixers] =
3665 alc880_capture_alt_mixer;
3666 spec->num_mixers++;
3667 } else {
3668 spec->adc_nids = alc880_adc_nids;
3669 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3670 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3671 spec->num_mixers++;
3672 }
3673 }
3674
3675 spec->vmaster_nid = 0x0c;
3676
3677 codec->patch_ops = alc_patch_ops;
3678 if (board_config == ALC880_AUTO)
3679 spec->init_hook = alc880_auto_init;
3680#ifdef CONFIG_SND_HDA_POWER_SAVE
3681 if (!spec->loopback.amplist)
3682 spec->loopback.amplist = alc880_loopbacks;
3683#endif
3684
3685 return 0;
3686}
3687
3688
3689/*
3690 * ALC260 support
3691 */
3692
3693static hda_nid_t alc260_dac_nids[1] = {
3694 /* front */
3695 0x02,
3696};
3697
3698static hda_nid_t alc260_adc_nids[1] = {
3699 /* ADC0 */
3700 0x04,
3701};
3702
3703static hda_nid_t alc260_adc_nids_alt[1] = {
3704 /* ADC1 */
3705 0x05,
3706};
3707
3708static hda_nid_t alc260_hp_adc_nids[2] = {
3709 /* ADC1, 0 */
3710 0x05, 0x04
3711};
3712
3713/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3714 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3715 */
3716static hda_nid_t alc260_dual_adc_nids[2] = {
3717 /* ADC0, ADC1 */
3718 0x04, 0x05
3719};
3720
3721#define ALC260_DIGOUT_NID 0x03
3722#define ALC260_DIGIN_NID 0x06
3723
3724static struct hda_input_mux alc260_capture_source = {
3725 .num_items = 4,
3726 .items = {
3727 { "Mic", 0x0 },
3728 { "Front Mic", 0x1 },
3729 { "Line", 0x2 },
3730 { "CD", 0x4 },
3731 },
3732};
3733
3734/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
3735 * headphone jack and the internal CD lines since these are the only pins at
3736 * which audio can appear. For flexibility, also allow the option of
3737 * recording the mixer output on the second ADC (ADC0 doesn't have a
3738 * connection to the mixer output).
3739 */
3740static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3741 {
3742 .num_items = 3,
3743 .items = {
3744 { "Mic/Line", 0x0 },
3745 { "CD", 0x4 },
3746 { "Headphone", 0x2 },
3747 },
3748 },
3749 {
3750 .num_items = 4,
3751 .items = {
3752 { "Mic/Line", 0x0 },
3753 { "CD", 0x4 },
3754 { "Headphone", 0x2 },
3755 { "Mixer", 0x5 },
3756 },
3757 },
3758
3759};
3760
3761/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3762 * the Fujitsu S702x, but jacks are marked differently.
3763 */
3764static struct hda_input_mux alc260_acer_capture_sources[2] = {
3765 {
3766 .num_items = 4,
3767 .items = {
3768 { "Mic", 0x0 },
3769 { "Line", 0x2 },
3770 { "CD", 0x4 },
3771 { "Headphone", 0x5 },
3772 },
3773 },
3774 {
3775 .num_items = 5,
3776 .items = {
3777 { "Mic", 0x0 },
3778 { "Line", 0x2 },
3779 { "CD", 0x4 },
3780 { "Headphone", 0x6 },
3781 { "Mixer", 0x5 },
3782 },
3783 },
3784};
3785/*
3786 * This is just place-holder, so there's something for alc_build_pcms to look
3787 * at when it calculates the maximum number of channels. ALC260 has no mixer
3788 * element which allows changing the channel mode, so the verb list is
3789 * never used.
3790 */
3791static struct hda_channel_mode alc260_modes[1] = {
3792 { 2, NULL },
3793};
3794
3795
3796/* Mixer combinations
3797 *
3798 * basic: base_output + input + pc_beep + capture
3799 * HP: base_output + input + capture_alt
3800 * HP_3013: hp_3013 + input + capture
3801 * fujitsu: fujitsu + capture
3802 * acer: acer + capture
3803 */
3804
3805static struct snd_kcontrol_new alc260_base_output_mixer[] = {
3806 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3807 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
3808 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3809 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
3810 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3811 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
3812 { } /* end */
3813};
3814
3815static struct snd_kcontrol_new alc260_input_mixer[] = {
3816 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3817 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3818 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3819 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3821 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
3823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
3824 { } /* end */
3825};
3826
3827static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
3828 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
3829 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
3830 { } /* end */
3831};
3832
3833static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
3834 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3835 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3836 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
3837 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
3838 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3839 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
3840 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
3841 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
3842 { } /* end */
3843};
3844
3845/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
3846 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
3847 */
3848static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
3849 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3850 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
3851 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3852 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3853 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3854 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
3855 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
3856 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
3857 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3858 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3859 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
3860 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
3861 { } /* end */
3862};
3863
3864/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
3865 * versions of the ALC260 don't act on requests to enable mic bias from NID
3866 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
3867 * datasheet doesn't mention this restriction. At this stage it's not clear
3868 * whether this behaviour is intentional or is a hardware bug in chip
3869 * revisions available in early 2006. Therefore for now allow the
3870 * "Headphone Jack Mode" control to span all choices, but if it turns out
3871 * that the lack of mic bias for this NID is intentional we could change the
3872 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
3873 *
3874 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
3875 * don't appear to make the mic bias available from the "line" jack, even
3876 * though the NID used for this jack (0x14) can supply it. The theory is
3877 * that perhaps Acer have included blocking capacitors between the ALC260
3878 * and the output jack. If this turns out to be the case for all such
3879 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
3880 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
3881 *
3882 * The C20x Tablet series have a mono internal speaker which is controlled
3883 * via the chip's Mono sum widget and pin complex, so include the necessary
3884 * controls for such models. On models without a "mono speaker" the control
3885 * won't do anything.
3886 */
3887static struct snd_kcontrol_new alc260_acer_mixer[] = {
3888 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3889 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
3890 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
3891 HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
3892 HDA_OUTPUT),
3893 HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
3894 HDA_INPUT),
3895 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3896 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3898 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3899 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3900 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3901 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3902 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3903 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3904 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3905 { } /* end */
3906};
3907
3908/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
3909 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
3910 */
3911static struct snd_kcontrol_new alc260_will_mixer[] = {
3912 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3913 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3915 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3916 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3917 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3918 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3919 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3920 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
3921 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
3922 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
3923 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
3924 { } /* end */
3925};
3926
3927/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
3928 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
3929 */
3930static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
3931 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
3932 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
3933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
3934 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
3935 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
3936 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
3937 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
3938 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
3939 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
3940 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
3941 { } /* end */
3942};
3943
3944/* capture mixer elements */
3945static struct snd_kcontrol_new alc260_capture_mixer[] = {
3946 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
3947 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
3948 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
3949 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
3950 {
3951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3952 /* The multiple "Capture Source" controls confuse alsamixer
3953 * So call somewhat different..
3954 */
3955 /* .name = "Capture Source", */
3956 .name = "Input Source",
3957 .count = 2,
3958 .info = alc_mux_enum_info,
3959 .get = alc_mux_enum_get,
3960 .put = alc_mux_enum_put,
3961 },
3962 { } /* end */
3963};
3964
3965static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
3966 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
3967 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
3968 {
3969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3970 /* The multiple "Capture Source" controls confuse alsamixer
3971 * So call somewhat different..
3972 */
3973 /* .name = "Capture Source", */
3974 .name = "Input Source",
3975 .count = 1,
3976 .info = alc_mux_enum_info,
3977 .get = alc_mux_enum_get,
3978 .put = alc_mux_enum_put,
3979 },
3980 { } /* end */
3981};
3982
3983/*
3984 * initialization verbs
3985 */
3986static struct hda_verb alc260_init_verbs[] = {
3987 /* Line In pin widget for input */
3988 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3989 /* CD pin widget for input */
3990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3991 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3992 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3993 /* Mic2 (front panel) pin widget for input and vref at 80% */
3994 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3995 /* LINE-2 is used for line-out in rear */
3996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3997 /* select line-out */
3998 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
3999 /* LINE-OUT pin */
4000 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4001 /* enable HP */
4002 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4003 /* enable Mono */
4004 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4005 /* mute capture amp left and right */
4006 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4007 /* set connection select to line in (default select for this ADC) */
4008 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4009 /* mute capture amp left and right */
4010 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4011 /* set connection select to line in (default select for this ADC) */
4012 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
4013 /* set vol=0 Line-Out mixer amp left and right */
4014 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4015 /* unmute pin widget amp left and right (no gain on this amp) */
4016 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4017 /* set vol=0 HP mixer amp left and right */
4018 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4019 /* unmute pin widget amp left and right (no gain on this amp) */
4020 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4021 /* set vol=0 Mono mixer amp left and right */
4022 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4023 /* unmute pin widget amp left and right (no gain on this amp) */
4024 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4025 /* unmute LINE-2 out pin */
4026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4027 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4028 * Line In 2 = 0x03
4029 */
4030 /* mute analog inputs */
4031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4036 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4037 /* mute Front out path */
4038 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4040 /* mute Headphone out path */
4041 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4043 /* mute Mono out path */
4044 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4045 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4046 { }
4047};
4048
4049#if 0 /* should be identical with alc260_init_verbs? */
4050static struct hda_verb alc260_hp_init_verbs[] = {
4051 /* Headphone and output */
4052 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4053 /* mono output */
4054 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4055 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4056 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4057 /* Mic2 (front panel) pin widget for input and vref at 80% */
4058 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4059 /* Line In pin widget for input */
4060 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4061 /* Line-2 pin widget for output */
4062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4063 /* CD pin widget for input */
4064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4065 /* unmute amp left and right */
4066 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4067 /* set connection select to line in (default select for this ADC) */
4068 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4069 /* unmute Line-Out mixer amp left and right (volume = 0) */
4070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4071 /* mute pin widget amp left and right (no gain on this amp) */
4072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4073 /* unmute HP mixer amp left and right (volume = 0) */
4074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4075 /* mute pin widget amp left and right (no gain on this amp) */
4076 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4077 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4078 * Line In 2 = 0x03
4079 */
4080 /* mute analog inputs */
4081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4086 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4087 /* Unmute Front out path */
4088 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4089 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4090 /* Unmute Headphone out path */
4091 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4092 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4093 /* Unmute Mono out path */
4094 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4095 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4096 { }
4097};
4098#endif
4099
4100static struct hda_verb alc260_hp_3013_init_verbs[] = {
4101 /* Line out and output */
4102 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4103 /* mono output */
4104 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4105 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4106 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4107 /* Mic2 (front panel) pin widget for input and vref at 80% */
4108 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4109 /* Line In pin widget for input */
4110 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4111 /* Headphone pin widget for output */
4112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4113 /* CD pin widget for input */
4114 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4115 /* unmute amp left and right */
4116 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4117 /* set connection select to line in (default select for this ADC) */
4118 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4119 /* unmute Line-Out mixer amp left and right (volume = 0) */
4120 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4121 /* mute pin widget amp left and right (no gain on this amp) */
4122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4123 /* unmute HP mixer amp left and right (volume = 0) */
4124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4125 /* mute pin widget amp left and right (no gain on this amp) */
4126 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4127 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4128 * Line In 2 = 0x03
4129 */
4130 /* mute analog inputs */
4131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4134 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4136 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4137 /* Unmute Front out path */
4138 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4139 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4140 /* Unmute Headphone out path */
4141 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4142 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4143 /* Unmute Mono out path */
4144 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4145 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4146 { }
4147};
4148
4149/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
4150 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4151 * audio = 0x16, internal speaker = 0x10.
4152 */
4153static struct hda_verb alc260_fujitsu_init_verbs[] = {
4154 /* Disable all GPIOs */
4155 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4156 /* Internal speaker is connected to headphone pin */
4157 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4158 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4159 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4160 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4161 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4162 /* Ensure all other unused pins are disabled and muted. */
4163 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4164 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4165 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4166 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4167 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4168 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4170 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4171
4172 /* Disable digital (SPDIF) pins */
4173 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4174 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4175
4176 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
4177 * when acting as an output.
4178 */
4179 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4180
4181 /* Start with output sum widgets muted and their output gains at min */
4182 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4183 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4184 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4185 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4186 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4187 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4188 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4189 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4190 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4191
4192 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4193 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4194 /* Unmute Line1 pin widget output buffer since it starts as an output.
4195 * If the pin mode is changed by the user the pin mode control will
4196 * take care of enabling the pin's input/output buffers as needed.
4197 * Therefore there's no need to enable the input buffer at this
4198 * stage.
4199 */
4200 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4201 /* Unmute input buffer of pin widget used for Line-in (no equiv
4202 * mixer ctrl)
4203 */
4204 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4205
4206 /* Mute capture amp left and right */
4207 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4208 /* Set ADC connection select to match default mixer setting - line
4209 * in (on mic1 pin)
4210 */
4211 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4212
4213 /* Do the same for the second ADC: mute capture input amp and
4214 * set ADC connection to line in (on mic1 pin)
4215 */
4216 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4217 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4218
4219 /* Mute all inputs to mixer widget (even unconnected ones) */
4220 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4222 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4224 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4228
4229 { }
4230};
4231
4232/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4233 * similar laptops (adapted from Fujitsu init verbs).
4234 */
4235static struct hda_verb alc260_acer_init_verbs[] = {
4236 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4237 * the headphone jack. Turn this on and rely on the standard mute
4238 * methods whenever the user wants to turn these outputs off.
4239 */
4240 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4241 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4242 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4243 /* Internal speaker/Headphone jack is connected to Line-out pin */
4244 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4245 /* Internal microphone/Mic jack is connected to Mic1 pin */
4246 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4247 /* Line In jack is connected to Line1 pin */
4248 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4249 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4250 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4251 /* Ensure all other unused pins are disabled and muted. */
4252 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4253 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4254 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4255 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4258 /* Disable digital (SPDIF) pins */
4259 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4260 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4261
4262 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
4263 * bus when acting as outputs.
4264 */
4265 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4266 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4267
4268 /* Start with output sum widgets muted and their output gains at min */
4269 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4270 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4271 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4272 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4273 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4275 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4276 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4277 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4278
4279 /* Unmute Line-out pin widget amp left and right
4280 * (no equiv mixer ctrl)
4281 */
4282 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4283 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4284 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4285 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4286 * inputs. If the pin mode is changed by the user the pin mode control
4287 * will take care of enabling the pin's input/output buffers as needed.
4288 * Therefore there's no need to enable the input buffer at this
4289 * stage.
4290 */
4291 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4293
4294 /* Mute capture amp left and right */
4295 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4296 /* Set ADC connection select to match default mixer setting - mic
4297 * (on mic1 pin)
4298 */
4299 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4300
4301 /* Do similar with the second ADC: mute capture input amp and
4302 * set ADC connection to mic to match ALSA's default state.
4303 */
4304 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4305 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4306
4307 /* Mute all inputs to mixer widget (even unconnected ones) */
4308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4316
4317 { }
4318};
4319
4320static struct hda_verb alc260_will_verbs[] = {
4321 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4322 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4323 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4324 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4325 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4326 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4327 {}
4328};
4329
4330static struct hda_verb alc260_replacer_672v_verbs[] = {
4331 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4332 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4333 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4334
4335 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4336 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4337 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4338
4339 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4340 {}
4341};
4342
4343/* toggle speaker-output according to the hp-jack state */
4344static void alc260_replacer_672v_automute(struct hda_codec *codec)
4345{
4346 unsigned int present;
4347
4348 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4349 present = snd_hda_codec_read(codec, 0x0f, 0,
4350 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4351 if (present) {
4352 snd_hda_codec_write_cache(codec, 0x01, 0,
4353 AC_VERB_SET_GPIO_DATA, 1);
4354 snd_hda_codec_write_cache(codec, 0x0f, 0,
4355 AC_VERB_SET_PIN_WIDGET_CONTROL,
4356 PIN_HP);
4357 } else {
4358 snd_hda_codec_write_cache(codec, 0x01, 0,
4359 AC_VERB_SET_GPIO_DATA, 0);
4360 snd_hda_codec_write_cache(codec, 0x0f, 0,
4361 AC_VERB_SET_PIN_WIDGET_CONTROL,
4362 PIN_OUT);
4363 }
4364}
4365
4366static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4367 unsigned int res)
4368{
4369 if ((res >> 26) == ALC880_HP_EVENT)
4370 alc260_replacer_672v_automute(codec);
4371}
4372
4373/* Test configuration for debugging, modelled after the ALC880 test
4374 * configuration.
4375 */
4376#ifdef CONFIG_SND_DEBUG
4377static hda_nid_t alc260_test_dac_nids[1] = {
4378 0x02,
4379};
4380static hda_nid_t alc260_test_adc_nids[2] = {
4381 0x04, 0x05,
4382};
4383/* For testing the ALC260, each input MUX needs its own definition since
4384 * the signal assignments are different. This assumes that the first ADC
4385 * is NID 0x04.
4386 */
4387static struct hda_input_mux alc260_test_capture_sources[2] = {
4388 {
4389 .num_items = 7,
4390 .items = {
4391 { "MIC1 pin", 0x0 },
4392 { "MIC2 pin", 0x1 },
4393 { "LINE1 pin", 0x2 },
4394 { "LINE2 pin", 0x3 },
4395 { "CD pin", 0x4 },
4396 { "LINE-OUT pin", 0x5 },
4397 { "HP-OUT pin", 0x6 },
4398 },
4399 },
4400 {
4401 .num_items = 8,
4402 .items = {
4403 { "MIC1 pin", 0x0 },
4404 { "MIC2 pin", 0x1 },
4405 { "LINE1 pin", 0x2 },
4406 { "LINE2 pin", 0x3 },
4407 { "CD pin", 0x4 },
4408 { "Mixer", 0x5 },
4409 { "LINE-OUT pin", 0x6 },
4410 { "HP-OUT pin", 0x7 },
4411 },
4412 },
4413};
4414static struct snd_kcontrol_new alc260_test_mixer[] = {
4415 /* Output driver widgets */
4416 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4417 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4418 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4419 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4420 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4421 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4422
4423 /* Modes for retasking pin widgets
4424 * Note: the ALC260 doesn't seem to act on requests to enable mic
4425 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4426 * mention this restriction. At this stage it's not clear whether
4427 * this behaviour is intentional or is a hardware bug in chip
4428 * revisions available at least up until early 2006. Therefore for
4429 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4430 * choices, but if it turns out that the lack of mic bias for these
4431 * NIDs is intentional we could change their modes from
4432 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4433 */
4434 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4435 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4436 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4437 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4438 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4439 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4440
4441 /* Loopback mixer controls */
4442 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4443 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4444 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4445 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4446 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4447 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4448 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4449 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4450 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4451 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4452 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4453 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4454 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4455 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4456 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4457 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
4458
4459 /* Controls for GPIO pins, assuming they are configured as outputs */
4460 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4461 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4462 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4463 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4464
4465 /* Switches to allow the digital IO pins to be enabled. The datasheet
4466 * is ambigious as to which NID is which; testing on laptops which
4467 * make this output available should provide clarification.
4468 */
4469 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4470 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4471
4472 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4473 * this output to turn on an external amplifier.
4474 */
4475 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4476 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4477
4478 { } /* end */
4479};
4480static struct hda_verb alc260_test_init_verbs[] = {
4481 /* Enable all GPIOs as outputs with an initial value of 0 */
4482 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4483 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4484 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4485
4486 /* Enable retasking pins as output, initially without power amp */
4487 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4488 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4490 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4491 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4492 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4493
4494 /* Disable digital (SPDIF) pins initially, but users can enable
4495 * them via a mixer switch. In the case of SPDIF-out, this initverb
4496 * payload also sets the generation to 0, output to be in "consumer"
4497 * PCM format, copyright asserted, no pre-emphasis and no validity
4498 * control.
4499 */
4500 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4501 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4502
4503 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
4504 * OUT1 sum bus when acting as an output.
4505 */
4506 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4507 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4508 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4509 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4510
4511 /* Start with output sum widgets muted and their output gains at min */
4512 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4513 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4514 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4515 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4516 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4517 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4518 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4519 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4520 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4521
4522 /* Unmute retasking pin widget output buffers since the default
4523 * state appears to be output. As the pin mode is changed by the
4524 * user the pin mode control will take care of enabling the pin's
4525 * input/output buffers as needed.
4526 */
4527 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4528 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4530 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4531 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4532 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4533 /* Also unmute the mono-out pin widget */
4534 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4535
4536 /* Mute capture amp left and right */
4537 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4538 /* Set ADC connection select to match default mixer setting (mic1
4539 * pin)
4540 */
4541 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4542
4543 /* Do the same for the second ADC: mute capture input amp and
4544 * set ADC connection to mic1 pin
4545 */
4546 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4547 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4548
4549 /* Mute all inputs to mixer widget (even unconnected ones) */
4550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4554 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4558
4559 { }
4560};
4561#endif
4562
4563#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4564#define alc260_pcm_analog_capture alc880_pcm_analog_capture
4565
4566#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4567#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4568
4569/*
4570 * for BIOS auto-configuration
4571 */
4572
4573static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4574 const char *pfx)
4575{
4576 hda_nid_t nid_vol;
4577 unsigned long vol_val, sw_val;
4578 char name[32];
4579 int err;
4580
4581 if (nid >= 0x0f && nid < 0x11) {
4582 nid_vol = nid - 0x7;
4583 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4584 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4585 } else if (nid == 0x11) {
4586 nid_vol = nid - 0x7;
4587 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4588 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4589 } else if (nid >= 0x12 && nid <= 0x15) {
4590 nid_vol = 0x08;
4591 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4592 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4593 } else
4594 return 0; /* N/A */
4595
4596 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
4597 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4598 if (err < 0)
4599 return err;
4600 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
4601 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4602 if (err < 0)
4603 return err;
4604 return 1;
4605}
4606
4607/* add playback controls from the parsed DAC table */
4608static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4609 const struct auto_pin_cfg *cfg)
4610{
4611 hda_nid_t nid;
4612 int err;
4613
4614 spec->multiout.num_dacs = 1;
4615 spec->multiout.dac_nids = spec->private_dac_nids;
4616 spec->multiout.dac_nids[0] = 0x02;
4617
4618 nid = cfg->line_out_pins[0];
4619 if (nid) {
4620 err = alc260_add_playback_controls(spec, nid, "Front");
4621 if (err < 0)
4622 return err;
4623 }
4624
4625 nid = cfg->speaker_pins[0];
4626 if (nid) {
4627 err = alc260_add_playback_controls(spec, nid, "Speaker");
4628 if (err < 0)
4629 return err;
4630 }
4631
4632 nid = cfg->hp_pins[0];
4633 if (nid) {
4634 err = alc260_add_playback_controls(spec, nid, "Headphone");
4635 if (err < 0)
4636 return err;
4637 }
4638 return 0;
4639}
4640
4641/* create playback/capture controls for input pins */
4642static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
4643 const struct auto_pin_cfg *cfg)
4644{
4645 struct hda_input_mux *imux = &spec->private_imux;
4646 int i, err, idx;
4647
4648 for (i = 0; i < AUTO_PIN_LAST; i++) {
4649 if (cfg->input_pins[i] >= 0x12) {
4650 idx = cfg->input_pins[i] - 0x12;
4651 err = new_analog_input(spec, cfg->input_pins[i],
4652 auto_pin_cfg_labels[i], idx,
4653 0x07);
4654 if (err < 0)
4655 return err;
4656 imux->items[imux->num_items].label =
4657 auto_pin_cfg_labels[i];
4658 imux->items[imux->num_items].index = idx;
4659 imux->num_items++;
4660 }
4661 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
4662 idx = cfg->input_pins[i] - 0x09;
4663 err = new_analog_input(spec, cfg->input_pins[i],
4664 auto_pin_cfg_labels[i], idx,
4665 0x07);
4666 if (err < 0)
4667 return err;
4668 imux->items[imux->num_items].label =
4669 auto_pin_cfg_labels[i];
4670 imux->items[imux->num_items].index = idx;
4671 imux->num_items++;
4672 }
4673 }
4674 return 0;
4675}
4676
4677static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
4678 hda_nid_t nid, int pin_type,
4679 int sel_idx)
4680{
4681 /* set as output */
4682 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4683 pin_type);
4684 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4685 AMP_OUT_UNMUTE);
4686 /* need the manual connection? */
4687 if (nid >= 0x12) {
4688 int idx = nid - 0x12;
4689 snd_hda_codec_write(codec, idx + 0x0b, 0,
4690 AC_VERB_SET_CONNECT_SEL, sel_idx);
4691 }
4692}
4693
4694static void alc260_auto_init_multi_out(struct hda_codec *codec)
4695{
4696 struct alc_spec *spec = codec->spec;
4697 hda_nid_t nid;
4698
4699 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
4700 nid = spec->autocfg.line_out_pins[0];
4701 if (nid) {
4702 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4703 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
4704 }
4705
4706 nid = spec->autocfg.speaker_pins[0];
4707 if (nid)
4708 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
4709
4710 nid = spec->autocfg.hp_pins[0];
4711 if (nid)
4712 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
4713}
4714
4715#define ALC260_PIN_CD_NID 0x16
4716static void alc260_auto_init_analog_input(struct hda_codec *codec)
4717{
4718 struct alc_spec *spec = codec->spec;
4719 int i;
4720
4721 for (i = 0; i < AUTO_PIN_LAST; i++) {
4722 hda_nid_t nid = spec->autocfg.input_pins[i];
4723 if (nid >= 0x12) {
4724 snd_hda_codec_write(codec, nid, 0,
4725 AC_VERB_SET_PIN_WIDGET_CONTROL,
4726 i <= AUTO_PIN_FRONT_MIC ?
4727 PIN_VREF80 : PIN_IN);
4728 if (nid != ALC260_PIN_CD_NID)
4729 snd_hda_codec_write(codec, nid, 0,
4730 AC_VERB_SET_AMP_GAIN_MUTE,
4731 AMP_OUT_MUTE);
4732 }
4733 }
4734}
4735
4736/*
4737 * generic initialization of ADC, input mixers and output mixers
4738 */
4739static struct hda_verb alc260_volume_init_verbs[] = {
4740 /*
4741 * Unmute ADC0-1 and set the default input to mic-in
4742 */
4743 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4744 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4745 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4746 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4747
4748 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
4749 * mixer widget
4750 * Note: PASD motherboards uses the Line In 2 as the input for
4751 * front panel mic (mic 2)
4752 */
4753 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
4754 /* mute analog inputs */
4755 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4756 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4757 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4758 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4759 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
4760
4761 /*
4762 * Set up output mixers (0x08 - 0x0a)
4763 */
4764 /* set vol=0 to output mixers */
4765 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4766 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4767 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4768 /* set up input amps for analog loopback */
4769 /* Amp Indices: DAC = 0, mixer = 1 */
4770 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4771 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4772 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4773 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4774 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4775 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4776
4777 { }
4778};
4779
4780static int alc260_parse_auto_config(struct hda_codec *codec)
4781{
4782 struct alc_spec *spec = codec->spec;
4783 unsigned int wcap;
4784 int err;
4785 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
4786
4787 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4788 alc260_ignore);
4789 if (err < 0)
4790 return err;
4791 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
4792 if (err < 0)
4793 return err;
4794 if (!spec->kctl_alloc)
4795 return 0; /* can't find valid BIOS pin config */
4796 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
4797 if (err < 0)
4798 return err;
4799
4800 spec->multiout.max_channels = 2;
4801
4802 if (spec->autocfg.dig_out_pin)
4803 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
4804 if (spec->kctl_alloc)
4805 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
4806
4807 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
4808
4809 spec->num_mux_defs = 1;
4810 spec->input_mux = &spec->private_imux;
4811
4812 /* check whether NID 0x04 is valid */
4813 wcap = get_wcaps(codec, 0x04);
4814 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
4815 if (wcap != AC_WID_AUD_IN) {
4816 spec->adc_nids = alc260_adc_nids_alt;
4817 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
4818 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
4819 } else {
4820 spec->adc_nids = alc260_adc_nids;
4821 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
4822 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
4823 }
4824 spec->num_mixers++;
4825
4826 return 1;
4827}
4828
4829/* additional initialization for auto-configuration model */
4830static void alc260_auto_init(struct hda_codec *codec)
4831{
4832 alc260_auto_init_multi_out(codec);
4833 alc260_auto_init_analog_input(codec);
4834}
4835
4836#ifdef CONFIG_SND_HDA_POWER_SAVE
4837static struct hda_amp_list alc260_loopbacks[] = {
4838 { 0x07, HDA_INPUT, 0 },
4839 { 0x07, HDA_INPUT, 1 },
4840 { 0x07, HDA_INPUT, 2 },
4841 { 0x07, HDA_INPUT, 3 },
4842 { 0x07, HDA_INPUT, 4 },
4843 { } /* end */
4844};
4845#endif
4846
4847/*
4848 * ALC260 configurations
4849 */
4850static const char *alc260_models[ALC260_MODEL_LAST] = {
4851 [ALC260_BASIC] = "basic",
4852 [ALC260_HP] = "hp",
4853 [ALC260_HP_3013] = "hp-3013",
4854 [ALC260_FUJITSU_S702X] = "fujitsu",
4855 [ALC260_ACER] = "acer",
4856 [ALC260_WILL] = "will",
4857 [ALC260_REPLACER_672V] = "replacer",
4858#ifdef CONFIG_SND_DEBUG
4859 [ALC260_TEST] = "test",
4860#endif
4861 [ALC260_AUTO] = "auto",
4862};
4863
4864static struct snd_pci_quirk alc260_cfg_tbl[] = {
4865 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
4866 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
4867 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
4868 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
4869 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
4870 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
4871 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
4872 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
4873 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
4874 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
4875 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
4876 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
4877 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
4878 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
4879 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
4880 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
4881 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
4882 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
4883 {}
4884};
4885
4886static struct alc_config_preset alc260_presets[] = {
4887 [ALC260_BASIC] = {
4888 .mixers = { alc260_base_output_mixer,
4889 alc260_input_mixer,
4890 alc260_pc_beep_mixer,
4891 alc260_capture_mixer },
4892 .init_verbs = { alc260_init_verbs },
4893 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4894 .dac_nids = alc260_dac_nids,
4895 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4896 .adc_nids = alc260_adc_nids,
4897 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4898 .channel_mode = alc260_modes,
4899 .input_mux = &alc260_capture_source,
4900 },
4901 [ALC260_HP] = {
4902 .mixers = { alc260_base_output_mixer,
4903 alc260_input_mixer,
4904 alc260_capture_alt_mixer },
4905 .init_verbs = { alc260_init_verbs },
4906 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4907 .dac_nids = alc260_dac_nids,
4908 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4909 .adc_nids = alc260_hp_adc_nids,
4910 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4911 .channel_mode = alc260_modes,
4912 .input_mux = &alc260_capture_source,
4913 },
4914 [ALC260_HP_3013] = {
4915 .mixers = { alc260_hp_3013_mixer,
4916 alc260_input_mixer,
4917 alc260_capture_alt_mixer },
4918 .init_verbs = { alc260_hp_3013_init_verbs },
4919 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4920 .dac_nids = alc260_dac_nids,
4921 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
4922 .adc_nids = alc260_hp_adc_nids,
4923 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4924 .channel_mode = alc260_modes,
4925 .input_mux = &alc260_capture_source,
4926 },
4927 [ALC260_FUJITSU_S702X] = {
4928 .mixers = { alc260_fujitsu_mixer,
4929 alc260_capture_mixer },
4930 .init_verbs = { alc260_fujitsu_init_verbs },
4931 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4932 .dac_nids = alc260_dac_nids,
4933 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4934 .adc_nids = alc260_dual_adc_nids,
4935 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4936 .channel_mode = alc260_modes,
4937 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
4938 .input_mux = alc260_fujitsu_capture_sources,
4939 },
4940 [ALC260_ACER] = {
4941 .mixers = { alc260_acer_mixer,
4942 alc260_capture_mixer },
4943 .init_verbs = { alc260_acer_init_verbs },
4944 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4945 .dac_nids = alc260_dac_nids,
4946 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
4947 .adc_nids = alc260_dual_adc_nids,
4948 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4949 .channel_mode = alc260_modes,
4950 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
4951 .input_mux = alc260_acer_capture_sources,
4952 },
4953 [ALC260_WILL] = {
4954 .mixers = { alc260_will_mixer,
4955 alc260_capture_mixer },
4956 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
4957 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4958 .dac_nids = alc260_dac_nids,
4959 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4960 .adc_nids = alc260_adc_nids,
4961 .dig_out_nid = ALC260_DIGOUT_NID,
4962 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4963 .channel_mode = alc260_modes,
4964 .input_mux = &alc260_capture_source,
4965 },
4966 [ALC260_REPLACER_672V] = {
4967 .mixers = { alc260_replacer_672v_mixer,
4968 alc260_capture_mixer },
4969 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
4970 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
4971 .dac_nids = alc260_dac_nids,
4972 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
4973 .adc_nids = alc260_adc_nids,
4974 .dig_out_nid = ALC260_DIGOUT_NID,
4975 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4976 .channel_mode = alc260_modes,
4977 .input_mux = &alc260_capture_source,
4978 .unsol_event = alc260_replacer_672v_unsol_event,
4979 .init_hook = alc260_replacer_672v_automute,
4980 },
4981#ifdef CONFIG_SND_DEBUG
4982 [ALC260_TEST] = {
4983 .mixers = { alc260_test_mixer,
4984 alc260_capture_mixer },
4985 .init_verbs = { alc260_test_init_verbs },
4986 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
4987 .dac_nids = alc260_test_dac_nids,
4988 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
4989 .adc_nids = alc260_test_adc_nids,
4990 .num_channel_mode = ARRAY_SIZE(alc260_modes),
4991 .channel_mode = alc260_modes,
4992 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
4993 .input_mux = alc260_test_capture_sources,
4994 },
4995#endif
4996};
4997
4998static int patch_alc260(struct hda_codec *codec)
4999{
5000 struct alc_spec *spec;
5001 int err, board_config;
5002
5003 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5004 if (spec == NULL)
5005 return -ENOMEM;
5006
5007 codec->spec = spec;
5008
5009 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5010 alc260_models,
5011 alc260_cfg_tbl);
5012 if (board_config < 0) {
5013 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5014 "trying auto-probe from BIOS...\n");
5015 board_config = ALC260_AUTO;
5016 }
5017
5018 if (board_config == ALC260_AUTO) {
5019 /* automatic parse from the BIOS config */
5020 err = alc260_parse_auto_config(codec);
5021 if (err < 0) {
5022 alc_free(codec);
5023 return err;
5024 } else if (!err) {
5025 printk(KERN_INFO
5026 "hda_codec: Cannot set up configuration "
5027 "from BIOS. Using base mode...\n");
5028 board_config = ALC260_BASIC;
5029 }
5030 }
5031
5032 if (board_config != ALC260_AUTO)
5033 setup_preset(spec, &alc260_presets[board_config]);
5034
5035 spec->stream_name_analog = "ALC260 Analog";
5036 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5037 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5038
5039 spec->stream_name_digital = "ALC260 Digital";
5040 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5041 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5042
5043 spec->vmaster_nid = 0x08;
5044
5045 codec->patch_ops = alc_patch_ops;
5046 if (board_config == ALC260_AUTO)
5047 spec->init_hook = alc260_auto_init;
5048#ifdef CONFIG_SND_HDA_POWER_SAVE
5049 if (!spec->loopback.amplist)
5050 spec->loopback.amplist = alc260_loopbacks;
5051#endif
5052
5053 return 0;
5054}
5055
5056
5057/*
5058 * ALC882 support
5059 *
5060 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5061 * configuration. Each pin widget can choose any input DACs and a mixer.
5062 * Each ADC is connected from a mixer of all inputs. This makes possible
5063 * 6-channel independent captures.
5064 *
5065 * In addition, an independent DAC for the multi-playback (not used in this
5066 * driver yet).
5067 */
5068#define ALC882_DIGOUT_NID 0x06
5069#define ALC882_DIGIN_NID 0x0a
5070
5071static struct hda_channel_mode alc882_ch_modes[1] = {
5072 { 8, NULL }
5073};
5074
5075static hda_nid_t alc882_dac_nids[4] = {
5076 /* front, rear, clfe, rear_surr */
5077 0x02, 0x03, 0x04, 0x05
5078};
5079
5080/* identical with ALC880 */
5081#define alc882_adc_nids alc880_adc_nids
5082#define alc882_adc_nids_alt alc880_adc_nids_alt
5083
5084/* input MUX */
5085/* FIXME: should be a matrix-type input source selection */
5086
5087static struct hda_input_mux alc882_capture_source = {
5088 .num_items = 4,
5089 .items = {
5090 { "Mic", 0x0 },
5091 { "Front Mic", 0x1 },
5092 { "Line", 0x2 },
5093 { "CD", 0x4 },
5094 },
5095};
5096#define alc882_mux_enum_info alc_mux_enum_info
5097#define alc882_mux_enum_get alc_mux_enum_get
5098
5099static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5100 struct snd_ctl_elem_value *ucontrol)
5101{
5102 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5103 struct alc_spec *spec = codec->spec;
5104 const struct hda_input_mux *imux = spec->input_mux;
5105 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
5106 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
5107 hda_nid_t nid = capture_mixers[adc_idx];
5108 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5109 unsigned int i, idx;
5110
5111 idx = ucontrol->value.enumerated.item[0];
5112 if (idx >= imux->num_items)
5113 idx = imux->num_items - 1;
5114 if (*cur_val == idx)
5115 return 0;
5116 for (i = 0; i < imux->num_items; i++) {
5117 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5118 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
5119 imux->items[i].index,
5120 HDA_AMP_MUTE, v);
5121 }
5122 *cur_val = idx;
5123 return 1;
5124}
5125
5126/*
5127 * 2ch mode
5128 */
5129static struct hda_verb alc882_3ST_ch2_init[] = {
5130 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5131 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5132 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5133 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5134 { } /* end */
5135};
5136
5137/*
5138 * 6ch mode
5139 */
5140static struct hda_verb alc882_3ST_ch6_init[] = {
5141 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5142 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5143 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5144 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5145 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5146 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5147 { } /* end */
5148};
5149
5150static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5151 { 2, alc882_3ST_ch2_init },
5152 { 6, alc882_3ST_ch6_init },
5153};
5154
5155/*
5156 * 6ch mode
5157 */
5158static struct hda_verb alc882_sixstack_ch6_init[] = {
5159 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5160 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5161 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5162 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5163 { } /* end */
5164};
5165
5166/*
5167 * 8ch mode
5168 */
5169static struct hda_verb alc882_sixstack_ch8_init[] = {
5170 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5171 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5172 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5173 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5174 { } /* end */
5175};
5176
5177static struct hda_channel_mode alc882_sixstack_modes[2] = {
5178 { 6, alc882_sixstack_ch6_init },
5179 { 8, alc882_sixstack_ch8_init },
5180};
5181
5182/*
5183 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5184 */
5185
5186/*
5187 * 2ch mode
5188 */
5189static struct hda_verb alc885_mbp_ch2_init[] = {
5190 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5191 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5192 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5193 { } /* end */
5194};
5195
5196/*
5197 * 6ch mode
5198 */
5199static struct hda_verb alc885_mbp_ch6_init[] = {
5200 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5201 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5202 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5203 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5204 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5205 { } /* end */
5206};
5207
5208static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5209 { 2, alc885_mbp_ch2_init },
5210 { 6, alc885_mbp_ch6_init },
5211};
5212
5213
5214/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5215 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5216 */
5217static struct snd_kcontrol_new alc882_base_mixer[] = {
5218 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5219 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5220 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
5221 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
5222 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5223 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
5224 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5225 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
5226 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
5227 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
5228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5229 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5230 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5231 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5232 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5234 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5235 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5236 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5237 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5238 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5239 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5240 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5241 { } /* end */
5242};
5243
5244static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
5245 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5246 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5247 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5248 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5249 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5250 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5252 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
5253 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
5254 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5255 { } /* end */
5256};
5257static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5258 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5259 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5260 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5261 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5262 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5263 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5266 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5267 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5268 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5269 { } /* end */
5270};
5271
5272static struct snd_kcontrol_new alc882_targa_mixer[] = {
5273 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5274 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5278 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5279 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5282 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5283 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5284 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5285 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
5286 { } /* end */
5287};
5288
5289/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5290 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5291 */
5292static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5293 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5294 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5295 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5296 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5297 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5298 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5299 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5300 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5301 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5302 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5304 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5305 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5306 { } /* end */
5307};
5308
5309static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5310 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5311 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5312 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5318 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5320 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5321 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5322 { } /* end */
5323};
5324
5325static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5326 {
5327 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5328 .name = "Channel Mode",
5329 .info = alc_ch_mode_info,
5330 .get = alc_ch_mode_get,
5331 .put = alc_ch_mode_put,
5332 },
5333 { } /* end */
5334};
5335
5336static struct hda_verb alc882_init_verbs[] = {
5337 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5341 /* Rear mixer */
5342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5344 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5345 /* CLFE mixer */
5346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5349 /* Side mixer */
5350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5353
5354 /* Front Pin: output 0 (0x0c) */
5355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5356 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5357 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5358 /* Rear Pin: output 1 (0x0d) */
5359 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5361 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5362 /* CLFE Pin: output 2 (0x0e) */
5363 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5364 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5365 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
5366 /* Side Pin: output 3 (0x0f) */
5367 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5368 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5369 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
5370 /* Mic (rear) pin: input vref at 80% */
5371 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5372 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5373 /* Front Mic pin: input vref at 80% */
5374 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5376 /* Line In pin: input */
5377 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5379 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5380 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5381 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5382 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
5383 /* CD pin widget for input */
5384 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5385
5386 /* FIXME: use matrix-type input source selection */
5387 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5388 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5389 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5390 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5391 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5392 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5393 /* Input mixer2 */
5394 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5395 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5396 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5398 /* Input mixer3 */
5399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5401 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5403 /* ADC1: mute amp left and right */
5404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5405 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5406 /* ADC2: mute amp left and right */
5407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5408 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5409 /* ADC3: mute amp left and right */
5410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5411 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5412
5413 { }
5414};
5415
5416static struct hda_verb alc882_eapd_verbs[] = {
5417 /* change to EAPD mode */
5418 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
5419 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
5420 { }
5421};
5422
5423/* Mac Pro test */
5424static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5425 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5426 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5430 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5431 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5432 { } /* end */
5433};
5434
5435static struct hda_verb alc882_macpro_init_verbs[] = {
5436 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5438 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5439 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5440 /* Front Pin: output 0 (0x0c) */
5441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5442 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5443 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5444 /* Front Mic pin: input vref at 80% */
5445 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5446 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5447 /* Speaker: output */
5448 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5449 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5450 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5451 /* Headphone output (output 0 - 0x0c) */
5452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5453 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5454 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5455
5456 /* FIXME: use matrix-type input source selection */
5457 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5458 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5461 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5462 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5463 /* Input mixer2 */
5464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5465 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5466 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5467 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5468 /* Input mixer3 */
5469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5471 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5473 /* ADC1: mute amp left and right */
5474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5475 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5476 /* ADC2: mute amp left and right */
5477 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5478 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5479 /* ADC3: mute amp left and right */
5480 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5481 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5482
5483 { }
5484};
5485
5486/* Macbook Pro rev3 */
5487static struct hda_verb alc885_mbp3_init_verbs[] = {
5488 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5492 /* Rear mixer */
5493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5494 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5495 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5496 /* Front Pin: output 0 (0x0c) */
5497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5499 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5500 /* HP Pin: output 0 (0x0d) */
5501 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5502 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5503 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5504 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5505 /* Mic (rear) pin: input vref at 80% */
5506 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5507 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5508 /* Front Mic pin: input vref at 80% */
5509 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5510 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5511 /* Line In pin: use output 1 when in LineOut mode */
5512 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5513 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5514 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5515
5516 /* FIXME: use matrix-type input source selection */
5517 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5518 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5519 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5520 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5521 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5522 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5523 /* Input mixer2 */
5524 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5527 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5528 /* Input mixer3 */
5529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5531 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5532 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5533 /* ADC1: mute amp left and right */
5534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5535 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5536 /* ADC2: mute amp left and right */
5537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5538 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5539 /* ADC3: mute amp left and right */
5540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5541 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5542
5543 { }
5544};
5545
5546/* iMac 24 mixer. */
5547static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5548 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5549 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5550 { } /* end */
5551};
5552
5553/* iMac 24 init verbs. */
5554static struct hda_verb alc885_imac24_init_verbs[] = {
5555 /* Internal speakers: output 0 (0x0c) */
5556 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5557 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5558 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5559 /* Internal speakers: output 0 (0x0c) */
5560 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5561 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5562 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5563 /* Headphone: output 0 (0x0c) */
5564 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5565 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5566 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5567 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5568 /* Front Mic: input vref at 80% */
5569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5571 { }
5572};
5573
5574/* Toggle speaker-output according to the hp-jack state */
5575static void alc885_imac24_automute(struct hda_codec *codec)
5576{
5577 unsigned int present;
5578
5579 present = snd_hda_codec_read(codec, 0x14, 0,
5580 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5581 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5582 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5583 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5584 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5585}
5586
5587/* Processes unsolicited events. */
5588static void alc885_imac24_unsol_event(struct hda_codec *codec,
5589 unsigned int res)
5590{
5591 /* Headphone insertion or removal. */
5592 if ((res >> 26) == ALC880_HP_EVENT)
5593 alc885_imac24_automute(codec);
5594}
5595
5596static void alc885_mbp3_automute(struct hda_codec *codec)
5597{
5598 unsigned int present;
5599
5600 present = snd_hda_codec_read(codec, 0x15, 0,
5601 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5602 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
5603 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5604 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
5605 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
5606
5607}
5608static void alc885_mbp3_unsol_event(struct hda_codec *codec,
5609 unsigned int res)
5610{
5611 /* Headphone insertion or removal. */
5612 if ((res >> 26) == ALC880_HP_EVENT)
5613 alc885_mbp3_automute(codec);
5614}
5615
5616
5617static struct hda_verb alc882_targa_verbs[] = {
5618 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5619 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5620
5621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5623
5624 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5625 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5626 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5627
5628 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5629 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
5630 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
5631 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
5632 { } /* end */
5633};
5634
5635/* toggle speaker-output according to the hp-jack state */
5636static void alc882_targa_automute(struct hda_codec *codec)
5637{
5638 unsigned int present;
5639
5640 present = snd_hda_codec_read(codec, 0x14, 0,
5641 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5642 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
5643 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5644 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
5645 present ? 1 : 3);
5646}
5647
5648static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
5649{
5650 /* Looks like the unsol event is incompatible with the standard
5651 * definition. 4bit tag is placed at 26 bit!
5652 */
5653 if (((res >> 26) == ALC880_HP_EVENT)) {
5654 alc882_targa_automute(codec);
5655 }
5656}
5657
5658static struct hda_verb alc882_asus_a7j_verbs[] = {
5659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5661
5662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5665
5666 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5668 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5669
5670 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5671 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5672 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5673 { } /* end */
5674};
5675
5676static struct hda_verb alc882_asus_a7m_verbs[] = {
5677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5679
5680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5682 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5683
5684 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5686 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
5687
5688 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
5689 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
5690 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
5691 { } /* end */
5692};
5693
5694static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
5695{
5696 unsigned int gpiostate, gpiomask, gpiodir;
5697
5698 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
5699 AC_VERB_GET_GPIO_DATA, 0);
5700
5701 if (!muted)
5702 gpiostate |= (1 << pin);
5703 else
5704 gpiostate &= ~(1 << pin);
5705
5706 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
5707 AC_VERB_GET_GPIO_MASK, 0);
5708 gpiomask |= (1 << pin);
5709
5710 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
5711 AC_VERB_GET_GPIO_DIRECTION, 0);
5712 gpiodir |= (1 << pin);
5713
5714
5715 snd_hda_codec_write(codec, codec->afg, 0,
5716 AC_VERB_SET_GPIO_MASK, gpiomask);
5717 snd_hda_codec_write(codec, codec->afg, 0,
5718 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
5719
5720 msleep(1);
5721
5722 snd_hda_codec_write(codec, codec->afg, 0,
5723 AC_VERB_SET_GPIO_DATA, gpiostate);
5724}
5725
5726/* set up GPIO at initialization */
5727static void alc885_macpro_init_hook(struct hda_codec *codec)
5728{
5729 alc882_gpio_mute(codec, 0, 0);
5730 alc882_gpio_mute(codec, 1, 0);
5731}
5732
5733/* set up GPIO and update auto-muting at initialization */
5734static void alc885_imac24_init_hook(struct hda_codec *codec)
5735{
5736 alc885_macpro_init_hook(codec);
5737 alc885_imac24_automute(codec);
5738}
5739
5740/*
5741 * generic initialization of ADC, input mixers and output mixers
5742 */
5743static struct hda_verb alc882_auto_init_verbs[] = {
5744 /*
5745 * Unmute ADC0-2 and set the default input to mic-in
5746 */
5747 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5749 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5750 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5751 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5752 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5753
5754 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5755 * mixer widget
5756 * Note: PASD motherboards uses the Line In 2 as the input for
5757 * front panel mic (mic 2)
5758 */
5759 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
5760 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5761 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5762 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5763 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5764 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5765
5766 /*
5767 * Set up output mixers (0x0c - 0x0f)
5768 */
5769 /* set vol=0 to output mixers */
5770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5771 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5772 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5773 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5774 /* set up input amps for analog loopback */
5775 /* Amp Indices: DAC = 0, mixer = 1 */
5776 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5777 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5778 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5779 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5780 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5781 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5782 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5783 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5784 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5785 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5786
5787 /* FIXME: use matrix-type input source selection */
5788 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5789 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5790 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5791 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5792 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5793 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5794 /* Input mixer2 */
5795 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5798 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5799 /* Input mixer3 */
5800 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5801 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
5802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
5803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
5804
5805 { }
5806};
5807
5808/* capture mixer elements */
5809static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
5810 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
5811 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
5812 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
5813 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
5814 {
5815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5816 /* The multiple "Capture Source" controls confuse alsamixer
5817 * So call somewhat different..
5818 */
5819 /* .name = "Capture Source", */
5820 .name = "Input Source",
5821 .count = 2,
5822 .info = alc882_mux_enum_info,
5823 .get = alc882_mux_enum_get,
5824 .put = alc882_mux_enum_put,
5825 },
5826 { } /* end */
5827};
5828
5829static struct snd_kcontrol_new alc882_capture_mixer[] = {
5830 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
5831 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
5832 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
5833 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
5834 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
5835 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
5836 {
5837 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5838 /* The multiple "Capture Source" controls confuse alsamixer
5839 * So call somewhat different..
5840 */
5841 /* .name = "Capture Source", */
5842 .name = "Input Source",
5843 .count = 3,
5844 .info = alc882_mux_enum_info,
5845 .get = alc882_mux_enum_get,
5846 .put = alc882_mux_enum_put,
5847 },
5848 { } /* end */
5849};
5850
5851#ifdef CONFIG_SND_HDA_POWER_SAVE
5852#define alc882_loopbacks alc880_loopbacks
5853#endif
5854
5855/* pcm configuration: identiacal with ALC880 */
5856#define alc882_pcm_analog_playback alc880_pcm_analog_playback
5857#define alc882_pcm_analog_capture alc880_pcm_analog_capture
5858#define alc882_pcm_digital_playback alc880_pcm_digital_playback
5859#define alc882_pcm_digital_capture alc880_pcm_digital_capture
5860
5861/*
5862 * configuration and preset
5863 */
5864static const char *alc882_models[ALC882_MODEL_LAST] = {
5865 [ALC882_3ST_DIG] = "3stack-dig",
5866 [ALC882_6ST_DIG] = "6stack-dig",
5867 [ALC882_ARIMA] = "arima",
5868 [ALC882_W2JC] = "w2jc",
5869 [ALC882_TARGA] = "targa",
5870 [ALC882_ASUS_A7J] = "asus-a7j",
5871 [ALC882_ASUS_A7M] = "asus-a7m",
5872 [ALC885_MACPRO] = "macpro",
5873 [ALC885_MBP3] = "mbp3",
5874 [ALC885_IMAC24] = "imac24",
5875 [ALC882_AUTO] = "auto",
5876};
5877
5878static struct snd_pci_quirk alc882_cfg_tbl[] = {
5879 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
5880 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
5881 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
5882 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
5883 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
5884 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
5885 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
5886 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
5887 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
5888 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
5889 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
5890 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
5891 {}
5892};
5893
5894static struct alc_config_preset alc882_presets[] = {
5895 [ALC882_3ST_DIG] = {
5896 .mixers = { alc882_base_mixer },
5897 .init_verbs = { alc882_init_verbs },
5898 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5899 .dac_nids = alc882_dac_nids,
5900 .dig_out_nid = ALC882_DIGOUT_NID,
5901 .dig_in_nid = ALC882_DIGIN_NID,
5902 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5903 .channel_mode = alc882_ch_modes,
5904 .need_dac_fix = 1,
5905 .input_mux = &alc882_capture_source,
5906 },
5907 [ALC882_6ST_DIG] = {
5908 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5909 .init_verbs = { alc882_init_verbs },
5910 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5911 .dac_nids = alc882_dac_nids,
5912 .dig_out_nid = ALC882_DIGOUT_NID,
5913 .dig_in_nid = ALC882_DIGIN_NID,
5914 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5915 .channel_mode = alc882_sixstack_modes,
5916 .input_mux = &alc882_capture_source,
5917 },
5918 [ALC882_ARIMA] = {
5919 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
5920 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
5921 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5922 .dac_nids = alc882_dac_nids,
5923 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
5924 .channel_mode = alc882_sixstack_modes,
5925 .input_mux = &alc882_capture_source,
5926 },
5927 [ALC882_W2JC] = {
5928 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
5929 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
5930 alc880_gpio1_init_verbs },
5931 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5932 .dac_nids = alc882_dac_nids,
5933 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
5934 .channel_mode = alc880_threestack_modes,
5935 .need_dac_fix = 1,
5936 .input_mux = &alc882_capture_source,
5937 .dig_out_nid = ALC882_DIGOUT_NID,
5938 },
5939 [ALC885_MBP3] = {
5940 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
5941 .init_verbs = { alc885_mbp3_init_verbs,
5942 alc880_gpio1_init_verbs },
5943 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5944 .dac_nids = alc882_dac_nids,
5945 .channel_mode = alc885_mbp_6ch_modes,
5946 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
5947 .input_mux = &alc882_capture_source,
5948 .dig_out_nid = ALC882_DIGOUT_NID,
5949 .dig_in_nid = ALC882_DIGIN_NID,
5950 .unsol_event = alc885_mbp3_unsol_event,
5951 .init_hook = alc885_mbp3_automute,
5952 },
5953 [ALC885_MACPRO] = {
5954 .mixers = { alc882_macpro_mixer },
5955 .init_verbs = { alc882_macpro_init_verbs },
5956 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5957 .dac_nids = alc882_dac_nids,
5958 .dig_out_nid = ALC882_DIGOUT_NID,
5959 .dig_in_nid = ALC882_DIGIN_NID,
5960 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5961 .channel_mode = alc882_ch_modes,
5962 .input_mux = &alc882_capture_source,
5963 .init_hook = alc885_macpro_init_hook,
5964 },
5965 [ALC885_IMAC24] = {
5966 .mixers = { alc885_imac24_mixer },
5967 .init_verbs = { alc885_imac24_init_verbs },
5968 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5969 .dac_nids = alc882_dac_nids,
5970 .dig_out_nid = ALC882_DIGOUT_NID,
5971 .dig_in_nid = ALC882_DIGIN_NID,
5972 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
5973 .channel_mode = alc882_ch_modes,
5974 .input_mux = &alc882_capture_source,
5975 .unsol_event = alc885_imac24_unsol_event,
5976 .init_hook = alc885_imac24_init_hook,
5977 },
5978 [ALC882_TARGA] = {
5979 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
5980 alc882_capture_mixer },
5981 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
5982 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5983 .dac_nids = alc882_dac_nids,
5984 .dig_out_nid = ALC882_DIGOUT_NID,
5985 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
5986 .adc_nids = alc882_adc_nids,
5987 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
5988 .channel_mode = alc882_3ST_6ch_modes,
5989 .need_dac_fix = 1,
5990 .input_mux = &alc882_capture_source,
5991 .unsol_event = alc882_targa_unsol_event,
5992 .init_hook = alc882_targa_automute,
5993 },
5994 [ALC882_ASUS_A7J] = {
5995 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
5996 alc882_capture_mixer },
5997 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
5998 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
5999 .dac_nids = alc882_dac_nids,
6000 .dig_out_nid = ALC882_DIGOUT_NID,
6001 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6002 .adc_nids = alc882_adc_nids,
6003 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6004 .channel_mode = alc882_3ST_6ch_modes,
6005 .need_dac_fix = 1,
6006 .input_mux = &alc882_capture_source,
6007 },
6008 [ALC882_ASUS_A7M] = {
6009 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6010 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6011 alc880_gpio1_init_verbs,
6012 alc882_asus_a7m_verbs },
6013 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6014 .dac_nids = alc882_dac_nids,
6015 .dig_out_nid = ALC882_DIGOUT_NID,
6016 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6017 .channel_mode = alc880_threestack_modes,
6018 .need_dac_fix = 1,
6019 .input_mux = &alc882_capture_source,
6020 },
6021};
6022
6023
6024/*
6025 * Pin config fixes
6026 */
6027enum {
6028 PINFIX_ABIT_AW9D_MAX
6029};
6030
6031static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6032 { 0x15, 0x01080104 }, /* side */
6033 { 0x16, 0x01011012 }, /* rear */
6034 { 0x17, 0x01016011 }, /* clfe */
6035 { }
6036};
6037
6038static const struct alc_pincfg *alc882_pin_fixes[] = {
6039 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6040};
6041
6042static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6043 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6044 {}
6045};
6046
6047/*
6048 * BIOS auto configuration
6049 */
6050static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6051 hda_nid_t nid, int pin_type,
6052 int dac_idx)
6053{
6054 /* set as output */
6055 struct alc_spec *spec = codec->spec;
6056 int idx;
6057
6058 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6059 idx = 4;
6060 else
6061 idx = spec->multiout.dac_nids[dac_idx] - 2;
6062
6063 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6064 pin_type);
6065 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
6066 AMP_OUT_UNMUTE);
6067 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6068
6069}
6070
6071static void alc882_auto_init_multi_out(struct hda_codec *codec)
6072{
6073 struct alc_spec *spec = codec->spec;
6074 int i;
6075
6076 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
6077 for (i = 0; i <= HDA_SIDE; i++) {
6078 hda_nid_t nid = spec->autocfg.line_out_pins[i];
6079 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6080 if (nid)
6081 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
6082 i);
6083 }
6084}
6085
6086static void alc882_auto_init_hp_out(struct hda_codec *codec)
6087{
6088 struct alc_spec *spec = codec->spec;
6089 hda_nid_t pin;
6090
6091 pin = spec->autocfg.hp_pins[0];
6092 if (pin) /* connect to front */
6093 /* use dac 0 */
6094 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
6095}
6096
6097#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6098#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6099
6100static void alc882_auto_init_analog_input(struct hda_codec *codec)
6101{
6102 struct alc_spec *spec = codec->spec;
6103 int i;
6104
6105 for (i = 0; i < AUTO_PIN_LAST; i++) {
6106 hda_nid_t nid = spec->autocfg.input_pins[i];
6107 if (alc882_is_input_pin(nid)) {
6108 snd_hda_codec_write(codec, nid, 0,
6109 AC_VERB_SET_PIN_WIDGET_CONTROL,
6110 i <= AUTO_PIN_FRONT_MIC ?
6111 PIN_VREF80 : PIN_IN);
6112 if (nid != ALC882_PIN_CD_NID)
6113 snd_hda_codec_write(codec, nid, 0,
6114 AC_VERB_SET_AMP_GAIN_MUTE,
6115 AMP_OUT_MUTE);
6116 }
6117 }
6118}
6119
6120/* add mic boosts if needed */
6121static int alc_auto_add_mic_boost(struct hda_codec *codec)
6122{
6123 struct alc_spec *spec = codec->spec;
6124 int err;
6125 hda_nid_t nid;
6126
6127 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
6128 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6129 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6130 "Mic Boost",
6131 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6132 if (err < 0)
6133 return err;
6134 }
6135 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
6136 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
6137 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6138 "Front Mic Boost",
6139 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6140 if (err < 0)
6141 return err;
6142 }
6143 return 0;
6144}
6145
6146/* almost identical with ALC880 parser... */
6147static int alc882_parse_auto_config(struct hda_codec *codec)
6148{
6149 struct alc_spec *spec = codec->spec;
6150 int err = alc880_parse_auto_config(codec);
6151
6152 if (err < 0)
6153 return err;
6154 else if (!err)
6155 return 0; /* no config found */
6156
6157 err = alc_auto_add_mic_boost(codec);
6158 if (err < 0)
6159 return err;
6160
6161 /* hack - override the init verbs */
6162 spec->init_verbs[0] = alc882_auto_init_verbs;
6163
6164 return 1; /* config found */
6165}
6166
6167/* additional initialization for auto-configuration model */
6168static void alc882_auto_init(struct hda_codec *codec)
6169{
6170 alc882_auto_init_multi_out(codec);
6171 alc882_auto_init_hp_out(codec);
6172 alc882_auto_init_analog_input(codec);
6173}
6174
6175static int patch_alc882(struct hda_codec *codec)
6176{
6177 struct alc_spec *spec;
6178 int err, board_config;
6179
6180 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6181 if (spec == NULL)
6182 return -ENOMEM;
6183
6184 codec->spec = spec;
6185
6186 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6187 alc882_models,
6188 alc882_cfg_tbl);
6189
6190 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
6191 /* Pick up systems that don't supply PCI SSID */
6192 switch (codec->subsystem_id) {
6193 case 0x106b0c00: /* Mac Pro */
6194 board_config = ALC885_MACPRO;
6195 break;
6196 case 0x106b1000: /* iMac 24 */
6197 board_config = ALC885_IMAC24;
6198 break;
6199 case 0x106b00a1: /* Macbook */
6200 case 0x106b2c00: /* Macbook Pro rev3 */
6201 board_config = ALC885_MBP3;
6202 break;
6203 default:
6204 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6205 "trying auto-probe from BIOS...\n");
6206 board_config = ALC882_AUTO;
6207 }
6208 }
6209
6210 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6211
6212 if (board_config == ALC882_AUTO) {
6213 /* automatic parse from the BIOS config */
6214 err = alc882_parse_auto_config(codec);
6215 if (err < 0) {
6216 alc_free(codec);
6217 return err;
6218 } else if (!err) {
6219 printk(KERN_INFO
6220 "hda_codec: Cannot set up configuration "
6221 "from BIOS. Using base mode...\n");
6222 board_config = ALC882_3ST_DIG;
6223 }
6224 }
6225
6226 if (board_config != ALC882_AUTO)
6227 setup_preset(spec, &alc882_presets[board_config]);
6228
6229 spec->stream_name_analog = "ALC882 Analog";
6230 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6231 spec->stream_analog_capture = &alc882_pcm_analog_capture;
6232 /* FIXME: setup DAC5 */
6233 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6234 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
6235
6236 spec->stream_name_digital = "ALC882 Digital";
6237 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6238 spec->stream_digital_capture = &alc882_pcm_digital_capture;
6239
6240 if (!spec->adc_nids && spec->input_mux) {
6241 /* check whether NID 0x07 is valid */
6242 unsigned int wcap = get_wcaps(codec, 0x07);
6243 /* get type */
6244 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
6245 if (wcap != AC_WID_AUD_IN) {
6246 spec->adc_nids = alc882_adc_nids_alt;
6247 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
6248 spec->mixers[spec->num_mixers] =
6249 alc882_capture_alt_mixer;
6250 spec->num_mixers++;
6251 } else {
6252 spec->adc_nids = alc882_adc_nids;
6253 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
6254 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6255 spec->num_mixers++;
6256 }
6257 }
6258
6259 spec->vmaster_nid = 0x0c;
6260
6261 codec->patch_ops = alc_patch_ops;
6262 if (board_config == ALC882_AUTO)
6263 spec->init_hook = alc882_auto_init;
6264#ifdef CONFIG_SND_HDA_POWER_SAVE
6265 if (!spec->loopback.amplist)
6266 spec->loopback.amplist = alc882_loopbacks;
6267#endif
6268
6269 return 0;
6270}
6271
6272/*
6273 * ALC883 support
6274 *
6275 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6276 * configuration. Each pin widget can choose any input DACs and a mixer.
6277 * Each ADC is connected from a mixer of all inputs. This makes possible
6278 * 6-channel independent captures.
6279 *
6280 * In addition, an independent DAC for the multi-playback (not used in this
6281 * driver yet).
6282 */
6283#define ALC883_DIGOUT_NID 0x06
6284#define ALC883_DIGIN_NID 0x0a
6285
6286static hda_nid_t alc883_dac_nids[4] = {
6287 /* front, rear, clfe, rear_surr */
6288 0x02, 0x04, 0x03, 0x05
6289};
6290
6291static hda_nid_t alc883_adc_nids[2] = {
6292 /* ADC1-2 */
6293 0x08, 0x09,
6294};
6295
6296/* input MUX */
6297/* FIXME: should be a matrix-type input source selection */
6298
6299static struct hda_input_mux alc883_capture_source = {
6300 .num_items = 4,
6301 .items = {
6302 { "Mic", 0x0 },
6303 { "Front Mic", 0x1 },
6304 { "Line", 0x2 },
6305 { "CD", 0x4 },
6306 },
6307};
6308
6309static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6310 .num_items = 2,
6311 .items = {
6312 { "Mic", 0x1 },
6313 { "Line", 0x2 },
6314 },
6315};
6316
6317static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6318 .num_items = 4,
6319 .items = {
6320 { "Mic", 0x0 },
6321 { "iMic", 0x1 },
6322 { "Line", 0x2 },
6323 { "CD", 0x4 },
6324 },
6325};
6326
6327#define alc883_mux_enum_info alc_mux_enum_info
6328#define alc883_mux_enum_get alc_mux_enum_get
6329
6330static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
6331 struct snd_ctl_elem_value *ucontrol)
6332{
6333 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
6334 struct alc_spec *spec = codec->spec;
6335 const struct hda_input_mux *imux = spec->input_mux;
6336 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
6337 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
6338 hda_nid_t nid = capture_mixers[adc_idx];
6339 unsigned int *cur_val = &spec->cur_mux[adc_idx];
6340 unsigned int i, idx;
6341
6342 idx = ucontrol->value.enumerated.item[0];
6343 if (idx >= imux->num_items)
6344 idx = imux->num_items - 1;
6345 if (*cur_val == idx)
6346 return 0;
6347 for (i = 0; i < imux->num_items; i++) {
6348 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
6349 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
6350 imux->items[i].index,
6351 HDA_AMP_MUTE, v);
6352 }
6353 *cur_val = idx;
6354 return 1;
6355}
6356
6357/*
6358 * 2ch mode
6359 */
6360static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6361 { 2, NULL }
6362};
6363
6364/*
6365 * 2ch mode
6366 */
6367static struct hda_verb alc883_3ST_ch2_init[] = {
6368 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6369 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6370 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6371 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6372 { } /* end */
6373};
6374
6375/*
6376 * 4ch mode
6377 */
6378static struct hda_verb alc883_3ST_ch4_init[] = {
6379 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6380 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6381 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6382 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6383 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6384 { } /* end */
6385};
6386
6387/*
6388 * 6ch mode
6389 */
6390static struct hda_verb alc883_3ST_ch6_init[] = {
6391 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6392 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6393 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6394 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6395 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6396 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6397 { } /* end */
6398};
6399
6400static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
6401 { 2, alc883_3ST_ch2_init },
6402 { 4, alc883_3ST_ch4_init },
6403 { 6, alc883_3ST_ch6_init },
6404};
6405
6406/*
6407 * 6ch mode
6408 */
6409static struct hda_verb alc883_sixstack_ch6_init[] = {
6410 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6411 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6412 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6413 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6414 { } /* end */
6415};
6416
6417/*
6418 * 8ch mode
6419 */
6420static struct hda_verb alc883_sixstack_ch8_init[] = {
6421 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6422 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6423 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6424 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6425 { } /* end */
6426};
6427
6428static struct hda_channel_mode alc883_sixstack_modes[2] = {
6429 { 6, alc883_sixstack_ch6_init },
6430 { 8, alc883_sixstack_ch8_init },
6431};
6432
6433static struct hda_verb alc883_medion_eapd_verbs[] = {
6434 /* eanable EAPD on medion laptop */
6435 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6436 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6437 { }
6438};
6439
6440/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6441 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6442 */
6443
6444static struct snd_kcontrol_new alc883_base_mixer[] = {
6445 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6446 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6447 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6448 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6450 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6451 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6452 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6453 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6454 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6455 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6456 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6457 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6458 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6459 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6461 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6463 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6464 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6465 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6466 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6467 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6468 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6469 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6470 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6471 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6472 {
6473 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6474 /* .name = "Capture Source", */
6475 .name = "Input Source",
6476 .count = 2,
6477 .info = alc883_mux_enum_info,
6478 .get = alc883_mux_enum_get,
6479 .put = alc883_mux_enum_put,
6480 },
6481 { } /* end */
6482};
6483
6484static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6485 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6486 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6487 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6488 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6489 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6490 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6491 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6492 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6493 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6494 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6495 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6496 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6497 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6498 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6499 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6500 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6501 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6502 {
6503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6504 /* .name = "Capture Source", */
6505 .name = "Input Source",
6506 .count = 2,
6507 .info = alc883_mux_enum_info,
6508 .get = alc883_mux_enum_get,
6509 .put = alc883_mux_enum_put,
6510 },
6511 { } /* end */
6512};
6513
6514static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
6515 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6516 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6517 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6518 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6519 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6520 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6521 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6522 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6523 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6524 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6525 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6526 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6527 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6528 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6529 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6530 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6531 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6532 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6533 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6534 {
6535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6536 /* .name = "Capture Source", */
6537 .name = "Input Source",
6538 .count = 2,
6539 .info = alc883_mux_enum_info,
6540 .get = alc883_mux_enum_get,
6541 .put = alc883_mux_enum_put,
6542 },
6543 { } /* end */
6544};
6545
6546static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
6547 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6548 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6549 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6550 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6551 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6552 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6553 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6554 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6555 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6556 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6557 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6558 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6559 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6560 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6561 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6562 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6563 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6564 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6565 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6566 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6567 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6568 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6569 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6570 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6571 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6572 {
6573 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6574 /* .name = "Capture Source", */
6575 .name = "Input Source",
6576 .count = 2,
6577 .info = alc883_mux_enum_info,
6578 .get = alc883_mux_enum_get,
6579 .put = alc883_mux_enum_put,
6580 },
6581 { } /* end */
6582};
6583
6584static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
6585 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6586 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6587 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6588 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6589 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6590 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6591 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
6592 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
6593 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6594 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6595 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6596 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6597 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6598 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6599 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6600 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6601 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6602 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6603 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6604 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6605 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6606 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6607 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6608
6609 {
6610 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6611 /* .name = "Capture Source", */
6612 .name = "Input Source",
6613 .count = 1,
6614 .info = alc883_mux_enum_info,
6615 .get = alc883_mux_enum_get,
6616 .put = alc883_mux_enum_put,
6617 },
6618 { } /* end */
6619};
6620
6621static struct snd_kcontrol_new alc883_tagra_mixer[] = {
6622 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6623 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6624 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6625 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6626 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6627 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6628 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6629 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6630 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6631 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6632 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6633 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6634 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6636 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6638 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6639 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6640 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6641 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6642 {
6643 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6644 /* .name = "Capture Source", */
6645 .name = "Input Source",
6646 .count = 2,
6647 .info = alc883_mux_enum_info,
6648 .get = alc883_mux_enum_get,
6649 .put = alc883_mux_enum_put,
6650 },
6651 { } /* end */
6652};
6653
6654static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
6655 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6657 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6658 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6659 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6661 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6662 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6663 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6664 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6665 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6666 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6667 {
6668 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6669 /* .name = "Capture Source", */
6670 .name = "Input Source",
6671 .count = 2,
6672 .info = alc883_mux_enum_info,
6673 .get = alc883_mux_enum_get,
6674 .put = alc883_mux_enum_put,
6675 },
6676 { } /* end */
6677};
6678
6679static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
6680 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6681 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6682 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6683 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
6684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6686 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6687 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6688 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6689 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6690 {
6691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6692 /* .name = "Capture Source", */
6693 .name = "Input Source",
6694 .count = 1,
6695 .info = alc883_mux_enum_info,
6696 .get = alc883_mux_enum_get,
6697 .put = alc883_mux_enum_put,
6698 },
6699 { } /* end */
6700};
6701
6702static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
6703 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6704 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
6705 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6706 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6707 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6709 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6710 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6711 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6712 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6713 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6714 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6715 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6716 {
6717 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6718 /* .name = "Capture Source", */
6719 .name = "Input Source",
6720 .count = 2,
6721 .info = alc883_mux_enum_info,
6722 .get = alc883_mux_enum_get,
6723 .put = alc883_mux_enum_put,
6724 },
6725 { } /* end */
6726};
6727
6728static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
6729 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6730 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6731 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6732 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6733 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6734 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6735 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6736 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6737 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6738 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6739 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6740 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6741 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6742 {
6743 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6744 /* .name = "Capture Source", */
6745 .name = "Input Source",
6746 .count = 2,
6747 .info = alc883_mux_enum_info,
6748 .get = alc883_mux_enum_get,
6749 .put = alc883_mux_enum_put,
6750 },
6751 { } /* end */
6752};
6753
6754static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
6755 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6756 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6757 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6758 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6759 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6760 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6761 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6762 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6763 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6764 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6765 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6766 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6767 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6768 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6769 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6771 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6773 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6774 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6775 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6776 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6777 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6778 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6779 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6780 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6781 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6782 {
6783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6784 /* .name = "Capture Source", */
6785 .name = "Input Source",
6786 .count = 2,
6787 .info = alc883_mux_enum_info,
6788 .get = alc883_mux_enum_get,
6789 .put = alc883_mux_enum_put,
6790 },
6791 { } /* end */
6792};
6793
6794static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
6795 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6796 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6797 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6798 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6799 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6800 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6801 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6802 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6806 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6807 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6809 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6811 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6812 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6813 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6814 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6815 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6816 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6817 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6818 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6819 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6820 {
6821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6822 /* .name = "Capture Source", */
6823 .name = "Input Source",
6824 .count = 2,
6825 .info = alc883_mux_enum_info,
6826 .get = alc883_mux_enum_get,
6827 .put = alc883_mux_enum_put,
6828 },
6829 { } /* end */
6830};
6831
6832static struct snd_kcontrol_new alc888_6st_dell_mixer[] = {
6833 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6834 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6835 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
6836 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
6837 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
6838 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
6839 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
6840 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
6841 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6842 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6843 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6844 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6845 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6846 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6847 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6849 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6851 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6852 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6853 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6854 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6855 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6856 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6857 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6858 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6859 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6860 {
6861 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6862 /* .name = "Capture Source", */
6863 .name = "Input Source",
6864 .count = 2,
6865 .info = alc883_mux_enum_info,
6866 .get = alc883_mux_enum_get,
6867 .put = alc883_mux_enum_put,
6868 },
6869 { } /* end */
6870};
6871
6872static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
6873 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6874 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6875 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6876 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6877 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6880 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6881 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6882 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6883 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6884 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6885 {
6886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6887 /* .name = "Capture Source", */
6888 .name = "Input Source",
6889 .count = 2,
6890 .info = alc883_mux_enum_info,
6891 .get = alc883_mux_enum_get,
6892 .put = alc883_mux_enum_put,
6893 },
6894 { } /* end */
6895};
6896
6897static struct snd_kcontrol_new alc883_chmode_mixer[] = {
6898 {
6899 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6900 .name = "Channel Mode",
6901 .info = alc_ch_mode_info,
6902 .get = alc_ch_mode_get,
6903 .put = alc_ch_mode_put,
6904 },
6905 { } /* end */
6906};
6907
6908static struct hda_verb alc883_init_verbs[] = {
6909 /* ADC1: mute amp left and right */
6910 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6911 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6912 /* ADC2: mute amp left and right */
6913 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6914 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6915 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6916 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6919 /* Rear mixer */
6920 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6922 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6923 /* CLFE mixer */
6924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6926 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6927 /* Side mixer */
6928 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6929 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6930 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6931
6932 /* mute analog input loopbacks */
6933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6937 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6938
6939 /* Front Pin: output 0 (0x0c) */
6940 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6941 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6942 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6943 /* Rear Pin: output 1 (0x0d) */
6944 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6946 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6947 /* CLFE Pin: output 2 (0x0e) */
6948 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6949 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6950 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
6951 /* Side Pin: output 3 (0x0f) */
6952 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6953 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6954 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
6955 /* Mic (rear) pin: input vref at 80% */
6956 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6957 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6958 /* Front Mic pin: input vref at 80% */
6959 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6960 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6961 /* Line In pin: input */
6962 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6963 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6964 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6965 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6966 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6967 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
6968 /* CD pin widget for input */
6969 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6970
6971 /* FIXME: use matrix-type input source selection */
6972 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6973 /* Input mixer2 */
6974 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6978 /* Input mixer3 */
6979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6981 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
6982 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
6983 { }
6984};
6985
6986/* toggle speaker-output according to the hp-jack state */
6987static void alc883_mitac_hp_automute(struct hda_codec *codec)
6988{
6989 unsigned int present;
6990
6991 present = snd_hda_codec_read(codec, 0x15, 0,
6992 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6993 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6994 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6995 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
6996 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6997}
6998
6999/* auto-toggle front mic */
7000/*
7001static void alc883_mitac_mic_automute(struct hda_codec *codec)
7002{
7003 unsigned int present;
7004 unsigned char bits;
7005
7006 present = snd_hda_codec_read(codec, 0x18, 0,
7007 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7008 bits = present ? HDA_AMP_MUTE : 0;
7009 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7010}
7011*/
7012
7013static void alc883_mitac_automute(struct hda_codec *codec)
7014{
7015 alc883_mitac_hp_automute(codec);
7016 /* alc883_mitac_mic_automute(codec); */
7017}
7018
7019static void alc883_mitac_unsol_event(struct hda_codec *codec,
7020 unsigned int res)
7021{
7022 switch (res >> 26) {
7023 case ALC880_HP_EVENT:
7024 alc883_mitac_hp_automute(codec);
7025 break;
7026 case ALC880_MIC_EVENT:
7027 /* alc883_mitac_mic_automute(codec); */
7028 break;
7029 }
7030}
7031
7032static struct hda_verb alc883_mitac_verbs[] = {
7033 /* HP */
7034 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7036 /* Subwoofer */
7037 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7038 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7039
7040 /* enable unsolicited event */
7041 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7042 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7043
7044 { } /* end */
7045};
7046
7047static struct hda_verb alc883_tagra_verbs[] = {
7048 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7050
7051 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7052 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7053
7054 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7055 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7056 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7057
7058 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7059 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7060 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7061 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
7062
7063 { } /* end */
7064};
7065
7066static struct hda_verb alc883_lenovo_101e_verbs[] = {
7067 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7068 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7069 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7070 { } /* end */
7071};
7072
7073static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7074 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7075 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7076 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7077 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7078 { } /* end */
7079};
7080
7081static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7082 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7083 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7084 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7085 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7086 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7087 { } /* end */
7088};
7089
7090static struct hda_verb alc883_haier_w66_verbs[] = {
7091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7092 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7093
7094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7095
7096 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7097 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7098 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7099 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7100 { } /* end */
7101};
7102
7103static struct hda_verb alc888_6st_hp_verbs[] = {
7104 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7105 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
7106 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
7107 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7108 { }
7109};
7110
7111static struct hda_verb alc888_3st_hp_verbs[] = {
7112 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7113 {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7114 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7115 { }
7116};
7117
7118static struct hda_verb alc888_6st_dell_verbs[] = {
7119 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7120 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 1 (0x0e) */
7121 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 2 (0x0d) */
7122 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
7123 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7124 { }
7125};
7126
7127static struct hda_verb alc888_3st_hp_2ch_init[] = {
7128 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7129 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7130 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7131 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7132 { }
7133};
7134
7135static struct hda_verb alc888_3st_hp_6ch_init[] = {
7136 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7137 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7138 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7139 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7140 { }
7141};
7142
7143static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7144 { 2, alc888_3st_hp_2ch_init },
7145 { 6, alc888_3st_hp_6ch_init },
7146};
7147
7148/* toggle front-jack and RCA according to the hp-jack state */
7149static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7150{
7151 unsigned int present;
7152
7153 present = snd_hda_codec_read(codec, 0x1b, 0,
7154 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7155 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7156 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7157 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7158 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7159}
7160
7161/* toggle RCA according to the front-jack state */
7162static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7163{
7164 unsigned int present;
7165
7166 present = snd_hda_codec_read(codec, 0x14, 0,
7167 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7168 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7169 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7170}
7171
7172static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7173 unsigned int res)
7174{
7175 if ((res >> 26) == ALC880_HP_EVENT)
7176 alc888_lenovo_ms7195_front_automute(codec);
7177 if ((res >> 26) == ALC880_FRONT_EVENT)
7178 alc888_lenovo_ms7195_rca_automute(codec);
7179}
7180
7181static struct hda_verb alc883_medion_md2_verbs[] = {
7182 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7183 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7184
7185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7186
7187 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7188 { } /* end */
7189};
7190
7191/* toggle speaker-output according to the hp-jack state */
7192static void alc883_medion_md2_automute(struct hda_codec *codec)
7193{
7194 unsigned int present;
7195
7196 present = snd_hda_codec_read(codec, 0x14, 0,
7197 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7198 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7199 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7200}
7201
7202static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7203 unsigned int res)
7204{
7205 if ((res >> 26) == ALC880_HP_EVENT)
7206 alc883_medion_md2_automute(codec);
7207}
7208
7209/* toggle speaker-output according to the hp-jack state */
7210static void alc883_tagra_automute(struct hda_codec *codec)
7211{
7212 unsigned int present;
7213 unsigned char bits;
7214
7215 present = snd_hda_codec_read(codec, 0x14, 0,
7216 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7217 bits = present ? HDA_AMP_MUTE : 0;
7218 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7219 HDA_AMP_MUTE, bits);
7220 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7221 present ? 1 : 3);
7222}
7223
7224static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7225{
7226 if ((res >> 26) == ALC880_HP_EVENT)
7227 alc883_tagra_automute(codec);
7228}
7229
7230static void alc883_haier_w66_automute(struct hda_codec *codec)
7231{
7232 unsigned int present;
7233 unsigned char bits;
7234
7235 present = snd_hda_codec_read(codec, 0x1b, 0,
7236 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7237 bits = present ? 0x80 : 0;
7238 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7239 0x80, bits);
7240}
7241
7242static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7243 unsigned int res)
7244{
7245 if ((res >> 26) == ALC880_HP_EVENT)
7246 alc883_haier_w66_automute(codec);
7247}
7248
7249static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7250{
7251 unsigned int present;
7252 unsigned char bits;
7253
7254 present = snd_hda_codec_read(codec, 0x14, 0,
7255 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7256 bits = present ? HDA_AMP_MUTE : 0;
7257 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7258 HDA_AMP_MUTE, bits);
7259}
7260
7261static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7262{
7263 unsigned int present;
7264 unsigned char bits;
7265
7266 present = snd_hda_codec_read(codec, 0x1b, 0,
7267 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7268 bits = present ? HDA_AMP_MUTE : 0;
7269 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7270 HDA_AMP_MUTE, bits);
7271 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7272 HDA_AMP_MUTE, bits);
7273}
7274
7275static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7276 unsigned int res)
7277{
7278 if ((res >> 26) == ALC880_HP_EVENT)
7279 alc883_lenovo_101e_all_automute(codec);
7280 if ((res >> 26) == ALC880_FRONT_EVENT)
7281 alc883_lenovo_101e_ispeaker_automute(codec);
7282}
7283
7284/* toggle speaker-output according to the hp-jack state */
7285static void alc883_acer_aspire_automute(struct hda_codec *codec)
7286{
7287 unsigned int present;
7288
7289 present = snd_hda_codec_read(codec, 0x14, 0,
7290 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7291 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7292 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7293 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7294 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7295}
7296
7297static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7298 unsigned int res)
7299{
7300 if ((res >> 26) == ALC880_HP_EVENT)
7301 alc883_acer_aspire_automute(codec);
7302}
7303
7304static struct hda_verb alc883_acer_eapd_verbs[] = {
7305 /* HP Pin: output 0 (0x0c) */
7306 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7307 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7308 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7309 /* Front Pin: output 0 (0x0c) */
7310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7311 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7312 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7313 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7314 /* eanable EAPD on medion laptop */
7315 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7316 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
7317 /* enable unsolicited event */
7318 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7319 { }
7320};
7321
7322static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7323{
7324 unsigned int present;
7325
7326 present = snd_hda_codec_read(codec, 0x1b, 0,
7327 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7328 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7329 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7330 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7331 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7332 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7333 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7334 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7335 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7336}
7337
7338static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7339 unsigned int res)
7340{
7341 switch (res >> 26) {
7342 case ALC880_HP_EVENT:
7343 printk("hp_event\n");
7344 alc888_6st_dell_front_automute(codec);
7345 break;
7346 }
7347}
7348
7349/*
7350 * generic initialization of ADC, input mixers and output mixers
7351 */
7352static struct hda_verb alc883_auto_init_verbs[] = {
7353 /*
7354 * Unmute ADC0-2 and set the default input to mic-in
7355 */
7356 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7358 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7359 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7360
7361 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7362 * mixer widget
7363 * Note: PASD motherboards uses the Line In 2 as the input for
7364 * front panel mic (mic 2)
7365 */
7366 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7367 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7372
7373 /*
7374 * Set up output mixers (0x0c - 0x0f)
7375 */
7376 /* set vol=0 to output mixers */
7377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7380 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7381 /* set up input amps for analog loopback */
7382 /* Amp Indices: DAC = 0, mixer = 1 */
7383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7385 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7387 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7388 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7389 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7390 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7391 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7392 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7393
7394 /* FIXME: use matrix-type input source selection */
7395 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7396 /* Input mixer1 */
7397 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7398 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7399 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7400 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7401 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7402 /* Input mixer2 */
7403 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7404 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7405 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7406 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
7407 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7408
7409 { }
7410};
7411
7412/* capture mixer elements */
7413static struct snd_kcontrol_new alc883_capture_mixer[] = {
7414 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7415 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7416 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7417 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7418 {
7419 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7420 /* The multiple "Capture Source" controls confuse alsamixer
7421 * So call somewhat different..
7422 */
7423 /* .name = "Capture Source", */
7424 .name = "Input Source",
7425 .count = 2,
7426 .info = alc882_mux_enum_info,
7427 .get = alc882_mux_enum_get,
7428 .put = alc882_mux_enum_put,
7429 },
7430 { } /* end */
7431};
7432
7433#ifdef CONFIG_SND_HDA_POWER_SAVE
7434#define alc883_loopbacks alc880_loopbacks
7435#endif
7436
7437/* pcm configuration: identiacal with ALC880 */
7438#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7439#define alc883_pcm_analog_capture alc880_pcm_analog_capture
7440#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
7441#define alc883_pcm_digital_playback alc880_pcm_digital_playback
7442#define alc883_pcm_digital_capture alc880_pcm_digital_capture
7443
7444/*
7445 * configuration and preset
7446 */
7447static const char *alc883_models[ALC883_MODEL_LAST] = {
7448 [ALC883_3ST_2ch_DIG] = "3stack-dig",
7449 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
7450 [ALC883_3ST_6ch] = "3stack-6ch",
7451 [ALC883_6ST_DIG] = "6stack-dig",
7452 [ALC883_TARGA_DIG] = "targa-dig",
7453 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
7454 [ALC883_ACER] = "acer",
7455 [ALC883_ACER_ASPIRE] = "acer-aspire",
7456 [ALC883_MEDION] = "medion",
7457 [ALC883_MEDION_MD2] = "medion-md2",
7458 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
7459 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
7460 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
7461 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
7462 [ALC883_HAIER_W66] = "haier-w66",
7463 [ALC888_6ST_HP] = "6stack-hp",
7464 [ALC888_3ST_HP] = "3stack-hp",
7465 [ALC888_6ST_DELL] = "6stack-dell",
7466 [ALC883_MITAC] = "mitac",
7467 [ALC883_AUTO] = "auto",
7468};
7469
7470static struct snd_pci_quirk alc883_cfg_tbl[] = {
7471 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
7472 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
7473 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
7474 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
7475 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
7476 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
7477 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
7478 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
7479 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
7480 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
7481 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
7482 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
7483 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
7484 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
7485 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
7486 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
7487 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
7488 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
7489 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
7490 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
7491 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
7492 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
7493 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
7494 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
7495 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
7496 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
7497 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
7498 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
7499 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
7500 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
7501 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
7502 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
7503 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
7504 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
7505 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
7506 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
7507 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
7508 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
7509 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
7510 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
7511 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7512 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7513 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
7514 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
7515 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
7516 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
7517 {}
7518};
7519
7520static struct alc_config_preset alc883_presets[] = {
7521 [ALC883_3ST_2ch_DIG] = {
7522 .mixers = { alc883_3ST_2ch_mixer },
7523 .init_verbs = { alc883_init_verbs },
7524 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7525 .dac_nids = alc883_dac_nids,
7526 .dig_out_nid = ALC883_DIGOUT_NID,
7527 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7528 .adc_nids = alc883_adc_nids,
7529 .dig_in_nid = ALC883_DIGIN_NID,
7530 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7531 .channel_mode = alc883_3ST_2ch_modes,
7532 .input_mux = &alc883_capture_source,
7533 },
7534 [ALC883_3ST_6ch_DIG] = {
7535 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7536 .init_verbs = { alc883_init_verbs },
7537 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7538 .dac_nids = alc883_dac_nids,
7539 .dig_out_nid = ALC883_DIGOUT_NID,
7540 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7541 .adc_nids = alc883_adc_nids,
7542 .dig_in_nid = ALC883_DIGIN_NID,
7543 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7544 .channel_mode = alc883_3ST_6ch_modes,
7545 .need_dac_fix = 1,
7546 .input_mux = &alc883_capture_source,
7547 },
7548 [ALC883_3ST_6ch] = {
7549 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7550 .init_verbs = { alc883_init_verbs },
7551 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7552 .dac_nids = alc883_dac_nids,
7553 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7554 .adc_nids = alc883_adc_nids,
7555 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7556 .channel_mode = alc883_3ST_6ch_modes,
7557 .need_dac_fix = 1,
7558 .input_mux = &alc883_capture_source,
7559 },
7560 [ALC883_6ST_DIG] = {
7561 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
7562 .init_verbs = { alc883_init_verbs },
7563 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7564 .dac_nids = alc883_dac_nids,
7565 .dig_out_nid = ALC883_DIGOUT_NID,
7566 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7567 .adc_nids = alc883_adc_nids,
7568 .dig_in_nid = ALC883_DIGIN_NID,
7569 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7570 .channel_mode = alc883_sixstack_modes,
7571 .input_mux = &alc883_capture_source,
7572 },
7573 [ALC883_TARGA_DIG] = {
7574 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
7575 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7576 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7577 .dac_nids = alc883_dac_nids,
7578 .dig_out_nid = ALC883_DIGOUT_NID,
7579 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7580 .adc_nids = alc883_adc_nids,
7581 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7582 .channel_mode = alc883_3ST_6ch_modes,
7583 .need_dac_fix = 1,
7584 .input_mux = &alc883_capture_source,
7585 .unsol_event = alc883_tagra_unsol_event,
7586 .init_hook = alc883_tagra_automute,
7587 },
7588 [ALC883_TARGA_2ch_DIG] = {
7589 .mixers = { alc883_tagra_2ch_mixer},
7590 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
7591 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7592 .dac_nids = alc883_dac_nids,
7593 .dig_out_nid = ALC883_DIGOUT_NID,
7594 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7595 .adc_nids = alc883_adc_nids,
7596 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7597 .channel_mode = alc883_3ST_2ch_modes,
7598 .input_mux = &alc883_capture_source,
7599 .unsol_event = alc883_tagra_unsol_event,
7600 .init_hook = alc883_tagra_automute,
7601 },
7602 [ALC883_ACER] = {
7603 .mixers = { alc883_base_mixer },
7604 /* On TravelMate laptops, GPIO 0 enables the internal speaker
7605 * and the headphone jack. Turn this on and rely on the
7606 * standard mute methods whenever the user wants to turn
7607 * these outputs off.
7608 */
7609 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
7610 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7611 .dac_nids = alc883_dac_nids,
7612 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7613 .adc_nids = alc883_adc_nids,
7614 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7615 .channel_mode = alc883_3ST_2ch_modes,
7616 .input_mux = &alc883_capture_source,
7617 },
7618 [ALC883_ACER_ASPIRE] = {
7619 .mixers = { alc883_acer_aspire_mixer },
7620 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
7621 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7622 .dac_nids = alc883_dac_nids,
7623 .dig_out_nid = ALC883_DIGOUT_NID,
7624 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7625 .adc_nids = alc883_adc_nids,
7626 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7627 .channel_mode = alc883_3ST_2ch_modes,
7628 .input_mux = &alc883_capture_source,
7629 .unsol_event = alc883_acer_aspire_unsol_event,
7630 .init_hook = alc883_acer_aspire_automute,
7631 },
7632 [ALC883_MEDION] = {
7633 .mixers = { alc883_fivestack_mixer,
7634 alc883_chmode_mixer },
7635 .init_verbs = { alc883_init_verbs,
7636 alc883_medion_eapd_verbs },
7637 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7638 .dac_nids = alc883_dac_nids,
7639 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7640 .adc_nids = alc883_adc_nids,
7641 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7642 .channel_mode = alc883_sixstack_modes,
7643 .input_mux = &alc883_capture_source,
7644 },
7645 [ALC883_MEDION_MD2] = {
7646 .mixers = { alc883_medion_md2_mixer},
7647 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
7648 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7649 .dac_nids = alc883_dac_nids,
7650 .dig_out_nid = ALC883_DIGOUT_NID,
7651 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7652 .adc_nids = alc883_adc_nids,
7653 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7654 .channel_mode = alc883_3ST_2ch_modes,
7655 .input_mux = &alc883_capture_source,
7656 .unsol_event = alc883_medion_md2_unsol_event,
7657 .init_hook = alc883_medion_md2_automute,
7658 },
7659 [ALC883_LAPTOP_EAPD] = {
7660 .mixers = { alc883_base_mixer },
7661 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
7662 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7663 .dac_nids = alc883_dac_nids,
7664 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7665 .adc_nids = alc883_adc_nids,
7666 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7667 .channel_mode = alc883_3ST_2ch_modes,
7668 .input_mux = &alc883_capture_source,
7669 },
7670 [ALC883_LENOVO_101E_2ch] = {
7671 .mixers = { alc883_lenovo_101e_2ch_mixer},
7672 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
7673 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7674 .dac_nids = alc883_dac_nids,
7675 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7676 .adc_nids = alc883_adc_nids,
7677 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7678 .channel_mode = alc883_3ST_2ch_modes,
7679 .input_mux = &alc883_lenovo_101e_capture_source,
7680 .unsol_event = alc883_lenovo_101e_unsol_event,
7681 .init_hook = alc883_lenovo_101e_all_automute,
7682 },
7683 [ALC883_LENOVO_NB0763] = {
7684 .mixers = { alc883_lenovo_nb0763_mixer },
7685 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
7686 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7687 .dac_nids = alc883_dac_nids,
7688 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7689 .adc_nids = alc883_adc_nids,
7690 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7691 .channel_mode = alc883_3ST_2ch_modes,
7692 .need_dac_fix = 1,
7693 .input_mux = &alc883_lenovo_nb0763_capture_source,
7694 .unsol_event = alc883_medion_md2_unsol_event,
7695 .init_hook = alc883_medion_md2_automute,
7696 },
7697 [ALC888_LENOVO_MS7195_DIG] = {
7698 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
7699 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
7700 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7701 .dac_nids = alc883_dac_nids,
7702 .dig_out_nid = ALC883_DIGOUT_NID,
7703 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7704 .adc_nids = alc883_adc_nids,
7705 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
7706 .channel_mode = alc883_3ST_6ch_modes,
7707 .need_dac_fix = 1,
7708 .input_mux = &alc883_capture_source,
7709 .unsol_event = alc883_lenovo_ms7195_unsol_event,
7710 .init_hook = alc888_lenovo_ms7195_front_automute,
7711 },
7712 [ALC883_HAIER_W66] = {
7713 .mixers = { alc883_tagra_2ch_mixer},
7714 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
7715 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7716 .dac_nids = alc883_dac_nids,
7717 .dig_out_nid = ALC883_DIGOUT_NID,
7718 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7719 .adc_nids = alc883_adc_nids,
7720 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7721 .channel_mode = alc883_3ST_2ch_modes,
7722 .input_mux = &alc883_capture_source,
7723 .unsol_event = alc883_haier_w66_unsol_event,
7724 .init_hook = alc883_haier_w66_automute,
7725 },
7726 [ALC888_6ST_HP] = {
7727 .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
7728 .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
7729 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7730 .dac_nids = alc883_dac_nids,
7731 .dig_out_nid = ALC883_DIGOUT_NID,
7732 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7733 .adc_nids = alc883_adc_nids,
7734 .dig_in_nid = ALC883_DIGIN_NID,
7735 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7736 .channel_mode = alc883_sixstack_modes,
7737 .input_mux = &alc883_capture_source,
7738 },
7739 [ALC888_3ST_HP] = {
7740 .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
7741 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
7742 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7743 .dac_nids = alc883_dac_nids,
7744 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7745 .adc_nids = alc883_adc_nids,
7746 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
7747 .channel_mode = alc888_3st_hp_modes,
7748 .need_dac_fix = 1,
7749 .input_mux = &alc883_capture_source,
7750 },
7751 [ALC888_6ST_DELL] = {
7752 .mixers = { alc888_6st_dell_mixer, alc883_chmode_mixer },
7753 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
7754 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7755 .dac_nids = alc883_dac_nids,
7756 .dig_out_nid = ALC883_DIGOUT_NID,
7757 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7758 .adc_nids = alc883_adc_nids,
7759 .dig_in_nid = ALC883_DIGIN_NID,
7760 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
7761 .channel_mode = alc883_sixstack_modes,
7762 .input_mux = &alc883_capture_source,
7763 .unsol_event = alc888_6st_dell_unsol_event,
7764 .init_hook = alc888_6st_dell_front_automute,
7765 },
7766 [ALC883_MITAC] = {
7767 .mixers = { alc883_mitac_mixer },
7768 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
7769 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
7770 .dac_nids = alc883_dac_nids,
7771 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
7772 .adc_nids = alc883_adc_nids,
7773 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
7774 .channel_mode = alc883_3ST_2ch_modes,
7775 .input_mux = &alc883_capture_source,
7776 .unsol_event = alc883_mitac_unsol_event,
7777 .init_hook = alc883_mitac_automute,
7778 },
7779};
7780
7781
7782/*
7783 * BIOS auto configuration
7784 */
7785static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
7786 hda_nid_t nid, int pin_type,
7787 int dac_idx)
7788{
7789 /* set as output */
7790 struct alc_spec *spec = codec->spec;
7791 int idx;
7792
7793 if (spec->multiout.dac_nids[dac_idx] == 0x25)
7794 idx = 4;
7795 else
7796 idx = spec->multiout.dac_nids[dac_idx] - 2;
7797
7798 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
7799 pin_type);
7800 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
7801 AMP_OUT_UNMUTE);
7802 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
7803
7804}
7805
7806static void alc883_auto_init_multi_out(struct hda_codec *codec)
7807{
7808 struct alc_spec *spec = codec->spec;
7809 int i;
7810
7811 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
7812 for (i = 0; i <= HDA_SIDE; i++) {
7813 hda_nid_t nid = spec->autocfg.line_out_pins[i];
7814 int pin_type = get_pin_type(spec->autocfg.line_out_type);
7815 if (nid)
7816 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
7817 i);
7818 }
7819}
7820
7821static void alc883_auto_init_hp_out(struct hda_codec *codec)
7822{
7823 struct alc_spec *spec = codec->spec;
7824 hda_nid_t pin;
7825
7826 pin = spec->autocfg.hp_pins[0];
7827 if (pin) /* connect to front */
7828 /* use dac 0 */
7829 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
7830}
7831
7832#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
7833#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
7834
7835static void alc883_auto_init_analog_input(struct hda_codec *codec)
7836{
7837 struct alc_spec *spec = codec->spec;
7838 int i;
7839
7840 for (i = 0; i < AUTO_PIN_LAST; i++) {
7841 hda_nid_t nid = spec->autocfg.input_pins[i];
7842 if (alc883_is_input_pin(nid)) {
7843 snd_hda_codec_write(codec, nid, 0,
7844 AC_VERB_SET_PIN_WIDGET_CONTROL,
7845 (i <= AUTO_PIN_FRONT_MIC ?
7846 PIN_VREF80 : PIN_IN));
7847 if (nid != ALC883_PIN_CD_NID)
7848 snd_hda_codec_write(codec, nid, 0,
7849 AC_VERB_SET_AMP_GAIN_MUTE,
7850 AMP_OUT_MUTE);
7851 }
7852 }
7853}
7854
7855/* almost identical with ALC880 parser... */
7856static int alc883_parse_auto_config(struct hda_codec *codec)
7857{
7858 struct alc_spec *spec = codec->spec;
7859 int err = alc880_parse_auto_config(codec);
7860
7861 if (err < 0)
7862 return err;
7863 else if (!err)
7864 return 0; /* no config found */
7865
7866 err = alc_auto_add_mic_boost(codec);
7867 if (err < 0)
7868 return err;
7869
7870 /* hack - override the init verbs */
7871 spec->init_verbs[0] = alc883_auto_init_verbs;
7872 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
7873 spec->num_mixers++;
7874
7875 return 1; /* config found */
7876}
7877
7878/* additional initialization for auto-configuration model */
7879static void alc883_auto_init(struct hda_codec *codec)
7880{
7881 alc883_auto_init_multi_out(codec);
7882 alc883_auto_init_hp_out(codec);
7883 alc883_auto_init_analog_input(codec);
7884}
7885
7886static int patch_alc883(struct hda_codec *codec)
7887{
7888 struct alc_spec *spec;
7889 int err, board_config;
7890
7891 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
7892 if (spec == NULL)
7893 return -ENOMEM;
7894
7895 codec->spec = spec;
7896
7897 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
7898 alc883_models,
7899 alc883_cfg_tbl);
7900 if (board_config < 0) {
7901 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
7902 "trying auto-probe from BIOS...\n");
7903 board_config = ALC883_AUTO;
7904 }
7905
7906 if (board_config == ALC883_AUTO) {
7907 /* automatic parse from the BIOS config */
7908 err = alc883_parse_auto_config(codec);
7909 if (err < 0) {
7910 alc_free(codec);
7911 return err;
7912 } else if (!err) {
7913 printk(KERN_INFO
7914 "hda_codec: Cannot set up configuration "
7915 "from BIOS. Using base mode...\n");
7916 board_config = ALC883_3ST_2ch_DIG;
7917 }
7918 }
7919
7920 if (board_config != ALC883_AUTO)
7921 setup_preset(spec, &alc883_presets[board_config]);
7922
7923 spec->stream_name_analog = "ALC883 Analog";
7924 spec->stream_analog_playback = &alc883_pcm_analog_playback;
7925 spec->stream_analog_capture = &alc883_pcm_analog_capture;
7926 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
7927
7928 spec->stream_name_digital = "ALC883 Digital";
7929 spec->stream_digital_playback = &alc883_pcm_digital_playback;
7930 spec->stream_digital_capture = &alc883_pcm_digital_capture;
7931
7932 if (!spec->adc_nids && spec->input_mux) {
7933 spec->adc_nids = alc883_adc_nids;
7934 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
7935 }
7936
7937 spec->vmaster_nid = 0x0c;
7938
7939 codec->patch_ops = alc_patch_ops;
7940 if (board_config == ALC883_AUTO)
7941 spec->init_hook = alc883_auto_init;
7942#ifdef CONFIG_SND_HDA_POWER_SAVE
7943 if (!spec->loopback.amplist)
7944 spec->loopback.amplist = alc883_loopbacks;
7945#endif
7946
7947 return 0;
7948}
7949
7950/*
7951 * ALC262 support
7952 */
7953
7954#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
7955#define ALC262_DIGIN_NID ALC880_DIGIN_NID
7956
7957#define alc262_dac_nids alc260_dac_nids
7958#define alc262_adc_nids alc882_adc_nids
7959#define alc262_adc_nids_alt alc882_adc_nids_alt
7960
7961#define alc262_modes alc260_modes
7962#define alc262_capture_source alc882_capture_source
7963
7964static struct snd_kcontrol_new alc262_base_mixer[] = {
7965 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7966 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7967 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7968 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7969 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7970 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7972 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7973 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7974 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7975 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7976 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7977 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
7978 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
7979 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
7980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7981 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7982 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
7983 { } /* end */
7984};
7985
7986static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
7987 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7988 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7989 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7990 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7991 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7992 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7995 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7996 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7998 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7999 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8000 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
8001 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8002 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8003 { } /* end */
8004};
8005
8006static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
8007 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8008 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8010 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8011 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8012
8013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8015 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8016 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8018 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8019 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8020 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8021 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8022 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8023 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8024 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8025 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8026 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8027 { } /* end */
8028};
8029
8030static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
8031 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8032 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8033 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8034 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8035 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8036 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
8037 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8038 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
8039 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
8040 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8041 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8044 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8045 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8046 { } /* end */
8047};
8048
8049static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8050 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8051 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8052 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
8053 { } /* end */
8054};
8055
8056static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
8057 .ops = &snd_hda_bind_vol,
8058 .values = {
8059 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8060 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8061 0
8062 },
8063};
8064
8065static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
8066 .ops = &snd_hda_bind_sw,
8067 .values = {
8068 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8069 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8070 0
8071 },
8072};
8073
8074/* mute/unmute internal speaker according to the hp jack and mute state */
8075static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8076{
8077 struct alc_spec *spec = codec->spec;
8078 unsigned int mute;
8079
8080 if (force || !spec->sense_updated) {
8081 unsigned int present;
8082 present = snd_hda_codec_read(codec, 0x15, 0,
8083 AC_VERB_GET_PIN_SENSE, 0);
8084 spec->jack_present = (present & 0x80000000) != 0;
8085 spec->sense_updated = 1;
8086 }
8087 if (spec->jack_present)
8088 mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
8089 else /* unmute internal speaker if necessary */
8090 mute = (0x7000 | ((0)<<8));
8091 snd_hda_codec_write(codec, 0x0c, 0,
8092 AC_VERB_SET_AMP_GAIN_MUTE, mute );
8093}
8094
8095static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8096 unsigned int res)
8097{
8098 if ((res >> 26) != ALC880_HP_EVENT)
8099 return;
8100 alc262_hp_t5735_automute(codec, 1);
8101}
8102
8103static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8104{
8105 alc262_hp_t5735_automute(codec, 1);
8106}
8107
8108static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
8109 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
8110 HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
8111 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8112 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8113 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8114 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8115 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8116 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8117 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8119 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8120 { } /* end */
8121};
8122
8123static struct hda_verb alc262_hp_t5735_verbs[] = {
8124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8125 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8126
8127 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8128 { }
8129};
8130
8131static struct hda_bind_ctls alc262_hp_rp5700_bind_front_vol = {
8132 .ops = &snd_hda_bind_vol,
8133 .values = {
8134 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8135 HDA_COMPOSE_AMP_VAL(0x0e, 3, 0, HDA_OUTPUT),
8136 0
8137 },
8138};
8139
8140static struct hda_bind_ctls alc262_hp_rp5700_bind_front_sw = {
8141 .ops = &snd_hda_bind_sw,
8142 .values = {
8143 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
8144 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
8145 0
8146 },
8147};
8148
8149static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
8150 HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_rp5700_bind_front_vol),
8151 HDA_BIND_SW("PCM Playback Switch", &alc262_hp_rp5700_bind_front_sw),
8152 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8153 HDA_CODEC_MUTE("Master Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8154 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8155 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8156 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8157 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8158 { } /* end */
8159};
8160
8161static struct hda_verb alc262_hp_rp5700_verbs[] = {
8162 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8163 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8164 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8165 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8166 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8167 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8168 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8170 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8172 {}
8173};
8174
8175static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8176 .num_items = 1,
8177 .items = {
8178 { "Line", 0x1 },
8179 },
8180};
8181
8182/* bind hp and internal speaker mute (with plug check) */
8183static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8184 struct snd_ctl_elem_value *ucontrol)
8185{
8186 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8187 long *valp = ucontrol->value.integer.value;
8188 int change;
8189
8190 /* change hp mute */
8191 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8192 HDA_AMP_MUTE,
8193 valp[0] ? 0 : HDA_AMP_MUTE);
8194 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8195 HDA_AMP_MUTE,
8196 valp[1] ? 0 : HDA_AMP_MUTE);
8197 if (change) {
8198 /* change speaker according to HP jack state */
8199 struct alc_spec *spec = codec->spec;
8200 unsigned int mute;
8201 if (spec->jack_present)
8202 mute = HDA_AMP_MUTE;
8203 else
8204 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8205 HDA_OUTPUT, 0);
8206 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8207 HDA_AMP_MUTE, mute);
8208 }
8209 return change;
8210}
8211
8212static struct snd_kcontrol_new alc262_sony_mixer[] = {
8213 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8214 {
8215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8216 .name = "Master Playback Switch",
8217 .info = snd_hda_mixer_amp_switch_info,
8218 .get = snd_hda_mixer_amp_switch_get,
8219 .put = alc262_sony_master_sw_put,
8220 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8221 },
8222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8224 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8225 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8226 { } /* end */
8227};
8228
8229static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8230 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8231 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8232 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8234 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8235 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8236 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8237 { } /* end */
8238};
8239
8240#define alc262_capture_mixer alc882_capture_mixer
8241#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8242
8243/*
8244 * generic initialization of ADC, input mixers and output mixers
8245 */
8246static struct hda_verb alc262_init_verbs[] = {
8247 /*
8248 * Unmute ADC0-2 and set the default input to mic-in
8249 */
8250 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8252 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8253 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8254 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8255 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8256
8257 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8258 * mixer widget
8259 * Note: PASD motherboards uses the Line In 2 as the input for
8260 * front panel mic (mic 2)
8261 */
8262 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8268
8269 /*
8270 * Set up output mixers (0x0c - 0x0e)
8271 */
8272 /* set vol=0 to output mixers */
8273 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8274 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8275 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8276 /* set up input amps for analog loopback */
8277 /* Amp Indices: DAC = 0, mixer = 1 */
8278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8279 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8282 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8283 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8284
8285 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8287 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8288 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8289 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8290 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8291
8292 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8293 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8294 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8295 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8296 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8297
8298 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8299 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8300
8301 /* FIXME: use matrix-type input source selection */
8302 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8303 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8305 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8308 /* Input mixer2 */
8309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8313 /* Input mixer3 */
8314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8318
8319 { }
8320};
8321
8322static struct hda_verb alc262_hippo_unsol_verbs[] = {
8323 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8324 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8325 {}
8326};
8327
8328static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8329 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8330 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8331 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8332
8333 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8334 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8335 {}
8336};
8337
8338static struct hda_verb alc262_sony_unsol_verbs[] = {
8339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8340 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8341 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8342
8343 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8344 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8345};
8346
8347/* mute/unmute internal speaker according to the hp jack and mute state */
8348static void alc262_hippo_automute(struct hda_codec *codec)
8349{
8350 struct alc_spec *spec = codec->spec;
8351 unsigned int mute;
8352 unsigned int present;
8353
8354 /* need to execute and sync at first */
8355 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8356 present = snd_hda_codec_read(codec, 0x15, 0,
8357 AC_VERB_GET_PIN_SENSE, 0);
8358 spec->jack_present = (present & 0x80000000) != 0;
8359 if (spec->jack_present) {
8360 /* mute internal speaker */
8361 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8362 HDA_AMP_MUTE, HDA_AMP_MUTE);
8363 } else {
8364 /* unmute internal speaker if necessary */
8365 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8366 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8367 HDA_AMP_MUTE, mute);
8368 }
8369}
8370
8371/* unsolicited event for HP jack sensing */
8372static void alc262_hippo_unsol_event(struct hda_codec *codec,
8373 unsigned int res)
8374{
8375 if ((res >> 26) != ALC880_HP_EVENT)
8376 return;
8377 alc262_hippo_automute(codec);
8378}
8379
8380static void alc262_hippo1_automute(struct hda_codec *codec)
8381{
8382 unsigned int mute;
8383 unsigned int present;
8384
8385 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8386 present = snd_hda_codec_read(codec, 0x1b, 0,
8387 AC_VERB_GET_PIN_SENSE, 0);
8388 present = (present & 0x80000000) != 0;
8389 if (present) {
8390 /* mute internal speaker */
8391 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8392 HDA_AMP_MUTE, HDA_AMP_MUTE);
8393 } else {
8394 /* unmute internal speaker if necessary */
8395 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8396 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8397 HDA_AMP_MUTE, mute);
8398 }
8399}
8400
8401/* unsolicited event for HP jack sensing */
8402static void alc262_hippo1_unsol_event(struct hda_codec *codec,
8403 unsigned int res)
8404{
8405 if ((res >> 26) != ALC880_HP_EVENT)
8406 return;
8407 alc262_hippo1_automute(codec);
8408}
8409
8410/*
8411 * fujitsu model
8412 * 0x14 = headphone/spdif-out, 0x15 = internal speaker
8413 */
8414
8415#define ALC_HP_EVENT 0x37
8416
8417static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
8418 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
8419 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8420 {}
8421};
8422
8423static struct hda_input_mux alc262_fujitsu_capture_source = {
8424 .num_items = 3,
8425 .items = {
8426 { "Mic", 0x0 },
8427 { "Int Mic", 0x1 },
8428 { "CD", 0x4 },
8429 },
8430};
8431
8432static struct hda_input_mux alc262_HP_capture_source = {
8433 .num_items = 5,
8434 .items = {
8435 { "Mic", 0x0 },
8436 { "Front Mic", 0x1 },
8437 { "Line", 0x2 },
8438 { "CD", 0x4 },
8439 { "AUX IN", 0x6 },
8440 },
8441};
8442
8443static struct hda_input_mux alc262_HP_D7000_capture_source = {
8444 .num_items = 4,
8445 .items = {
8446 { "Mic", 0x0 },
8447 { "Front Mic", 0x2 },
8448 { "Line", 0x1 },
8449 { "CD", 0x4 },
8450 },
8451};
8452
8453/* mute/unmute internal speaker according to the hp jack and mute state */
8454static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
8455{
8456 struct alc_spec *spec = codec->spec;
8457 unsigned int mute;
8458
8459 if (force || !spec->sense_updated) {
8460 unsigned int present;
8461 /* need to execute and sync at first */
8462 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
8463 present = snd_hda_codec_read(codec, 0x14, 0,
8464 AC_VERB_GET_PIN_SENSE, 0);
8465 spec->jack_present = (present & 0x80000000) != 0;
8466 spec->sense_updated = 1;
8467 }
8468 if (spec->jack_present) {
8469 /* mute internal speaker */
8470 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8471 HDA_AMP_MUTE, HDA_AMP_MUTE);
8472 } else {
8473 /* unmute internal speaker if necessary */
8474 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
8475 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8476 HDA_AMP_MUTE, mute);
8477 }
8478}
8479
8480/* unsolicited event for HP jack sensing */
8481static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
8482 unsigned int res)
8483{
8484 if ((res >> 26) != ALC_HP_EVENT)
8485 return;
8486 alc262_fujitsu_automute(codec, 1);
8487}
8488
8489/* bind volumes of both NID 0x0c and 0x0d */
8490static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
8491 .ops = &snd_hda_bind_vol,
8492 .values = {
8493 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
8494 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
8495 0
8496 },
8497};
8498
8499/* bind hp and internal speaker mute (with plug check) */
8500static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
8501 struct snd_ctl_elem_value *ucontrol)
8502{
8503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8504 long *valp = ucontrol->value.integer.value;
8505 int change;
8506
8507 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
8508 HDA_AMP_MUTE,
8509 valp[0] ? 0 : HDA_AMP_MUTE);
8510 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
8511 HDA_AMP_MUTE,
8512 valp[1] ? 0 : HDA_AMP_MUTE);
8513 if (change)
8514 alc262_fujitsu_automute(codec, 0);
8515 return change;
8516}
8517
8518static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
8519 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
8520 {
8521 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8522 .name = "Master Playback Switch",
8523 .info = snd_hda_mixer_amp_switch_info,
8524 .get = snd_hda_mixer_amp_switch_get,
8525 .put = alc262_fujitsu_master_sw_put,
8526 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
8527 },
8528 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8529 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8530 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8532 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8533 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8534 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8535 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8536 { } /* end */
8537};
8538
8539/* additional init verbs for Benq laptops */
8540static struct hda_verb alc262_EAPD_verbs[] = {
8541 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8542 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8543 {}
8544};
8545
8546static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
8547 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8548 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8549
8550 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8551 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8552 {}
8553};
8554
8555/* Samsung Q1 Ultra Vista model setup */
8556static struct snd_kcontrol_new alc262_ultra_mixer[] = {
8557 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8558 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8559 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8560 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8561 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8562 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8563 { } /* end */
8564};
8565
8566static struct hda_verb alc262_ultra_verbs[] = {
8567 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8569 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8570 /* Mic is on Node 0x19 */
8571 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8572 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
8573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8574 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
8575 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8576 {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
8577 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8578 {}
8579};
8580
8581static struct hda_input_mux alc262_ultra_capture_source = {
8582 .num_items = 1,
8583 .items = {
8584 { "Mic", 0x1 },
8585 },
8586};
8587
8588/* mute/unmute internal speaker according to the hp jack and mute state */
8589static void alc262_ultra_automute(struct hda_codec *codec)
8590{
8591 struct alc_spec *spec = codec->spec;
8592 unsigned int mute;
8593 unsigned int present;
8594
8595 /* need to execute and sync at first */
8596 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
8597 present = snd_hda_codec_read(codec, 0x15, 0,
8598 AC_VERB_GET_PIN_SENSE, 0);
8599 spec->jack_present = (present & 0x80000000) != 0;
8600 if (spec->jack_present) {
8601 /* mute internal speaker */
8602 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8603 HDA_AMP_MUTE, HDA_AMP_MUTE);
8604 } else {
8605 /* unmute internal speaker if necessary */
8606 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
8607 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8608 HDA_AMP_MUTE, mute);
8609 }
8610}
8611
8612/* unsolicited event for HP jack sensing */
8613static void alc262_ultra_unsol_event(struct hda_codec *codec,
8614 unsigned int res)
8615{
8616 if ((res >> 26) != ALC880_HP_EVENT)
8617 return;
8618 alc262_ultra_automute(codec);
8619}
8620
8621/* add playback controls from the parsed DAC table */
8622static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
8623 const struct auto_pin_cfg *cfg)
8624{
8625 hda_nid_t nid;
8626 int err;
8627
8628 spec->multiout.num_dacs = 1; /* only use one dac */
8629 spec->multiout.dac_nids = spec->private_dac_nids;
8630 spec->multiout.dac_nids[0] = 2;
8631
8632 nid = cfg->line_out_pins[0];
8633 if (nid) {
8634 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8635 "Front Playback Volume",
8636 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
8637 if (err < 0)
8638 return err;
8639 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8640 "Front Playback Switch",
8641 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
8642 if (err < 0)
8643 return err;
8644 }
8645
8646 nid = cfg->speaker_pins[0];
8647 if (nid) {
8648 if (nid == 0x16) {
8649 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8650 "Speaker Playback Volume",
8651 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8652 HDA_OUTPUT));
8653 if (err < 0)
8654 return err;
8655 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8656 "Speaker Playback Switch",
8657 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8658 HDA_OUTPUT));
8659 if (err < 0)
8660 return err;
8661 } else {
8662 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8663 "Speaker Playback Switch",
8664 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8665 HDA_OUTPUT));
8666 if (err < 0)
8667 return err;
8668 }
8669 }
8670 nid = cfg->hp_pins[0];
8671 if (nid) {
8672 /* spec->multiout.hp_nid = 2; */
8673 if (nid == 0x16) {
8674 err = add_control(spec, ALC_CTL_WIDGET_VOL,
8675 "Headphone Playback Volume",
8676 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
8677 HDA_OUTPUT));
8678 if (err < 0)
8679 return err;
8680 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8681 "Headphone Playback Switch",
8682 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
8683 HDA_OUTPUT));
8684 if (err < 0)
8685 return err;
8686 } else {
8687 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
8688 "Headphone Playback Switch",
8689 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
8690 HDA_OUTPUT));
8691 if (err < 0)
8692 return err;
8693 }
8694 }
8695 return 0;
8696}
8697
8698/* identical with ALC880 */
8699#define alc262_auto_create_analog_input_ctls \
8700 alc880_auto_create_analog_input_ctls
8701
8702/*
8703 * generic initialization of ADC, input mixers and output mixers
8704 */
8705static struct hda_verb alc262_volume_init_verbs[] = {
8706 /*
8707 * Unmute ADC0-2 and set the default input to mic-in
8708 */
8709 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8711 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8712 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8713 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8714 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8715
8716 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8717 * mixer widget
8718 * Note: PASD motherboards uses the Line In 2 as the input for
8719 * front panel mic (mic 2)
8720 */
8721 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8722 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8724 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8725 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8726 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8727
8728 /*
8729 * Set up output mixers (0x0c - 0x0f)
8730 */
8731 /* set vol=0 to output mixers */
8732 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8733 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8734 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8735
8736 /* set up input amps for analog loopback */
8737 /* Amp Indices: DAC = 0, mixer = 1 */
8738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8743 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8744
8745 /* FIXME: use matrix-type input source selection */
8746 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8747 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8748 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8749 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8750 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8751 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8752 /* Input mixer2 */
8753 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8754 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8755 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8756 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8757 /* Input mixer3 */
8758 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8759 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8760 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8761 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8762
8763 { }
8764};
8765
8766static struct hda_verb alc262_HP_BPC_init_verbs[] = {
8767 /*
8768 * Unmute ADC0-2 and set the default input to mic-in
8769 */
8770 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8771 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8772 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8773 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8774 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8775 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8776
8777 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8778 * mixer widget
8779 * Note: PASD motherboards uses the Line In 2 as the input for
8780 * front panel mic (mic 2)
8781 */
8782 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8783 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8784 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8785 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8786 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8787 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8788 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8789 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8790
8791 /*
8792 * Set up output mixers (0x0c - 0x0e)
8793 */
8794 /* set vol=0 to output mixers */
8795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8796 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8797 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8798
8799 /* set up input amps for analog loopback */
8800 /* Amp Indices: DAC = 0, mixer = 1 */
8801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8802 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8804 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8805 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8806 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8807
8808 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8810 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8811
8812 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8813 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8814
8815 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8816 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8817
8818 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8819 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8820 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8821 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8822 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8823
8824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8825 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8826 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8827 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8828 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8829 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8830
8831
8832 /* FIXME: use matrix-type input source selection */
8833 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8834 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8835 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8836 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8837 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8838 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8839 /* Input mixer2 */
8840 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8841 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8842 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8843 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8844 /* Input mixer3 */
8845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8848 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8849
8850 { }
8851};
8852
8853static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
8854 /*
8855 * Unmute ADC0-2 and set the default input to mic-in
8856 */
8857 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8859 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8860 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8861 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8863
8864 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
8865 * mixer widget
8866 * Note: PASD motherboards uses the Line In 2 as the input for front
8867 * panel mic (mic 2)
8868 */
8869 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
8870 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8871 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8872 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8873 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
8876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
8877 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
8878 /*
8879 * Set up output mixers (0x0c - 0x0e)
8880 */
8881 /* set vol=0 to output mixers */
8882 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8883 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8884 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8885
8886 /* set up input amps for analog loopback */
8887 /* Amp Indices: DAC = 0, mixer = 1 */
8888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8891 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8894
8895
8896 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
8897 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
8898 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
8899 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
8900 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
8901 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
8902 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
8903
8904 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8906
8907 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8908 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8909
8910 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
8911 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8912 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8913 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
8914 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8915 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
8916
8917 /* FIXME: use matrix-type input source selection */
8918 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8919 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8920 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
8921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
8922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
8923 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
8924 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
8925 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8926 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
8927 /* Input mixer2 */
8928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8929 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8930 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8931 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8933 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8934 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8935 /* Input mixer3 */
8936 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
8939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
8940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
8941 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
8942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
8943
8944 { }
8945};
8946
8947#ifdef CONFIG_SND_HDA_POWER_SAVE
8948#define alc262_loopbacks alc880_loopbacks
8949#endif
8950
8951/* pcm configuration: identiacal with ALC880 */
8952#define alc262_pcm_analog_playback alc880_pcm_analog_playback
8953#define alc262_pcm_analog_capture alc880_pcm_analog_capture
8954#define alc262_pcm_digital_playback alc880_pcm_digital_playback
8955#define alc262_pcm_digital_capture alc880_pcm_digital_capture
8956
8957/*
8958 * BIOS auto configuration
8959 */
8960static int alc262_parse_auto_config(struct hda_codec *codec)
8961{
8962 struct alc_spec *spec = codec->spec;
8963 int err;
8964 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
8965
8966 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
8967 alc262_ignore);
8968 if (err < 0)
8969 return err;
8970 if (!spec->autocfg.line_outs)
8971 return 0; /* can't find valid BIOS pin config */
8972 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
8973 if (err < 0)
8974 return err;
8975 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
8976 if (err < 0)
8977 return err;
8978
8979 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
8980
8981 if (spec->autocfg.dig_out_pin)
8982 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
8983 if (spec->autocfg.dig_in_pin)
8984 spec->dig_in_nid = ALC262_DIGIN_NID;
8985
8986 if (spec->kctl_alloc)
8987 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
8988
8989 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
8990 spec->num_mux_defs = 1;
8991 spec->input_mux = &spec->private_imux;
8992
8993 err = alc_auto_add_mic_boost(codec);
8994 if (err < 0)
8995 return err;
8996
8997 return 1;
8998}
8999
9000#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9001#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9002#define alc262_auto_init_analog_input alc882_auto_init_analog_input
9003
9004
9005/* init callback for auto-configuration model -- overriding the default init */
9006static void alc262_auto_init(struct hda_codec *codec)
9007{
9008 alc262_auto_init_multi_out(codec);
9009 alc262_auto_init_hp_out(codec);
9010 alc262_auto_init_analog_input(codec);
9011}
9012
9013/*
9014 * configuration and preset
9015 */
9016static const char *alc262_models[ALC262_MODEL_LAST] = {
9017 [ALC262_BASIC] = "basic",
9018 [ALC262_HIPPO] = "hippo",
9019 [ALC262_HIPPO_1] = "hippo_1",
9020 [ALC262_FUJITSU] = "fujitsu",
9021 [ALC262_HP_BPC] = "hp-bpc",
9022 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
9023 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
9024 [ALC262_HP_RP5700] = "hp-rp5700",
9025 [ALC262_BENQ_ED8] = "benq",
9026 [ALC262_BENQ_T31] = "benq-t31",
9027 [ALC262_SONY_ASSAMD] = "sony-assamd",
9028 [ALC262_ULTRA] = "ultra",
9029 [ALC262_AUTO] = "auto",
9030};
9031
9032static struct snd_pci_quirk alc262_cfg_tbl[] = {
9033 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
9034 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
9035 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
9036 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9037 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
9038 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
9039 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
9040 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
9041 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
9042 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
9043 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
9044 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
9045 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
9046 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
9047 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
9048 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
9049 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
9050 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9051 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9052 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
9053 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9054 ALC262_HP_TC_T5735),
9055 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
9056 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9057 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
9058 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9059 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9060 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
9061 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
9062 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
9063 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
9064 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
9065 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
9066 {}
9067};
9068
9069static struct alc_config_preset alc262_presets[] = {
9070 [ALC262_BASIC] = {
9071 .mixers = { alc262_base_mixer },
9072 .init_verbs = { alc262_init_verbs },
9073 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9074 .dac_nids = alc262_dac_nids,
9075 .hp_nid = 0x03,
9076 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9077 .channel_mode = alc262_modes,
9078 .input_mux = &alc262_capture_source,
9079 },
9080 [ALC262_HIPPO] = {
9081 .mixers = { alc262_base_mixer },
9082 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
9083 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9084 .dac_nids = alc262_dac_nids,
9085 .hp_nid = 0x03,
9086 .dig_out_nid = ALC262_DIGOUT_NID,
9087 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9088 .channel_mode = alc262_modes,
9089 .input_mux = &alc262_capture_source,
9090 .unsol_event = alc262_hippo_unsol_event,
9091 .init_hook = alc262_hippo_automute,
9092 },
9093 [ALC262_HIPPO_1] = {
9094 .mixers = { alc262_hippo1_mixer },
9095 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
9096 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9097 .dac_nids = alc262_dac_nids,
9098 .hp_nid = 0x02,
9099 .dig_out_nid = ALC262_DIGOUT_NID,
9100 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9101 .channel_mode = alc262_modes,
9102 .input_mux = &alc262_capture_source,
9103 .unsol_event = alc262_hippo1_unsol_event,
9104 .init_hook = alc262_hippo1_automute,
9105 },
9106 [ALC262_FUJITSU] = {
9107 .mixers = { alc262_fujitsu_mixer },
9108 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
9109 alc262_fujitsu_unsol_verbs },
9110 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9111 .dac_nids = alc262_dac_nids,
9112 .hp_nid = 0x03,
9113 .dig_out_nid = ALC262_DIGOUT_NID,
9114 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9115 .channel_mode = alc262_modes,
9116 .input_mux = &alc262_fujitsu_capture_source,
9117 .unsol_event = alc262_fujitsu_unsol_event,
9118 },
9119 [ALC262_HP_BPC] = {
9120 .mixers = { alc262_HP_BPC_mixer },
9121 .init_verbs = { alc262_HP_BPC_init_verbs },
9122 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9123 .dac_nids = alc262_dac_nids,
9124 .hp_nid = 0x03,
9125 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9126 .channel_mode = alc262_modes,
9127 .input_mux = &alc262_HP_capture_source,
9128 },
9129 [ALC262_HP_BPC_D7000_WF] = {
9130 .mixers = { alc262_HP_BPC_WildWest_mixer },
9131 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9132 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9133 .dac_nids = alc262_dac_nids,
9134 .hp_nid = 0x03,
9135 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9136 .channel_mode = alc262_modes,
9137 .input_mux = &alc262_HP_D7000_capture_source,
9138 },
9139 [ALC262_HP_BPC_D7000_WL] = {
9140 .mixers = { alc262_HP_BPC_WildWest_mixer,
9141 alc262_HP_BPC_WildWest_option_mixer },
9142 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
9143 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9144 .dac_nids = alc262_dac_nids,
9145 .hp_nid = 0x03,
9146 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9147 .channel_mode = alc262_modes,
9148 .input_mux = &alc262_HP_D7000_capture_source,
9149 },
9150 [ALC262_HP_TC_T5735] = {
9151 .mixers = { alc262_hp_t5735_mixer },
9152 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
9153 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9154 .dac_nids = alc262_dac_nids,
9155 .hp_nid = 0x03,
9156 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9157 .channel_mode = alc262_modes,
9158 .input_mux = &alc262_capture_source,
9159 .unsol_event = alc262_hp_t5735_unsol_event,
9160 .init_hook = alc262_hp_t5735_init_hook,
9161 },
9162 [ALC262_HP_RP5700] = {
9163 .mixers = { alc262_hp_rp5700_mixer },
9164 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
9165 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9166 .dac_nids = alc262_dac_nids,
9167 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9168 .channel_mode = alc262_modes,
9169 .input_mux = &alc262_hp_rp5700_capture_source,
9170 },
9171 [ALC262_BENQ_ED8] = {
9172 .mixers = { alc262_base_mixer },
9173 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
9174 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9175 .dac_nids = alc262_dac_nids,
9176 .hp_nid = 0x03,
9177 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9178 .channel_mode = alc262_modes,
9179 .input_mux = &alc262_capture_source,
9180 },
9181 [ALC262_SONY_ASSAMD] = {
9182 .mixers = { alc262_sony_mixer },
9183 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
9184 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9185 .dac_nids = alc262_dac_nids,
9186 .hp_nid = 0x02,
9187 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9188 .channel_mode = alc262_modes,
9189 .input_mux = &alc262_capture_source,
9190 .unsol_event = alc262_hippo_unsol_event,
9191 .init_hook = alc262_hippo_automute,
9192 },
9193 [ALC262_BENQ_T31] = {
9194 .mixers = { alc262_benq_t31_mixer },
9195 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
9196 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9197 .dac_nids = alc262_dac_nids,
9198 .hp_nid = 0x03,
9199 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9200 .channel_mode = alc262_modes,
9201 .input_mux = &alc262_capture_source,
9202 .unsol_event = alc262_hippo_unsol_event,
9203 .init_hook = alc262_hippo_automute,
9204 },
9205 [ALC262_ULTRA] = {
9206 .mixers = { alc262_ultra_mixer },
9207 .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
9208 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
9209 .dac_nids = alc262_dac_nids,
9210 .hp_nid = 0x03,
9211 .dig_out_nid = ALC262_DIGOUT_NID,
9212 .num_channel_mode = ARRAY_SIZE(alc262_modes),
9213 .channel_mode = alc262_modes,
9214 .input_mux = &alc262_ultra_capture_source,
9215 .unsol_event = alc262_ultra_unsol_event,
9216 .init_hook = alc262_ultra_automute,
9217 },
9218};
9219
9220static int patch_alc262(struct hda_codec *codec)
9221{
9222 struct alc_spec *spec;
9223 int board_config;
9224 int err;
9225
9226 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9227 if (spec == NULL)
9228 return -ENOMEM;
9229
9230 codec->spec = spec;
9231#if 0
9232 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
9233 * under-run
9234 */
9235 {
9236 int tmp;
9237 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9238 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
9239 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
9240 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
9241 }
9242#endif
9243
9244 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
9245 alc262_models,
9246 alc262_cfg_tbl);
9247
9248 if (board_config < 0) {
9249 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
9250 "trying auto-probe from BIOS...\n");
9251 board_config = ALC262_AUTO;
9252 }
9253
9254 if (board_config == ALC262_AUTO) {
9255 /* automatic parse from the BIOS config */
9256 err = alc262_parse_auto_config(codec);
9257 if (err < 0) {
9258 alc_free(codec);
9259 return err;
9260 } else if (!err) {
9261 printk(KERN_INFO
9262 "hda_codec: Cannot set up configuration "
9263 "from BIOS. Using base mode...\n");
9264 board_config = ALC262_BASIC;
9265 }
9266 }
9267
9268 if (board_config != ALC262_AUTO)
9269 setup_preset(spec, &alc262_presets[board_config]);
9270
9271 spec->stream_name_analog = "ALC262 Analog";
9272 spec->stream_analog_playback = &alc262_pcm_analog_playback;
9273 spec->stream_analog_capture = &alc262_pcm_analog_capture;
9274
9275 spec->stream_name_digital = "ALC262 Digital";
9276 spec->stream_digital_playback = &alc262_pcm_digital_playback;
9277 spec->stream_digital_capture = &alc262_pcm_digital_capture;
9278
9279 if (!spec->adc_nids && spec->input_mux) {
9280 /* check whether NID 0x07 is valid */
9281 unsigned int wcap = get_wcaps(codec, 0x07);
9282
9283 /* get type */
9284 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
9285 if (wcap != AC_WID_AUD_IN) {
9286 spec->adc_nids = alc262_adc_nids_alt;
9287 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
9288 spec->mixers[spec->num_mixers] =
9289 alc262_capture_alt_mixer;
9290 spec->num_mixers++;
9291 } else {
9292 spec->adc_nids = alc262_adc_nids;
9293 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
9294 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
9295 spec->num_mixers++;
9296 }
9297 }
9298
9299 spec->vmaster_nid = 0x0c;
9300
9301 codec->patch_ops = alc_patch_ops;
9302 if (board_config == ALC262_AUTO)
9303 spec->init_hook = alc262_auto_init;
9304#ifdef CONFIG_SND_HDA_POWER_SAVE
9305 if (!spec->loopback.amplist)
9306 spec->loopback.amplist = alc262_loopbacks;
9307#endif
9308
9309 return 0;
9310}
9311
9312/*
9313 * ALC268 channel source setting (2 channel)
9314 */
9315#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
9316#define alc268_modes alc260_modes
9317
9318static hda_nid_t alc268_dac_nids[2] = {
9319 /* front, hp */
9320 0x02, 0x03
9321};
9322
9323static hda_nid_t alc268_adc_nids[2] = {
9324 /* ADC0-1 */
9325 0x08, 0x07
9326};
9327
9328static hda_nid_t alc268_adc_nids_alt[1] = {
9329 /* ADC0 */
9330 0x08
9331};
9332
9333static struct snd_kcontrol_new alc268_base_mixer[] = {
9334 /* output mixer control */
9335 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9336 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9337 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9338 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9339 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9340 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9341 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
9342 { }
9343};
9344
9345static struct hda_verb alc268_eapd_verbs[] = {
9346 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9347 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9348 { }
9349};
9350
9351/* Toshiba specific */
9352#define alc268_toshiba_automute alc262_hippo_automute
9353
9354static struct hda_verb alc268_toshiba_verbs[] = {
9355 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9356 { } /* end */
9357};
9358
9359/* Acer specific */
9360/* bind volumes of both NID 0x02 and 0x03 */
9361static struct hda_bind_ctls alc268_acer_bind_master_vol = {
9362 .ops = &snd_hda_bind_vol,
9363 .values = {
9364 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
9365 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
9366 0
9367 },
9368};
9369
9370/* mute/unmute internal speaker according to the hp jack and mute state */
9371static void alc268_acer_automute(struct hda_codec *codec, int force)
9372{
9373 struct alc_spec *spec = codec->spec;
9374 unsigned int mute;
9375
9376 if (force || !spec->sense_updated) {
9377 unsigned int present;
9378 present = snd_hda_codec_read(codec, 0x14, 0,
9379 AC_VERB_GET_PIN_SENSE, 0);
9380 spec->jack_present = (present & 0x80000000) != 0;
9381 spec->sense_updated = 1;
9382 }
9383 if (spec->jack_present)
9384 mute = HDA_AMP_MUTE; /* mute internal speaker */
9385 else /* unmute internal speaker if necessary */
9386 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
9387 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9388 HDA_AMP_MUTE, mute);
9389}
9390
9391
9392/* bind hp and internal speaker mute (with plug check) */
9393static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
9394 struct snd_ctl_elem_value *ucontrol)
9395{
9396 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9397 long *valp = ucontrol->value.integer.value;
9398 int change;
9399
9400 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
9401 HDA_AMP_MUTE,
9402 valp[0] ? 0 : HDA_AMP_MUTE);
9403 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
9404 HDA_AMP_MUTE,
9405 valp[1] ? 0 : HDA_AMP_MUTE);
9406 if (change)
9407 alc268_acer_automute(codec, 0);
9408 return change;
9409}
9410
9411static struct snd_kcontrol_new alc268_acer_mixer[] = {
9412 /* output mixer control */
9413 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
9414 {
9415 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9416 .name = "Master Playback Switch",
9417 .info = snd_hda_mixer_amp_switch_info,
9418 .get = snd_hda_mixer_amp_switch_get,
9419 .put = alc268_acer_master_sw_put,
9420 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9421 },
9422 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9423 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9424 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
9425 { }
9426};
9427
9428static struct hda_verb alc268_acer_verbs[] = {
9429 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9430 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9431
9432 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9433 { }
9434};
9435
9436/* unsolicited event for HP jack sensing */
9437static void alc268_toshiba_unsol_event(struct hda_codec *codec,
9438 unsigned int res)
9439{
9440 if ((res >> 26) != ALC880_HP_EVENT)
9441 return;
9442 alc268_toshiba_automute(codec);
9443}
9444
9445static void alc268_acer_unsol_event(struct hda_codec *codec,
9446 unsigned int res)
9447{
9448 if ((res >> 26) != ALC880_HP_EVENT)
9449 return;
9450 alc268_acer_automute(codec, 1);
9451}
9452
9453static void alc268_acer_init_hook(struct hda_codec *codec)
9454{
9455 alc268_acer_automute(codec, 1);
9456}
9457
9458static struct snd_kcontrol_new alc268_dell_mixer[] = {
9459 /* output mixer control */
9460 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9461 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9462 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9463 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9464 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9465 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
9466 { }
9467};
9468
9469static struct hda_verb alc268_dell_verbs[] = {
9470 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9472 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9473 { }
9474};
9475
9476/* mute/unmute internal speaker according to the hp jack and mute state */
9477static void alc268_dell_automute(struct hda_codec *codec)
9478{
9479 unsigned int present;
9480 unsigned int mute;
9481
9482 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
9483 if (present & 0x80000000)
9484 mute = HDA_AMP_MUTE;
9485 else
9486 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
9487 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9488 HDA_AMP_MUTE, mute);
9489}
9490
9491static void alc268_dell_unsol_event(struct hda_codec *codec,
9492 unsigned int res)
9493{
9494 if ((res >> 26) != ALC880_HP_EVENT)
9495 return;
9496 alc268_dell_automute(codec);
9497}
9498
9499#define alc268_dell_init_hook alc268_dell_automute
9500
9501/*
9502 * generic initialization of ADC, input mixers and output mixers
9503 */
9504static struct hda_verb alc268_base_init_verbs[] = {
9505 /* Unmute DAC0-1 and set vol = 0 */
9506 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9507 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9508 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9509 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9510 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9511 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9512
9513 /*
9514 * Set up output mixers (0x0c - 0x0e)
9515 */
9516 /* set vol=0 to output mixers */
9517 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9519 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9520 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
9521
9522 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9523 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9524
9525 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9527 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9528 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9529 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9530 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9531 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9532 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9533
9534 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9536 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9537 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9538 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9539 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9540 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9541 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9542
9543 /* Unmute Selector 23h,24h and set the default input to mic-in */
9544
9545 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
9546 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9547 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
9548 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9549
9550 { }
9551};
9552
9553/*
9554 * generic initialization of ADC, input mixers and output mixers
9555 */
9556static struct hda_verb alc268_volume_init_verbs[] = {
9557 /* set output DAC */
9558 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9559 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9560 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9561 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9562
9563 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9564 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9565 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9566 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9567 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9568
9569 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9570 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9571 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9572 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9573 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9574
9575 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9576 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9578 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9579
9580 /* set PCBEEP vol = 0 */
9581 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
9582
9583 { }
9584};
9585
9586#define alc268_mux_enum_info alc_mux_enum_info
9587#define alc268_mux_enum_get alc_mux_enum_get
9588
9589static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
9590 struct snd_ctl_elem_value *ucontrol)
9591{
9592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9593 struct alc_spec *spec = codec->spec;
9594
9595 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
9596 static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
9597 hda_nid_t nid = capture_mixers[adc_idx];
9598
9599 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
9600 nid,
9601 &spec->cur_mux[adc_idx]);
9602}
9603
9604static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
9605 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9606 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9607 {
9608 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9609 /* The multiple "Capture Source" controls confuse alsamixer
9610 * So call somewhat different..
9611 */
9612 /* .name = "Capture Source", */
9613 .name = "Input Source",
9614 .count = 1,
9615 .info = alc268_mux_enum_info,
9616 .get = alc268_mux_enum_get,
9617 .put = alc268_mux_enum_put,
9618 },
9619 { } /* end */
9620};
9621
9622static struct snd_kcontrol_new alc268_capture_mixer[] = {
9623 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9624 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
9625 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
9626 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
9627 {
9628 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9629 /* The multiple "Capture Source" controls confuse alsamixer
9630 * So call somewhat different..
9631 */
9632 /* .name = "Capture Source", */
9633 .name = "Input Source",
9634 .count = 2,
9635 .info = alc268_mux_enum_info,
9636 .get = alc268_mux_enum_get,
9637 .put = alc268_mux_enum_put,
9638 },
9639 { } /* end */
9640};
9641
9642static struct hda_input_mux alc268_capture_source = {
9643 .num_items = 4,
9644 .items = {
9645 { "Mic", 0x0 },
9646 { "Front Mic", 0x1 },
9647 { "Line", 0x2 },
9648 { "CD", 0x3 },
9649 },
9650};
9651
9652#ifdef CONFIG_SND_DEBUG
9653static struct snd_kcontrol_new alc268_test_mixer[] = {
9654 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
9655 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9656 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
9657 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9658
9659 /* Volume widgets */
9660 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
9661 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
9662 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9663 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
9664 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
9665 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
9666 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
9667 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
9668 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
9669 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
9670 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
9671 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
9672 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
9673 /* The below appears problematic on some hardwares */
9674 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
9675 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
9676 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
9677 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
9678 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
9679
9680 /* Modes for retasking pin widgets */
9681 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
9682 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
9683 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
9684 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
9685
9686 /* Controls for GPIO pins, assuming they are configured as outputs */
9687 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
9688 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
9689 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
9690 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
9691
9692 /* Switches to allow the digital SPDIF output pin to be enabled.
9693 * The ALC268 does not have an SPDIF input.
9694 */
9695 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
9696
9697 /* A switch allowing EAPD to be enabled. Some laptops seem to use
9698 * this output to turn on an external amplifier.
9699 */
9700 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
9701 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
9702
9703 { } /* end */
9704};
9705#endif
9706
9707/* create input playback/capture controls for the given pin */
9708static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
9709 const char *ctlname, int idx)
9710{
9711 char name[32];
9712 int err;
9713
9714 sprintf(name, "%s Playback Volume", ctlname);
9715 if (nid == 0x14) {
9716 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9717 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
9718 HDA_OUTPUT));
9719 if (err < 0)
9720 return err;
9721 } else if (nid == 0x15) {
9722 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
9723 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
9724 HDA_OUTPUT));
9725 if (err < 0)
9726 return err;
9727 } else
9728 return -1;
9729 sprintf(name, "%s Playback Switch", ctlname);
9730 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
9731 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
9732 if (err < 0)
9733 return err;
9734 return 0;
9735}
9736
9737/* add playback controls from the parsed DAC table */
9738static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
9739 const struct auto_pin_cfg *cfg)
9740{
9741 hda_nid_t nid;
9742 int err;
9743
9744 spec->multiout.num_dacs = 2; /* only use one dac */
9745 spec->multiout.dac_nids = spec->private_dac_nids;
9746 spec->multiout.dac_nids[0] = 2;
9747 spec->multiout.dac_nids[1] = 3;
9748
9749 nid = cfg->line_out_pins[0];
9750 if (nid)
9751 alc268_new_analog_output(spec, nid, "Front", 0);
9752
9753 nid = cfg->speaker_pins[0];
9754 if (nid == 0x1d) {
9755 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9756 "Speaker Playback Volume",
9757 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9758 if (err < 0)
9759 return err;
9760 }
9761 nid = cfg->hp_pins[0];
9762 if (nid)
9763 alc268_new_analog_output(spec, nid, "Headphone", 0);
9764
9765 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
9766 if (nid == 0x16) {
9767 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9768 "Mono Playback Switch",
9769 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
9770 if (err < 0)
9771 return err;
9772 }
9773 return 0;
9774}
9775
9776/* create playback/capture controls for input pins */
9777static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
9778 const struct auto_pin_cfg *cfg)
9779{
9780 struct hda_input_mux *imux = &spec->private_imux;
9781 int i, idx1;
9782
9783 for (i = 0; i < AUTO_PIN_LAST; i++) {
9784 switch(cfg->input_pins[i]) {
9785 case 0x18:
9786 idx1 = 0; /* Mic 1 */
9787 break;
9788 case 0x19:
9789 idx1 = 1; /* Mic 2 */
9790 break;
9791 case 0x1a:
9792 idx1 = 2; /* Line In */
9793 break;
9794 case 0x1c:
9795 idx1 = 3; /* CD */
9796 break;
9797 default:
9798 continue;
9799 }
9800 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
9801 imux->items[imux->num_items].index = idx1;
9802 imux->num_items++;
9803 }
9804 return 0;
9805}
9806
9807static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
9808{
9809 struct alc_spec *spec = codec->spec;
9810 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9811 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9812 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9813 unsigned int dac_vol1, dac_vol2;
9814
9815 if (speaker_nid) {
9816 snd_hda_codec_write(codec, speaker_nid, 0,
9817 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
9818 snd_hda_codec_write(codec, 0x0f, 0,
9819 AC_VERB_SET_AMP_GAIN_MUTE,
9820 AMP_IN_UNMUTE(1));
9821 snd_hda_codec_write(codec, 0x10, 0,
9822 AC_VERB_SET_AMP_GAIN_MUTE,
9823 AMP_IN_UNMUTE(1));
9824 } else {
9825 snd_hda_codec_write(codec, 0x0f, 0,
9826 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9827 snd_hda_codec_write(codec, 0x10, 0,
9828 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
9829 }
9830
9831 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
9832 if (line_nid == 0x14)
9833 dac_vol2 = AMP_OUT_ZERO;
9834 else if (line_nid == 0x15)
9835 dac_vol1 = AMP_OUT_ZERO;
9836 if (hp_nid == 0x14)
9837 dac_vol2 = AMP_OUT_ZERO;
9838 else if (hp_nid == 0x15)
9839 dac_vol1 = AMP_OUT_ZERO;
9840 if (line_nid != 0x16 || hp_nid != 0x16 ||
9841 spec->autocfg.line_out_pins[1] != 0x16 ||
9842 spec->autocfg.line_out_pins[2] != 0x16)
9843 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
9844
9845 snd_hda_codec_write(codec, 0x02, 0,
9846 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
9847 snd_hda_codec_write(codec, 0x03, 0,
9848 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
9849}
9850
9851/* pcm configuration: identiacal with ALC880 */
9852#define alc268_pcm_analog_playback alc880_pcm_analog_playback
9853#define alc268_pcm_analog_capture alc880_pcm_analog_capture
9854#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
9855#define alc268_pcm_digital_playback alc880_pcm_digital_playback
9856
9857/*
9858 * BIOS auto configuration
9859 */
9860static int alc268_parse_auto_config(struct hda_codec *codec)
9861{
9862 struct alc_spec *spec = codec->spec;
9863 int err;
9864 static hda_nid_t alc268_ignore[] = { 0 };
9865
9866 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9867 alc268_ignore);
9868 if (err < 0)
9869 return err;
9870 if (!spec->autocfg.line_outs)
9871 return 0; /* can't find valid BIOS pin config */
9872
9873 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
9874 if (err < 0)
9875 return err;
9876 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
9877 if (err < 0)
9878 return err;
9879
9880 spec->multiout.max_channels = 2;
9881
9882 /* digital only support output */
9883 if (spec->autocfg.dig_out_pin)
9884 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
9885
9886 if (spec->kctl_alloc)
9887 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9888
9889 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
9890 spec->num_mux_defs = 1;
9891 spec->input_mux = &spec->private_imux;
9892
9893 err = alc_auto_add_mic_boost(codec);
9894 if (err < 0)
9895 return err;
9896
9897 return 1;
9898}
9899
9900#define alc268_auto_init_multi_out alc882_auto_init_multi_out
9901#define alc268_auto_init_hp_out alc882_auto_init_hp_out
9902#define alc268_auto_init_analog_input alc882_auto_init_analog_input
9903
9904/* init callback for auto-configuration model -- overriding the default init */
9905static void alc268_auto_init(struct hda_codec *codec)
9906{
9907 alc268_auto_init_multi_out(codec);
9908 alc268_auto_init_hp_out(codec);
9909 alc268_auto_init_mono_speaker_out(codec);
9910 alc268_auto_init_analog_input(codec);
9911}
9912
9913/*
9914 * configuration and preset
9915 */
9916static const char *alc268_models[ALC268_MODEL_LAST] = {
9917 [ALC268_3ST] = "3stack",
9918 [ALC268_TOSHIBA] = "toshiba",
9919 [ALC268_ACER] = "acer",
9920 [ALC268_DELL] = "dell",
9921#ifdef CONFIG_SND_DEBUG
9922 [ALC268_TEST] = "test",
9923#endif
9924 [ALC268_AUTO] = "auto",
9925};
9926
9927static struct snd_pci_quirk alc268_cfg_tbl[] = {
9928 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
9929 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
9930 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
9931 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
9932 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
9933 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
9934 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
9935 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
9936 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
9937 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
9938 {}
9939};
9940
9941static struct alc_config_preset alc268_presets[] = {
9942 [ALC268_3ST] = {
9943 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9944 .init_verbs = { alc268_base_init_verbs },
9945 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9946 .dac_nids = alc268_dac_nids,
9947 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9948 .adc_nids = alc268_adc_nids_alt,
9949 .hp_nid = 0x03,
9950 .dig_out_nid = ALC268_DIGOUT_NID,
9951 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9952 .channel_mode = alc268_modes,
9953 .input_mux = &alc268_capture_source,
9954 },
9955 [ALC268_TOSHIBA] = {
9956 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
9957 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9958 alc268_toshiba_verbs },
9959 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9960 .dac_nids = alc268_dac_nids,
9961 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9962 .adc_nids = alc268_adc_nids_alt,
9963 .hp_nid = 0x03,
9964 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9965 .channel_mode = alc268_modes,
9966 .input_mux = &alc268_capture_source,
9967 .unsol_event = alc268_toshiba_unsol_event,
9968 .init_hook = alc268_toshiba_automute,
9969 },
9970 [ALC268_ACER] = {
9971 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
9972 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9973 alc268_acer_verbs },
9974 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9975 .dac_nids = alc268_dac_nids,
9976 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
9977 .adc_nids = alc268_adc_nids_alt,
9978 .hp_nid = 0x02,
9979 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9980 .channel_mode = alc268_modes,
9981 .input_mux = &alc268_capture_source,
9982 .unsol_event = alc268_acer_unsol_event,
9983 .init_hook = alc268_acer_init_hook,
9984 },
9985 [ALC268_DELL] = {
9986 .mixers = { alc268_dell_mixer },
9987 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
9988 alc268_dell_verbs },
9989 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
9990 .dac_nids = alc268_dac_nids,
9991 .hp_nid = 0x02,
9992 .num_channel_mode = ARRAY_SIZE(alc268_modes),
9993 .channel_mode = alc268_modes,
9994 .unsol_event = alc268_dell_unsol_event,
9995 .init_hook = alc268_dell_init_hook,
9996 .input_mux = &alc268_capture_source,
9997 },
9998#ifdef CONFIG_SND_DEBUG
9999 [ALC268_TEST] = {
10000 .mixers = { alc268_test_mixer, alc268_capture_mixer },
10001 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
10002 alc268_volume_init_verbs },
10003 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
10004 .dac_nids = alc268_dac_nids,
10005 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
10006 .adc_nids = alc268_adc_nids_alt,
10007 .hp_nid = 0x03,
10008 .dig_out_nid = ALC268_DIGOUT_NID,
10009 .num_channel_mode = ARRAY_SIZE(alc268_modes),
10010 .channel_mode = alc268_modes,
10011 .input_mux = &alc268_capture_source,
10012 },
10013#endif
10014};
10015
10016static int patch_alc268(struct hda_codec *codec)
10017{
10018 struct alc_spec *spec;
10019 int board_config;
10020 int err;
10021
10022 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
10023 if (spec == NULL)
10024 return -ENOMEM;
10025
10026 codec->spec = spec;
10027
10028 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
10029 alc268_models,
10030 alc268_cfg_tbl);
10031
10032 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
10033 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
10034 "trying auto-probe from BIOS...\n");
10035 board_config = ALC268_AUTO;
10036 }
10037
10038 if (board_config == ALC268_AUTO) {
10039 /* automatic parse from the BIOS config */
10040 err = alc268_parse_auto_config(codec);
10041 if (err < 0) {
10042 alc_free(codec);
10043 return err;
10044 } else if (!err) {
10045 printk(KERN_INFO
10046 "hda_codec: Cannot set up configuration "
10047 "from BIOS. Using base mode...\n");
10048 board_config = ALC268_3ST;
10049 }
10050 }
10051
10052 if (board_config != ALC268_AUTO)
10053 setup_preset(spec, &alc268_presets[board_config]);
10054
10055 spec->stream_name_analog = "ALC268 Analog";
10056 spec->stream_analog_playback = &alc268_pcm_analog_playback;
10057 spec->stream_analog_capture = &alc268_pcm_analog_capture;
10058 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
10059
10060 spec->stream_name_digital = "ALC268 Digital";
10061 spec->stream_digital_playback = &alc268_pcm_digital_playback;
10062
10063 if (!spec->adc_nids && spec->input_mux) {
10064 /* check whether NID 0x07 is valid */
10065 unsigned int wcap = get_wcaps(codec, 0x07);
10066
10067 /* get type */
10068 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
10069 if (wcap != AC_WID_AUD_IN) {
10070 spec->adc_nids = alc268_adc_nids_alt;
10071 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
10072 spec->mixers[spec->num_mixers] =
10073 alc268_capture_alt_mixer;
10074 spec->num_mixers++;
10075 } else {
10076 spec->adc_nids = alc268_adc_nids;
10077 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
10078 spec->mixers[spec->num_mixers] =
10079 alc268_capture_mixer;
10080 spec->num_mixers++;
10081 }
10082 }
10083
10084 spec->vmaster_nid = 0x02;
10085
10086 codec->patch_ops = alc_patch_ops;
10087 if (board_config == ALC268_AUTO)
10088 spec->init_hook = alc268_auto_init;
10089
10090 return 0;
10091}
10092
10093/*
10094 * ALC269 channel source setting (2 channel)
10095 */
10096#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
10097
10098#define alc269_dac_nids alc260_dac_nids
10099
10100static hda_nid_t alc269_adc_nids[1] = {
10101 /* ADC1 */
10102 0x07,
10103};
10104
10105#define alc269_modes alc260_modes
10106#define alc269_capture_source alc880_lg_lw_capture_source
10107
10108static struct snd_kcontrol_new alc269_base_mixer[] = {
10109 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10110 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10115 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10116 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10117 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10118 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10119 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10120 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10121 { } /* end */
10122};
10123
10124/* capture mixer elements */
10125static struct snd_kcontrol_new alc269_capture_mixer[] = {
10126 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10127 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10128 {
10129 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10130 /* The multiple "Capture Source" controls confuse alsamixer
10131 * So call somewhat different..
10132 */
10133 /* .name = "Capture Source", */
10134 .name = "Input Source",
10135 .count = 1,
10136 .info = alc_mux_enum_info,
10137 .get = alc_mux_enum_get,
10138 .put = alc_mux_enum_put,
10139 },
10140 { } /* end */
10141};
10142
10143/*
10144 * generic initialization of ADC, input mixers and output mixers
10145 */
10146static struct hda_verb alc269_init_verbs[] = {
10147 /*
10148 * Unmute ADC0 and set the default input to mic-in
10149 */
10150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10151
10152 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
10153 * analog-loopback mixer widget
10154 * Note: PASD motherboards uses the Line In 2 as the input for
10155 * front panel mic (mic 2)
10156 */
10157 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10159 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10161 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10162 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10163
10164 /*
10165 * Set up output mixers (0x0c - 0x0e)
10166 */
10167 /* set vol=0 to output mixers */
10168 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10169 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10170
10171 /* set up input amps for analog loopback */
10172 /* Amp Indices: DAC = 0, mixer = 1 */
10173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10174 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10175 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10176 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10177 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10178 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10179
10180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10182 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10183 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10184 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10185 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10186 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10187
10188 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10190 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10191 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10192 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10193 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10195
10196 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10198
10199 /* FIXME: use matrix-type input source selection */
10200 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
10201 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10202 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10203 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10204 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10205 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10206
10207 /* set EAPD */
10208 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10209 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10210 { }
10211};
10212
10213/* add playback controls from the parsed DAC table */
10214static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
10215 const struct auto_pin_cfg *cfg)
10216{
10217 hda_nid_t nid;
10218 int err;
10219
10220 spec->multiout.num_dacs = 1; /* only use one dac */
10221 spec->multiout.dac_nids = spec->private_dac_nids;
10222 spec->multiout.dac_nids[0] = 2;
10223
10224 nid = cfg->line_out_pins[0];
10225 if (nid) {
10226 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10227 "Front Playback Volume",
10228 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
10229 if (err < 0)
10230 return err;
10231 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10232 "Front Playback Switch",
10233 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10234 if (err < 0)
10235 return err;
10236 }
10237
10238 nid = cfg->speaker_pins[0];
10239 if (nid) {
10240 if (!cfg->line_out_pins[0]) {
10241 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10242 "Speaker Playback Volume",
10243 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10244 HDA_OUTPUT));
10245 if (err < 0)
10246 return err;
10247 }
10248 if (nid == 0x16) {
10249 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10250 "Speaker Playback Switch",
10251 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10252 HDA_OUTPUT));
10253 if (err < 0)
10254 return err;
10255 } else {
10256 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10257 "Speaker Playback Switch",
10258 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10259 HDA_OUTPUT));
10260 if (err < 0)
10261 return err;
10262 }
10263 }
10264 nid = cfg->hp_pins[0];
10265 if (nid) {
10266 /* spec->multiout.hp_nid = 2; */
10267 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
10268 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10269 "Headphone Playback Volume",
10270 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
10271 HDA_OUTPUT));
10272 if (err < 0)
10273 return err;
10274 }
10275 if (nid == 0x16) {
10276 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10277 "Headphone Playback Switch",
10278 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10279 HDA_OUTPUT));
10280 if (err < 0)
10281 return err;
10282 } else {
10283 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10284 "Headphone Playback Switch",
10285 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10286 HDA_OUTPUT));
10287 if (err < 0)
10288 return err;
10289 }
10290 }
10291 return 0;
10292}
10293
10294#define alc269_auto_create_analog_input_ctls \
10295 alc880_auto_create_analog_input_ctls
10296
10297#ifdef CONFIG_SND_HDA_POWER_SAVE
10298#define alc269_loopbacks alc880_loopbacks
10299#endif
10300
10301/* pcm configuration: identiacal with ALC880 */
10302#define alc269_pcm_analog_playback alc880_pcm_analog_playback
10303#define alc269_pcm_analog_capture alc880_pcm_analog_capture
10304#define alc269_pcm_digital_playback alc880_pcm_digital_playback
10305#define alc269_pcm_digital_capture alc880_pcm_digital_capture
10306
10307/*
10308 * BIOS auto configuration
10309 */
10310static int alc269_parse_auto_config(struct hda_codec *codec)
10311{
10312 struct alc_spec *spec = codec->spec;
10313 int err;
10314 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
10315
10316 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10317 alc269_ignore);
10318 if (err < 0)
10319 return err;
10320
10321 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
10322 if (err < 0)
10323 return err;
10324 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
10325 if (err < 0)
10326 return err;
10327
10328 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10329
10330 if (spec->autocfg.dig_out_pin)
10331 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
10332
10333 if (spec->kctl_alloc)
10334 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
10335
10336 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
10337 spec->num_mux_defs = 1;
10338 spec->input_mux = &spec->private_imux;
10339
10340 err = alc_auto_add_mic_boost(codec);
10341 if (err < 0)
10342 return err;
10343
10344 return 1;
10345}
10346
10347#define alc269_auto_init_multi_out alc882_auto_init_multi_out
10348#define alc269_auto_init_hp_out alc882_auto_init_hp_out
10349#define alc269_auto_init_analog_input alc882_auto_init_analog_input
10350
10351
10352/* init callback for auto-configuration model -- overriding the default init */
10353static void alc269_auto_init(struct hda_codec *codec)
10354{
10355 alc269_auto_init_multi_out(codec);
10356 alc269_auto_init_hp_out(codec);
10357 alc269_auto_init_analog_input(codec);
10358}
10359
10360/*
10361 * configuration and preset
10362 */
10363static const char *alc269_models[ALC269_MODEL_LAST] = {
10364 [ALC269_BASIC] = "basic",
10365};
10366
10367static struct snd_pci_quirk alc269_cfg_tbl[] = {
10368 {}
10369};
10370
10371static struct alc_config_preset alc269_presets[] = {
10372 [ALC269_BASIC] = {
10373 .mixers = { alc269_base_mixer },
10374 .init_verbs = { alc269_init_verbs },
10375 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
10376 .dac_nids = alc269_dac_nids,
10377 .hp_nid = 0x03,
10378 .num_channel_mode = ARRAY_SIZE(alc269_modes),
10379 .channel_mode = alc269_modes,
10380 .input_mux = &alc269_capture_source,
10381 },
10382};
10383
10384static int patch_alc269(struct hda_codec *codec)
10385{
10386 struct alc_spec *spec;
10387 int board_config;
10388 int err;
10389
10390 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10391 if (spec == NULL)
10392 return -ENOMEM;
10393
10394 codec->spec = spec;
10395
10396 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
10397 alc269_models,
10398 alc269_cfg_tbl);
10399
10400 if (board_config < 0) {
10401 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
10402 "trying auto-probe from BIOS...\n");
10403 board_config = ALC269_AUTO;
10404 }
10405
10406 if (board_config == ALC269_AUTO) {
10407 /* automatic parse from the BIOS config */
10408 err = alc269_parse_auto_config(codec);
10409 if (err < 0) {
10410 alc_free(codec);
10411 return err;
10412 } else if (!err) {
10413 printk(KERN_INFO
10414 "hda_codec: Cannot set up configuration "
10415 "from BIOS. Using base mode...\n");
10416 board_config = ALC269_BASIC;
10417 }
10418 }
10419
10420 if (board_config != ALC269_AUTO)
10421 setup_preset(spec, &alc269_presets[board_config]);
10422
10423 spec->stream_name_analog = "ALC269 Analog";
10424 spec->stream_analog_playback = &alc269_pcm_analog_playback;
10425 spec->stream_analog_capture = &alc269_pcm_analog_capture;
10426
10427 spec->stream_name_digital = "ALC269 Digital";
10428 spec->stream_digital_playback = &alc269_pcm_digital_playback;
10429 spec->stream_digital_capture = &alc269_pcm_digital_capture;
10430
10431 spec->adc_nids = alc269_adc_nids;
10432 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
10433 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
10434 spec->num_mixers++;
10435
10436 codec->patch_ops = alc_patch_ops;
10437 if (board_config == ALC269_AUTO)
10438 spec->init_hook = alc269_auto_init;
10439#ifdef CONFIG_SND_HDA_POWER_SAVE
10440 if (!spec->loopback.amplist)
10441 spec->loopback.amplist = alc269_loopbacks;
10442#endif
10443
10444 return 0;
10445}
10446
10447/*
10448 * ALC861 channel source setting (2/6 channel selection for 3-stack)
10449 */
10450
10451/*
10452 * set the path ways for 2 channel output
10453 * need to set the codec line out and mic 1 pin widgets to inputs
10454 */
10455static struct hda_verb alc861_threestack_ch2_init[] = {
10456 /* set pin widget 1Ah (line in) for input */
10457 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10458 /* set pin widget 18h (mic1/2) for input, for mic also enable
10459 * the vref
10460 */
10461 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10462
10463 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10464#if 0
10465 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10466 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10467#endif
10468 { } /* end */
10469};
10470/*
10471 * 6ch mode
10472 * need to set the codec line out and mic 1 pin widgets to outputs
10473 */
10474static struct hda_verb alc861_threestack_ch6_init[] = {
10475 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10476 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10477 /* set pin widget 18h (mic1) for output (CLFE)*/
10478 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10479
10480 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10481 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10482
10483 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10484#if 0
10485 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10486 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10487#endif
10488 { } /* end */
10489};
10490
10491static struct hda_channel_mode alc861_threestack_modes[2] = {
10492 { 2, alc861_threestack_ch2_init },
10493 { 6, alc861_threestack_ch6_init },
10494};
10495/* Set mic1 as input and unmute the mixer */
10496static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
10497 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10498 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10499 { } /* end */
10500};
10501/* Set mic1 as output and mute mixer */
10502static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
10503 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10504 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10505 { } /* end */
10506};
10507
10508static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
10509 { 2, alc861_uniwill_m31_ch2_init },
10510 { 4, alc861_uniwill_m31_ch4_init },
10511};
10512
10513/* Set mic1 and line-in as input and unmute the mixer */
10514static struct hda_verb alc861_asus_ch2_init[] = {
10515 /* set pin widget 1Ah (line in) for input */
10516 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10517 /* set pin widget 18h (mic1/2) for input, for mic also enable
10518 * the vref
10519 */
10520 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10521
10522 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
10523#if 0
10524 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
10525 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
10526#endif
10527 { } /* end */
10528};
10529/* Set mic1 nad line-in as output and mute mixer */
10530static struct hda_verb alc861_asus_ch6_init[] = {
10531 /* set pin widget 1Ah (line in) for output (Back Surround)*/
10532 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10533 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10534 /* set pin widget 18h (mic1) for output (CLFE)*/
10535 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10536 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
10537 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
10538 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
10539
10540 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
10541#if 0
10542 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
10543 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
10544#endif
10545 { } /* end */
10546};
10547
10548static struct hda_channel_mode alc861_asus_modes[2] = {
10549 { 2, alc861_asus_ch2_init },
10550 { 6, alc861_asus_ch6_init },
10551};
10552
10553/* patch-ALC861 */
10554
10555static struct snd_kcontrol_new alc861_base_mixer[] = {
10556 /* output mixer control */
10557 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10558 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10559 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10560 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10561 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10562
10563 /*Input mixer control */
10564 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10565 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10566 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10567 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10568 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10569 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10571 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10572 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10574
10575 /* Capture mixer control */
10576 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10577 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10578 {
10579 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10580 .name = "Capture Source",
10581 .count = 1,
10582 .info = alc_mux_enum_info,
10583 .get = alc_mux_enum_get,
10584 .put = alc_mux_enum_put,
10585 },
10586 { } /* end */
10587};
10588
10589static struct snd_kcontrol_new alc861_3ST_mixer[] = {
10590 /* output mixer control */
10591 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10592 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10593 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10594 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10595 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10596
10597 /* Input mixer control */
10598 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10599 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10600 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10601 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10602 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10603 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10604 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10605 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10606 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10607 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10608
10609 /* Capture mixer control */
10610 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10611 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10612 {
10613 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10614 .name = "Capture Source",
10615 .count = 1,
10616 .info = alc_mux_enum_info,
10617 .get = alc_mux_enum_get,
10618 .put = alc_mux_enum_put,
10619 },
10620 {
10621 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10622 .name = "Channel Mode",
10623 .info = alc_ch_mode_info,
10624 .get = alc_ch_mode_get,
10625 .put = alc_ch_mode_put,
10626 .private_value = ARRAY_SIZE(alc861_threestack_modes),
10627 },
10628 { } /* end */
10629};
10630
10631static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
10632 /* output mixer control */
10633 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10635 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10636
10637 /*Capture mixer control */
10638 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10639 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10640 {
10641 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10642 .name = "Capture Source",
10643 .count = 1,
10644 .info = alc_mux_enum_info,
10645 .get = alc_mux_enum_get,
10646 .put = alc_mux_enum_put,
10647 },
10648
10649 { } /* end */
10650};
10651
10652static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
10653 /* output mixer control */
10654 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10655 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10656 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10657 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10658 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
10659
10660 /* Input mixer control */
10661 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10662 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
10663 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10664 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10665 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10666 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10668 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10669 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10670 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
10671
10672 /* Capture mixer control */
10673 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10674 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10675 {
10676 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10677 .name = "Capture Source",
10678 .count = 1,
10679 .info = alc_mux_enum_info,
10680 .get = alc_mux_enum_get,
10681 .put = alc_mux_enum_put,
10682 },
10683 {
10684 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10685 .name = "Channel Mode",
10686 .info = alc_ch_mode_info,
10687 .get = alc_ch_mode_get,
10688 .put = alc_ch_mode_put,
10689 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
10690 },
10691 { } /* end */
10692};
10693
10694static struct snd_kcontrol_new alc861_asus_mixer[] = {
10695 /* output mixer control */
10696 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
10697 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
10698 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
10699 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
10700 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
10701
10702 /* Input mixer control */
10703 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
10704 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10705 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10706 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10707 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
10708 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
10709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
10710 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
10711 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
10712 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
10713
10714 /* Capture mixer control */
10715 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
10716 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
10717 {
10718 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10719 .name = "Capture Source",
10720 .count = 1,
10721 .info = alc_mux_enum_info,
10722 .get = alc_mux_enum_get,
10723 .put = alc_mux_enum_put,
10724 },
10725 {
10726 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10727 .name = "Channel Mode",
10728 .info = alc_ch_mode_info,
10729 .get = alc_ch_mode_get,
10730 .put = alc_ch_mode_put,
10731 .private_value = ARRAY_SIZE(alc861_asus_modes),
10732 },
10733 { }
10734};
10735
10736/* additional mixer */
10737static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
10738 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
10739 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
10740 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
10741 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
10742 { }
10743};
10744
10745/*
10746 * generic initialization of ADC, input mixers and output mixers
10747 */
10748static struct hda_verb alc861_base_init_verbs[] = {
10749 /*
10750 * Unmute ADC0 and set the default input to mic-in
10751 */
10752 /* port-A for surround (rear panel) */
10753 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10754 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
10755 /* port-B for mic-in (rear panel) with vref */
10756 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10757 /* port-C for line-in (rear panel) */
10758 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10759 /* port-D for Front */
10760 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10761 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10762 /* port-E for HP out (front panel) */
10763 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10764 /* route front PCM to HP */
10765 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10766 /* port-F for mic-in (front panel) with vref */
10767 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10768 /* port-G for CLFE (rear panel) */
10769 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10770 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10771 /* port-H for side (rear panel) */
10772 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10773 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
10774 /* CD-in */
10775 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10776 /* route front mic to ADC1*/
10777 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10778 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10779
10780 /* Unmute DAC0~3 & spdif out*/
10781 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10782 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10783 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10784 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10785 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10786
10787 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10788 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10789 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10790 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10791 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10792
10793 /* Unmute Stereo Mixer 15 */
10794 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10795 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10797 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
10798
10799 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10800 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10801 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10802 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10803 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10804 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10805 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10806 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10807 /* hp used DAC 3 (Front) */
10808 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10809 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10810
10811 { }
10812};
10813
10814static struct hda_verb alc861_threestack_init_verbs[] = {
10815 /*
10816 * Unmute ADC0 and set the default input to mic-in
10817 */
10818 /* port-A for surround (rear panel) */
10819 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10820 /* port-B for mic-in (rear panel) with vref */
10821 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10822 /* port-C for line-in (rear panel) */
10823 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10824 /* port-D for Front */
10825 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10826 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10827 /* port-E for HP out (front panel) */
10828 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
10829 /* route front PCM to HP */
10830 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10831 /* port-F for mic-in (front panel) with vref */
10832 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10833 /* port-G for CLFE (rear panel) */
10834 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10835 /* port-H for side (rear panel) */
10836 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10837 /* CD-in */
10838 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10839 /* route front mic to ADC1*/
10840 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10841 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10842 /* Unmute DAC0~3 & spdif out*/
10843 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10844 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10845 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10846 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10847 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10848
10849 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10850 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10851 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10852 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10853 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10854
10855 /* Unmute Stereo Mixer 15 */
10856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10857 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10858 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
10860
10861 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10862 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10863 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10864 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10865 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10866 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10867 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10868 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10869 /* hp used DAC 3 (Front) */
10870 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10871 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10872 { }
10873};
10874
10875static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
10876 /*
10877 * Unmute ADC0 and set the default input to mic-in
10878 */
10879 /* port-A for surround (rear panel) */
10880 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10881 /* port-B for mic-in (rear panel) with vref */
10882 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10883 /* port-C for line-in (rear panel) */
10884 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10885 /* port-D for Front */
10886 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10887 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10888 /* port-E for HP out (front panel) */
10889 /* this has to be set to VREF80 */
10890 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10891 /* route front PCM to HP */
10892 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10893 /* port-F for mic-in (front panel) with vref */
10894 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10895 /* port-G for CLFE (rear panel) */
10896 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10897 /* port-H for side (rear panel) */
10898 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
10899 /* CD-in */
10900 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10901 /* route front mic to ADC1*/
10902 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10903 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10904 /* Unmute DAC0~3 & spdif out*/
10905 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10906 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10907 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10908 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10910
10911 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10912 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10913 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10914 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10915 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10916
10917 /* Unmute Stereo Mixer 15 */
10918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10919 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10921 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
10922
10923 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10924 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10925 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10926 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10929 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10930 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10931 /* hp used DAC 3 (Front) */
10932 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10934 { }
10935};
10936
10937static struct hda_verb alc861_asus_init_verbs[] = {
10938 /*
10939 * Unmute ADC0 and set the default input to mic-in
10940 */
10941 /* port-A for surround (rear panel)
10942 * according to codec#0 this is the HP jack
10943 */
10944 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
10945 /* route front PCM to HP */
10946 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
10947 /* port-B for mic-in (rear panel) with vref */
10948 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10949 /* port-C for line-in (rear panel) */
10950 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10951 /* port-D for Front */
10952 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10953 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
10954 /* port-E for HP out (front panel) */
10955 /* this has to be set to VREF80 */
10956 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10957 /* route front PCM to HP */
10958 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
10959 /* port-F for mic-in (front panel) with vref */
10960 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
10961 /* port-G for CLFE (rear panel) */
10962 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10963 /* port-H for side (rear panel) */
10964 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
10965 /* CD-in */
10966 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
10967 /* route front mic to ADC1*/
10968 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10969 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10970 /* Unmute DAC0~3 & spdif out*/
10971 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10972 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10973 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10974 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10975 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10976 /* Unmute Mixer 14 (mic) 1c (Line in)*/
10977 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10978 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10979 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10980 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10981
10982 /* Unmute Stereo Mixer 15 */
10983 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10985 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10986 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
10987
10988 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10989 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10990 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10991 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10992 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10993 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10994 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10995 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10996 /* hp used DAC 3 (Front) */
10997 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
10998 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
10999 { }
11000};
11001
11002/* additional init verbs for ASUS laptops */
11003static struct hda_verb alc861_asus_laptop_init_verbs[] = {
11004 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
11005 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
11006 { }
11007};
11008
11009/*
11010 * generic initialization of ADC, input mixers and output mixers
11011 */
11012static struct hda_verb alc861_auto_init_verbs[] = {
11013 /*
11014 * Unmute ADC0 and set the default input to mic-in
11015 */
11016 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
11017 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11018
11019 /* Unmute DAC0~3 & spdif out*/
11020 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11021 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11022 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11023 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11025
11026 /* Unmute Mixer 14 (mic) 1c (Line in)*/
11027 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11028 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11029 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11030 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11031
11032 /* Unmute Stereo Mixer 15 */
11033 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11034 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
11037
11038 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11039 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11040 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11041 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11042 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11043 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11044 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11045 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11046
11047 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11048 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11049 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11051 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11052 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11054 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
11055
11056 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
11057
11058 { }
11059};
11060
11061static struct hda_verb alc861_toshiba_init_verbs[] = {
11062 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11063
11064 { }
11065};
11066
11067/* toggle speaker-output according to the hp-jack state */
11068static void alc861_toshiba_automute(struct hda_codec *codec)
11069{
11070 unsigned int present;
11071
11072 present = snd_hda_codec_read(codec, 0x0f, 0,
11073 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11074 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
11075 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
11076 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
11077 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
11078}
11079
11080static void alc861_toshiba_unsol_event(struct hda_codec *codec,
11081 unsigned int res)
11082{
11083 if ((res >> 26) == ALC880_HP_EVENT)
11084 alc861_toshiba_automute(codec);
11085}
11086
11087/* pcm configuration: identiacal with ALC880 */
11088#define alc861_pcm_analog_playback alc880_pcm_analog_playback
11089#define alc861_pcm_analog_capture alc880_pcm_analog_capture
11090#define alc861_pcm_digital_playback alc880_pcm_digital_playback
11091#define alc861_pcm_digital_capture alc880_pcm_digital_capture
11092
11093
11094#define ALC861_DIGOUT_NID 0x07
11095
11096static struct hda_channel_mode alc861_8ch_modes[1] = {
11097 { 8, NULL }
11098};
11099
11100static hda_nid_t alc861_dac_nids[4] = {
11101 /* front, surround, clfe, side */
11102 0x03, 0x06, 0x05, 0x04
11103};
11104
11105static hda_nid_t alc660_dac_nids[3] = {
11106 /* front, clfe, surround */
11107 0x03, 0x05, 0x06
11108};
11109
11110static hda_nid_t alc861_adc_nids[1] = {
11111 /* ADC0-2 */
11112 0x08,
11113};
11114
11115static struct hda_input_mux alc861_capture_source = {
11116 .num_items = 5,
11117 .items = {
11118 { "Mic", 0x0 },
11119 { "Front Mic", 0x3 },
11120 { "Line", 0x1 },
11121 { "CD", 0x4 },
11122 { "Mixer", 0x5 },
11123 },
11124};
11125
11126/* fill in the dac_nids table from the parsed pin configuration */
11127static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
11128 const struct auto_pin_cfg *cfg)
11129{
11130 int i;
11131 hda_nid_t nid;
11132
11133 spec->multiout.dac_nids = spec->private_dac_nids;
11134 for (i = 0; i < cfg->line_outs; i++) {
11135 nid = cfg->line_out_pins[i];
11136 if (nid) {
11137 if (i >= ARRAY_SIZE(alc861_dac_nids))
11138 continue;
11139 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
11140 }
11141 }
11142 spec->multiout.num_dacs = cfg->line_outs;
11143 return 0;
11144}
11145
11146/* add playback controls from the parsed DAC table */
11147static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
11148 const struct auto_pin_cfg *cfg)
11149{
11150 char name[32];
11151 static const char *chname[4] = {
11152 "Front", "Surround", NULL /*CLFE*/, "Side"
11153 };
11154 hda_nid_t nid;
11155 int i, idx, err;
11156
11157 for (i = 0; i < cfg->line_outs; i++) {
11158 nid = spec->multiout.dac_nids[i];
11159 if (!nid)
11160 continue;
11161 if (nid == 0x05) {
11162 /* Center/LFE */
11163 err = add_control(spec, ALC_CTL_BIND_MUTE,
11164 "Center Playback Switch",
11165 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
11166 HDA_OUTPUT));
11167 if (err < 0)
11168 return err;
11169 err = add_control(spec, ALC_CTL_BIND_MUTE,
11170 "LFE Playback Switch",
11171 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11172 HDA_OUTPUT));
11173 if (err < 0)
11174 return err;
11175 } else {
11176 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
11177 idx++)
11178 if (nid == alc861_dac_nids[idx])
11179 break;
11180 sprintf(name, "%s Playback Switch", chname[idx]);
11181 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
11182 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11183 HDA_OUTPUT));
11184 if (err < 0)
11185 return err;
11186 }
11187 }
11188 return 0;
11189}
11190
11191static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
11192{
11193 int err;
11194 hda_nid_t nid;
11195
11196 if (!pin)
11197 return 0;
11198
11199 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
11200 nid = 0x03;
11201 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11202 "Headphone Playback Switch",
11203 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11204 if (err < 0)
11205 return err;
11206 spec->multiout.hp_nid = nid;
11207 }
11208 return 0;
11209}
11210
11211/* create playback/capture controls for input pins */
11212static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
11213 const struct auto_pin_cfg *cfg)
11214{
11215 struct hda_input_mux *imux = &spec->private_imux;
11216 int i, err, idx, idx1;
11217
11218 for (i = 0; i < AUTO_PIN_LAST; i++) {
11219 switch (cfg->input_pins[i]) {
11220 case 0x0c:
11221 idx1 = 1;
11222 idx = 2; /* Line In */
11223 break;
11224 case 0x0f:
11225 idx1 = 2;
11226 idx = 2; /* Line In */
11227 break;
11228 case 0x0d:
11229 idx1 = 0;
11230 idx = 1; /* Mic In */
11231 break;
11232 case 0x10:
11233 idx1 = 3;
11234 idx = 1; /* Mic In */
11235 break;
11236 case 0x11:
11237 idx1 = 4;
11238 idx = 0; /* CD */
11239 break;
11240 default:
11241 continue;
11242 }
11243
11244 err = new_analog_input(spec, cfg->input_pins[i],
11245 auto_pin_cfg_labels[i], idx, 0x15);
11246 if (err < 0)
11247 return err;
11248
11249 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11250 imux->items[imux->num_items].index = idx1;
11251 imux->num_items++;
11252 }
11253 return 0;
11254}
11255
11256static struct snd_kcontrol_new alc861_capture_mixer[] = {
11257 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11258 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11259
11260 {
11261 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11262 /* The multiple "Capture Source" controls confuse alsamixer
11263 * So call somewhat different..
11264 */
11265 /* .name = "Capture Source", */
11266 .name = "Input Source",
11267 .count = 1,
11268 .info = alc_mux_enum_info,
11269 .get = alc_mux_enum_get,
11270 .put = alc_mux_enum_put,
11271 },
11272 { } /* end */
11273};
11274
11275static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11276 hda_nid_t nid,
11277 int pin_type, int dac_idx)
11278{
11279 /* set as output */
11280
11281 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11282 pin_type);
11283 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11284 AMP_OUT_UNMUTE);
11285
11286}
11287
11288static void alc861_auto_init_multi_out(struct hda_codec *codec)
11289{
11290 struct alc_spec *spec = codec->spec;
11291 int i;
11292
11293 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
11294 for (i = 0; i < spec->autocfg.line_outs; i++) {
11295 hda_nid_t nid = spec->autocfg.line_out_pins[i];
11296 int pin_type = get_pin_type(spec->autocfg.line_out_type);
11297 if (nid)
11298 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
11299 spec->multiout.dac_nids[i]);
11300 }
11301}
11302
11303static void alc861_auto_init_hp_out(struct hda_codec *codec)
11304{
11305 struct alc_spec *spec = codec->spec;
11306 hda_nid_t pin;
11307
11308 pin = spec->autocfg.hp_pins[0];
11309 if (pin) /* connect to front */
11310 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
11311 spec->multiout.dac_nids[0]);
11312}
11313
11314static void alc861_auto_init_analog_input(struct hda_codec *codec)
11315{
11316 struct alc_spec *spec = codec->spec;
11317 int i;
11318
11319 for (i = 0; i < AUTO_PIN_LAST; i++) {
11320 hda_nid_t nid = spec->autocfg.input_pins[i];
11321 if (nid >= 0x0c && nid <= 0x11) {
11322 snd_hda_codec_write(codec, nid, 0,
11323 AC_VERB_SET_PIN_WIDGET_CONTROL,
11324 i <= AUTO_PIN_FRONT_MIC ?
11325 PIN_VREF80 : PIN_IN);
11326 }
11327 }
11328}
11329
11330/* parse the BIOS configuration and set up the alc_spec */
11331/* return 1 if successful, 0 if the proper config is not found,
11332 * or a negative error code
11333 */
11334static int alc861_parse_auto_config(struct hda_codec *codec)
11335{
11336 struct alc_spec *spec = codec->spec;
11337 int err;
11338 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
11339
11340 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11341 alc861_ignore);
11342 if (err < 0)
11343 return err;
11344 if (!spec->autocfg.line_outs)
11345 return 0; /* can't find valid BIOS pin config */
11346
11347 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
11348 if (err < 0)
11349 return err;
11350 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
11351 if (err < 0)
11352 return err;
11353 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
11354 if (err < 0)
11355 return err;
11356 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
11357 if (err < 0)
11358 return err;
11359
11360 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11361
11362 if (spec->autocfg.dig_out_pin)
11363 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
11364
11365 if (spec->kctl_alloc)
11366 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11367
11368 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
11369
11370 spec->num_mux_defs = 1;
11371 spec->input_mux = &spec->private_imux;
11372
11373 spec->adc_nids = alc861_adc_nids;
11374 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
11375 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
11376 spec->num_mixers++;
11377
11378 return 1;
11379}
11380
11381/* additional initialization for auto-configuration model */
11382static void alc861_auto_init(struct hda_codec *codec)
11383{
11384 alc861_auto_init_multi_out(codec);
11385 alc861_auto_init_hp_out(codec);
11386 alc861_auto_init_analog_input(codec);
11387}
11388
11389#ifdef CONFIG_SND_HDA_POWER_SAVE
11390static struct hda_amp_list alc861_loopbacks[] = {
11391 { 0x15, HDA_INPUT, 0 },
11392 { 0x15, HDA_INPUT, 1 },
11393 { 0x15, HDA_INPUT, 2 },
11394 { 0x15, HDA_INPUT, 3 },
11395 { } /* end */
11396};
11397#endif
11398
11399
11400/*
11401 * configuration and preset
11402 */
11403static const char *alc861_models[ALC861_MODEL_LAST] = {
11404 [ALC861_3ST] = "3stack",
11405 [ALC660_3ST] = "3stack-660",
11406 [ALC861_3ST_DIG] = "3stack-dig",
11407 [ALC861_6ST_DIG] = "6stack-dig",
11408 [ALC861_UNIWILL_M31] = "uniwill-m31",
11409 [ALC861_TOSHIBA] = "toshiba",
11410 [ALC861_ASUS] = "asus",
11411 [ALC861_ASUS_LAPTOP] = "asus-laptop",
11412 [ALC861_AUTO] = "auto",
11413};
11414
11415static struct snd_pci_quirk alc861_cfg_tbl[] = {
11416 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
11417 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11418 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
11419 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
11420 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
11421 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
11422 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
11423 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
11424 * Any other models that need this preset?
11425 */
11426 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
11427 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
11428 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
11429 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
11430 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
11431 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
11432 /* FIXME: the below seems conflict */
11433 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
11434 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
11435 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
11436 {}
11437};
11438
11439static struct alc_config_preset alc861_presets[] = {
11440 [ALC861_3ST] = {
11441 .mixers = { alc861_3ST_mixer },
11442 .init_verbs = { alc861_threestack_init_verbs },
11443 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11444 .dac_nids = alc861_dac_nids,
11445 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11446 .channel_mode = alc861_threestack_modes,
11447 .need_dac_fix = 1,
11448 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11449 .adc_nids = alc861_adc_nids,
11450 .input_mux = &alc861_capture_source,
11451 },
11452 [ALC861_3ST_DIG] = {
11453 .mixers = { alc861_base_mixer },
11454 .init_verbs = { alc861_threestack_init_verbs },
11455 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11456 .dac_nids = alc861_dac_nids,
11457 .dig_out_nid = ALC861_DIGOUT_NID,
11458 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11459 .channel_mode = alc861_threestack_modes,
11460 .need_dac_fix = 1,
11461 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11462 .adc_nids = alc861_adc_nids,
11463 .input_mux = &alc861_capture_source,
11464 },
11465 [ALC861_6ST_DIG] = {
11466 .mixers = { alc861_base_mixer },
11467 .init_verbs = { alc861_base_init_verbs },
11468 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11469 .dac_nids = alc861_dac_nids,
11470 .dig_out_nid = ALC861_DIGOUT_NID,
11471 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
11472 .channel_mode = alc861_8ch_modes,
11473 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11474 .adc_nids = alc861_adc_nids,
11475 .input_mux = &alc861_capture_source,
11476 },
11477 [ALC660_3ST] = {
11478 .mixers = { alc861_3ST_mixer },
11479 .init_verbs = { alc861_threestack_init_verbs },
11480 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
11481 .dac_nids = alc660_dac_nids,
11482 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
11483 .channel_mode = alc861_threestack_modes,
11484 .need_dac_fix = 1,
11485 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11486 .adc_nids = alc861_adc_nids,
11487 .input_mux = &alc861_capture_source,
11488 },
11489 [ALC861_UNIWILL_M31] = {
11490 .mixers = { alc861_uniwill_m31_mixer },
11491 .init_verbs = { alc861_uniwill_m31_init_verbs },
11492 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11493 .dac_nids = alc861_dac_nids,
11494 .dig_out_nid = ALC861_DIGOUT_NID,
11495 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
11496 .channel_mode = alc861_uniwill_m31_modes,
11497 .need_dac_fix = 1,
11498 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11499 .adc_nids = alc861_adc_nids,
11500 .input_mux = &alc861_capture_source,
11501 },
11502 [ALC861_TOSHIBA] = {
11503 .mixers = { alc861_toshiba_mixer },
11504 .init_verbs = { alc861_base_init_verbs,
11505 alc861_toshiba_init_verbs },
11506 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11507 .dac_nids = alc861_dac_nids,
11508 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11509 .channel_mode = alc883_3ST_2ch_modes,
11510 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11511 .adc_nids = alc861_adc_nids,
11512 .input_mux = &alc861_capture_source,
11513 .unsol_event = alc861_toshiba_unsol_event,
11514 .init_hook = alc861_toshiba_automute,
11515 },
11516 [ALC861_ASUS] = {
11517 .mixers = { alc861_asus_mixer },
11518 .init_verbs = { alc861_asus_init_verbs },
11519 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11520 .dac_nids = alc861_dac_nids,
11521 .dig_out_nid = ALC861_DIGOUT_NID,
11522 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
11523 .channel_mode = alc861_asus_modes,
11524 .need_dac_fix = 1,
11525 .hp_nid = 0x06,
11526 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11527 .adc_nids = alc861_adc_nids,
11528 .input_mux = &alc861_capture_source,
11529 },
11530 [ALC861_ASUS_LAPTOP] = {
11531 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
11532 .init_verbs = { alc861_asus_init_verbs,
11533 alc861_asus_laptop_init_verbs },
11534 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
11535 .dac_nids = alc861_dac_nids,
11536 .dig_out_nid = ALC861_DIGOUT_NID,
11537 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
11538 .channel_mode = alc883_3ST_2ch_modes,
11539 .need_dac_fix = 1,
11540 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
11541 .adc_nids = alc861_adc_nids,
11542 .input_mux = &alc861_capture_source,
11543 },
11544};
11545
11546
11547static int patch_alc861(struct hda_codec *codec)
11548{
11549 struct alc_spec *spec;
11550 int board_config;
11551 int err;
11552
11553 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11554 if (spec == NULL)
11555 return -ENOMEM;
11556
11557 codec->spec = spec;
11558
11559 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
11560 alc861_models,
11561 alc861_cfg_tbl);
11562
11563 if (board_config < 0) {
11564 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
11565 "trying auto-probe from BIOS...\n");
11566 board_config = ALC861_AUTO;
11567 }
11568
11569 if (board_config == ALC861_AUTO) {
11570 /* automatic parse from the BIOS config */
11571 err = alc861_parse_auto_config(codec);
11572 if (err < 0) {
11573 alc_free(codec);
11574 return err;
11575 } else if (!err) {
11576 printk(KERN_INFO
11577 "hda_codec: Cannot set up configuration "
11578 "from BIOS. Using base mode...\n");
11579 board_config = ALC861_3ST_DIG;
11580 }
11581 }
11582
11583 if (board_config != ALC861_AUTO)
11584 setup_preset(spec, &alc861_presets[board_config]);
11585
11586 spec->stream_name_analog = "ALC861 Analog";
11587 spec->stream_analog_playback = &alc861_pcm_analog_playback;
11588 spec->stream_analog_capture = &alc861_pcm_analog_capture;
11589
11590 spec->stream_name_digital = "ALC861 Digital";
11591 spec->stream_digital_playback = &alc861_pcm_digital_playback;
11592 spec->stream_digital_capture = &alc861_pcm_digital_capture;
11593
11594 spec->vmaster_nid = 0x03;
11595
11596 codec->patch_ops = alc_patch_ops;
11597 if (board_config == ALC861_AUTO)
11598 spec->init_hook = alc861_auto_init;
11599#ifdef CONFIG_SND_HDA_POWER_SAVE
11600 if (!spec->loopback.amplist)
11601 spec->loopback.amplist = alc861_loopbacks;
11602#endif
11603
11604 return 0;
11605}
11606
11607/*
11608 * ALC861-VD support
11609 *
11610 * Based on ALC882
11611 *
11612 * In addition, an independent DAC
11613 */
11614#define ALC861VD_DIGOUT_NID 0x06
11615
11616static hda_nid_t alc861vd_dac_nids[4] = {
11617 /* front, surr, clfe, side surr */
11618 0x02, 0x03, 0x04, 0x05
11619};
11620
11621/* dac_nids for ALC660vd are in a different order - according to
11622 * Realtek's driver.
11623 * This should probably tesult in a different mixer for 6stack models
11624 * of ALC660vd codecs, but for now there is only 3stack mixer
11625 * - and it is the same as in 861vd.
11626 * adc_nids in ALC660vd are (is) the same as in 861vd
11627 */
11628static hda_nid_t alc660vd_dac_nids[3] = {
11629 /* front, rear, clfe, rear_surr */
11630 0x02, 0x04, 0x03
11631};
11632
11633static hda_nid_t alc861vd_adc_nids[1] = {
11634 /* ADC0 */
11635 0x09,
11636};
11637
11638/* input MUX */
11639/* FIXME: should be a matrix-type input source selection */
11640static struct hda_input_mux alc861vd_capture_source = {
11641 .num_items = 4,
11642 .items = {
11643 { "Mic", 0x0 },
11644 { "Front Mic", 0x1 },
11645 { "Line", 0x2 },
11646 { "CD", 0x4 },
11647 },
11648};
11649
11650static struct hda_input_mux alc861vd_dallas_capture_source = {
11651 .num_items = 3,
11652 .items = {
11653 { "Front Mic", 0x0 },
11654 { "ATAPI Mic", 0x1 },
11655 { "Line In", 0x5 },
11656 },
11657};
11658
11659static struct hda_input_mux alc861vd_hp_capture_source = {
11660 .num_items = 2,
11661 .items = {
11662 { "Front Mic", 0x0 },
11663 { "ATAPI Mic", 0x1 },
11664 },
11665};
11666
11667#define alc861vd_mux_enum_info alc_mux_enum_info
11668#define alc861vd_mux_enum_get alc_mux_enum_get
11669
11670static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
11671 struct snd_ctl_elem_value *ucontrol)
11672{
11673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11674 struct alc_spec *spec = codec->spec;
11675 const struct hda_input_mux *imux = spec->input_mux;
11676 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
11677 static hda_nid_t capture_mixers[1] = { 0x22 };
11678 hda_nid_t nid = capture_mixers[adc_idx];
11679 unsigned int *cur_val = &spec->cur_mux[adc_idx];
11680 unsigned int i, idx;
11681
11682 idx = ucontrol->value.enumerated.item[0];
11683 if (idx >= imux->num_items)
11684 idx = imux->num_items - 1;
11685 if (*cur_val == idx)
11686 return 0;
11687 for (i = 0; i < imux->num_items; i++) {
11688 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
11689 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
11690 imux->items[i].index,
11691 HDA_AMP_MUTE, v);
11692 }
11693 *cur_val = idx;
11694 return 1;
11695}
11696
11697/*
11698 * 2ch mode
11699 */
11700static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
11701 { 2, NULL }
11702};
11703
11704/*
11705 * 6ch mode
11706 */
11707static struct hda_verb alc861vd_6stack_ch6_init[] = {
11708 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
11709 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11710 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11711 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11712 { } /* end */
11713};
11714
11715/*
11716 * 8ch mode
11717 */
11718static struct hda_verb alc861vd_6stack_ch8_init[] = {
11719 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11720 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11721 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11722 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11723 { } /* end */
11724};
11725
11726static struct hda_channel_mode alc861vd_6stack_modes[2] = {
11727 { 6, alc861vd_6stack_ch6_init },
11728 { 8, alc861vd_6stack_ch8_init },
11729};
11730
11731static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
11732 {
11733 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11734 .name = "Channel Mode",
11735 .info = alc_ch_mode_info,
11736 .get = alc_ch_mode_get,
11737 .put = alc_ch_mode_put,
11738 },
11739 { } /* end */
11740};
11741
11742static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
11743 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
11744 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
11745
11746 {
11747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11748 /* The multiple "Capture Source" controls confuse alsamixer
11749 * So call somewhat different..
11750 */
11751 /* .name = "Capture Source", */
11752 .name = "Input Source",
11753 .count = 1,
11754 .info = alc861vd_mux_enum_info,
11755 .get = alc861vd_mux_enum_get,
11756 .put = alc861vd_mux_enum_put,
11757 },
11758 { } /* end */
11759};
11760
11761/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
11762 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
11763 */
11764static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
11765 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11766 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11767
11768 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11769 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
11770
11771 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
11772 HDA_OUTPUT),
11773 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
11774 HDA_OUTPUT),
11775 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11776 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
11777
11778 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
11779 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
11780
11781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11782
11783 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11785 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11786
11787 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11788 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11789 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11790
11791 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11792 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11793
11794 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11795 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11796
11797 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11798 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11799
11800 { } /* end */
11801};
11802
11803static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
11804 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11805 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11806
11807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11808
11809 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11811 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11812
11813 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11814 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11815 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11816
11817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11819
11820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11822
11823 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
11824 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
11825
11826 { } /* end */
11827};
11828
11829static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
11830 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11831 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
11832 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11833
11834 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11835
11836 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11838 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11839
11840 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11841 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11842 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11843
11844 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11845 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11846
11847 { } /* end */
11848};
11849
11850/* Pin assignment: Front=0x14, HP = 0x15,
11851 * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
11852 */
11853static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
11854 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11855 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11856 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11857 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11858 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11859 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11860 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11861 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11862 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
11863 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
11864 { } /* end */
11865};
11866
11867/* Pin assignment: Speaker=0x14, Line-out = 0x15,
11868 * Front Mic=0x18, ATAPI Mic = 0x19,
11869 */
11870static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
11871 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11872 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
11873 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11874 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
11875 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11876 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11877 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11878 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11879
11880 { } /* end */
11881};
11882
11883/*
11884 * generic initialization of ADC, input mixers and output mixers
11885 */
11886static struct hda_verb alc861vd_volume_init_verbs[] = {
11887 /*
11888 * Unmute ADC0 and set the default input to mic-in
11889 */
11890 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11891 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11892
11893 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
11894 * the analog-loopback mixer widget
11895 */
11896 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11902
11903 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
11904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
11907 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
11908
11909 /*
11910 * Set up output mixers (0x02 - 0x05)
11911 */
11912 /* set vol=0 to output mixers */
11913 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11914 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11915 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11916 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11917
11918 /* set up input amps for analog loopback */
11919 /* Amp Indices: DAC = 0, mixer = 1 */
11920 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11922 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11923 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11926 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11927 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11928
11929 { }
11930};
11931
11932/*
11933 * 3-stack pin configuration:
11934 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
11935 */
11936static struct hda_verb alc861vd_3stack_init_verbs[] = {
11937 /*
11938 * Set pin mode and muting
11939 */
11940 /* set front pin widgets 0x14 for output */
11941 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11942 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11943 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11944
11945 /* Mic (rear) pin: input vref at 80% */
11946 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11947 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11948 /* Front Mic pin: input vref at 80% */
11949 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11950 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11951 /* Line In pin: input */
11952 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11953 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11954 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11955 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11956 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11957 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11958 /* CD pin widget for input */
11959 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11960
11961 { }
11962};
11963
11964/*
11965 * 6-stack pin configuration:
11966 */
11967static struct hda_verb alc861vd_6stack_init_verbs[] = {
11968 /*
11969 * Set pin mode and muting
11970 */
11971 /* set front pin widgets 0x14 for output */
11972 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11973 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11974 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11975
11976 /* Rear Pin: output 1 (0x0d) */
11977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11978 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11979 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11980 /* CLFE Pin: output 2 (0x0e) */
11981 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11982 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11983 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
11984 /* Side Pin: output 3 (0x0f) */
11985 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11986 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11987 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
11988
11989 /* Mic (rear) pin: input vref at 80% */
11990 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11991 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11992 /* Front Mic pin: input vref at 80% */
11993 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11994 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11995 /* Line In pin: input */
11996 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11997 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11998 /* Line-2 In: Headphone output (output 0 - 0x0c) */
11999 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12000 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12001 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12002 /* CD pin widget for input */
12003 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12004
12005 { }
12006};
12007
12008static struct hda_verb alc861vd_eapd_verbs[] = {
12009 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12010 { }
12011};
12012
12013static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
12014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12015 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12016 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12017 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12018 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12019 {}
12020};
12021
12022/* toggle speaker-output according to the hp-jack state */
12023static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
12024{
12025 unsigned int present;
12026 unsigned char bits;
12027
12028 present = snd_hda_codec_read(codec, 0x1b, 0,
12029 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12030 bits = present ? HDA_AMP_MUTE : 0;
12031 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12032 HDA_AMP_MUTE, bits);
12033}
12034
12035static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
12036{
12037 unsigned int present;
12038 unsigned char bits;
12039
12040 present = snd_hda_codec_read(codec, 0x18, 0,
12041 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12042 bits = present ? HDA_AMP_MUTE : 0;
12043 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
12044 HDA_AMP_MUTE, bits);
12045}
12046
12047static void alc861vd_lenovo_automute(struct hda_codec *codec)
12048{
12049 alc861vd_lenovo_hp_automute(codec);
12050 alc861vd_lenovo_mic_automute(codec);
12051}
12052
12053static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
12054 unsigned int res)
12055{
12056 switch (res >> 26) {
12057 case ALC880_HP_EVENT:
12058 alc861vd_lenovo_hp_automute(codec);
12059 break;
12060 case ALC880_MIC_EVENT:
12061 alc861vd_lenovo_mic_automute(codec);
12062 break;
12063 }
12064}
12065
12066static struct hda_verb alc861vd_dallas_verbs[] = {
12067 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12068 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12069 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12070 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12071
12072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12075 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12077 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12078 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12079 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12080
12081 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12082 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12084 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12085 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12086 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12087 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12088 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12089
12090 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12092 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
12093 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12094 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12095 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12096 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12097 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12098
12099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12103
12104 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12105 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12106 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12107
12108 { } /* end */
12109};
12110
12111/* toggle speaker-output according to the hp-jack state */
12112static void alc861vd_dallas_automute(struct hda_codec *codec)
12113{
12114 unsigned int present;
12115
12116 present = snd_hda_codec_read(codec, 0x15, 0,
12117 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12118 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12119 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12120}
12121
12122static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
12123{
12124 if ((res >> 26) == ALC880_HP_EVENT)
12125 alc861vd_dallas_automute(codec);
12126}
12127
12128#ifdef CONFIG_SND_HDA_POWER_SAVE
12129#define alc861vd_loopbacks alc880_loopbacks
12130#endif
12131
12132/* pcm configuration: identiacal with ALC880 */
12133#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
12134#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
12135#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
12136#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
12137
12138/*
12139 * configuration and preset
12140 */
12141static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
12142 [ALC660VD_3ST] = "3stack-660",
12143 [ALC660VD_3ST_DIG] = "3stack-660-digout",
12144 [ALC861VD_3ST] = "3stack",
12145 [ALC861VD_3ST_DIG] = "3stack-digout",
12146 [ALC861VD_6ST_DIG] = "6stack-digout",
12147 [ALC861VD_LENOVO] = "lenovo",
12148 [ALC861VD_DALLAS] = "dallas",
12149 [ALC861VD_HP] = "hp",
12150 [ALC861VD_AUTO] = "auto",
12151};
12152
12153static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
12154 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
12155 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
12156 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
12157 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
12158 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
12159 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
12160 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
12161 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
12162 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
12163 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
12164 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
12165 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
12166 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
12167 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
12168 {}
12169};
12170
12171static struct alc_config_preset alc861vd_presets[] = {
12172 [ALC660VD_3ST] = {
12173 .mixers = { alc861vd_3st_mixer },
12174 .init_verbs = { alc861vd_volume_init_verbs,
12175 alc861vd_3stack_init_verbs },
12176 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12177 .dac_nids = alc660vd_dac_nids,
12178 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12179 .adc_nids = alc861vd_adc_nids,
12180 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12181 .channel_mode = alc861vd_3stack_2ch_modes,
12182 .input_mux = &alc861vd_capture_source,
12183 },
12184 [ALC660VD_3ST_DIG] = {
12185 .mixers = { alc861vd_3st_mixer },
12186 .init_verbs = { alc861vd_volume_init_verbs,
12187 alc861vd_3stack_init_verbs },
12188 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12189 .dac_nids = alc660vd_dac_nids,
12190 .dig_out_nid = ALC861VD_DIGOUT_NID,
12191 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12192 .adc_nids = alc861vd_adc_nids,
12193 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12194 .channel_mode = alc861vd_3stack_2ch_modes,
12195 .input_mux = &alc861vd_capture_source,
12196 },
12197 [ALC861VD_3ST] = {
12198 .mixers = { alc861vd_3st_mixer },
12199 .init_verbs = { alc861vd_volume_init_verbs,
12200 alc861vd_3stack_init_verbs },
12201 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12202 .dac_nids = alc861vd_dac_nids,
12203 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12204 .channel_mode = alc861vd_3stack_2ch_modes,
12205 .input_mux = &alc861vd_capture_source,
12206 },
12207 [ALC861VD_3ST_DIG] = {
12208 .mixers = { alc861vd_3st_mixer },
12209 .init_verbs = { alc861vd_volume_init_verbs,
12210 alc861vd_3stack_init_verbs },
12211 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12212 .dac_nids = alc861vd_dac_nids,
12213 .dig_out_nid = ALC861VD_DIGOUT_NID,
12214 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12215 .channel_mode = alc861vd_3stack_2ch_modes,
12216 .input_mux = &alc861vd_capture_source,
12217 },
12218 [ALC861VD_6ST_DIG] = {
12219 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
12220 .init_verbs = { alc861vd_volume_init_verbs,
12221 alc861vd_6stack_init_verbs },
12222 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12223 .dac_nids = alc861vd_dac_nids,
12224 .dig_out_nid = ALC861VD_DIGOUT_NID,
12225 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
12226 .channel_mode = alc861vd_6stack_modes,
12227 .input_mux = &alc861vd_capture_source,
12228 },
12229 [ALC861VD_LENOVO] = {
12230 .mixers = { alc861vd_lenovo_mixer },
12231 .init_verbs = { alc861vd_volume_init_verbs,
12232 alc861vd_3stack_init_verbs,
12233 alc861vd_eapd_verbs,
12234 alc861vd_lenovo_unsol_verbs },
12235 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
12236 .dac_nids = alc660vd_dac_nids,
12237 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12238 .adc_nids = alc861vd_adc_nids,
12239 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12240 .channel_mode = alc861vd_3stack_2ch_modes,
12241 .input_mux = &alc861vd_capture_source,
12242 .unsol_event = alc861vd_lenovo_unsol_event,
12243 .init_hook = alc861vd_lenovo_automute,
12244 },
12245 [ALC861VD_DALLAS] = {
12246 .mixers = { alc861vd_dallas_mixer },
12247 .init_verbs = { alc861vd_dallas_verbs },
12248 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12249 .dac_nids = alc861vd_dac_nids,
12250 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12251 .adc_nids = alc861vd_adc_nids,
12252 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12253 .channel_mode = alc861vd_3stack_2ch_modes,
12254 .input_mux = &alc861vd_dallas_capture_source,
12255 .unsol_event = alc861vd_dallas_unsol_event,
12256 .init_hook = alc861vd_dallas_automute,
12257 },
12258 [ALC861VD_HP] = {
12259 .mixers = { alc861vd_hp_mixer },
12260 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
12261 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
12262 .dac_nids = alc861vd_dac_nids,
12263 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
12264 .dig_out_nid = ALC861VD_DIGOUT_NID,
12265 .adc_nids = alc861vd_adc_nids,
12266 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
12267 .channel_mode = alc861vd_3stack_2ch_modes,
12268 .input_mux = &alc861vd_hp_capture_source,
12269 .unsol_event = alc861vd_dallas_unsol_event,
12270 .init_hook = alc861vd_dallas_automute,
12271 },
12272};
12273
12274/*
12275 * BIOS auto configuration
12276 */
12277static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
12278 hda_nid_t nid, int pin_type, int dac_idx)
12279{
12280 /* set as output */
12281 snd_hda_codec_write(codec, nid, 0,
12282 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
12283 snd_hda_codec_write(codec, nid, 0,
12284 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
12285}
12286
12287static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
12288{
12289 struct alc_spec *spec = codec->spec;
12290 int i;
12291
12292 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
12293 for (i = 0; i <= HDA_SIDE; i++) {
12294 hda_nid_t nid = spec->autocfg.line_out_pins[i];
12295 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12296 if (nid)
12297 alc861vd_auto_set_output_and_unmute(codec, nid,
12298 pin_type, i);
12299 }
12300}
12301
12302
12303static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
12304{
12305 struct alc_spec *spec = codec->spec;
12306 hda_nid_t pin;
12307
12308 pin = spec->autocfg.hp_pins[0];
12309 if (pin) /* connect to front and use dac 0 */
12310 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
12311}
12312
12313#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
12314#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
12315
12316static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
12317{
12318 struct alc_spec *spec = codec->spec;
12319 int i;
12320
12321 for (i = 0; i < AUTO_PIN_LAST; i++) {
12322 hda_nid_t nid = spec->autocfg.input_pins[i];
12323 if (alc861vd_is_input_pin(nid)) {
12324 snd_hda_codec_write(codec, nid, 0,
12325 AC_VERB_SET_PIN_WIDGET_CONTROL,
12326 i <= AUTO_PIN_FRONT_MIC ?
12327 PIN_VREF80 : PIN_IN);
12328 if (nid != ALC861VD_PIN_CD_NID)
12329 snd_hda_codec_write(codec, nid, 0,
12330 AC_VERB_SET_AMP_GAIN_MUTE,
12331 AMP_OUT_MUTE);
12332 }
12333 }
12334}
12335
12336#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
12337#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
12338
12339/* add playback controls from the parsed DAC table */
12340/* Based on ALC880 version. But ALC861VD has separate,
12341 * different NIDs for mute/unmute switch and volume control */
12342static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
12343 const struct auto_pin_cfg *cfg)
12344{
12345 char name[32];
12346 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
12347 hda_nid_t nid_v, nid_s;
12348 int i, err;
12349
12350 for (i = 0; i < cfg->line_outs; i++) {
12351 if (!spec->multiout.dac_nids[i])
12352 continue;
12353 nid_v = alc861vd_idx_to_mixer_vol(
12354 alc880_dac_to_idx(
12355 spec->multiout.dac_nids[i]));
12356 nid_s = alc861vd_idx_to_mixer_switch(
12357 alc880_dac_to_idx(
12358 spec->multiout.dac_nids[i]));
12359
12360 if (i == 2) {
12361 /* Center/LFE */
12362 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12363 "Center Playback Volume",
12364 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
12365 HDA_OUTPUT));
12366 if (err < 0)
12367 return err;
12368 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12369 "LFE Playback Volume",
12370 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
12371 HDA_OUTPUT));
12372 if (err < 0)
12373 return err;
12374 err = add_control(spec, ALC_CTL_BIND_MUTE,
12375 "Center Playback Switch",
12376 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
12377 HDA_INPUT));
12378 if (err < 0)
12379 return err;
12380 err = add_control(spec, ALC_CTL_BIND_MUTE,
12381 "LFE Playback Switch",
12382 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
12383 HDA_INPUT));
12384 if (err < 0)
12385 return err;
12386 } else {
12387 sprintf(name, "%s Playback Volume", chname[i]);
12388 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12389 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
12390 HDA_OUTPUT));
12391 if (err < 0)
12392 return err;
12393 sprintf(name, "%s Playback Switch", chname[i]);
12394 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12395 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
12396 HDA_INPUT));
12397 if (err < 0)
12398 return err;
12399 }
12400 }
12401 return 0;
12402}
12403
12404/* add playback controls for speaker and HP outputs */
12405/* Based on ALC880 version. But ALC861VD has separate,
12406 * different NIDs for mute/unmute switch and volume control */
12407static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
12408 hda_nid_t pin, const char *pfx)
12409{
12410 hda_nid_t nid_v, nid_s;
12411 int err;
12412 char name[32];
12413
12414 if (!pin)
12415 return 0;
12416
12417 if (alc880_is_fixed_pin(pin)) {
12418 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
12419 /* specify the DAC as the extra output */
12420 if (!spec->multiout.hp_nid)
12421 spec->multiout.hp_nid = nid_v;
12422 else
12423 spec->multiout.extra_out_nid[0] = nid_v;
12424 /* control HP volume/switch on the output mixer amp */
12425 nid_v = alc861vd_idx_to_mixer_vol(
12426 alc880_fixed_pin_idx(pin));
12427 nid_s = alc861vd_idx_to_mixer_switch(
12428 alc880_fixed_pin_idx(pin));
12429
12430 sprintf(name, "%s Playback Volume", pfx);
12431 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12432 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
12433 if (err < 0)
12434 return err;
12435 sprintf(name, "%s Playback Switch", pfx);
12436 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12437 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
12438 if (err < 0)
12439 return err;
12440 } else if (alc880_is_multi_pin(pin)) {
12441 /* set manual connection */
12442 /* we have only a switch on HP-out PIN */
12443 sprintf(name, "%s Playback Switch", pfx);
12444 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12445 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
12446 if (err < 0)
12447 return err;
12448 }
12449 return 0;
12450}
12451
12452/* parse the BIOS configuration and set up the alc_spec
12453 * return 1 if successful, 0 if the proper config is not found,
12454 * or a negative error code
12455 * Based on ALC880 version - had to change it to override
12456 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
12457static int alc861vd_parse_auto_config(struct hda_codec *codec)
12458{
12459 struct alc_spec *spec = codec->spec;
12460 int err;
12461 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
12462
12463 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12464 alc861vd_ignore);
12465 if (err < 0)
12466 return err;
12467 if (!spec->autocfg.line_outs)
12468 return 0; /* can't find valid BIOS pin config */
12469
12470 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
12471 if (err < 0)
12472 return err;
12473 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
12474 if (err < 0)
12475 return err;
12476 err = alc861vd_auto_create_extra_out(spec,
12477 spec->autocfg.speaker_pins[0],
12478 "Speaker");
12479 if (err < 0)
12480 return err;
12481 err = alc861vd_auto_create_extra_out(spec,
12482 spec->autocfg.hp_pins[0],
12483 "Headphone");
12484 if (err < 0)
12485 return err;
12486 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
12487 if (err < 0)
12488 return err;
12489
12490 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12491
12492 if (spec->autocfg.dig_out_pin)
12493 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
12494
12495 if (spec->kctl_alloc)
12496 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12497
12498 spec->init_verbs[spec->num_init_verbs++]
12499 = alc861vd_volume_init_verbs;
12500
12501 spec->num_mux_defs = 1;
12502 spec->input_mux = &spec->private_imux;
12503
12504 err = alc_auto_add_mic_boost(codec);
12505 if (err < 0)
12506 return err;
12507
12508 return 1;
12509}
12510
12511/* additional initialization for auto-configuration model */
12512static void alc861vd_auto_init(struct hda_codec *codec)
12513{
12514 alc861vd_auto_init_multi_out(codec);
12515 alc861vd_auto_init_hp_out(codec);
12516 alc861vd_auto_init_analog_input(codec);
12517}
12518
12519static int patch_alc861vd(struct hda_codec *codec)
12520{
12521 struct alc_spec *spec;
12522 int err, board_config;
12523
12524 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12525 if (spec == NULL)
12526 return -ENOMEM;
12527
12528 codec->spec = spec;
12529
12530 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
12531 alc861vd_models,
12532 alc861vd_cfg_tbl);
12533
12534 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
12535 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
12536 "ALC861VD, trying auto-probe from BIOS...\n");
12537 board_config = ALC861VD_AUTO;
12538 }
12539
12540 if (board_config == ALC861VD_AUTO) {
12541 /* automatic parse from the BIOS config */
12542 err = alc861vd_parse_auto_config(codec);
12543 if (err < 0) {
12544 alc_free(codec);
12545 return err;
12546 } else if (!err) {
12547 printk(KERN_INFO
12548 "hda_codec: Cannot set up configuration "
12549 "from BIOS. Using base mode...\n");
12550 board_config = ALC861VD_3ST;
12551 }
12552 }
12553
12554 if (board_config != ALC861VD_AUTO)
12555 setup_preset(spec, &alc861vd_presets[board_config]);
12556
12557 spec->stream_name_analog = "ALC861VD Analog";
12558 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
12559 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
12560
12561 spec->stream_name_digital = "ALC861VD Digital";
12562 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
12563 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
12564
12565 spec->adc_nids = alc861vd_adc_nids;
12566 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
12567
12568 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
12569 spec->num_mixers++;
12570
12571 spec->vmaster_nid = 0x02;
12572
12573 codec->patch_ops = alc_patch_ops;
12574
12575 if (board_config == ALC861VD_AUTO)
12576 spec->init_hook = alc861vd_auto_init;
12577#ifdef CONFIG_SND_HDA_POWER_SAVE
12578 if (!spec->loopback.amplist)
12579 spec->loopback.amplist = alc861vd_loopbacks;
12580#endif
12581
12582 return 0;
12583}
12584
12585/*
12586 * ALC662 support
12587 *
12588 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
12589 * configuration. Each pin widget can choose any input DACs and a mixer.
12590 * Each ADC is connected from a mixer of all inputs. This makes possible
12591 * 6-channel independent captures.
12592 *
12593 * In addition, an independent DAC for the multi-playback (not used in this
12594 * driver yet).
12595 */
12596#define ALC662_DIGOUT_NID 0x06
12597#define ALC662_DIGIN_NID 0x0a
12598
12599static hda_nid_t alc662_dac_nids[4] = {
12600 /* front, rear, clfe, rear_surr */
12601 0x02, 0x03, 0x04
12602};
12603
12604static hda_nid_t alc662_adc_nids[1] = {
12605 /* ADC1-2 */
12606 0x09,
12607};
12608/* input MUX */
12609/* FIXME: should be a matrix-type input source selection */
12610
12611static struct hda_input_mux alc662_capture_source = {
12612 .num_items = 4,
12613 .items = {
12614 { "Mic", 0x0 },
12615 { "Front Mic", 0x1 },
12616 { "Line", 0x2 },
12617 { "CD", 0x4 },
12618 },
12619};
12620
12621static struct hda_input_mux alc662_lenovo_101e_capture_source = {
12622 .num_items = 2,
12623 .items = {
12624 { "Mic", 0x1 },
12625 { "Line", 0x2 },
12626 },
12627};
12628
12629static struct hda_input_mux alc662_eeepc_capture_source = {
12630 .num_items = 2,
12631 .items = {
12632 { "i-Mic", 0x1 },
12633 { "e-Mic", 0x0 },
12634 },
12635};
12636
12637#define alc662_mux_enum_info alc_mux_enum_info
12638#define alc662_mux_enum_get alc_mux_enum_get
12639
12640static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
12641 struct snd_ctl_elem_value *ucontrol)
12642{
12643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12644 struct alc_spec *spec = codec->spec;
12645 const struct hda_input_mux *imux = spec->input_mux;
12646 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
12647 static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
12648 hda_nid_t nid = capture_mixers[adc_idx];
12649 unsigned int *cur_val = &spec->cur_mux[adc_idx];
12650 unsigned int i, idx;
12651
12652 idx = ucontrol->value.enumerated.item[0];
12653 if (idx >= imux->num_items)
12654 idx = imux->num_items - 1;
12655 if (*cur_val == idx)
12656 return 0;
12657 for (i = 0; i < imux->num_items; i++) {
12658 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
12659 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
12660 imux->items[i].index,
12661 HDA_AMP_MUTE, v);
12662 }
12663 *cur_val = idx;
12664 return 1;
12665}
12666/*
12667 * 2ch mode
12668 */
12669static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
12670 { 2, NULL }
12671};
12672
12673/*
12674 * 2ch mode
12675 */
12676static struct hda_verb alc662_3ST_ch2_init[] = {
12677 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
12678 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12679 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
12680 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
12681 { } /* end */
12682};
12683
12684/*
12685 * 6ch mode
12686 */
12687static struct hda_verb alc662_3ST_ch6_init[] = {
12688 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12689 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12690 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
12691 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12692 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12693 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
12694 { } /* end */
12695};
12696
12697static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
12698 { 2, alc662_3ST_ch2_init },
12699 { 6, alc662_3ST_ch6_init },
12700};
12701
12702/*
12703 * 2ch mode
12704 */
12705static struct hda_verb alc662_sixstack_ch6_init[] = {
12706 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12707 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12708 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12709 { } /* end */
12710};
12711
12712/*
12713 * 6ch mode
12714 */
12715static struct hda_verb alc662_sixstack_ch8_init[] = {
12716 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12717 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12718 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12719 { } /* end */
12720};
12721
12722static struct hda_channel_mode alc662_5stack_modes[2] = {
12723 { 2, alc662_sixstack_ch6_init },
12724 { 6, alc662_sixstack_ch8_init },
12725};
12726
12727/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
12728 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
12729 */
12730
12731static struct snd_kcontrol_new alc662_base_mixer[] = {
12732 /* output mixer control */
12733 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12734 HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
12735 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12736 HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12737 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12738 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12739 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12740 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12741 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12742
12743 /*Input mixer control */
12744 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
12745 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
12746 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
12747 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
12748 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
12749 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
12750 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
12751 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
12752 { } /* end */
12753};
12754
12755static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
12756 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12757 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12758 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12759 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12760 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12761 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12762 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12765 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12766 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12767 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12768 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12769 { } /* end */
12770};
12771
12772static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
12773 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12774 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12775 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12776 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12777 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12778 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12779 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12780 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12782 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
12783 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
12784 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12785 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12787 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12788 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12789 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12790 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
12791 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
12792 { } /* end */
12793};
12794
12795static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
12796 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12797 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
12798 HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12799 HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
12800 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12801 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12802 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12805 { } /* end */
12806};
12807
12808static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
12809 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12810
12811 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12812 HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12813
12814 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
12815 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12816 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12817
12818 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
12819 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
12820 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
12821 { } /* end */
12822};
12823
12824static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
12825 HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12826 HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12827 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12828 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
12829 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
12830 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
12831 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
12832 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
12833 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
12834 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
12835 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12836 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12838 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12839 { } /* end */
12840};
12841
12842static struct snd_kcontrol_new alc662_chmode_mixer[] = {
12843 {
12844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12845 .name = "Channel Mode",
12846 .info = alc_ch_mode_info,
12847 .get = alc_ch_mode_get,
12848 .put = alc_ch_mode_put,
12849 },
12850 { } /* end */
12851};
12852
12853static struct hda_verb alc662_init_verbs[] = {
12854 /* ADC: mute amp left and right */
12855 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12856 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12857 /* Front mixer: unmute input/output amp left and right (volume = 0) */
12858
12859 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12864
12865 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12866 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12867 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12868 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12869 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12870 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12871
12872 /* Front Pin: output 0 (0x0c) */
12873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12874 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12875
12876 /* Rear Pin: output 1 (0x0d) */
12877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12879
12880 /* CLFE Pin: output 2 (0x0e) */
12881 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12882 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12883
12884 /* Mic (rear) pin: input vref at 80% */
12885 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12886 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12887 /* Front Mic pin: input vref at 80% */
12888 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12889 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12890 /* Line In pin: input */
12891 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12892 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12893 /* Line-2 In: Headphone output (output 0 - 0x0c) */
12894 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12895 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12896 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12897 /* CD pin widget for input */
12898 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12899
12900 /* FIXME: use matrix-type input source selection */
12901 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12902 /* Input mixer */
12903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12906 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
12907
12908 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12909 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12910 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12911 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
12912 { }
12913};
12914
12915static struct hda_verb alc662_sue_init_verbs[] = {
12916 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
12917 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
12918 {}
12919};
12920
12921static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
12922 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12923 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12924 {}
12925};
12926
12927/* Set Unsolicited Event*/
12928static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
12929 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12930 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12931 {}
12932};
12933
12934/*
12935 * generic initialization of ADC, input mixers and output mixers
12936 */
12937static struct hda_verb alc662_auto_init_verbs[] = {
12938 /*
12939 * Unmute ADC and set the default input to mic-in
12940 */
12941 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12942 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12943
12944 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
12945 * mixer widget
12946 * Note: PASD motherboards uses the Line In 2 as the input for front
12947 * panel mic (mic 2)
12948 */
12949 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12952 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12953 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12954 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12955
12956 /*
12957 * Set up output mixers (0x0c - 0x0f)
12958 */
12959 /* set vol=0 to output mixers */
12960 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12961 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12962 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12963
12964 /* set up input amps for analog loopback */
12965 /* Amp Indices: DAC = 0, mixer = 1 */
12966 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12967 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12968 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12969 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12970 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12971 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12972
12973
12974 /* FIXME: use matrix-type input source selection */
12975 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12976 /* Input mixer */
12977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12978 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12979 { }
12980};
12981
12982/* capture mixer elements */
12983static struct snd_kcontrol_new alc662_capture_mixer[] = {
12984 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
12985 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
12986 {
12987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12988 /* The multiple "Capture Source" controls confuse alsamixer
12989 * So call somewhat different..
12990 */
12991 /* .name = "Capture Source", */
12992 .name = "Input Source",
12993 .count = 1,
12994 .info = alc662_mux_enum_info,
12995 .get = alc662_mux_enum_get,
12996 .put = alc662_mux_enum_put,
12997 },
12998 { } /* end */
12999};
13000
13001static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
13002{
13003 unsigned int present;
13004 unsigned char bits;
13005
13006 present = snd_hda_codec_read(codec, 0x14, 0,
13007 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13008 bits = present ? HDA_AMP_MUTE : 0;
13009 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13010 HDA_AMP_MUTE, bits);
13011}
13012
13013static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
13014{
13015 unsigned int present;
13016 unsigned char bits;
13017
13018 present = snd_hda_codec_read(codec, 0x1b, 0,
13019 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13020 bits = present ? HDA_AMP_MUTE : 0;
13021 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13022 HDA_AMP_MUTE, bits);
13023 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13024 HDA_AMP_MUTE, bits);
13025}
13026
13027static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
13028 unsigned int res)
13029{
13030 if ((res >> 26) == ALC880_HP_EVENT)
13031 alc662_lenovo_101e_all_automute(codec);
13032 if ((res >> 26) == ALC880_FRONT_EVENT)
13033 alc662_lenovo_101e_ispeaker_automute(codec);
13034}
13035
13036static void alc662_eeepc_mic_automute(struct hda_codec *codec)
13037{
13038 unsigned int present;
13039
13040 present = snd_hda_codec_read(codec, 0x18, 0,
13041 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13042 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13043 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13044 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13045 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13046 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13047 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13048 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13049 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13050}
13051
13052/* unsolicited event for HP jack sensing */
13053static void alc662_eeepc_unsol_event(struct hda_codec *codec,
13054 unsigned int res)
13055{
13056 if ((res >> 26) == ALC880_HP_EVENT)
13057 alc262_hippo1_automute( codec );
13058
13059 if ((res >> 26) == ALC880_MIC_EVENT)
13060 alc662_eeepc_mic_automute(codec);
13061}
13062
13063static void alc662_eeepc_inithook(struct hda_codec *codec)
13064{
13065 alc262_hippo1_automute( codec );
13066 alc662_eeepc_mic_automute(codec);
13067}
13068
13069static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
13070{
13071 unsigned int mute;
13072 unsigned int present;
13073
13074 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
13075 present = snd_hda_codec_read(codec, 0x14, 0,
13076 AC_VERB_GET_PIN_SENSE, 0);
13077 present = (present & 0x80000000) != 0;
13078 if (present) {
13079 /* mute internal speaker */
13080 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13081 HDA_AMP_MUTE, HDA_AMP_MUTE);
13082 } else {
13083 /* unmute internal speaker if necessary */
13084 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13085 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
13086 HDA_AMP_MUTE, mute);
13087 }
13088}
13089
13090/* unsolicited event for HP jack sensing */
13091static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
13092 unsigned int res)
13093{
13094 if ((res >> 26) == ALC880_HP_EVENT)
13095 alc662_eeepc_ep20_automute(codec);
13096}
13097
13098static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
13099{
13100 alc662_eeepc_ep20_automute(codec);
13101}
13102
13103#ifdef CONFIG_SND_HDA_POWER_SAVE
13104#define alc662_loopbacks alc880_loopbacks
13105#endif
13106
13107
13108/* pcm configuration: identiacal with ALC880 */
13109#define alc662_pcm_analog_playback alc880_pcm_analog_playback
13110#define alc662_pcm_analog_capture alc880_pcm_analog_capture
13111#define alc662_pcm_digital_playback alc880_pcm_digital_playback
13112#define alc662_pcm_digital_capture alc880_pcm_digital_capture
13113
13114/*
13115 * configuration and preset
13116 */
13117static const char *alc662_models[ALC662_MODEL_LAST] = {
13118 [ALC662_3ST_2ch_DIG] = "3stack-dig",
13119 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
13120 [ALC662_3ST_6ch] = "3stack-6ch",
13121 [ALC662_5ST_DIG] = "6stack-dig",
13122 [ALC662_LENOVO_101E] = "lenovo-101e",
13123 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
13124 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
13125 [ALC662_AUTO] = "auto",
13126};
13127
13128static struct snd_pci_quirk alc662_cfg_tbl[] = {
13129 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
13130 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
13131 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
13132 {}
13133};
13134
13135static struct alc_config_preset alc662_presets[] = {
13136 [ALC662_3ST_2ch_DIG] = {
13137 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
13138 .init_verbs = { alc662_init_verbs },
13139 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13140 .dac_nids = alc662_dac_nids,
13141 .dig_out_nid = ALC662_DIGOUT_NID,
13142 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13143 .adc_nids = alc662_adc_nids,
13144 .dig_in_nid = ALC662_DIGIN_NID,
13145 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13146 .channel_mode = alc662_3ST_2ch_modes,
13147 .input_mux = &alc662_capture_source,
13148 },
13149 [ALC662_3ST_6ch_DIG] = {
13150 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13151 alc662_capture_mixer },
13152 .init_verbs = { alc662_init_verbs },
13153 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13154 .dac_nids = alc662_dac_nids,
13155 .dig_out_nid = ALC662_DIGOUT_NID,
13156 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13157 .adc_nids = alc662_adc_nids,
13158 .dig_in_nid = ALC662_DIGIN_NID,
13159 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13160 .channel_mode = alc662_3ST_6ch_modes,
13161 .need_dac_fix = 1,
13162 .input_mux = &alc662_capture_source,
13163 },
13164 [ALC662_3ST_6ch] = {
13165 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
13166 alc662_capture_mixer },
13167 .init_verbs = { alc662_init_verbs },
13168 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13169 .dac_nids = alc662_dac_nids,
13170 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13171 .adc_nids = alc662_adc_nids,
13172 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13173 .channel_mode = alc662_3ST_6ch_modes,
13174 .need_dac_fix = 1,
13175 .input_mux = &alc662_capture_source,
13176 },
13177 [ALC662_5ST_DIG] = {
13178 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
13179 alc662_capture_mixer },
13180 .init_verbs = { alc662_init_verbs },
13181 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13182 .dac_nids = alc662_dac_nids,
13183 .dig_out_nid = ALC662_DIGOUT_NID,
13184 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13185 .adc_nids = alc662_adc_nids,
13186 .dig_in_nid = ALC662_DIGIN_NID,
13187 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
13188 .channel_mode = alc662_5stack_modes,
13189 .input_mux = &alc662_capture_source,
13190 },
13191 [ALC662_LENOVO_101E] = {
13192 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
13193 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
13194 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13195 .dac_nids = alc662_dac_nids,
13196 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13197 .adc_nids = alc662_adc_nids,
13198 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13199 .channel_mode = alc662_3ST_2ch_modes,
13200 .input_mux = &alc662_lenovo_101e_capture_source,
13201 .unsol_event = alc662_lenovo_101e_unsol_event,
13202 .init_hook = alc662_lenovo_101e_all_automute,
13203 },
13204 [ALC662_ASUS_EEEPC_P701] = {
13205 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
13206 .init_verbs = { alc662_init_verbs,
13207 alc662_eeepc_sue_init_verbs },
13208 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13209 .dac_nids = alc662_dac_nids,
13210 .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
13211 .adc_nids = alc662_adc_nids,
13212 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
13213 .channel_mode = alc662_3ST_2ch_modes,
13214 .input_mux = &alc662_eeepc_capture_source,
13215 .unsol_event = alc662_eeepc_unsol_event,
13216 .init_hook = alc662_eeepc_inithook,
13217 },
13218 [ALC662_ASUS_EEEPC_EP20] = {
13219 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
13220 alc662_chmode_mixer },
13221 .init_verbs = { alc662_init_verbs,
13222 alc662_eeepc_ep20_sue_init_verbs },
13223 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
13224 .dac_nids = alc662_dac_nids,
13225 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
13226 .adc_nids = alc662_adc_nids,
13227 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
13228 .channel_mode = alc662_3ST_6ch_modes,
13229 .input_mux = &alc662_lenovo_101e_capture_source,
13230 .unsol_event = alc662_eeepc_ep20_unsol_event,
13231 .init_hook = alc662_eeepc_ep20_inithook,
13232 },
13233
13234};
13235
13236
13237/*
13238 * BIOS auto configuration
13239 */
13240
13241/* add playback controls from the parsed DAC table */
13242static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
13243 const struct auto_pin_cfg *cfg)
13244{
13245 char name[32];
13246 static const char *chname[4] = {
13247 "Front", "Surround", NULL /*CLFE*/, "Side"
13248 };
13249 hda_nid_t nid;
13250 int i, err;
13251
13252 for (i = 0; i < cfg->line_outs; i++) {
13253 if (!spec->multiout.dac_nids[i])
13254 continue;
13255 nid = alc880_idx_to_dac(i);
13256 if (i == 2) {
13257 /* Center/LFE */
13258 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13259 "Center Playback Volume",
13260 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13261 HDA_OUTPUT));
13262 if (err < 0)
13263 return err;
13264 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13265 "LFE Playback Volume",
13266 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13267 HDA_OUTPUT));
13268 if (err < 0)
13269 return err;
13270 err = add_control(spec, ALC_CTL_BIND_MUTE,
13271 "Center Playback Switch",
13272 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
13273 HDA_INPUT));
13274 if (err < 0)
13275 return err;
13276 err = add_control(spec, ALC_CTL_BIND_MUTE,
13277 "LFE Playback Switch",
13278 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
13279 HDA_INPUT));
13280 if (err < 0)
13281 return err;
13282 } else {
13283 sprintf(name, "%s Playback Volume", chname[i]);
13284 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13285 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13286 HDA_OUTPUT));
13287 if (err < 0)
13288 return err;
13289 sprintf(name, "%s Playback Switch", chname[i]);
13290 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13291 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
13292 HDA_INPUT));
13293 if (err < 0)
13294 return err;
13295 }
13296 }
13297 return 0;
13298}
13299
13300/* add playback controls for speaker and HP outputs */
13301static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
13302 const char *pfx)
13303{
13304 hda_nid_t nid;
13305 int err;
13306 char name[32];
13307
13308 if (!pin)
13309 return 0;
13310
13311 if (alc880_is_fixed_pin(pin)) {
13312 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13313 /* printk("DAC nid=%x\n",nid); */
13314 /* specify the DAC as the extra output */
13315 if (!spec->multiout.hp_nid)
13316 spec->multiout.hp_nid = nid;
13317 else
13318 spec->multiout.extra_out_nid[0] = nid;
13319 /* control HP volume/switch on the output mixer amp */
13320 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13321 sprintf(name, "%s Playback Volume", pfx);
13322 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13323 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13324 if (err < 0)
13325 return err;
13326 sprintf(name, "%s Playback Switch", pfx);
13327 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13328 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
13329 if (err < 0)
13330 return err;
13331 } else if (alc880_is_multi_pin(pin)) {
13332 /* set manual connection */
13333 /* we have only a switch on HP-out PIN */
13334 sprintf(name, "%s Playback Switch", pfx);
13335 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13336 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13337 if (err < 0)
13338 return err;
13339 }
13340 return 0;
13341}
13342
13343/* create playback/capture controls for input pins */
13344static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
13345 const struct auto_pin_cfg *cfg)
13346{
13347 struct hda_input_mux *imux = &spec->private_imux;
13348 int i, err, idx;
13349
13350 for (i = 0; i < AUTO_PIN_LAST; i++) {
13351 if (alc880_is_input_pin(cfg->input_pins[i])) {
13352 idx = alc880_input_pin_idx(cfg->input_pins[i]);
13353 err = new_analog_input(spec, cfg->input_pins[i],
13354 auto_pin_cfg_labels[i],
13355 idx, 0x0b);
13356 if (err < 0)
13357 return err;
13358 imux->items[imux->num_items].label =
13359 auto_pin_cfg_labels[i];
13360 imux->items[imux->num_items].index =
13361 alc880_input_pin_idx(cfg->input_pins[i]);
13362 imux->num_items++;
13363 }
13364 }
13365 return 0;
13366}
13367
13368static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
13369 hda_nid_t nid, int pin_type,
13370 int dac_idx)
13371{
13372 /* set as output */
13373 snd_hda_codec_write(codec, nid, 0,
13374 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
13375 snd_hda_codec_write(codec, nid, 0,
13376 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
13377 /* need the manual connection? */
13378 if (alc880_is_multi_pin(nid)) {
13379 struct alc_spec *spec = codec->spec;
13380 int idx = alc880_multi_pin_idx(nid);
13381 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
13382 AC_VERB_SET_CONNECT_SEL,
13383 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
13384 }
13385}
13386
13387static void alc662_auto_init_multi_out(struct hda_codec *codec)
13388{
13389 struct alc_spec *spec = codec->spec;
13390 int i;
13391
13392 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
13393 for (i = 0; i <= HDA_SIDE; i++) {
13394 hda_nid_t nid = spec->autocfg.line_out_pins[i];
13395 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13396 if (nid)
13397 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
13398 i);
13399 }
13400}
13401
13402static void alc662_auto_init_hp_out(struct hda_codec *codec)
13403{
13404 struct alc_spec *spec = codec->spec;
13405 hda_nid_t pin;
13406
13407 pin = spec->autocfg.hp_pins[0];
13408 if (pin) /* connect to front */
13409 /* use dac 0 */
13410 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
13411}
13412
13413#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
13414#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
13415
13416static void alc662_auto_init_analog_input(struct hda_codec *codec)
13417{
13418 struct alc_spec *spec = codec->spec;
13419 int i;
13420
13421 for (i = 0; i < AUTO_PIN_LAST; i++) {
13422 hda_nid_t nid = spec->autocfg.input_pins[i];
13423 if (alc662_is_input_pin(nid)) {
13424 snd_hda_codec_write(codec, nid, 0,
13425 AC_VERB_SET_PIN_WIDGET_CONTROL,
13426 (i <= AUTO_PIN_FRONT_MIC ?
13427 PIN_VREF80 : PIN_IN));
13428 if (nid != ALC662_PIN_CD_NID)
13429 snd_hda_codec_write(codec, nid, 0,
13430 AC_VERB_SET_AMP_GAIN_MUTE,
13431 AMP_OUT_MUTE);
13432 }
13433 }
13434}
13435
13436static int alc662_parse_auto_config(struct hda_codec *codec)
13437{
13438 struct alc_spec *spec = codec->spec;
13439 int err;
13440 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
13441
13442 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13443 alc662_ignore);
13444 if (err < 0)
13445 return err;
13446 if (!spec->autocfg.line_outs)
13447 return 0; /* can't find valid BIOS pin config */
13448
13449 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13450 if (err < 0)
13451 return err;
13452 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
13453 if (err < 0)
13454 return err;
13455 err = alc662_auto_create_extra_out(spec,
13456 spec->autocfg.speaker_pins[0],
13457 "Speaker");
13458 if (err < 0)
13459 return err;
13460 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
13461 "Headphone");
13462 if (err < 0)
13463 return err;
13464 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
13465 if (err < 0)
13466 return err;
13467
13468 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13469
13470 if (spec->autocfg.dig_out_pin)
13471 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
13472
13473 if (spec->kctl_alloc)
13474 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
13475
13476 spec->num_mux_defs = 1;
13477 spec->input_mux = &spec->private_imux;
13478
13479 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
13480 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
13481 spec->num_mixers++;
13482 return 1;
13483}
13484
13485/* additional initialization for auto-configuration model */
13486static void alc662_auto_init(struct hda_codec *codec)
13487{
13488 alc662_auto_init_multi_out(codec);
13489 alc662_auto_init_hp_out(codec);
13490 alc662_auto_init_analog_input(codec);
13491}
13492
13493static int patch_alc662(struct hda_codec *codec)
13494{
13495 struct alc_spec *spec;
13496 int err, board_config;
13497
13498 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13499 if (!spec)
13500 return -ENOMEM;
13501
13502 codec->spec = spec;
13503
13504 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
13505 alc662_models,
13506 alc662_cfg_tbl);
13507 if (board_config < 0) {
13508 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
13509 "trying auto-probe from BIOS...\n");
13510 board_config = ALC662_AUTO;
13511 }
13512
13513 if (board_config == ALC662_AUTO) {
13514 /* automatic parse from the BIOS config */
13515 err = alc662_parse_auto_config(codec);
13516 if (err < 0) {
13517 alc_free(codec);
13518 return err;
13519 } else if (!err) {
13520 printk(KERN_INFO
13521 "hda_codec: Cannot set up configuration "
13522 "from BIOS. Using base mode...\n");
13523 board_config = ALC662_3ST_2ch_DIG;
13524 }
13525 }
13526
13527 if (board_config != ALC662_AUTO)
13528 setup_preset(spec, &alc662_presets[board_config]);
13529
13530 spec->stream_name_analog = "ALC662 Analog";
13531 spec->stream_analog_playback = &alc662_pcm_analog_playback;
13532 spec->stream_analog_capture = &alc662_pcm_analog_capture;
13533
13534 spec->stream_name_digital = "ALC662 Digital";
13535 spec->stream_digital_playback = &alc662_pcm_digital_playback;
13536 spec->stream_digital_capture = &alc662_pcm_digital_capture;
13537
13538 if (!spec->adc_nids && spec->input_mux) {
13539 spec->adc_nids = alc662_adc_nids;
13540 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
13541 }
13542
13543 spec->vmaster_nid = 0x02;
13544
13545 codec->patch_ops = alc_patch_ops;
13546 if (board_config == ALC662_AUTO)
13547 spec->init_hook = alc662_auto_init;
13548#ifdef CONFIG_SND_HDA_POWER_SAVE
13549 if (!spec->loopback.amplist)
13550 spec->loopback.amplist = alc662_loopbacks;
13551#endif
13552
13553 return 0;
13554}
13555
13556/*
13557 * patch entries
13558 */
13559struct hda_codec_preset snd_hda_preset_realtek[] = {
13560 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
13561 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
13562 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
13563 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
13564 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
13565 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
13566 .patch = patch_alc861 },
13567 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
13568 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
13569 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
13570 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
13571 .patch = patch_alc883 },
13572 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
13573 .patch = patch_alc662 },
13574 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
13575 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
13576 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
13577 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
13578 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
13579 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
13580 {} /* terminator */
13581};