at91: at91sam9g45 family: identify several chip versions
[linux-2.6/next.git] / sound / pci / hda / patch_realtek.c
blobff20048504b6484057e4a5464809c52773d7594e
1 /*
2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for ALC 260/880/882 codecs
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>
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.
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.
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
26 #include <linux/init.h>
27 #include <linux/delay.h>
28 #include <linux/slab.h>
29 #include <linux/pci.h>
30 #include <sound/core.h>
31 #include "hda_codec.h"
32 #include "hda_local.h"
33 #include "hda_beep.h"
35 #define ALC880_FRONT_EVENT 0x01
36 #define ALC880_DCVOL_EVENT 0x02
37 #define ALC880_HP_EVENT 0x04
38 #define ALC880_MIC_EVENT 0x08
40 /* ALC880 board config type */
41 enum {
42 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
47 ALC880_Z71V,
48 ALC880_6ST,
49 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
54 ALC880_ASUS_DIG2,
55 ALC880_FUJITSU,
56 ALC880_UNIWILL_DIG,
57 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
59 ALC880_CLEVO,
60 ALC880_TCL_S700,
61 ALC880_LG,
62 ALC880_LG_LW,
63 ALC880_MEDION_RIM,
64 #ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66 #endif
67 ALC880_AUTO,
68 ALC880_MODEL_LAST /* last tag */
71 /* ALC260 models */
72 enum {
73 ALC260_BASIC,
74 ALC260_HP,
75 ALC260_HP_DC7600,
76 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
78 ALC260_ACER,
79 ALC260_WILL,
80 ALC260_REPLACER_672V,
81 ALC260_FAVORIT100,
82 #ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84 #endif
85 ALC260_AUTO,
86 ALC260_MODEL_LAST /* last tag */
89 /* ALC262 models */
90 enum {
91 ALC262_BASIC,
92 ALC262_HIPPO,
93 ALC262_HIPPO_1,
94 ALC262_FUJITSU,
95 ALC262_HP_BPC,
96 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
98 ALC262_HP_TC_T5735,
99 ALC262_HP_RP5700,
100 ALC262_BENQ_ED8,
101 ALC262_SONY_ASSAMD,
102 ALC262_BENQ_T31,
103 ALC262_ULTRA,
104 ALC262_LENOVO_3000,
105 ALC262_NEC,
106 ALC262_TOSHIBA_S06,
107 ALC262_TOSHIBA_RX1,
108 ALC262_TYAN,
109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
113 /* ALC268 models */
114 enum {
115 ALC267_QUANTA_IL1,
116 ALC268_3ST,
117 ALC268_TOSHIBA,
118 ALC268_ACER,
119 ALC268_ACER_DMIC,
120 ALC268_ACER_ASPIRE_ONE,
121 ALC268_DELL,
122 ALC268_ZEPTO,
123 #ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125 #endif
126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
130 /* ALC269 models */
131 enum {
132 ALC269_BASIC,
133 ALC269_QUANTA_FL1,
134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
136 ALC269_FUJITSU,
137 ALC269_LIFEBOOK,
138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
142 /* ALC861 models */
143 enum {
144 ALC861_3ST,
145 ALC660_3ST,
146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
148 ALC861_UNIWILL_M31,
149 ALC861_TOSHIBA,
150 ALC861_ASUS,
151 ALC861_ASUS_LAPTOP,
152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
156 /* ALC861-VD models */
157 enum {
158 ALC660VD_3ST,
159 ALC660VD_3ST_DIG,
160 ALC660VD_ASUS_V1S,
161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
164 ALC861VD_LENOVO,
165 ALC861VD_DALLAS,
166 ALC861VD_HP,
167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
171 /* ALC662 models */
172 enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
178 ALC662_ASUS_EEEPC_P701,
179 ALC662_ASUS_EEEPC_EP20,
180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
191 ALC272_DELL,
192 ALC272_DELL_ZM1,
193 ALC272_SAMSUNG_NC10,
194 ALC662_AUTO,
195 ALC662_MODEL_LAST,
198 /* ALC882 models */
199 enum {
200 ALC882_3ST_DIG,
201 ALC882_6ST_DIG,
202 ALC882_ARIMA,
203 ALC882_W2JC,
204 ALC882_TARGA,
205 ALC882_ASUS_A7J,
206 ALC882_ASUS_A7M,
207 ALC885_MACPRO,
208 ALC885_MBP3,
209 ALC885_MB5,
210 ALC885_IMAC24,
211 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch,
214 ALC883_6ST_DIG,
215 ALC883_TARGA_DIG,
216 ALC883_TARGA_2ch_DIG,
217 ALC883_TARGA_8ch_DIG,
218 ALC883_ACER,
219 ALC883_ACER_ASPIRE,
220 ALC888_ACER_ASPIRE_4930G,
221 ALC888_ACER_ASPIRE_6530G,
222 ALC888_ACER_ASPIRE_8930G,
223 ALC888_ACER_ASPIRE_7730G,
224 ALC883_MEDION,
225 ALC883_MEDION_MD2,
226 ALC883_LAPTOP_EAPD,
227 ALC883_LENOVO_101E_2ch,
228 ALC883_LENOVO_NB0763,
229 ALC888_LENOVO_MS7195_DIG,
230 ALC888_LENOVO_SKY,
231 ALC883_HAIER_W66,
232 ALC888_3ST_HP,
233 ALC888_6ST_DELL,
234 ALC883_MITAC,
235 ALC883_CLEVO_M540R,
236 ALC883_CLEVO_M720,
237 ALC883_FUJITSU_PI2515,
238 ALC888_FUJITSU_XA3530,
239 ALC883_3ST_6ch_INTEL,
240 ALC889A_INTEL,
241 ALC889_INTEL,
242 ALC888_ASUS_M90V,
243 ALC888_ASUS_EEE1601,
244 ALC889A_MB31,
245 ALC1200_ASUS_P5Q,
246 ALC883_SONY_VAIO_TT,
247 ALC882_AUTO,
248 ALC882_MODEL_LAST,
251 /* for GPIO Poll */
252 #define GPIO_MASK 0x03
254 /* extra amp-initialization sequence types */
255 enum {
256 ALC_INIT_NONE,
257 ALC_INIT_DEFAULT,
258 ALC_INIT_GPIO1,
259 ALC_INIT_GPIO2,
260 ALC_INIT_GPIO3,
263 struct alc_mic_route {
264 hda_nid_t pin;
265 unsigned char mux_idx;
266 unsigned char amix_idx;
269 #define MUX_IDX_UNDEF ((unsigned char)-1)
271 struct alc_spec {
272 /* codec parameterization */
273 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
274 unsigned int num_mixers;
275 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
276 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
278 const struct hda_verb *init_verbs[10]; /* initialization verbs
279 * don't forget NULL
280 * termination!
282 unsigned int num_init_verbs;
284 char stream_name_analog[32]; /* analog PCM stream */
285 struct hda_pcm_stream *stream_analog_playback;
286 struct hda_pcm_stream *stream_analog_capture;
287 struct hda_pcm_stream *stream_analog_alt_playback;
288 struct hda_pcm_stream *stream_analog_alt_capture;
290 char stream_name_digital[32]; /* digital PCM stream */
291 struct hda_pcm_stream *stream_digital_playback;
292 struct hda_pcm_stream *stream_digital_capture;
294 /* playback */
295 struct hda_multi_out multiout; /* playback set-up
296 * max_channels, dacs must be set
297 * dig_out_nid and hp_nid are optional
299 hda_nid_t alt_dac_nid;
300 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
301 int dig_out_type;
303 /* capture */
304 unsigned int num_adc_nids;
305 hda_nid_t *adc_nids;
306 hda_nid_t *capsrc_nids;
307 hda_nid_t dig_in_nid; /* digital-in NID; optional */
309 /* capture source */
310 unsigned int num_mux_defs;
311 const struct hda_input_mux *input_mux;
312 unsigned int cur_mux[3];
313 struct alc_mic_route ext_mic;
314 struct alc_mic_route int_mic;
316 /* channel model */
317 const struct hda_channel_mode *channel_mode;
318 int num_channel_mode;
319 int need_dac_fix;
320 int const_channel_count;
321 int ext_channel_count;
323 /* PCM information */
324 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
326 /* dynamic controls, init_verbs and input_mux */
327 struct auto_pin_cfg autocfg;
328 struct snd_array kctls;
329 struct hda_input_mux private_imux[3];
330 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
331 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
332 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
334 /* hooks */
335 void (*init_hook)(struct hda_codec *codec);
336 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
338 /* for pin sensing */
339 unsigned int sense_updated: 1;
340 unsigned int jack_present: 1;
341 unsigned int master_sw: 1;
342 unsigned int auto_mic:1;
344 /* other flags */
345 unsigned int no_analog :1; /* digital I/O only */
346 int init_amp;
348 /* for virtual master */
349 hda_nid_t vmaster_nid;
350 #ifdef CONFIG_SND_HDA_POWER_SAVE
351 struct hda_loopback_check loopback;
352 #endif
354 /* for PLL fix */
355 hda_nid_t pll_nid;
356 unsigned int pll_coef_idx, pll_coef_bit;
360 * configuration template - to be copied to the spec instance
362 struct alc_config_preset {
363 struct snd_kcontrol_new *mixers[5]; /* should be identical size
364 * with spec
366 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
367 const struct hda_verb *init_verbs[5];
368 unsigned int num_dacs;
369 hda_nid_t *dac_nids;
370 hda_nid_t dig_out_nid; /* optional */
371 hda_nid_t hp_nid; /* optional */
372 hda_nid_t *slave_dig_outs;
373 unsigned int num_adc_nids;
374 hda_nid_t *adc_nids;
375 hda_nid_t *capsrc_nids;
376 hda_nid_t dig_in_nid;
377 unsigned int num_channel_mode;
378 const struct hda_channel_mode *channel_mode;
379 int need_dac_fix;
380 int const_channel_count;
381 unsigned int num_mux_defs;
382 const struct hda_input_mux *input_mux;
383 void (*unsol_event)(struct hda_codec *, unsigned int);
384 void (*setup)(struct hda_codec *);
385 void (*init_hook)(struct hda_codec *);
386 #ifdef CONFIG_SND_HDA_POWER_SAVE
387 struct hda_amp_list *loopbacks;
388 #endif
393 * input MUX handling
395 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
396 struct snd_ctl_elem_info *uinfo)
398 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
399 struct alc_spec *spec = codec->spec;
400 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
401 if (mux_idx >= spec->num_mux_defs)
402 mux_idx = 0;
403 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
406 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_value *ucontrol)
409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
410 struct alc_spec *spec = codec->spec;
411 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
413 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
414 return 0;
417 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_value *ucontrol)
420 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
421 struct alc_spec *spec = codec->spec;
422 const struct hda_input_mux *imux;
423 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
424 unsigned int mux_idx;
425 hda_nid_t nid = spec->capsrc_nids ?
426 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
427 unsigned int type;
429 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
430 imux = &spec->input_mux[mux_idx];
432 type = get_wcaps_type(get_wcaps(codec, nid));
433 if (type == AC_WID_AUD_MIX) {
434 /* Matrix-mixer style (e.g. ALC882) */
435 unsigned int *cur_val = &spec->cur_mux[adc_idx];
436 unsigned int i, idx;
438 idx = ucontrol->value.enumerated.item[0];
439 if (idx >= imux->num_items)
440 idx = imux->num_items - 1;
441 if (*cur_val == idx)
442 return 0;
443 for (i = 0; i < imux->num_items; i++) {
444 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
445 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
446 imux->items[i].index,
447 HDA_AMP_MUTE, v);
449 *cur_val = idx;
450 return 1;
451 } else {
452 /* MUX style (e.g. ALC880) */
453 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
454 &spec->cur_mux[adc_idx]);
459 * channel mode setting
461 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
462 struct snd_ctl_elem_info *uinfo)
464 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
465 struct alc_spec *spec = codec->spec;
466 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
467 spec->num_channel_mode);
470 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_value *ucontrol)
473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
474 struct alc_spec *spec = codec->spec;
475 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
476 spec->num_channel_mode,
477 spec->ext_channel_count);
480 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
481 struct snd_ctl_elem_value *ucontrol)
483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
484 struct alc_spec *spec = codec->spec;
485 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
486 spec->num_channel_mode,
487 &spec->ext_channel_count);
488 if (err >= 0 && !spec->const_channel_count) {
489 spec->multiout.max_channels = spec->ext_channel_count;
490 if (spec->need_dac_fix)
491 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
493 return err;
497 * Control the mode of pin widget settings via the mixer. "pc" is used
498 * instead of "%" to avoid consequences of accidently treating the % as
499 * being part of a format specifier. Maximum allowed length of a value is
500 * 63 characters plus NULL terminator.
502 * Note: some retasking pin complexes seem to ignore requests for input
503 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
504 * are requested. Therefore order this list so that this behaviour will not
505 * cause problems when mixer clients move through the enum sequentially.
506 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
507 * March 2006.
509 static char *alc_pin_mode_names[] = {
510 "Mic 50pc bias", "Mic 80pc bias",
511 "Line in", "Line out", "Headphone out",
513 static unsigned char alc_pin_mode_values[] = {
514 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
516 /* The control can present all 5 options, or it can limit the options based
517 * in the pin being assumed to be exclusively an input or an output pin. In
518 * addition, "input" pins may or may not process the mic bias option
519 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
520 * accept requests for bias as of chip versions up to March 2006) and/or
521 * wiring in the computer.
523 #define ALC_PIN_DIR_IN 0x00
524 #define ALC_PIN_DIR_OUT 0x01
525 #define ALC_PIN_DIR_INOUT 0x02
526 #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
527 #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
529 /* Info about the pin modes supported by the different pin direction modes.
530 * For each direction the minimum and maximum values are given.
532 static signed char alc_pin_mode_dir_info[5][2] = {
533 { 0, 2 }, /* ALC_PIN_DIR_IN */
534 { 3, 4 }, /* ALC_PIN_DIR_OUT */
535 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
536 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
537 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
539 #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
540 #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
541 #define alc_pin_mode_n_items(_dir) \
542 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
544 static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
545 struct snd_ctl_elem_info *uinfo)
547 unsigned int item_num = uinfo->value.enumerated.item;
548 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
550 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
551 uinfo->count = 1;
552 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
554 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
555 item_num = alc_pin_mode_min(dir);
556 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
557 return 0;
560 static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_value *ucontrol)
563 unsigned int i;
564 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
565 hda_nid_t nid = kcontrol->private_value & 0xffff;
566 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
567 long *valp = ucontrol->value.integer.value;
568 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
569 AC_VERB_GET_PIN_WIDGET_CONTROL,
570 0x00);
572 /* Find enumerated value for current pinctl setting */
573 i = alc_pin_mode_min(dir);
574 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
575 i++;
576 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
577 return 0;
580 static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
581 struct snd_ctl_elem_value *ucontrol)
583 signed int change;
584 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
585 hda_nid_t nid = kcontrol->private_value & 0xffff;
586 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
587 long val = *ucontrol->value.integer.value;
588 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
589 AC_VERB_GET_PIN_WIDGET_CONTROL,
590 0x00);
592 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
593 val = alc_pin_mode_min(dir);
595 change = pinctl != alc_pin_mode_values[val];
596 if (change) {
597 /* Set pin mode to that requested */
598 snd_hda_codec_write_cache(codec, nid, 0,
599 AC_VERB_SET_PIN_WIDGET_CONTROL,
600 alc_pin_mode_values[val]);
602 /* Also enable the retasking pin's input/output as required
603 * for the requested pin mode. Enum values of 2 or less are
604 * input modes.
606 * Dynamically switching the input/output buffers probably
607 * reduces noise slightly (particularly on input) so we'll
608 * do it. However, having both input and output buffers
609 * enabled simultaneously doesn't seem to be problematic if
610 * this turns out to be necessary in the future.
612 if (val <= 2) {
613 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
614 HDA_AMP_MUTE, HDA_AMP_MUTE);
615 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
616 HDA_AMP_MUTE, 0);
617 } else {
618 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
619 HDA_AMP_MUTE, HDA_AMP_MUTE);
620 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
621 HDA_AMP_MUTE, 0);
624 return change;
627 #define ALC_PIN_MODE(xname, nid, dir) \
628 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
629 .info = alc_pin_mode_info, \
630 .get = alc_pin_mode_get, \
631 .put = alc_pin_mode_put, \
632 .private_value = nid | (dir<<16) }
634 /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
635 * together using a mask with more than one bit set. This control is
636 * currently used only by the ALC260 test model. At this stage they are not
637 * needed for any "production" models.
639 #ifdef CONFIG_SND_DEBUG
640 #define alc_gpio_data_info snd_ctl_boolean_mono_info
642 static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 hda_nid_t nid = kcontrol->private_value & 0xffff;
647 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
648 long *valp = ucontrol->value.integer.value;
649 unsigned int val = snd_hda_codec_read(codec, nid, 0,
650 AC_VERB_GET_GPIO_DATA, 0x00);
652 *valp = (val & mask) != 0;
653 return 0;
655 static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
658 signed int change;
659 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
660 hda_nid_t nid = kcontrol->private_value & 0xffff;
661 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
662 long val = *ucontrol->value.integer.value;
663 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
664 AC_VERB_GET_GPIO_DATA,
665 0x00);
667 /* Set/unset the masked GPIO bit(s) as needed */
668 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
669 if (val == 0)
670 gpio_data &= ~mask;
671 else
672 gpio_data |= mask;
673 snd_hda_codec_write_cache(codec, nid, 0,
674 AC_VERB_SET_GPIO_DATA, gpio_data);
676 return change;
678 #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
679 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
680 .info = alc_gpio_data_info, \
681 .get = alc_gpio_data_get, \
682 .put = alc_gpio_data_put, \
683 .private_value = nid | (mask<<16) }
684 #endif /* CONFIG_SND_DEBUG */
686 /* A switch control to allow the enabling of the digital IO pins on the
687 * ALC260. This is incredibly simplistic; the intention of this control is
688 * to provide something in the test model allowing digital outputs to be
689 * identified if present. If models are found which can utilise these
690 * outputs a more complete mixer control can be devised for those models if
691 * necessary.
693 #ifdef CONFIG_SND_DEBUG
694 #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
696 static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
697 struct snd_ctl_elem_value *ucontrol)
699 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
700 hda_nid_t nid = kcontrol->private_value & 0xffff;
701 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
702 long *valp = ucontrol->value.integer.value;
703 unsigned int val = snd_hda_codec_read(codec, nid, 0,
704 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
706 *valp = (val & mask) != 0;
707 return 0;
709 static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
710 struct snd_ctl_elem_value *ucontrol)
712 signed int change;
713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
714 hda_nid_t nid = kcontrol->private_value & 0xffff;
715 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
716 long val = *ucontrol->value.integer.value;
717 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
718 AC_VERB_GET_DIGI_CONVERT_1,
719 0x00);
721 /* Set/unset the masked control bit(s) as needed */
722 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
723 if (val==0)
724 ctrl_data &= ~mask;
725 else
726 ctrl_data |= mask;
727 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
728 ctrl_data);
730 return change;
732 #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
733 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
734 .info = alc_spdif_ctrl_info, \
735 .get = alc_spdif_ctrl_get, \
736 .put = alc_spdif_ctrl_put, \
737 .private_value = nid | (mask<<16) }
738 #endif /* CONFIG_SND_DEBUG */
740 /* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
741 * Again, this is only used in the ALC26x test models to help identify when
742 * the EAPD line must be asserted for features to work.
744 #ifdef CONFIG_SND_DEBUG
745 #define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
747 static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
748 struct snd_ctl_elem_value *ucontrol)
750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
751 hda_nid_t nid = kcontrol->private_value & 0xffff;
752 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
753 long *valp = ucontrol->value.integer.value;
754 unsigned int val = snd_hda_codec_read(codec, nid, 0,
755 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
757 *valp = (val & mask) != 0;
758 return 0;
761 static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
762 struct snd_ctl_elem_value *ucontrol)
764 int change;
765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
766 hda_nid_t nid = kcontrol->private_value & 0xffff;
767 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
768 long val = *ucontrol->value.integer.value;
769 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
770 AC_VERB_GET_EAPD_BTLENABLE,
771 0x00);
773 /* Set/unset the masked control bit(s) as needed */
774 change = (!val ? 0 : mask) != (ctrl_data & mask);
775 if (!val)
776 ctrl_data &= ~mask;
777 else
778 ctrl_data |= mask;
779 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
780 ctrl_data);
782 return change;
785 #define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
786 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
787 .info = alc_eapd_ctrl_info, \
788 .get = alc_eapd_ctrl_get, \
789 .put = alc_eapd_ctrl_put, \
790 .private_value = nid | (mask<<16) }
791 #endif /* CONFIG_SND_DEBUG */
794 * set up the input pin config (depending on the given auto-pin type)
796 static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
797 int auto_pin_type)
799 unsigned int val = PIN_IN;
801 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
802 unsigned int pincap;
803 pincap = snd_hda_query_pin_caps(codec, nid);
804 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
805 if (pincap & AC_PINCAP_VREF_80)
806 val = PIN_VREF80;
807 else if (pincap & AC_PINCAP_VREF_50)
808 val = PIN_VREF50;
809 else if (pincap & AC_PINCAP_VREF_100)
810 val = PIN_VREF100;
811 else if (pincap & AC_PINCAP_VREF_GRD)
812 val = PIN_VREFGRD;
814 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
819 static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
821 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
822 return;
823 spec->mixers[spec->num_mixers++] = mix;
826 static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
828 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
829 return;
830 spec->init_verbs[spec->num_init_verbs++] = verb;
833 #ifdef CONFIG_PROC_FS
835 * hook for proc
837 static void print_realtek_coef(struct snd_info_buffer *buffer,
838 struct hda_codec *codec, hda_nid_t nid)
840 int coeff;
842 if (nid != 0x20)
843 return;
844 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
845 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
846 coeff = snd_hda_codec_read(codec, nid, 0,
847 AC_VERB_GET_COEF_INDEX, 0);
848 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
850 #else
851 #define print_realtek_coef NULL
852 #endif
855 * set up from the preset table
857 static void setup_preset(struct hda_codec *codec,
858 const struct alc_config_preset *preset)
860 struct alc_spec *spec = codec->spec;
861 int i;
863 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
864 add_mixer(spec, preset->mixers[i]);
865 spec->cap_mixer = preset->cap_mixer;
866 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
867 i++)
868 add_verb(spec, preset->init_verbs[i]);
870 spec->channel_mode = preset->channel_mode;
871 spec->num_channel_mode = preset->num_channel_mode;
872 spec->need_dac_fix = preset->need_dac_fix;
873 spec->const_channel_count = preset->const_channel_count;
875 if (preset->const_channel_count)
876 spec->multiout.max_channels = preset->const_channel_count;
877 else
878 spec->multiout.max_channels = spec->channel_mode[0].channels;
879 spec->ext_channel_count = spec->channel_mode[0].channels;
881 spec->multiout.num_dacs = preset->num_dacs;
882 spec->multiout.dac_nids = preset->dac_nids;
883 spec->multiout.dig_out_nid = preset->dig_out_nid;
884 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
885 spec->multiout.hp_nid = preset->hp_nid;
887 spec->num_mux_defs = preset->num_mux_defs;
888 if (!spec->num_mux_defs)
889 spec->num_mux_defs = 1;
890 spec->input_mux = preset->input_mux;
892 spec->num_adc_nids = preset->num_adc_nids;
893 spec->adc_nids = preset->adc_nids;
894 spec->capsrc_nids = preset->capsrc_nids;
895 spec->dig_in_nid = preset->dig_in_nid;
897 spec->unsol_event = preset->unsol_event;
898 spec->init_hook = preset->init_hook;
899 #ifdef CONFIG_SND_HDA_POWER_SAVE
900 spec->loopback.amplist = preset->loopbacks;
901 #endif
903 if (preset->setup)
904 preset->setup(codec);
907 /* Enable GPIO mask and set output */
908 static struct hda_verb alc_gpio1_init_verbs[] = {
909 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
910 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
911 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
915 static struct hda_verb alc_gpio2_init_verbs[] = {
916 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
917 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
918 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
922 static struct hda_verb alc_gpio3_init_verbs[] = {
923 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
924 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
925 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
930 * Fix hardware PLL issue
931 * On some codecs, the analog PLL gating control must be off while
932 * the default value is 1.
934 static void alc_fix_pll(struct hda_codec *codec)
936 struct alc_spec *spec = codec->spec;
937 unsigned int val;
939 if (!spec->pll_nid)
940 return;
941 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
942 spec->pll_coef_idx);
943 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
944 AC_VERB_GET_PROC_COEF, 0);
945 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
946 spec->pll_coef_idx);
947 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
948 val & ~(1 << spec->pll_coef_bit));
951 static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
952 unsigned int coef_idx, unsigned int coef_bit)
954 struct alc_spec *spec = codec->spec;
955 spec->pll_nid = nid;
956 spec->pll_coef_idx = coef_idx;
957 spec->pll_coef_bit = coef_bit;
958 alc_fix_pll(codec);
961 static void alc_automute_pin(struct hda_codec *codec)
963 struct alc_spec *spec = codec->spec;
964 unsigned int present, pincap;
965 unsigned int nid = spec->autocfg.hp_pins[0];
966 int i;
968 if (!nid)
969 return;
970 pincap = snd_hda_query_pin_caps(codec, nid);
971 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
972 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
973 present = snd_hda_codec_read(codec, nid, 0,
974 AC_VERB_GET_PIN_SENSE, 0);
975 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
976 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
977 nid = spec->autocfg.speaker_pins[i];
978 if (!nid)
979 break;
980 snd_hda_codec_write(codec, nid, 0,
981 AC_VERB_SET_PIN_WIDGET_CONTROL,
982 spec->jack_present ? 0 : PIN_OUT);
986 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
987 hda_nid_t nid)
989 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
990 int i, nums;
992 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
993 for (i = 0; i < nums; i++)
994 if (conn[i] == nid)
995 return i;
996 return -1;
999 static void alc_mic_automute(struct hda_codec *codec)
1001 struct alc_spec *spec = codec->spec;
1002 struct alc_mic_route *dead, *alive;
1003 unsigned int present, type;
1004 hda_nid_t cap_nid;
1006 if (!spec->auto_mic)
1007 return;
1008 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1009 return;
1010 if (snd_BUG_ON(!spec->adc_nids))
1011 return;
1013 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1015 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1016 AC_VERB_GET_PIN_SENSE, 0);
1017 present &= AC_PINSENSE_PRESENCE;
1018 if (present) {
1019 alive = &spec->ext_mic;
1020 dead = &spec->int_mic;
1021 } else {
1022 alive = &spec->int_mic;
1023 dead = &spec->ext_mic;
1026 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1027 if (type == AC_WID_AUD_MIX) {
1028 /* Matrix-mixer style (e.g. ALC882) */
1029 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1030 alive->mux_idx,
1031 HDA_AMP_MUTE, 0);
1032 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1033 dead->mux_idx,
1034 HDA_AMP_MUTE, HDA_AMP_MUTE);
1035 } else {
1036 /* MUX style (e.g. ALC880) */
1037 snd_hda_codec_write_cache(codec, cap_nid, 0,
1038 AC_VERB_SET_CONNECT_SEL,
1039 alive->mux_idx);
1042 /* FIXME: analog mixer */
1045 /* unsolicited event for HP jack sensing */
1046 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1048 if (codec->vendor_id == 0x10ec0880)
1049 res >>= 28;
1050 else
1051 res >>= 26;
1052 switch (res) {
1053 case ALC880_HP_EVENT:
1054 alc_automute_pin(codec);
1055 break;
1056 case ALC880_MIC_EVENT:
1057 alc_mic_automute(codec);
1058 break;
1062 static void alc_inithook(struct hda_codec *codec)
1064 alc_automute_pin(codec);
1065 alc_mic_automute(codec);
1068 /* additional initialization for ALC888 variants */
1069 static void alc888_coef_init(struct hda_codec *codec)
1071 unsigned int tmp;
1073 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1074 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1075 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1076 if ((tmp & 0xf0) == 0x20)
1077 /* alc888S-VC */
1078 snd_hda_codec_read(codec, 0x20, 0,
1079 AC_VERB_SET_PROC_COEF, 0x830);
1080 else
1081 /* alc888-VB */
1082 snd_hda_codec_read(codec, 0x20, 0,
1083 AC_VERB_SET_PROC_COEF, 0x3030);
1086 static void alc889_coef_init(struct hda_codec *codec)
1088 unsigned int tmp;
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1091 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1092 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1093 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1096 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1098 unsigned int tmp;
1100 switch (type) {
1101 case ALC_INIT_GPIO1:
1102 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1103 break;
1104 case ALC_INIT_GPIO2:
1105 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1106 break;
1107 case ALC_INIT_GPIO3:
1108 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1109 break;
1110 case ALC_INIT_DEFAULT:
1111 switch (codec->vendor_id) {
1112 case 0x10ec0260:
1113 snd_hda_codec_write(codec, 0x0f, 0,
1114 AC_VERB_SET_EAPD_BTLENABLE, 2);
1115 snd_hda_codec_write(codec, 0x10, 0,
1116 AC_VERB_SET_EAPD_BTLENABLE, 2);
1117 break;
1118 case 0x10ec0262:
1119 case 0x10ec0267:
1120 case 0x10ec0268:
1121 case 0x10ec0269:
1122 case 0x10ec0272:
1123 case 0x10ec0660:
1124 case 0x10ec0662:
1125 case 0x10ec0663:
1126 case 0x10ec0862:
1127 case 0x10ec0889:
1128 snd_hda_codec_write(codec, 0x14, 0,
1129 AC_VERB_SET_EAPD_BTLENABLE, 2);
1130 snd_hda_codec_write(codec, 0x15, 0,
1131 AC_VERB_SET_EAPD_BTLENABLE, 2);
1132 break;
1134 switch (codec->vendor_id) {
1135 case 0x10ec0260:
1136 snd_hda_codec_write(codec, 0x1a, 0,
1137 AC_VERB_SET_COEF_INDEX, 7);
1138 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1139 AC_VERB_GET_PROC_COEF, 0);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_COEF_INDEX, 7);
1142 snd_hda_codec_write(codec, 0x1a, 0,
1143 AC_VERB_SET_PROC_COEF,
1144 tmp | 0x2010);
1145 break;
1146 case 0x10ec0262:
1147 case 0x10ec0880:
1148 case 0x10ec0882:
1149 case 0x10ec0883:
1150 case 0x10ec0885:
1151 case 0x10ec0887:
1152 case 0x10ec0889:
1153 alc889_coef_init(codec);
1154 break;
1155 case 0x10ec0888:
1156 alc888_coef_init(codec);
1157 break;
1158 case 0x10ec0267:
1159 case 0x10ec0268:
1160 snd_hda_codec_write(codec, 0x20, 0,
1161 AC_VERB_SET_COEF_INDEX, 7);
1162 tmp = snd_hda_codec_read(codec, 0x20, 0,
1163 AC_VERB_GET_PROC_COEF, 0);
1164 snd_hda_codec_write(codec, 0x20, 0,
1165 AC_VERB_SET_COEF_INDEX, 7);
1166 snd_hda_codec_write(codec, 0x20, 0,
1167 AC_VERB_SET_PROC_COEF,
1168 tmp | 0x3000);
1169 break;
1171 break;
1175 static void alc_init_auto_hp(struct hda_codec *codec)
1177 struct alc_spec *spec = codec->spec;
1179 if (!spec->autocfg.hp_pins[0])
1180 return;
1182 if (!spec->autocfg.speaker_pins[0]) {
1183 if (spec->autocfg.line_out_pins[0] &&
1184 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
1185 spec->autocfg.speaker_pins[0] =
1186 spec->autocfg.line_out_pins[0];
1187 else
1188 return;
1191 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1192 spec->autocfg.hp_pins[0]);
1193 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1194 AC_VERB_SET_UNSOLICITED_ENABLE,
1195 AC_USRSP_EN | ALC880_HP_EVENT);
1196 spec->unsol_event = alc_sku_unsol_event;
1199 static void alc_init_auto_mic(struct hda_codec *codec)
1201 struct alc_spec *spec = codec->spec;
1202 struct auto_pin_cfg *cfg = &spec->autocfg;
1203 hda_nid_t fixed, ext;
1204 int i;
1206 /* there must be only two mic inputs exclusively */
1207 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1208 if (cfg->input_pins[i])
1209 return;
1211 fixed = ext = 0;
1212 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1213 hda_nid_t nid = cfg->input_pins[i];
1214 unsigned int defcfg;
1215 if (!nid)
1216 return;
1217 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1218 switch (get_defcfg_connect(defcfg)) {
1219 case AC_JACK_PORT_FIXED:
1220 if (fixed)
1221 return; /* already occupied */
1222 fixed = nid;
1223 break;
1224 case AC_JACK_PORT_COMPLEX:
1225 if (ext)
1226 return; /* already occupied */
1227 ext = nid;
1228 break;
1229 default:
1230 return; /* invalid entry */
1233 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1234 return; /* no unsol support */
1235 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1236 ext, fixed);
1237 spec->ext_mic.pin = ext;
1238 spec->int_mic.pin = fixed;
1239 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1240 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1241 spec->auto_mic = 1;
1242 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1243 AC_VERB_SET_UNSOLICITED_ENABLE,
1244 AC_USRSP_EN | ALC880_MIC_EVENT);
1245 spec->unsol_event = alc_sku_unsol_event;
1248 /* check subsystem ID and set up device-specific initialization;
1249 * return 1 if initialized, 0 if invalid SSID
1251 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1252 * 31 ~ 16 : Manufacture ID
1253 * 15 ~ 8 : SKU ID
1254 * 7 ~ 0 : Assembly ID
1255 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1257 static int alc_subsystem_id(struct hda_codec *codec,
1258 hda_nid_t porta, hda_nid_t porte,
1259 hda_nid_t portd)
1261 unsigned int ass, tmp, i;
1262 unsigned nid;
1263 struct alc_spec *spec = codec->spec;
1265 ass = codec->subsystem_id & 0xffff;
1266 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1267 goto do_sku;
1269 /* invalid SSID, check the special NID pin defcfg instead */
1271 * 31~30 : port connectivity
1272 * 29~21 : reserve
1273 * 20 : PCBEEP input
1274 * 19~16 : Check sum (15:1)
1275 * 15~1 : Custom
1276 * 0 : override
1278 nid = 0x1d;
1279 if (codec->vendor_id == 0x10ec0260)
1280 nid = 0x17;
1281 ass = snd_hda_codec_get_pincfg(codec, nid);
1282 snd_printd("realtek: No valid SSID, "
1283 "checking pincfg 0x%08x for NID 0x%x\n",
1284 ass, nid);
1285 if (!(ass & 1) && !(ass & 0x100000))
1286 return 0;
1287 if ((ass >> 30) != 1) /* no physical connection */
1288 return 0;
1290 /* check sum */
1291 tmp = 0;
1292 for (i = 1; i < 16; i++) {
1293 if ((ass >> i) & 1)
1294 tmp++;
1296 if (((ass >> 16) & 0xf) != tmp)
1297 return 0;
1298 do_sku:
1299 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1300 ass & 0xffff, codec->vendor_id);
1302 * 0 : override
1303 * 1 : Swap Jack
1304 * 2 : 0 --> Desktop, 1 --> Laptop
1305 * 3~5 : External Amplifier control
1306 * 7~6 : Reserved
1308 tmp = (ass & 0x38) >> 3; /* external Amp control */
1309 switch (tmp) {
1310 case 1:
1311 spec->init_amp = ALC_INIT_GPIO1;
1312 break;
1313 case 3:
1314 spec->init_amp = ALC_INIT_GPIO2;
1315 break;
1316 case 7:
1317 spec->init_amp = ALC_INIT_GPIO3;
1318 break;
1319 case 5:
1320 spec->init_amp = ALC_INIT_DEFAULT;
1321 break;
1324 /* is laptop or Desktop and enable the function "Mute internal speaker
1325 * when the external headphone out jack is plugged"
1327 if (!(ass & 0x8000))
1328 return 1;
1330 * 10~8 : Jack location
1331 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1332 * 14~13: Resvered
1333 * 15 : 1 --> enable the function "Mute internal speaker
1334 * when the external headphone out jack is plugged"
1336 if (!spec->autocfg.hp_pins[0]) {
1337 hda_nid_t nid;
1338 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1339 if (tmp == 0)
1340 nid = porta;
1341 else if (tmp == 1)
1342 nid = porte;
1343 else if (tmp == 2)
1344 nid = portd;
1345 else
1346 return 1;
1347 for (i = 0; i < spec->autocfg.line_outs; i++)
1348 if (spec->autocfg.line_out_pins[i] == nid)
1349 return 1;
1350 spec->autocfg.hp_pins[0] = nid;
1353 alc_init_auto_hp(codec);
1354 alc_init_auto_mic(codec);
1355 return 1;
1358 static void alc_ssid_check(struct hda_codec *codec,
1359 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1361 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1362 struct alc_spec *spec = codec->spec;
1363 snd_printd("realtek: "
1364 "Enable default setup for auto mode as fallback\n");
1365 spec->init_amp = ALC_INIT_DEFAULT;
1366 alc_init_auto_hp(codec);
1367 alc_init_auto_mic(codec);
1372 * Fix-up pin default configurations and add default verbs
1375 struct alc_pincfg {
1376 hda_nid_t nid;
1377 u32 val;
1380 struct alc_fixup {
1381 const struct alc_pincfg *pins;
1382 const struct hda_verb *verbs;
1385 static void alc_pick_fixup(struct hda_codec *codec,
1386 const struct snd_pci_quirk *quirk,
1387 const struct alc_fixup *fix)
1389 const struct alc_pincfg *cfg;
1391 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1392 if (!quirk)
1393 return;
1395 fix += quirk->value;
1396 cfg = fix->pins;
1397 if (cfg) {
1398 for (; cfg->nid; cfg++)
1399 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1401 if (fix->verbs)
1402 add_verb(codec->spec, fix->verbs);
1406 * ALC888
1410 * 2ch mode
1412 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1413 /* Mic-in jack as mic in */
1414 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1415 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1416 /* Line-in jack as Line in */
1417 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1418 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1419 /* Line-Out as Front */
1420 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1421 { } /* end */
1425 * 4ch mode
1427 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1428 /* Mic-in jack as mic in */
1429 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1430 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1431 /* Line-in jack as Surround */
1432 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1433 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1434 /* Line-Out as Front */
1435 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1436 { } /* end */
1440 * 6ch mode
1442 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1443 /* Mic-in jack as CLFE */
1444 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1445 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1446 /* Line-in jack as Surround */
1447 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1448 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1449 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1450 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1451 { } /* end */
1455 * 8ch mode
1457 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1458 /* Mic-in jack as CLFE */
1459 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1460 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1461 /* Line-in jack as Surround */
1462 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1463 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1464 /* Line-Out as Side */
1465 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1466 { } /* end */
1469 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1470 { 2, alc888_4ST_ch2_intel_init },
1471 { 4, alc888_4ST_ch4_intel_init },
1472 { 6, alc888_4ST_ch6_intel_init },
1473 { 8, alc888_4ST_ch8_intel_init },
1477 * ALC888 Fujitsu Siemens Amillo xa3530
1480 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1481 /* Front Mic: set to PIN_IN (empty by default) */
1482 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1483 /* Connect Internal HP to Front */
1484 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1485 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1486 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1487 /* Connect Bass HP to Front */
1488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1489 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1490 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1491 /* Connect Line-Out side jack (SPDIF) to Side */
1492 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1493 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1494 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1495 /* Connect Mic jack to CLFE */
1496 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1497 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1498 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1499 /* Connect Line-in jack to Surround */
1500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1503 /* Connect HP out jack to Front */
1504 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1505 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1506 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1507 /* Enable unsolicited event for HP jack and Line-out jack */
1508 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1509 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1513 static void alc_automute_amp(struct hda_codec *codec)
1515 struct alc_spec *spec = codec->spec;
1516 unsigned int val, mute, pincap;
1517 hda_nid_t nid;
1518 int i;
1520 spec->jack_present = 0;
1521 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1522 nid = spec->autocfg.hp_pins[i];
1523 if (!nid)
1524 break;
1525 pincap = snd_hda_query_pin_caps(codec, nid);
1526 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1527 snd_hda_codec_read(codec, nid, 0,
1528 AC_VERB_SET_PIN_SENSE, 0);
1529 val = snd_hda_codec_read(codec, nid, 0,
1530 AC_VERB_GET_PIN_SENSE, 0);
1531 if (val & AC_PINSENSE_PRESENCE) {
1532 spec->jack_present = 1;
1533 break;
1537 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1538 /* Toggle internal speakers muting */
1539 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1540 nid = spec->autocfg.speaker_pins[i];
1541 if (!nid)
1542 break;
1543 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1544 HDA_AMP_MUTE, mute);
1548 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1549 unsigned int res)
1551 if (codec->vendor_id == 0x10ec0880)
1552 res >>= 28;
1553 else
1554 res >>= 26;
1555 if (res == ALC880_HP_EVENT)
1556 alc_automute_amp(codec);
1559 static void alc889_automute_setup(struct hda_codec *codec)
1561 struct alc_spec *spec = codec->spec;
1563 spec->autocfg.hp_pins[0] = 0x15;
1564 spec->autocfg.speaker_pins[0] = 0x14;
1565 spec->autocfg.speaker_pins[1] = 0x16;
1566 spec->autocfg.speaker_pins[2] = 0x17;
1567 spec->autocfg.speaker_pins[3] = 0x19;
1568 spec->autocfg.speaker_pins[4] = 0x1a;
1571 static void alc889_intel_init_hook(struct hda_codec *codec)
1573 alc889_coef_init(codec);
1574 alc_automute_amp(codec);
1577 static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1579 struct alc_spec *spec = codec->spec;
1581 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1582 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1583 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1584 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1588 * ALC888 Acer Aspire 4930G model
1591 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1592 /* Front Mic: set to PIN_IN (empty by default) */
1593 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1594 /* Unselect Front Mic by default in input mixer 3 */
1595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1596 /* Enable unsolicited event for HP jack */
1597 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1598 /* Connect Internal HP to front */
1599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1601 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1602 /* Connect HP out to front */
1603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1610 * ALC888 Acer Aspire 6530G model
1613 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1614 /* Bias voltage on for external mic port */
1615 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1616 /* Front Mic: set to PIN_IN (empty by default) */
1617 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1618 /* Unselect Front Mic by default in input mixer 3 */
1619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1620 /* Enable unsolicited event for HP jack */
1621 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1622 /* Enable speaker output */
1623 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1624 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1625 /* Enable headphone output */
1626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1628 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1633 * ALC889 Acer Aspire 8930G model
1636 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1637 /* Front Mic: set to PIN_IN (empty by default) */
1638 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1639 /* Unselect Front Mic by default in input mixer 3 */
1640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1641 /* Enable unsolicited event for HP jack */
1642 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1643 /* Connect Internal Front to Front */
1644 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1645 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1646 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1647 /* Connect Internal Rear to Rear */
1648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1650 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1651 /* Connect Internal CLFE to CLFE */
1652 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1654 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1655 /* Connect HP out to Front */
1656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1658 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1659 /* Enable all DACs */
1660 /* DAC DISABLE/MUTE 1? */
1661 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1662 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1663 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1664 /* DAC DISABLE/MUTE 2? */
1665 /* some bit here disables the other DACs. Init=0x4900 */
1666 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1667 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1668 /* Enable amplifiers */
1669 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1670 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1671 /* DMIC fix
1672 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1673 * which makes the stereo useless. However, either the mic or the ALC889
1674 * makes the signal become a difference/sum signal instead of standard
1675 * stereo, which is annoying. So instead we flip this bit which makes the
1676 * codec replicate the sum signal to both channels, turning it into a
1677 * normal mono mic.
1679 /* DMIC_CONTROL? Init value = 0x0001 */
1680 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1681 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
1685 static struct hda_input_mux alc888_2_capture_sources[2] = {
1686 /* Front mic only available on one ADC */
1688 .num_items = 4,
1689 .items = {
1690 { "Mic", 0x0 },
1691 { "Line", 0x2 },
1692 { "CD", 0x4 },
1693 { "Front Mic", 0xb },
1697 .num_items = 3,
1698 .items = {
1699 { "Mic", 0x0 },
1700 { "Line", 0x2 },
1701 { "CD", 0x4 },
1706 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1707 /* Interal mic only available on one ADC */
1709 .num_items = 5,
1710 .items = {
1711 { "Ext Mic", 0x0 },
1712 { "Line In", 0x2 },
1713 { "CD", 0x4 },
1714 { "Input Mix", 0xa },
1715 { "Int Mic", 0xb },
1719 .num_items = 4,
1720 .items = {
1721 { "Ext Mic", 0x0 },
1722 { "Line In", 0x2 },
1723 { "CD", 0x4 },
1724 { "Input Mix", 0xa },
1729 static struct hda_input_mux alc889_capture_sources[3] = {
1730 /* Digital mic only available on first "ADC" */
1732 .num_items = 5,
1733 .items = {
1734 { "Mic", 0x0 },
1735 { "Line", 0x2 },
1736 { "CD", 0x4 },
1737 { "Front Mic", 0xb },
1738 { "Input Mix", 0xa },
1742 .num_items = 4,
1743 .items = {
1744 { "Mic", 0x0 },
1745 { "Line", 0x2 },
1746 { "CD", 0x4 },
1747 { "Input Mix", 0xa },
1751 .num_items = 4,
1752 .items = {
1753 { "Mic", 0x0 },
1754 { "Line", 0x2 },
1755 { "CD", 0x4 },
1756 { "Input Mix", 0xa },
1761 static struct snd_kcontrol_new alc888_base_mixer[] = {
1762 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1763 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1764 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1765 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1766 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1767 HDA_OUTPUT),
1768 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1769 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1770 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1771 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1772 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1773 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1774 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1776 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1780 { } /* end */
1783 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
1785 struct alc_spec *spec = codec->spec;
1787 spec->autocfg.hp_pins[0] = 0x15;
1788 spec->autocfg.speaker_pins[0] = 0x14;
1791 static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
1793 struct alc_spec *spec = codec->spec;
1795 spec->autocfg.hp_pins[0] = 0x15;
1796 spec->autocfg.speaker_pins[0] = 0x14;
1797 spec->autocfg.speaker_pins[1] = 0x16;
1798 spec->autocfg.speaker_pins[2] = 0x17;
1801 static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
1803 struct alc_spec *spec = codec->spec;
1805 spec->autocfg.hp_pins[0] = 0x15;
1806 spec->autocfg.speaker_pins[0] = 0x14;
1807 spec->autocfg.speaker_pins[1] = 0x16;
1808 spec->autocfg.speaker_pins[2] = 0x1b;
1812 * ALC880 3-stack model
1814 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1815 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1816 * F-Mic = 0x1b, HP = 0x19
1819 static hda_nid_t alc880_dac_nids[4] = {
1820 /* front, rear, clfe, rear_surr */
1821 0x02, 0x05, 0x04, 0x03
1824 static hda_nid_t alc880_adc_nids[3] = {
1825 /* ADC0-2 */
1826 0x07, 0x08, 0x09,
1829 /* The datasheet says the node 0x07 is connected from inputs,
1830 * but it shows zero connection in the real implementation on some devices.
1831 * Note: this is a 915GAV bug, fixed on 915GLV
1833 static hda_nid_t alc880_adc_nids_alt[2] = {
1834 /* ADC1-2 */
1835 0x08, 0x09,
1838 #define ALC880_DIGOUT_NID 0x06
1839 #define ALC880_DIGIN_NID 0x0a
1841 static struct hda_input_mux alc880_capture_source = {
1842 .num_items = 4,
1843 .items = {
1844 { "Mic", 0x0 },
1845 { "Front Mic", 0x3 },
1846 { "Line", 0x2 },
1847 { "CD", 0x4 },
1851 /* channel source setting (2/6 channel selection for 3-stack) */
1852 /* 2ch mode */
1853 static struct hda_verb alc880_threestack_ch2_init[] = {
1854 /* set line-in to input, mute it */
1855 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1856 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1857 /* set mic-in to input vref 80%, mute it */
1858 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1859 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1860 { } /* end */
1863 /* 6ch mode */
1864 static struct hda_verb alc880_threestack_ch6_init[] = {
1865 /* set line-in to output, unmute it */
1866 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1867 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1868 /* set mic-in to output, unmute it */
1869 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1870 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1871 { } /* end */
1874 static struct hda_channel_mode alc880_threestack_modes[2] = {
1875 { 2, alc880_threestack_ch2_init },
1876 { 6, alc880_threestack_ch6_init },
1879 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1880 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1881 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1882 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1883 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1884 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1885 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1886 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1887 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1888 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1889 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1890 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1891 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1894 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1895 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1896 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1899 .name = "Channel Mode",
1900 .info = alc_ch_mode_info,
1901 .get = alc_ch_mode_get,
1902 .put = alc_ch_mode_put,
1904 { } /* end */
1907 /* capture mixer elements */
1908 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1909 struct snd_ctl_elem_info *uinfo)
1911 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1912 struct alc_spec *spec = codec->spec;
1913 int err;
1915 mutex_lock(&codec->control_mutex);
1916 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1917 HDA_INPUT);
1918 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1919 mutex_unlock(&codec->control_mutex);
1920 return err;
1923 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1924 unsigned int size, unsigned int __user *tlv)
1926 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1927 struct alc_spec *spec = codec->spec;
1928 int err;
1930 mutex_lock(&codec->control_mutex);
1931 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1932 HDA_INPUT);
1933 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1934 mutex_unlock(&codec->control_mutex);
1935 return err;
1938 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1939 struct snd_ctl_elem_value *ucontrol);
1941 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1942 struct snd_ctl_elem_value *ucontrol,
1943 getput_call_t func)
1945 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1946 struct alc_spec *spec = codec->spec;
1947 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1948 int err;
1950 mutex_lock(&codec->control_mutex);
1951 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1952 3, 0, HDA_INPUT);
1953 err = func(kcontrol, ucontrol);
1954 mutex_unlock(&codec->control_mutex);
1955 return err;
1958 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1959 struct snd_ctl_elem_value *ucontrol)
1961 return alc_cap_getput_caller(kcontrol, ucontrol,
1962 snd_hda_mixer_amp_volume_get);
1965 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1966 struct snd_ctl_elem_value *ucontrol)
1968 return alc_cap_getput_caller(kcontrol, ucontrol,
1969 snd_hda_mixer_amp_volume_put);
1972 /* capture mixer elements */
1973 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1975 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1976 struct snd_ctl_elem_value *ucontrol)
1978 return alc_cap_getput_caller(kcontrol, ucontrol,
1979 snd_hda_mixer_amp_switch_get);
1982 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1983 struct snd_ctl_elem_value *ucontrol)
1985 return alc_cap_getput_caller(kcontrol, ucontrol,
1986 snd_hda_mixer_amp_switch_put);
1989 #define _DEFINE_CAPMIX(num) \
1991 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1992 .name = "Capture Switch", \
1993 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1994 .count = num, \
1995 .info = alc_cap_sw_info, \
1996 .get = alc_cap_sw_get, \
1997 .put = alc_cap_sw_put, \
1998 }, \
2000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2001 .name = "Capture Volume", \
2002 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2003 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2004 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2005 .count = num, \
2006 .info = alc_cap_vol_info, \
2007 .get = alc_cap_vol_get, \
2008 .put = alc_cap_vol_put, \
2009 .tlv = { .c = alc_cap_vol_tlv }, \
2012 #define _DEFINE_CAPSRC(num) \
2014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2015 /* .name = "Capture Source", */ \
2016 .name = "Input Source", \
2017 .count = num, \
2018 .info = alc_mux_enum_info, \
2019 .get = alc_mux_enum_get, \
2020 .put = alc_mux_enum_put, \
2023 #define DEFINE_CAPMIX(num) \
2024 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2025 _DEFINE_CAPMIX(num), \
2026 _DEFINE_CAPSRC(num), \
2027 { } /* end */ \
2030 #define DEFINE_CAPMIX_NOSRC(num) \
2031 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2032 _DEFINE_CAPMIX(num), \
2033 { } /* end */ \
2036 /* up to three ADCs */
2037 DEFINE_CAPMIX(1);
2038 DEFINE_CAPMIX(2);
2039 DEFINE_CAPMIX(3);
2040 DEFINE_CAPMIX_NOSRC(1);
2041 DEFINE_CAPMIX_NOSRC(2);
2042 DEFINE_CAPMIX_NOSRC(3);
2045 * ALC880 5-stack model
2047 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2048 * Side = 0x02 (0xd)
2049 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2050 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2053 /* additional mixers to alc880_three_stack_mixer */
2054 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2055 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2056 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2057 { } /* end */
2060 /* channel source setting (6/8 channel selection for 5-stack) */
2061 /* 6ch mode */
2062 static struct hda_verb alc880_fivestack_ch6_init[] = {
2063 /* set line-in to input, mute it */
2064 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2065 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2066 { } /* end */
2069 /* 8ch mode */
2070 static struct hda_verb alc880_fivestack_ch8_init[] = {
2071 /* set line-in to output, unmute it */
2072 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2073 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2074 { } /* end */
2077 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2078 { 6, alc880_fivestack_ch6_init },
2079 { 8, alc880_fivestack_ch8_init },
2084 * ALC880 6-stack model
2086 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2087 * Side = 0x05 (0x0f)
2088 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2089 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2092 static hda_nid_t alc880_6st_dac_nids[4] = {
2093 /* front, rear, clfe, rear_surr */
2094 0x02, 0x03, 0x04, 0x05
2097 static struct hda_input_mux alc880_6stack_capture_source = {
2098 .num_items = 4,
2099 .items = {
2100 { "Mic", 0x0 },
2101 { "Front Mic", 0x1 },
2102 { "Line", 0x2 },
2103 { "CD", 0x4 },
2107 /* fixed 8-channels */
2108 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2109 { 8, NULL },
2112 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2115 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2116 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2117 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2118 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2119 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2120 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2121 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2122 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2123 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2124 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2129 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2130 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2132 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2133 .name = "Channel Mode",
2134 .info = alc_ch_mode_info,
2135 .get = alc_ch_mode_get,
2136 .put = alc_ch_mode_put,
2138 { } /* end */
2143 * ALC880 W810 model
2145 * W810 has rear IO for:
2146 * Front (DAC 02)
2147 * Surround (DAC 03)
2148 * Center/LFE (DAC 04)
2149 * Digital out (06)
2151 * The system also has a pair of internal speakers, and a headphone jack.
2152 * These are both connected to Line2 on the codec, hence to DAC 02.
2154 * There is a variable resistor to control the speaker or headphone
2155 * volume. This is a hardware-only device without a software API.
2157 * Plugging headphones in will disable the internal speakers. This is
2158 * implemented in hardware, not via the driver using jack sense. In
2159 * a similar fashion, plugging into the rear socket marked "front" will
2160 * disable both the speakers and headphones.
2162 * For input, there's a microphone jack, and an "audio in" jack.
2163 * These may not do anything useful with this driver yet, because I
2164 * haven't setup any initialization verbs for these yet...
2167 static hda_nid_t alc880_w810_dac_nids[3] = {
2168 /* front, rear/surround, clfe */
2169 0x02, 0x03, 0x04
2172 /* fixed 6 channels */
2173 static struct hda_channel_mode alc880_w810_modes[1] = {
2174 { 6, NULL }
2177 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2178 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2179 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2180 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2181 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2182 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2183 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2184 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2185 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2186 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2188 { } /* end */
2193 * Z710V model
2195 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2196 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2197 * Line = 0x1a
2200 static hda_nid_t alc880_z71v_dac_nids[1] = {
2201 0x02
2203 #define ALC880_Z71V_HP_DAC 0x03
2205 /* fixed 2 channels */
2206 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2207 { 2, NULL }
2210 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2211 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2212 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2213 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2214 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2215 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2216 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2219 { } /* end */
2224 * ALC880 F1734 model
2226 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2227 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2230 static hda_nid_t alc880_f1734_dac_nids[1] = {
2231 0x03
2233 #define ALC880_F1734_HP_DAC 0x02
2235 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2236 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2237 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2238 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2239 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2240 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2241 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2243 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2244 { } /* end */
2247 static struct hda_input_mux alc880_f1734_capture_source = {
2248 .num_items = 2,
2249 .items = {
2250 { "Mic", 0x1 },
2251 { "CD", 0x4 },
2257 * ALC880 ASUS model
2259 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2260 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2261 * Mic = 0x18, Line = 0x1a
2264 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2265 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2267 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2268 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2269 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2270 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2271 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2272 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2273 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2274 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2275 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2276 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2277 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2278 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2279 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2283 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2284 .name = "Channel Mode",
2285 .info = alc_ch_mode_info,
2286 .get = alc_ch_mode_get,
2287 .put = alc_ch_mode_put,
2289 { } /* end */
2293 * ALC880 ASUS W1V model
2295 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2296 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2297 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2300 /* additional mixers to alc880_asus_mixer */
2301 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2302 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2303 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2304 { } /* end */
2307 /* TCL S700 */
2308 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2309 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2310 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2313 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2315 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2317 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2318 { } /* end */
2321 /* Uniwill */
2322 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2323 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2324 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2325 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2326 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2327 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2328 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2329 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2330 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2331 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2332 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2341 .name = "Channel Mode",
2342 .info = alc_ch_mode_info,
2343 .get = alc_ch_mode_get,
2344 .put = alc_ch_mode_put,
2346 { } /* end */
2349 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2350 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2351 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2352 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2353 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2356 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2357 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2358 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2359 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2360 { } /* end */
2363 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2364 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2365 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2366 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2367 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2370 { } /* end */
2374 * virtual master controls
2378 * slave controls for virtual master
2380 static const char *alc_slave_vols[] = {
2381 "Front Playback Volume",
2382 "Surround Playback Volume",
2383 "Center Playback Volume",
2384 "LFE Playback Volume",
2385 "Side Playback Volume",
2386 "Headphone Playback Volume",
2387 "Speaker Playback Volume",
2388 "Mono Playback Volume",
2389 "Line-Out Playback Volume",
2390 "PCM Playback Volume",
2391 NULL,
2394 static const char *alc_slave_sws[] = {
2395 "Front Playback Switch",
2396 "Surround Playback Switch",
2397 "Center Playback Switch",
2398 "LFE Playback Switch",
2399 "Side Playback Switch",
2400 "Headphone Playback Switch",
2401 "Speaker Playback Switch",
2402 "Mono Playback Switch",
2403 "IEC958 Playback Switch",
2404 NULL,
2408 * build control elements
2411 static void alc_free_kctls(struct hda_codec *codec);
2413 /* additional beep mixers; the actual parameters are overwritten at build */
2414 static struct snd_kcontrol_new alc_beep_mixer[] = {
2415 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2416 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2417 { } /* end */
2420 static int alc_build_controls(struct hda_codec *codec)
2422 struct alc_spec *spec = codec->spec;
2423 int err;
2424 int i;
2426 for (i = 0; i < spec->num_mixers; i++) {
2427 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2428 if (err < 0)
2429 return err;
2431 if (spec->cap_mixer) {
2432 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2433 if (err < 0)
2434 return err;
2436 if (spec->multiout.dig_out_nid) {
2437 err = snd_hda_create_spdif_out_ctls(codec,
2438 spec->multiout.dig_out_nid);
2439 if (err < 0)
2440 return err;
2441 if (!spec->no_analog) {
2442 err = snd_hda_create_spdif_share_sw(codec,
2443 &spec->multiout);
2444 if (err < 0)
2445 return err;
2446 spec->multiout.share_spdif = 1;
2449 if (spec->dig_in_nid) {
2450 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2451 if (err < 0)
2452 return err;
2455 /* create beep controls if needed */
2456 if (spec->beep_amp) {
2457 struct snd_kcontrol_new *knew;
2458 for (knew = alc_beep_mixer; knew->name; knew++) {
2459 struct snd_kcontrol *kctl;
2460 kctl = snd_ctl_new1(knew, codec);
2461 if (!kctl)
2462 return -ENOMEM;
2463 kctl->private_value = spec->beep_amp;
2464 err = snd_hda_ctl_add(codec, kctl);
2465 if (err < 0)
2466 return err;
2470 /* if we have no master control, let's create it */
2471 if (!spec->no_analog &&
2472 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2473 unsigned int vmaster_tlv[4];
2474 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2475 HDA_OUTPUT, vmaster_tlv);
2476 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2477 vmaster_tlv, alc_slave_vols);
2478 if (err < 0)
2479 return err;
2481 if (!spec->no_analog &&
2482 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2483 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2484 NULL, alc_slave_sws);
2485 if (err < 0)
2486 return err;
2489 alc_free_kctls(codec); /* no longer needed */
2490 return 0;
2495 * initialize the codec volumes, etc
2499 * generic initialization of ADC, input mixers and output mixers
2501 static struct hda_verb alc880_volume_init_verbs[] = {
2503 * Unmute ADC0-2 and set the default input to mic-in
2505 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2506 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2507 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2508 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2509 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2510 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2512 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2513 * mixer widget
2514 * Note: PASD motherboards uses the Line In 2 as the input for front
2515 * panel mic (mic 2)
2517 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2523 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2524 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2527 * Set up output mixers (0x0c - 0x0f)
2529 /* set vol=0 to output mixers */
2530 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2533 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2534 /* set up input amps for analog loopback */
2535 /* Amp Indices: DAC = 0, mixer = 1 */
2536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2540 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2542 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2543 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2549 * 3-stack pin configuration:
2550 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2552 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2554 * preset connection lists of input pins
2555 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2557 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2558 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2559 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2562 * Set pin mode and muting
2564 /* set front pin widgets 0x14 for output */
2565 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2566 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2567 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2568 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2569 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2570 /* Mic2 (as headphone out) for HP output */
2571 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2573 /* Line In pin widget for input */
2574 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2575 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2576 /* Line2 (as front mic) pin widget for input and vref at 80% */
2577 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2578 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2579 /* CD pin widget for input */
2580 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2586 * 5-stack pin configuration:
2587 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2588 * line-in/side = 0x1a, f-mic = 0x1b
2590 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2592 * preset connection lists of input pins
2593 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2595 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2596 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2599 * Set pin mode and muting
2601 /* set pin widgets 0x14-0x17 for output */
2602 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2604 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2605 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2606 /* unmute pins for output (no gain on this amp) */
2607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2609 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2610 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2612 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2613 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2614 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2615 /* Mic2 (as headphone out) for HP output */
2616 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2617 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2618 /* Line In pin widget for input */
2619 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2620 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2621 /* Line2 (as front mic) pin widget for input and vref at 80% */
2622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2623 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2624 /* CD pin widget for input */
2625 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2631 * W810 pin configuration:
2632 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2634 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2635 /* hphone/speaker input selector: front DAC */
2636 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2642 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2643 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2646 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2652 * Z71V pin configuration:
2653 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2655 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2656 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2657 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2658 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2659 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2661 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2662 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2663 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2664 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2670 * 6-stack pin configuration:
2671 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2672 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2674 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2675 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2677 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2678 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2679 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2680 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2681 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2682 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2683 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2686 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2687 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2688 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2689 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2693 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2694 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2700 * Uniwill pin configuration:
2701 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2702 * line = 0x1a
2704 static struct hda_verb alc880_uniwill_init_verbs[] = {
2705 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2709 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2711 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2712 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2713 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2714 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2717 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2718 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2719 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2720 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2722 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2724 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2725 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2726 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2728 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2729 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2730 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2732 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2733 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2739 * Uniwill P53
2740 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2742 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2743 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2745 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2746 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2750 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2758 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2759 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2760 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2761 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2762 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2765 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2766 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2771 static struct hda_verb alc880_beep_init_verbs[] = {
2772 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2776 /* auto-toggle front mic */
2777 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2779 unsigned int present;
2780 unsigned char bits;
2782 present = snd_hda_codec_read(codec, 0x18, 0,
2783 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2784 bits = present ? HDA_AMP_MUTE : 0;
2785 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2788 static void alc880_uniwill_setup(struct hda_codec *codec)
2790 struct alc_spec *spec = codec->spec;
2792 spec->autocfg.hp_pins[0] = 0x14;
2793 spec->autocfg.speaker_pins[0] = 0x15;
2794 spec->autocfg.speaker_pins[0] = 0x16;
2797 static void alc880_uniwill_init_hook(struct hda_codec *codec)
2799 alc_automute_amp(codec);
2800 alc880_uniwill_mic_automute(codec);
2803 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2804 unsigned int res)
2806 /* Looks like the unsol event is incompatible with the standard
2807 * definition. 4bit tag is placed at 28 bit!
2809 switch (res >> 28) {
2810 case ALC880_MIC_EVENT:
2811 alc880_uniwill_mic_automute(codec);
2812 break;
2813 default:
2814 alc_automute_amp_unsol_event(codec, res);
2815 break;
2819 static void alc880_uniwill_p53_setup(struct hda_codec *codec)
2821 struct alc_spec *spec = codec->spec;
2823 spec->autocfg.hp_pins[0] = 0x14;
2824 spec->autocfg.speaker_pins[0] = 0x15;
2827 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2829 unsigned int present;
2831 present = snd_hda_codec_read(codec, 0x21, 0,
2832 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2833 present &= HDA_AMP_VOLMASK;
2834 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2835 HDA_AMP_VOLMASK, present);
2836 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2837 HDA_AMP_VOLMASK, present);
2840 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2841 unsigned int res)
2843 /* Looks like the unsol event is incompatible with the standard
2844 * definition. 4bit tag is placed at 28 bit!
2846 if ((res >> 28) == ALC880_DCVOL_EVENT)
2847 alc880_uniwill_p53_dcvol_automute(codec);
2848 else
2849 alc_automute_amp_unsol_event(codec, res);
2853 * F1734 pin configuration:
2854 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2856 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2857 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2858 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2859 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2860 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2861 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2863 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2864 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2865 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2866 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2868 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2869 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2870 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2871 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2872 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2873 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2874 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2875 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2876 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2878 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2879 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2885 * ASUS pin configuration:
2886 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2888 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2889 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2890 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2891 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2892 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2894 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2895 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2896 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2898 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2899 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2900 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2903 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2905 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2907 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2909 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2911 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2916 /* Enable GPIO mask and set output */
2917 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2918 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2919 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
2921 /* Clevo m520g init */
2922 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2923 /* headphone output */
2924 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2925 /* line-out */
2926 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2928 /* Line-in */
2929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2931 /* CD */
2932 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2933 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2934 /* Mic1 (rear panel) */
2935 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2936 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2937 /* Mic2 (front panel) */
2938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2939 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2940 /* headphone */
2941 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2942 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2943 /* change to EAPD mode */
2944 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2945 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2950 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2951 /* change to EAPD mode */
2952 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2953 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2955 /* Headphone output */
2956 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2957 /* Front output*/
2958 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2959 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2961 /* Line In pin widget for input */
2962 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2963 /* CD pin widget for input */
2964 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2965 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2966 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2968 /* change to EAPD mode */
2969 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2970 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2976 * LG m1 express dual
2978 * Pin assignment:
2979 * Rear Line-In/Out (blue): 0x14
2980 * Build-in Mic-In: 0x15
2981 * Speaker-out: 0x17
2982 * HP-Out (green): 0x1b
2983 * Mic-In/Out (red): 0x19
2984 * SPDIF-Out: 0x1e
2987 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2988 static hda_nid_t alc880_lg_dac_nids[3] = {
2989 0x05, 0x02, 0x03
2992 /* seems analog CD is not working */
2993 static struct hda_input_mux alc880_lg_capture_source = {
2994 .num_items = 3,
2995 .items = {
2996 { "Mic", 0x1 },
2997 { "Line", 0x5 },
2998 { "Internal Mic", 0x6 },
3002 /* 2,4,6 channel modes */
3003 static struct hda_verb alc880_lg_ch2_init[] = {
3004 /* set line-in and mic-in to input */
3005 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3006 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3010 static struct hda_verb alc880_lg_ch4_init[] = {
3011 /* set line-in to out and mic-in to input */
3012 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3013 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3017 static struct hda_verb alc880_lg_ch6_init[] = {
3018 /* set line-in and mic-in to output */
3019 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3020 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3024 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3025 { 2, alc880_lg_ch2_init },
3026 { 4, alc880_lg_ch4_init },
3027 { 6, alc880_lg_ch6_init },
3030 static struct snd_kcontrol_new alc880_lg_mixer[] = {
3031 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3032 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
3033 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3034 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3035 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3036 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3037 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3038 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3039 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3040 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3041 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3042 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3043 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3044 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3047 .name = "Channel Mode",
3048 .info = alc_ch_mode_info,
3049 .get = alc_ch_mode_get,
3050 .put = alc_ch_mode_put,
3052 { } /* end */
3055 static struct hda_verb alc880_lg_init_verbs[] = {
3056 /* set capture source to mic-in */
3057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3060 /* mute all amp mixer inputs */
3061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
3062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3064 /* line-in to input */
3065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3066 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3067 /* built-in mic */
3068 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3070 /* speaker-out */
3071 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3072 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3073 /* mic-in to input */
3074 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3075 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3076 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3077 /* HP-out */
3078 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3079 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3080 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3081 /* jack sense */
3082 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3086 /* toggle speaker-output according to the hp-jack state */
3087 static void alc880_lg_setup(struct hda_codec *codec)
3089 struct alc_spec *spec = codec->spec;
3091 spec->autocfg.hp_pins[0] = 0x1b;
3092 spec->autocfg.speaker_pins[0] = 0x17;
3096 * LG LW20
3098 * Pin assignment:
3099 * Speaker-out: 0x14
3100 * Mic-In: 0x18
3101 * Built-in Mic-In: 0x19
3102 * Line-In: 0x1b
3103 * HP-Out: 0x1a
3104 * SPDIF-Out: 0x1e
3107 static struct hda_input_mux alc880_lg_lw_capture_source = {
3108 .num_items = 3,
3109 .items = {
3110 { "Mic", 0x0 },
3111 { "Internal Mic", 0x1 },
3112 { "Line In", 0x2 },
3116 #define alc880_lg_lw_modes alc880_threestack_modes
3118 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
3119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3120 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3121 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3122 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3123 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3124 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3125 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3126 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3131 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3132 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3135 .name = "Channel Mode",
3136 .info = alc_ch_mode_info,
3137 .get = alc_ch_mode_get,
3138 .put = alc_ch_mode_put,
3140 { } /* end */
3143 static struct hda_verb alc880_lg_lw_init_verbs[] = {
3144 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3145 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3146 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3148 /* set capture source to mic-in */
3149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3151 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3153 /* speaker-out */
3154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3156 /* HP-out */
3157 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3158 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3159 /* mic-in to input */
3160 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3162 /* built-in mic */
3163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3164 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3165 /* jack sense */
3166 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3170 /* toggle speaker-output according to the hp-jack state */
3171 static void alc880_lg_lw_setup(struct hda_codec *codec)
3173 struct alc_spec *spec = codec->spec;
3175 spec->autocfg.hp_pins[0] = 0x1b;
3176 spec->autocfg.speaker_pins[0] = 0x14;
3179 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3180 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3181 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3183 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3184 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3185 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3186 { } /* end */
3189 static struct hda_input_mux alc880_medion_rim_capture_source = {
3190 .num_items = 2,
3191 .items = {
3192 { "Mic", 0x0 },
3193 { "Internal Mic", 0x1 },
3197 static struct hda_verb alc880_medion_rim_init_verbs[] = {
3198 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3201 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3203 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3204 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3206 /* Mic2 (as headphone out) for HP output */
3207 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3208 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3209 /* Internal Speaker */
3210 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3211 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3213 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3214 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3216 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3220 /* toggle speaker-output according to the hp-jack state */
3221 static void alc880_medion_rim_automute(struct hda_codec *codec)
3223 struct alc_spec *spec = codec->spec;
3224 alc_automute_amp(codec);
3225 /* toggle EAPD */
3226 if (spec->jack_present)
3227 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3228 else
3229 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3232 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3233 unsigned int res)
3235 /* Looks like the unsol event is incompatible with the standard
3236 * definition. 4bit tag is placed at 28 bit!
3238 if ((res >> 28) == ALC880_HP_EVENT)
3239 alc880_medion_rim_automute(codec);
3242 static void alc880_medion_rim_setup(struct hda_codec *codec)
3244 struct alc_spec *spec = codec->spec;
3246 spec->autocfg.hp_pins[0] = 0x14;
3247 spec->autocfg.speaker_pins[0] = 0x1b;
3250 #ifdef CONFIG_SND_HDA_POWER_SAVE
3251 static struct hda_amp_list alc880_loopbacks[] = {
3252 { 0x0b, HDA_INPUT, 0 },
3253 { 0x0b, HDA_INPUT, 1 },
3254 { 0x0b, HDA_INPUT, 2 },
3255 { 0x0b, HDA_INPUT, 3 },
3256 { 0x0b, HDA_INPUT, 4 },
3257 { } /* end */
3260 static struct hda_amp_list alc880_lg_loopbacks[] = {
3261 { 0x0b, HDA_INPUT, 1 },
3262 { 0x0b, HDA_INPUT, 6 },
3263 { 0x0b, HDA_INPUT, 7 },
3264 { } /* end */
3266 #endif
3269 * Common callbacks
3272 static int alc_init(struct hda_codec *codec)
3274 struct alc_spec *spec = codec->spec;
3275 unsigned int i;
3277 alc_fix_pll(codec);
3278 alc_auto_init_amp(codec, spec->init_amp);
3280 for (i = 0; i < spec->num_init_verbs; i++)
3281 snd_hda_sequence_write(codec, spec->init_verbs[i]);
3283 if (spec->init_hook)
3284 spec->init_hook(codec);
3286 return 0;
3289 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3291 struct alc_spec *spec = codec->spec;
3293 if (spec->unsol_event)
3294 spec->unsol_event(codec, res);
3297 #ifdef CONFIG_SND_HDA_POWER_SAVE
3298 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3300 struct alc_spec *spec = codec->spec;
3301 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3303 #endif
3306 * Analog playback callbacks
3308 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3309 struct hda_codec *codec,
3310 struct snd_pcm_substream *substream)
3312 struct alc_spec *spec = codec->spec;
3313 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3314 hinfo);
3317 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3318 struct hda_codec *codec,
3319 unsigned int stream_tag,
3320 unsigned int format,
3321 struct snd_pcm_substream *substream)
3323 struct alc_spec *spec = codec->spec;
3324 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3325 stream_tag, format, substream);
3328 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3329 struct hda_codec *codec,
3330 struct snd_pcm_substream *substream)
3332 struct alc_spec *spec = codec->spec;
3333 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3337 * Digital out
3339 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3340 struct hda_codec *codec,
3341 struct snd_pcm_substream *substream)
3343 struct alc_spec *spec = codec->spec;
3344 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3347 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3348 struct hda_codec *codec,
3349 unsigned int stream_tag,
3350 unsigned int format,
3351 struct snd_pcm_substream *substream)
3353 struct alc_spec *spec = codec->spec;
3354 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3355 stream_tag, format, substream);
3358 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3359 struct hda_codec *codec,
3360 struct snd_pcm_substream *substream)
3362 struct alc_spec *spec = codec->spec;
3363 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3366 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3367 struct hda_codec *codec,
3368 struct snd_pcm_substream *substream)
3370 struct alc_spec *spec = codec->spec;
3371 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3375 * Analog capture
3377 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3378 struct hda_codec *codec,
3379 unsigned int stream_tag,
3380 unsigned int format,
3381 struct snd_pcm_substream *substream)
3383 struct alc_spec *spec = codec->spec;
3385 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
3386 stream_tag, 0, format);
3387 return 0;
3390 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3391 struct hda_codec *codec,
3392 struct snd_pcm_substream *substream)
3394 struct alc_spec *spec = codec->spec;
3396 snd_hda_codec_cleanup_stream(codec,
3397 spec->adc_nids[substream->number + 1]);
3398 return 0;
3404 static struct hda_pcm_stream alc880_pcm_analog_playback = {
3405 .substreams = 1,
3406 .channels_min = 2,
3407 .channels_max = 8,
3408 /* NID is set in alc_build_pcms */
3409 .ops = {
3410 .open = alc880_playback_pcm_open,
3411 .prepare = alc880_playback_pcm_prepare,
3412 .cleanup = alc880_playback_pcm_cleanup
3416 static struct hda_pcm_stream alc880_pcm_analog_capture = {
3417 .substreams = 1,
3418 .channels_min = 2,
3419 .channels_max = 2,
3420 /* NID is set in alc_build_pcms */
3423 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3424 .substreams = 1,
3425 .channels_min = 2,
3426 .channels_max = 2,
3427 /* NID is set in alc_build_pcms */
3430 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3431 .substreams = 2, /* can be overridden */
3432 .channels_min = 2,
3433 .channels_max = 2,
3434 /* NID is set in alc_build_pcms */
3435 .ops = {
3436 .prepare = alc880_alt_capture_pcm_prepare,
3437 .cleanup = alc880_alt_capture_pcm_cleanup
3441 static struct hda_pcm_stream alc880_pcm_digital_playback = {
3442 .substreams = 1,
3443 .channels_min = 2,
3444 .channels_max = 2,
3445 /* NID is set in alc_build_pcms */
3446 .ops = {
3447 .open = alc880_dig_playback_pcm_open,
3448 .close = alc880_dig_playback_pcm_close,
3449 .prepare = alc880_dig_playback_pcm_prepare,
3450 .cleanup = alc880_dig_playback_pcm_cleanup
3454 static struct hda_pcm_stream alc880_pcm_digital_capture = {
3455 .substreams = 1,
3456 .channels_min = 2,
3457 .channels_max = 2,
3458 /* NID is set in alc_build_pcms */
3461 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
3462 static struct hda_pcm_stream alc_pcm_null_stream = {
3463 .substreams = 0,
3464 .channels_min = 0,
3465 .channels_max = 0,
3468 static int alc_build_pcms(struct hda_codec *codec)
3470 struct alc_spec *spec = codec->spec;
3471 struct hda_pcm *info = spec->pcm_rec;
3472 int i;
3474 codec->num_pcms = 1;
3475 codec->pcm_info = info;
3477 if (spec->no_analog)
3478 goto skip_analog;
3480 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3481 "%s Analog", codec->chip_name);
3482 info->name = spec->stream_name_analog;
3484 if (spec->stream_analog_playback) {
3485 if (snd_BUG_ON(!spec->multiout.dac_nids))
3486 return -EINVAL;
3487 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3488 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3490 if (spec->stream_analog_capture) {
3491 if (snd_BUG_ON(!spec->adc_nids))
3492 return -EINVAL;
3493 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3494 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3497 if (spec->channel_mode) {
3498 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3499 for (i = 0; i < spec->num_channel_mode; i++) {
3500 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3501 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3506 skip_analog:
3507 /* SPDIF for stream index #1 */
3508 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3509 snprintf(spec->stream_name_digital,
3510 sizeof(spec->stream_name_digital),
3511 "%s Digital", codec->chip_name);
3512 codec->num_pcms = 2;
3513 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
3514 info = spec->pcm_rec + 1;
3515 info->name = spec->stream_name_digital;
3516 if (spec->dig_out_type)
3517 info->pcm_type = spec->dig_out_type;
3518 else
3519 info->pcm_type = HDA_PCM_TYPE_SPDIF;
3520 if (spec->multiout.dig_out_nid &&
3521 spec->stream_digital_playback) {
3522 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3523 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3525 if (spec->dig_in_nid &&
3526 spec->stream_digital_capture) {
3527 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3528 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3530 /* FIXME: do we need this for all Realtek codec models? */
3531 codec->spdif_status_reset = 1;
3534 if (spec->no_analog)
3535 return 0;
3537 /* If the use of more than one ADC is requested for the current
3538 * model, configure a second analog capture-only PCM.
3540 /* Additional Analaog capture for index #2 */
3541 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3542 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
3543 codec->num_pcms = 3;
3544 info = spec->pcm_rec + 2;
3545 info->name = spec->stream_name_analog;
3546 if (spec->alt_dac_nid) {
3547 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3548 *spec->stream_analog_alt_playback;
3549 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3550 spec->alt_dac_nid;
3551 } else {
3552 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3553 alc_pcm_null_stream;
3554 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3556 if (spec->num_adc_nids > 1) {
3557 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3558 *spec->stream_analog_alt_capture;
3559 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3560 spec->adc_nids[1];
3561 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3562 spec->num_adc_nids - 1;
3563 } else {
3564 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3565 alc_pcm_null_stream;
3566 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
3570 return 0;
3573 static void alc_free_kctls(struct hda_codec *codec)
3575 struct alc_spec *spec = codec->spec;
3577 if (spec->kctls.list) {
3578 struct snd_kcontrol_new *kctl = spec->kctls.list;
3579 int i;
3580 for (i = 0; i < spec->kctls.used; i++)
3581 kfree(kctl[i].name);
3583 snd_array_free(&spec->kctls);
3586 static void alc_free(struct hda_codec *codec)
3588 struct alc_spec *spec = codec->spec;
3590 if (!spec)
3591 return;
3593 alc_free_kctls(codec);
3594 kfree(spec);
3595 snd_hda_detach_beep_device(codec);
3598 #ifdef SND_HDA_NEEDS_RESUME
3599 static int alc_resume(struct hda_codec *codec)
3601 codec->patch_ops.init(codec);
3602 snd_hda_codec_resume_amp(codec);
3603 snd_hda_codec_resume_cache(codec);
3604 return 0;
3606 #endif
3610 static struct hda_codec_ops alc_patch_ops = {
3611 .build_controls = alc_build_controls,
3612 .build_pcms = alc_build_pcms,
3613 .init = alc_init,
3614 .free = alc_free,
3615 .unsol_event = alc_unsol_event,
3616 #ifdef SND_HDA_NEEDS_RESUME
3617 .resume = alc_resume,
3618 #endif
3619 #ifdef CONFIG_SND_HDA_POWER_SAVE
3620 .check_power_status = alc_check_power_status,
3621 #endif
3626 * Test configuration for debugging
3628 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3629 * enum controls.
3631 #ifdef CONFIG_SND_DEBUG
3632 static hda_nid_t alc880_test_dac_nids[4] = {
3633 0x02, 0x03, 0x04, 0x05
3636 static struct hda_input_mux alc880_test_capture_source = {
3637 .num_items = 7,
3638 .items = {
3639 { "In-1", 0x0 },
3640 { "In-2", 0x1 },
3641 { "In-3", 0x2 },
3642 { "In-4", 0x3 },
3643 { "CD", 0x4 },
3644 { "Front", 0x5 },
3645 { "Surround", 0x6 },
3649 static struct hda_channel_mode alc880_test_modes[4] = {
3650 { 2, NULL },
3651 { 4, NULL },
3652 { 6, NULL },
3653 { 8, NULL },
3656 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3657 struct snd_ctl_elem_info *uinfo)
3659 static char *texts[] = {
3660 "N/A", "Line Out", "HP Out",
3661 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3663 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3664 uinfo->count = 1;
3665 uinfo->value.enumerated.items = 8;
3666 if (uinfo->value.enumerated.item >= 8)
3667 uinfo->value.enumerated.item = 7;
3668 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3669 return 0;
3672 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3673 struct snd_ctl_elem_value *ucontrol)
3675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3676 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3677 unsigned int pin_ctl, item = 0;
3679 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3680 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3681 if (pin_ctl & AC_PINCTL_OUT_EN) {
3682 if (pin_ctl & AC_PINCTL_HP_EN)
3683 item = 2;
3684 else
3685 item = 1;
3686 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3687 switch (pin_ctl & AC_PINCTL_VREFEN) {
3688 case AC_PINCTL_VREF_HIZ: item = 3; break;
3689 case AC_PINCTL_VREF_50: item = 4; break;
3690 case AC_PINCTL_VREF_GRD: item = 5; break;
3691 case AC_PINCTL_VREF_80: item = 6; break;
3692 case AC_PINCTL_VREF_100: item = 7; break;
3695 ucontrol->value.enumerated.item[0] = item;
3696 return 0;
3699 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3700 struct snd_ctl_elem_value *ucontrol)
3702 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3703 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3704 static unsigned int ctls[] = {
3705 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3706 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3707 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3708 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3709 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3710 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3712 unsigned int old_ctl, new_ctl;
3714 old_ctl = snd_hda_codec_read(codec, nid, 0,
3715 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3716 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3717 if (old_ctl != new_ctl) {
3718 int val;
3719 snd_hda_codec_write_cache(codec, nid, 0,
3720 AC_VERB_SET_PIN_WIDGET_CONTROL,
3721 new_ctl);
3722 val = ucontrol->value.enumerated.item[0] >= 3 ?
3723 HDA_AMP_MUTE : 0;
3724 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3725 HDA_AMP_MUTE, val);
3726 return 1;
3728 return 0;
3731 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3732 struct snd_ctl_elem_info *uinfo)
3734 static char *texts[] = {
3735 "Front", "Surround", "CLFE", "Side"
3737 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3738 uinfo->count = 1;
3739 uinfo->value.enumerated.items = 4;
3740 if (uinfo->value.enumerated.item >= 4)
3741 uinfo->value.enumerated.item = 3;
3742 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3743 return 0;
3746 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3747 struct snd_ctl_elem_value *ucontrol)
3749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3750 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3751 unsigned int sel;
3753 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3754 ucontrol->value.enumerated.item[0] = sel & 3;
3755 return 0;
3758 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3759 struct snd_ctl_elem_value *ucontrol)
3761 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3762 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3763 unsigned int sel;
3765 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3766 if (ucontrol->value.enumerated.item[0] != sel) {
3767 sel = ucontrol->value.enumerated.item[0] & 3;
3768 snd_hda_codec_write_cache(codec, nid, 0,
3769 AC_VERB_SET_CONNECT_SEL, sel);
3770 return 1;
3772 return 0;
3775 #define PIN_CTL_TEST(xname,nid) { \
3776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3777 .name = xname, \
3778 .info = alc_test_pin_ctl_info, \
3779 .get = alc_test_pin_ctl_get, \
3780 .put = alc_test_pin_ctl_put, \
3781 .private_value = nid \
3784 #define PIN_SRC_TEST(xname,nid) { \
3785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3786 .name = xname, \
3787 .info = alc_test_pin_src_info, \
3788 .get = alc_test_pin_src_get, \
3789 .put = alc_test_pin_src_put, \
3790 .private_value = nid \
3793 static struct snd_kcontrol_new alc880_test_mixer[] = {
3794 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3795 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3796 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3797 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3798 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3799 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3800 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3801 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
3802 PIN_CTL_TEST("Front Pin Mode", 0x14),
3803 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3804 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3805 PIN_CTL_TEST("Side Pin Mode", 0x17),
3806 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3807 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3808 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3809 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3810 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3811 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3812 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3813 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3814 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3815 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3816 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3817 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3818 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3819 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3820 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3821 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3822 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3823 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
3825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3826 .name = "Channel Mode",
3827 .info = alc_ch_mode_info,
3828 .get = alc_ch_mode_get,
3829 .put = alc_ch_mode_put,
3831 { } /* end */
3834 static struct hda_verb alc880_test_init_verbs[] = {
3835 /* Unmute inputs of 0x0c - 0x0f */
3836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3838 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3839 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3840 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3841 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3842 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3844 /* Vol output for 0x0c-0x0f */
3845 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3846 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3847 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3848 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3849 /* Set output pins 0x14-0x17 */
3850 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3851 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3852 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3853 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3854 /* Unmute output pins 0x14-0x17 */
3855 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3857 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3858 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3859 /* Set input pins 0x18-0x1c */
3860 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3861 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3862 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3863 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3864 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3865 /* Mute input pins 0x18-0x1b */
3866 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3867 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3868 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3869 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3870 /* ADC set up */
3871 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3872 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3873 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3874 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3875 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3876 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3877 /* Analog input/passthru */
3878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3885 #endif
3890 static const char *alc880_models[ALC880_MODEL_LAST] = {
3891 [ALC880_3ST] = "3stack",
3892 [ALC880_TCL_S700] = "tcl",
3893 [ALC880_3ST_DIG] = "3stack-digout",
3894 [ALC880_CLEVO] = "clevo",
3895 [ALC880_5ST] = "5stack",
3896 [ALC880_5ST_DIG] = "5stack-digout",
3897 [ALC880_W810] = "w810",
3898 [ALC880_Z71V] = "z71v",
3899 [ALC880_6ST] = "6stack",
3900 [ALC880_6ST_DIG] = "6stack-digout",
3901 [ALC880_ASUS] = "asus",
3902 [ALC880_ASUS_W1V] = "asus-w1v",
3903 [ALC880_ASUS_DIG] = "asus-dig",
3904 [ALC880_ASUS_DIG2] = "asus-dig2",
3905 [ALC880_UNIWILL_DIG] = "uniwill",
3906 [ALC880_UNIWILL_P53] = "uniwill-p53",
3907 [ALC880_FUJITSU] = "fujitsu",
3908 [ALC880_F1734] = "F1734",
3909 [ALC880_LG] = "lg",
3910 [ALC880_LG_LW] = "lg-lw",
3911 [ALC880_MEDION_RIM] = "medion",
3912 #ifdef CONFIG_SND_DEBUG
3913 [ALC880_TEST] = "test",
3914 #endif
3915 [ALC880_AUTO] = "auto",
3918 static struct snd_pci_quirk alc880_cfg_tbl[] = {
3919 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
3920 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3921 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3922 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3923 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3924 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3925 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3926 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3927 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
3928 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3929 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
3930 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3931 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3932 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3933 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3934 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3935 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3936 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3937 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3938 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3939 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
3940 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
3941 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3942 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3943 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
3944 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
3945 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
3946 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3947 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
3948 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3949 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
3950 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3951 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3952 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3953 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
3954 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3955 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
3956 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
3957 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
3958 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
3959 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
3960 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3961 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
3962 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
3963 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
3964 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
3965 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
3966 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
3967 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
3968 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
3969 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
3970 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
3971 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3972 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
3973 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
3974 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3975 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3976 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3977 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
3978 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3979 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
3980 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
3981 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
3982 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3983 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
3984 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3985 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3986 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
3987 /* default Intel */
3988 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
3989 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3990 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
3995 * ALC880 codec presets
3997 static struct alc_config_preset alc880_presets[] = {
3998 [ALC880_3ST] = {
3999 .mixers = { alc880_three_stack_mixer },
4000 .init_verbs = { alc880_volume_init_verbs,
4001 alc880_pin_3stack_init_verbs },
4002 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4003 .dac_nids = alc880_dac_nids,
4004 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4005 .channel_mode = alc880_threestack_modes,
4006 .need_dac_fix = 1,
4007 .input_mux = &alc880_capture_source,
4009 [ALC880_3ST_DIG] = {
4010 .mixers = { alc880_three_stack_mixer },
4011 .init_verbs = { alc880_volume_init_verbs,
4012 alc880_pin_3stack_init_verbs },
4013 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4014 .dac_nids = alc880_dac_nids,
4015 .dig_out_nid = ALC880_DIGOUT_NID,
4016 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4017 .channel_mode = alc880_threestack_modes,
4018 .need_dac_fix = 1,
4019 .input_mux = &alc880_capture_source,
4021 [ALC880_TCL_S700] = {
4022 .mixers = { alc880_tcl_s700_mixer },
4023 .init_verbs = { alc880_volume_init_verbs,
4024 alc880_pin_tcl_S700_init_verbs,
4025 alc880_gpio2_init_verbs },
4026 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4027 .dac_nids = alc880_dac_nids,
4028 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4029 .num_adc_nids = 1, /* single ADC */
4030 .hp_nid = 0x03,
4031 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4032 .channel_mode = alc880_2_jack_modes,
4033 .input_mux = &alc880_capture_source,
4035 [ALC880_5ST] = {
4036 .mixers = { alc880_three_stack_mixer,
4037 alc880_five_stack_mixer},
4038 .init_verbs = { alc880_volume_init_verbs,
4039 alc880_pin_5stack_init_verbs },
4040 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4041 .dac_nids = alc880_dac_nids,
4042 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4043 .channel_mode = alc880_fivestack_modes,
4044 .input_mux = &alc880_capture_source,
4046 [ALC880_5ST_DIG] = {
4047 .mixers = { alc880_three_stack_mixer,
4048 alc880_five_stack_mixer },
4049 .init_verbs = { alc880_volume_init_verbs,
4050 alc880_pin_5stack_init_verbs },
4051 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4052 .dac_nids = alc880_dac_nids,
4053 .dig_out_nid = ALC880_DIGOUT_NID,
4054 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4055 .channel_mode = alc880_fivestack_modes,
4056 .input_mux = &alc880_capture_source,
4058 [ALC880_6ST] = {
4059 .mixers = { alc880_six_stack_mixer },
4060 .init_verbs = { alc880_volume_init_verbs,
4061 alc880_pin_6stack_init_verbs },
4062 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4063 .dac_nids = alc880_6st_dac_nids,
4064 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4065 .channel_mode = alc880_sixstack_modes,
4066 .input_mux = &alc880_6stack_capture_source,
4068 [ALC880_6ST_DIG] = {
4069 .mixers = { alc880_six_stack_mixer },
4070 .init_verbs = { alc880_volume_init_verbs,
4071 alc880_pin_6stack_init_verbs },
4072 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4073 .dac_nids = alc880_6st_dac_nids,
4074 .dig_out_nid = ALC880_DIGOUT_NID,
4075 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4076 .channel_mode = alc880_sixstack_modes,
4077 .input_mux = &alc880_6stack_capture_source,
4079 [ALC880_W810] = {
4080 .mixers = { alc880_w810_base_mixer },
4081 .init_verbs = { alc880_volume_init_verbs,
4082 alc880_pin_w810_init_verbs,
4083 alc880_gpio2_init_verbs },
4084 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4085 .dac_nids = alc880_w810_dac_nids,
4086 .dig_out_nid = ALC880_DIGOUT_NID,
4087 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4088 .channel_mode = alc880_w810_modes,
4089 .input_mux = &alc880_capture_source,
4091 [ALC880_Z71V] = {
4092 .mixers = { alc880_z71v_mixer },
4093 .init_verbs = { alc880_volume_init_verbs,
4094 alc880_pin_z71v_init_verbs },
4095 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4096 .dac_nids = alc880_z71v_dac_nids,
4097 .dig_out_nid = ALC880_DIGOUT_NID,
4098 .hp_nid = 0x03,
4099 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4100 .channel_mode = alc880_2_jack_modes,
4101 .input_mux = &alc880_capture_source,
4103 [ALC880_F1734] = {
4104 .mixers = { alc880_f1734_mixer },
4105 .init_verbs = { alc880_volume_init_verbs,
4106 alc880_pin_f1734_init_verbs },
4107 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4108 .dac_nids = alc880_f1734_dac_nids,
4109 .hp_nid = 0x02,
4110 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4111 .channel_mode = alc880_2_jack_modes,
4112 .input_mux = &alc880_f1734_capture_source,
4113 .unsol_event = alc880_uniwill_p53_unsol_event,
4114 .setup = alc880_uniwill_p53_setup,
4115 .init_hook = alc_automute_amp,
4117 [ALC880_ASUS] = {
4118 .mixers = { alc880_asus_mixer },
4119 .init_verbs = { alc880_volume_init_verbs,
4120 alc880_pin_asus_init_verbs,
4121 alc880_gpio1_init_verbs },
4122 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4123 .dac_nids = alc880_asus_dac_nids,
4124 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4125 .channel_mode = alc880_asus_modes,
4126 .need_dac_fix = 1,
4127 .input_mux = &alc880_capture_source,
4129 [ALC880_ASUS_DIG] = {
4130 .mixers = { alc880_asus_mixer },
4131 .init_verbs = { alc880_volume_init_verbs,
4132 alc880_pin_asus_init_verbs,
4133 alc880_gpio1_init_verbs },
4134 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4135 .dac_nids = alc880_asus_dac_nids,
4136 .dig_out_nid = ALC880_DIGOUT_NID,
4137 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4138 .channel_mode = alc880_asus_modes,
4139 .need_dac_fix = 1,
4140 .input_mux = &alc880_capture_source,
4142 [ALC880_ASUS_DIG2] = {
4143 .mixers = { alc880_asus_mixer },
4144 .init_verbs = { alc880_volume_init_verbs,
4145 alc880_pin_asus_init_verbs,
4146 alc880_gpio2_init_verbs }, /* use GPIO2 */
4147 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4148 .dac_nids = alc880_asus_dac_nids,
4149 .dig_out_nid = ALC880_DIGOUT_NID,
4150 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4151 .channel_mode = alc880_asus_modes,
4152 .need_dac_fix = 1,
4153 .input_mux = &alc880_capture_source,
4155 [ALC880_ASUS_W1V] = {
4156 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
4157 .init_verbs = { alc880_volume_init_verbs,
4158 alc880_pin_asus_init_verbs,
4159 alc880_gpio1_init_verbs },
4160 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4161 .dac_nids = alc880_asus_dac_nids,
4162 .dig_out_nid = ALC880_DIGOUT_NID,
4163 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4164 .channel_mode = alc880_asus_modes,
4165 .need_dac_fix = 1,
4166 .input_mux = &alc880_capture_source,
4168 [ALC880_UNIWILL_DIG] = {
4169 .mixers = { alc880_asus_mixer },
4170 .init_verbs = { alc880_volume_init_verbs,
4171 alc880_pin_asus_init_verbs },
4172 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4173 .dac_nids = alc880_asus_dac_nids,
4174 .dig_out_nid = ALC880_DIGOUT_NID,
4175 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4176 .channel_mode = alc880_asus_modes,
4177 .need_dac_fix = 1,
4178 .input_mux = &alc880_capture_source,
4180 [ALC880_UNIWILL] = {
4181 .mixers = { alc880_uniwill_mixer },
4182 .init_verbs = { alc880_volume_init_verbs,
4183 alc880_uniwill_init_verbs },
4184 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4185 .dac_nids = alc880_asus_dac_nids,
4186 .dig_out_nid = ALC880_DIGOUT_NID,
4187 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4188 .channel_mode = alc880_threestack_modes,
4189 .need_dac_fix = 1,
4190 .input_mux = &alc880_capture_source,
4191 .unsol_event = alc880_uniwill_unsol_event,
4192 .setup = alc880_uniwill_setup,
4193 .init_hook = alc880_uniwill_init_hook,
4195 [ALC880_UNIWILL_P53] = {
4196 .mixers = { alc880_uniwill_p53_mixer },
4197 .init_verbs = { alc880_volume_init_verbs,
4198 alc880_uniwill_p53_init_verbs },
4199 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4200 .dac_nids = alc880_asus_dac_nids,
4201 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4202 .channel_mode = alc880_threestack_modes,
4203 .input_mux = &alc880_capture_source,
4204 .unsol_event = alc880_uniwill_p53_unsol_event,
4205 .setup = alc880_uniwill_p53_setup,
4206 .init_hook = alc_automute_amp,
4208 [ALC880_FUJITSU] = {
4209 .mixers = { alc880_fujitsu_mixer },
4210 .init_verbs = { alc880_volume_init_verbs,
4211 alc880_uniwill_p53_init_verbs,
4212 alc880_beep_init_verbs },
4213 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4214 .dac_nids = alc880_dac_nids,
4215 .dig_out_nid = ALC880_DIGOUT_NID,
4216 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4217 .channel_mode = alc880_2_jack_modes,
4218 .input_mux = &alc880_capture_source,
4219 .unsol_event = alc880_uniwill_p53_unsol_event,
4220 .setup = alc880_uniwill_p53_setup,
4221 .init_hook = alc_automute_amp,
4223 [ALC880_CLEVO] = {
4224 .mixers = { alc880_three_stack_mixer },
4225 .init_verbs = { alc880_volume_init_verbs,
4226 alc880_pin_clevo_init_verbs },
4227 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4228 .dac_nids = alc880_dac_nids,
4229 .hp_nid = 0x03,
4230 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4231 .channel_mode = alc880_threestack_modes,
4232 .need_dac_fix = 1,
4233 .input_mux = &alc880_capture_source,
4235 [ALC880_LG] = {
4236 .mixers = { alc880_lg_mixer },
4237 .init_verbs = { alc880_volume_init_verbs,
4238 alc880_lg_init_verbs },
4239 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4240 .dac_nids = alc880_lg_dac_nids,
4241 .dig_out_nid = ALC880_DIGOUT_NID,
4242 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4243 .channel_mode = alc880_lg_ch_modes,
4244 .need_dac_fix = 1,
4245 .input_mux = &alc880_lg_capture_source,
4246 .unsol_event = alc_automute_amp_unsol_event,
4247 .setup = alc880_lg_setup,
4248 .init_hook = alc_automute_amp,
4249 #ifdef CONFIG_SND_HDA_POWER_SAVE
4250 .loopbacks = alc880_lg_loopbacks,
4251 #endif
4253 [ALC880_LG_LW] = {
4254 .mixers = { alc880_lg_lw_mixer },
4255 .init_verbs = { alc880_volume_init_verbs,
4256 alc880_lg_lw_init_verbs },
4257 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4258 .dac_nids = alc880_dac_nids,
4259 .dig_out_nid = ALC880_DIGOUT_NID,
4260 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4261 .channel_mode = alc880_lg_lw_modes,
4262 .input_mux = &alc880_lg_lw_capture_source,
4263 .unsol_event = alc_automute_amp_unsol_event,
4264 .setup = alc880_lg_lw_setup,
4265 .init_hook = alc_automute_amp,
4267 [ALC880_MEDION_RIM] = {
4268 .mixers = { alc880_medion_rim_mixer },
4269 .init_verbs = { alc880_volume_init_verbs,
4270 alc880_medion_rim_init_verbs,
4271 alc_gpio2_init_verbs },
4272 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4273 .dac_nids = alc880_dac_nids,
4274 .dig_out_nid = ALC880_DIGOUT_NID,
4275 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4276 .channel_mode = alc880_2_jack_modes,
4277 .input_mux = &alc880_medion_rim_capture_source,
4278 .unsol_event = alc880_medion_rim_unsol_event,
4279 .setup = alc880_medion_rim_setup,
4280 .init_hook = alc880_medion_rim_automute,
4282 #ifdef CONFIG_SND_DEBUG
4283 [ALC880_TEST] = {
4284 .mixers = { alc880_test_mixer },
4285 .init_verbs = { alc880_test_init_verbs },
4286 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4287 .dac_nids = alc880_test_dac_nids,
4288 .dig_out_nid = ALC880_DIGOUT_NID,
4289 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4290 .channel_mode = alc880_test_modes,
4291 .input_mux = &alc880_test_capture_source,
4293 #endif
4297 * Automatic parse of I/O pins from the BIOS configuration
4300 enum {
4301 ALC_CTL_WIDGET_VOL,
4302 ALC_CTL_WIDGET_MUTE,
4303 ALC_CTL_BIND_MUTE,
4305 static struct snd_kcontrol_new alc880_control_templates[] = {
4306 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4307 HDA_CODEC_MUTE(NULL, 0, 0, 0),
4308 HDA_BIND_MUTE(NULL, 0, 0, 0),
4311 /* add dynamic controls */
4312 static int add_control(struct alc_spec *spec, int type, const char *name,
4313 unsigned long val)
4315 struct snd_kcontrol_new *knew;
4317 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4318 knew = snd_array_new(&spec->kctls);
4319 if (!knew)
4320 return -ENOMEM;
4321 *knew = alc880_control_templates[type];
4322 knew->name = kstrdup(name, GFP_KERNEL);
4323 if (!knew->name)
4324 return -ENOMEM;
4325 knew->private_value = val;
4326 return 0;
4329 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4330 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4331 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4332 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4333 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
4334 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
4335 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4336 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
4337 #define ALC880_PIN_CD_NID 0x1c
4339 /* fill in the dac_nids table from the parsed pin configuration */
4340 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4341 const struct auto_pin_cfg *cfg)
4343 hda_nid_t nid;
4344 int assigned[4];
4345 int i, j;
4347 memset(assigned, 0, sizeof(assigned));
4348 spec->multiout.dac_nids = spec->private_dac_nids;
4350 /* check the pins hardwired to audio widget */
4351 for (i = 0; i < cfg->line_outs; i++) {
4352 nid = cfg->line_out_pins[i];
4353 if (alc880_is_fixed_pin(nid)) {
4354 int idx = alc880_fixed_pin_idx(nid);
4355 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
4356 assigned[idx] = 1;
4359 /* left pins can be connect to any audio widget */
4360 for (i = 0; i < cfg->line_outs; i++) {
4361 nid = cfg->line_out_pins[i];
4362 if (alc880_is_fixed_pin(nid))
4363 continue;
4364 /* search for an empty channel */
4365 for (j = 0; j < cfg->line_outs; j++) {
4366 if (!assigned[j]) {
4367 spec->multiout.dac_nids[i] =
4368 alc880_idx_to_dac(j);
4369 assigned[j] = 1;
4370 break;
4374 spec->multiout.num_dacs = cfg->line_outs;
4375 return 0;
4378 /* add playback controls from the parsed DAC table */
4379 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4380 const struct auto_pin_cfg *cfg)
4382 char name[32];
4383 static const char *chname[4] = {
4384 "Front", "Surround", NULL /*CLFE*/, "Side"
4386 hda_nid_t nid;
4387 int i, err;
4389 for (i = 0; i < cfg->line_outs; i++) {
4390 if (!spec->multiout.dac_nids[i])
4391 continue;
4392 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4393 if (i == 2) {
4394 /* Center/LFE */
4395 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4396 "Center Playback Volume",
4397 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4398 HDA_OUTPUT));
4399 if (err < 0)
4400 return err;
4401 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4402 "LFE Playback Volume",
4403 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4404 HDA_OUTPUT));
4405 if (err < 0)
4406 return err;
4407 err = add_control(spec, ALC_CTL_BIND_MUTE,
4408 "Center Playback Switch",
4409 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4410 HDA_INPUT));
4411 if (err < 0)
4412 return err;
4413 err = add_control(spec, ALC_CTL_BIND_MUTE,
4414 "LFE Playback Switch",
4415 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4416 HDA_INPUT));
4417 if (err < 0)
4418 return err;
4419 } else {
4420 const char *pfx;
4421 if (cfg->line_outs == 1 &&
4422 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4423 pfx = "Speaker";
4424 else
4425 pfx = chname[i];
4426 sprintf(name, "%s Playback Volume", pfx);
4427 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4428 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4429 HDA_OUTPUT));
4430 if (err < 0)
4431 return err;
4432 sprintf(name, "%s Playback Switch", pfx);
4433 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4434 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4435 HDA_INPUT));
4436 if (err < 0)
4437 return err;
4440 return 0;
4443 /* add playback controls for speaker and HP outputs */
4444 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4445 const char *pfx)
4447 hda_nid_t nid;
4448 int err;
4449 char name[32];
4451 if (!pin)
4452 return 0;
4454 if (alc880_is_fixed_pin(pin)) {
4455 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
4456 /* specify the DAC as the extra output */
4457 if (!spec->multiout.hp_nid)
4458 spec->multiout.hp_nid = nid;
4459 else
4460 spec->multiout.extra_out_nid[0] = nid;
4461 /* control HP volume/switch on the output mixer amp */
4462 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
4463 sprintf(name, "%s Playback Volume", pfx);
4464 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4465 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4466 if (err < 0)
4467 return err;
4468 sprintf(name, "%s Playback Switch", pfx);
4469 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4470 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4471 if (err < 0)
4472 return err;
4473 } else if (alc880_is_multi_pin(pin)) {
4474 /* set manual connection */
4475 /* we have only a switch on HP-out PIN */
4476 sprintf(name, "%s Playback Switch", pfx);
4477 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4478 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4479 if (err < 0)
4480 return err;
4482 return 0;
4485 /* create input playback/capture controls for the given pin */
4486 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4487 const char *ctlname,
4488 int idx, hda_nid_t mix_nid)
4490 char name[32];
4491 int err;
4493 sprintf(name, "%s Playback Volume", ctlname);
4494 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4495 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4496 if (err < 0)
4497 return err;
4498 sprintf(name, "%s Playback Switch", ctlname);
4499 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4500 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4501 if (err < 0)
4502 return err;
4503 return 0;
4506 static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
4508 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4509 return (pincap & AC_PINCAP_IN) != 0;
4512 /* create playback/capture controls for input pins */
4513 static int alc_auto_create_input_ctls(struct hda_codec *codec,
4514 const struct auto_pin_cfg *cfg,
4515 hda_nid_t mixer,
4516 hda_nid_t cap1, hda_nid_t cap2)
4518 struct alc_spec *spec = codec->spec;
4519 struct hda_input_mux *imux = &spec->private_imux[0];
4520 int i, err, idx;
4522 for (i = 0; i < AUTO_PIN_LAST; i++) {
4523 hda_nid_t pin;
4525 pin = cfg->input_pins[i];
4526 if (!alc_is_input_pin(codec, pin))
4527 continue;
4529 if (mixer) {
4530 idx = get_connection_index(codec, mixer, pin);
4531 if (idx >= 0) {
4532 err = new_analog_input(spec, pin,
4533 auto_pin_cfg_labels[i],
4534 idx, mixer);
4535 if (err < 0)
4536 return err;
4540 if (!cap1)
4541 continue;
4542 idx = get_connection_index(codec, cap1, pin);
4543 if (idx < 0 && cap2)
4544 idx = get_connection_index(codec, cap2, pin);
4545 if (idx >= 0) {
4546 imux->items[imux->num_items].label =
4547 auto_pin_cfg_labels[i];
4548 imux->items[imux->num_items].index = idx;
4549 imux->num_items++;
4552 return 0;
4555 static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4556 const struct auto_pin_cfg *cfg)
4558 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4561 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4562 unsigned int pin_type)
4564 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4565 pin_type);
4566 /* unmute pin */
4567 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4568 AMP_OUT_UNMUTE);
4571 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4572 hda_nid_t nid, int pin_type,
4573 int dac_idx)
4575 alc_set_pin_output(codec, nid, pin_type);
4576 /* need the manual connection? */
4577 if (alc880_is_multi_pin(nid)) {
4578 struct alc_spec *spec = codec->spec;
4579 int idx = alc880_multi_pin_idx(nid);
4580 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4581 AC_VERB_SET_CONNECT_SEL,
4582 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4586 static int get_pin_type(int line_out_type)
4588 if (line_out_type == AUTO_PIN_HP_OUT)
4589 return PIN_HP;
4590 else
4591 return PIN_OUT;
4594 static void alc880_auto_init_multi_out(struct hda_codec *codec)
4596 struct alc_spec *spec = codec->spec;
4597 int i;
4599 for (i = 0; i < spec->autocfg.line_outs; i++) {
4600 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4601 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4602 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
4606 static void alc880_auto_init_extra_out(struct hda_codec *codec)
4608 struct alc_spec *spec = codec->spec;
4609 hda_nid_t pin;
4611 pin = spec->autocfg.speaker_pins[0];
4612 if (pin) /* connect to front */
4613 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
4614 pin = spec->autocfg.hp_pins[0];
4615 if (pin) /* connect to front */
4616 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4619 static void alc880_auto_init_analog_input(struct hda_codec *codec)
4621 struct alc_spec *spec = codec->spec;
4622 int i;
4624 for (i = 0; i < AUTO_PIN_LAST; i++) {
4625 hda_nid_t nid = spec->autocfg.input_pins[i];
4626 if (alc_is_input_pin(codec, nid)) {
4627 alc_set_input_pin(codec, nid, i);
4628 if (nid != ALC880_PIN_CD_NID &&
4629 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
4630 snd_hda_codec_write(codec, nid, 0,
4631 AC_VERB_SET_AMP_GAIN_MUTE,
4632 AMP_OUT_MUTE);
4637 /* parse the BIOS configuration and set up the alc_spec */
4638 /* return 1 if successful, 0 if the proper config is not found,
4639 * or a negative error code
4641 static int alc880_parse_auto_config(struct hda_codec *codec)
4643 struct alc_spec *spec = codec->spec;
4644 int i, err;
4645 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
4647 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4648 alc880_ignore);
4649 if (err < 0)
4650 return err;
4651 if (!spec->autocfg.line_outs)
4652 return 0; /* can't find valid BIOS pin config */
4654 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4655 if (err < 0)
4656 return err;
4657 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4658 if (err < 0)
4659 return err;
4660 err = alc880_auto_create_extra_out(spec,
4661 spec->autocfg.speaker_pins[0],
4662 "Speaker");
4663 if (err < 0)
4664 return err;
4665 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4666 "Headphone");
4667 if (err < 0)
4668 return err;
4669 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
4670 if (err < 0)
4671 return err;
4673 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4675 /* check multiple SPDIF-out (for recent codecs) */
4676 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4677 hda_nid_t dig_nid;
4678 err = snd_hda_get_connections(codec,
4679 spec->autocfg.dig_out_pins[i],
4680 &dig_nid, 1);
4681 if (err < 0)
4682 continue;
4683 if (!i)
4684 spec->multiout.dig_out_nid = dig_nid;
4685 else {
4686 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4687 spec->slave_dig_outs[i - 1] = dig_nid;
4688 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4689 break;
4692 if (spec->autocfg.dig_in_pin)
4693 spec->dig_in_nid = ALC880_DIGIN_NID;
4695 if (spec->kctls.list)
4696 add_mixer(spec, spec->kctls.list);
4698 add_verb(spec, alc880_volume_init_verbs);
4700 spec->num_mux_defs = 1;
4701 spec->input_mux = &spec->private_imux[0];
4703 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4705 return 1;
4708 /* additional initialization for auto-configuration model */
4709 static void alc880_auto_init(struct hda_codec *codec)
4711 struct alc_spec *spec = codec->spec;
4712 alc880_auto_init_multi_out(codec);
4713 alc880_auto_init_extra_out(codec);
4714 alc880_auto_init_analog_input(codec);
4715 if (spec->unsol_event)
4716 alc_inithook(codec);
4719 /* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4720 * one of two digital mic pins, e.g. on ALC272
4722 static void fixup_automic_adc(struct hda_codec *codec)
4724 struct alc_spec *spec = codec->spec;
4725 int i;
4727 for (i = 0; i < spec->num_adc_nids; i++) {
4728 hda_nid_t cap = spec->capsrc_nids ?
4729 spec->capsrc_nids[i] : spec->adc_nids[i];
4730 int iidx, eidx;
4732 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4733 if (iidx < 0)
4734 continue;
4735 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4736 if (eidx < 0)
4737 continue;
4738 spec->int_mic.mux_idx = iidx;
4739 spec->ext_mic.mux_idx = eidx;
4740 if (spec->capsrc_nids)
4741 spec->capsrc_nids += i;
4742 spec->adc_nids += i;
4743 spec->num_adc_nids = 1;
4744 return;
4746 snd_printd(KERN_INFO "hda_codec: %s: "
4747 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4748 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4749 spec->auto_mic = 0; /* disable auto-mic to be sure */
4752 static void set_capture_mixer(struct hda_codec *codec)
4754 struct alc_spec *spec = codec->spec;
4755 static struct snd_kcontrol_new *caps[2][3] = {
4756 { alc_capture_mixer_nosrc1,
4757 alc_capture_mixer_nosrc2,
4758 alc_capture_mixer_nosrc3 },
4759 { alc_capture_mixer1,
4760 alc_capture_mixer2,
4761 alc_capture_mixer3 },
4763 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4764 int mux;
4765 if (spec->auto_mic) {
4766 mux = 0;
4767 fixup_automic_adc(codec);
4768 } else if (spec->input_mux && spec->input_mux->num_items > 1)
4769 mux = 1;
4770 else
4771 mux = 0;
4772 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4776 #define set_beep_amp(spec, nid, idx, dir) \
4777 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4780 * OK, here we have finally the patch for ALC880
4783 static int patch_alc880(struct hda_codec *codec)
4785 struct alc_spec *spec;
4786 int board_config;
4787 int err;
4789 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4790 if (spec == NULL)
4791 return -ENOMEM;
4793 codec->spec = spec;
4795 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4796 alc880_models,
4797 alc880_cfg_tbl);
4798 if (board_config < 0) {
4799 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4800 codec->chip_name);
4801 board_config = ALC880_AUTO;
4804 if (board_config == ALC880_AUTO) {
4805 /* automatic parse from the BIOS config */
4806 err = alc880_parse_auto_config(codec);
4807 if (err < 0) {
4808 alc_free(codec);
4809 return err;
4810 } else if (!err) {
4811 printk(KERN_INFO
4812 "hda_codec: Cannot set up configuration "
4813 "from BIOS. Using 3-stack mode...\n");
4814 board_config = ALC880_3ST;
4818 err = snd_hda_attach_beep_device(codec, 0x1);
4819 if (err < 0) {
4820 alc_free(codec);
4821 return err;
4824 if (board_config != ALC880_AUTO)
4825 setup_preset(codec, &alc880_presets[board_config]);
4827 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4828 spec->stream_analog_capture = &alc880_pcm_analog_capture;
4829 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
4831 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4832 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4834 if (!spec->adc_nids && spec->input_mux) {
4835 /* check whether NID 0x07 is valid */
4836 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
4837 /* get type */
4838 wcap = get_wcaps_type(wcap);
4839 if (wcap != AC_WID_AUD_IN) {
4840 spec->adc_nids = alc880_adc_nids_alt;
4841 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
4842 } else {
4843 spec->adc_nids = alc880_adc_nids;
4844 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
4847 set_capture_mixer(codec);
4848 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4850 spec->vmaster_nid = 0x0c;
4852 codec->patch_ops = alc_patch_ops;
4853 if (board_config == ALC880_AUTO)
4854 spec->init_hook = alc880_auto_init;
4855 #ifdef CONFIG_SND_HDA_POWER_SAVE
4856 if (!spec->loopback.amplist)
4857 spec->loopback.amplist = alc880_loopbacks;
4858 #endif
4859 codec->proc_widget_hook = print_realtek_coef;
4861 return 0;
4866 * ALC260 support
4869 static hda_nid_t alc260_dac_nids[1] = {
4870 /* front */
4871 0x02,
4874 static hda_nid_t alc260_adc_nids[1] = {
4875 /* ADC0 */
4876 0x04,
4879 static hda_nid_t alc260_adc_nids_alt[1] = {
4880 /* ADC1 */
4881 0x05,
4884 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
4885 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4887 static hda_nid_t alc260_dual_adc_nids[2] = {
4888 /* ADC0, ADC1 */
4889 0x04, 0x05
4892 #define ALC260_DIGOUT_NID 0x03
4893 #define ALC260_DIGIN_NID 0x06
4895 static struct hda_input_mux alc260_capture_source = {
4896 .num_items = 4,
4897 .items = {
4898 { "Mic", 0x0 },
4899 { "Front Mic", 0x1 },
4900 { "Line", 0x2 },
4901 { "CD", 0x4 },
4905 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
4906 * headphone jack and the internal CD lines since these are the only pins at
4907 * which audio can appear. For flexibility, also allow the option of
4908 * recording the mixer output on the second ADC (ADC0 doesn't have a
4909 * connection to the mixer output).
4911 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4913 .num_items = 3,
4914 .items = {
4915 { "Mic/Line", 0x0 },
4916 { "CD", 0x4 },
4917 { "Headphone", 0x2 },
4921 .num_items = 4,
4922 .items = {
4923 { "Mic/Line", 0x0 },
4924 { "CD", 0x4 },
4925 { "Headphone", 0x2 },
4926 { "Mixer", 0x5 },
4932 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4933 * the Fujitsu S702x, but jacks are marked differently.
4935 static struct hda_input_mux alc260_acer_capture_sources[2] = {
4937 .num_items = 4,
4938 .items = {
4939 { "Mic", 0x0 },
4940 { "Line", 0x2 },
4941 { "CD", 0x4 },
4942 { "Headphone", 0x5 },
4946 .num_items = 5,
4947 .items = {
4948 { "Mic", 0x0 },
4949 { "Line", 0x2 },
4950 { "CD", 0x4 },
4951 { "Headphone", 0x6 },
4952 { "Mixer", 0x5 },
4957 /* Maxdata Favorit 100XS */
4958 static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4960 .num_items = 2,
4961 .items = {
4962 { "Line/Mic", 0x0 },
4963 { "CD", 0x4 },
4967 .num_items = 3,
4968 .items = {
4969 { "Line/Mic", 0x0 },
4970 { "CD", 0x4 },
4971 { "Mixer", 0x5 },
4977 * This is just place-holder, so there's something for alc_build_pcms to look
4978 * at when it calculates the maximum number of channels. ALC260 has no mixer
4979 * element which allows changing the channel mode, so the verb list is
4980 * never used.
4982 static struct hda_channel_mode alc260_modes[1] = {
4983 { 2, NULL },
4987 /* Mixer combinations
4989 * basic: base_output + input + pc_beep + capture
4990 * HP: base_output + input + capture_alt
4991 * HP_3013: hp_3013 + input + capture
4992 * fujitsu: fujitsu + capture
4993 * acer: acer + capture
4996 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
4997 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4998 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4999 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5000 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5001 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5002 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5003 { } /* end */
5006 static struct snd_kcontrol_new alc260_input_mixer[] = {
5007 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5008 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5009 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5010 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5012 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5013 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5014 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
5015 { } /* end */
5018 /* update HP, line and mono out pins according to the master switch */
5019 static void alc260_hp_master_update(struct hda_codec *codec,
5020 hda_nid_t hp, hda_nid_t line,
5021 hda_nid_t mono)
5023 struct alc_spec *spec = codec->spec;
5024 unsigned int val = spec->master_sw ? PIN_HP : 0;
5025 /* change HP and line-out pins */
5026 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5027 val);
5028 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5029 val);
5030 /* mono (speaker) depending on the HP jack sense */
5031 val = (val && !spec->jack_present) ? PIN_OUT : 0;
5032 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5033 val);
5036 static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5037 struct snd_ctl_elem_value *ucontrol)
5039 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5040 struct alc_spec *spec = codec->spec;
5041 *ucontrol->value.integer.value = spec->master_sw;
5042 return 0;
5045 static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5046 struct snd_ctl_elem_value *ucontrol)
5048 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5049 struct alc_spec *spec = codec->spec;
5050 int val = !!*ucontrol->value.integer.value;
5051 hda_nid_t hp, line, mono;
5053 if (val == spec->master_sw)
5054 return 0;
5055 spec->master_sw = val;
5056 hp = (kcontrol->private_value >> 16) & 0xff;
5057 line = (kcontrol->private_value >> 8) & 0xff;
5058 mono = kcontrol->private_value & 0xff;
5059 alc260_hp_master_update(codec, hp, line, mono);
5060 return 1;
5063 static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5066 .name = "Master Playback Switch",
5067 .info = snd_ctl_boolean_mono_info,
5068 .get = alc260_hp_master_sw_get,
5069 .put = alc260_hp_master_sw_put,
5070 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5072 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5073 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5074 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5075 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5076 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5077 HDA_OUTPUT),
5078 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5079 { } /* end */
5082 static struct hda_verb alc260_hp_unsol_verbs[] = {
5083 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5087 static void alc260_hp_automute(struct hda_codec *codec)
5089 struct alc_spec *spec = codec->spec;
5090 unsigned int present;
5092 present = snd_hda_codec_read(codec, 0x10, 0,
5093 AC_VERB_GET_PIN_SENSE, 0);
5094 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5095 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5098 static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5100 if ((res >> 26) == ALC880_HP_EVENT)
5101 alc260_hp_automute(codec);
5104 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
5106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5107 .name = "Master Playback Switch",
5108 .info = snd_ctl_boolean_mono_info,
5109 .get = alc260_hp_master_sw_get,
5110 .put = alc260_hp_master_sw_put,
5111 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
5113 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5114 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5115 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5116 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5117 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5118 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5119 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5120 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
5121 { } /* end */
5124 static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5125 .ops = &snd_hda_bind_vol,
5126 .values = {
5127 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5128 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5129 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5134 static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5135 .ops = &snd_hda_bind_sw,
5136 .values = {
5137 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5138 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5143 static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5144 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5145 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5146 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5147 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5148 { } /* end */
5151 static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5152 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5156 static void alc260_hp_3013_automute(struct hda_codec *codec)
5158 struct alc_spec *spec = codec->spec;
5159 unsigned int present;
5161 present = snd_hda_codec_read(codec, 0x15, 0,
5162 AC_VERB_GET_PIN_SENSE, 0);
5163 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5164 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
5167 static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5168 unsigned int res)
5170 if ((res >> 26) == ALC880_HP_EVENT)
5171 alc260_hp_3013_automute(codec);
5174 static void alc260_hp_3012_automute(struct hda_codec *codec)
5176 unsigned int present, bits;
5178 present = snd_hda_codec_read(codec, 0x10, 0,
5179 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5181 bits = present ? 0 : PIN_OUT;
5182 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5183 bits);
5184 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5185 bits);
5186 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5187 bits);
5190 static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5191 unsigned int res)
5193 if ((res >> 26) == ALC880_HP_EVENT)
5194 alc260_hp_3012_automute(codec);
5197 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
5198 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5200 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
5201 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5202 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
5203 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5204 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5205 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5206 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5207 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
5208 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
5209 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5210 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
5211 { } /* end */
5214 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5215 * versions of the ALC260 don't act on requests to enable mic bias from NID
5216 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5217 * datasheet doesn't mention this restriction. At this stage it's not clear
5218 * whether this behaviour is intentional or is a hardware bug in chip
5219 * revisions available in early 2006. Therefore for now allow the
5220 * "Headphone Jack Mode" control to span all choices, but if it turns out
5221 * that the lack of mic bias for this NID is intentional we could change the
5222 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5224 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5225 * don't appear to make the mic bias available from the "line" jack, even
5226 * though the NID used for this jack (0x14) can supply it. The theory is
5227 * that perhaps Acer have included blocking capacitors between the ALC260
5228 * and the output jack. If this turns out to be the case for all such
5229 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5230 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
5232 * The C20x Tablet series have a mono internal speaker which is controlled
5233 * via the chip's Mono sum widget and pin complex, so include the necessary
5234 * controls for such models. On models without a "mono speaker" the control
5235 * won't do anything.
5237 static struct snd_kcontrol_new alc260_acer_mixer[] = {
5238 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5239 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5240 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5241 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5242 HDA_OUTPUT),
5243 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
5244 HDA_INPUT),
5245 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5246 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5248 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5249 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5250 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5251 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5252 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5253 { } /* end */
5256 /* Maxdata Favorit 100XS: one output and one input (0x12) jack
5258 static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5259 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5260 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5261 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5262 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5263 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5264 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5265 { } /* end */
5268 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5269 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5271 static struct snd_kcontrol_new alc260_will_mixer[] = {
5272 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5273 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5275 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5276 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5277 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5278 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5279 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5280 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5281 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5282 { } /* end */
5285 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5286 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5288 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5289 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5290 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5292 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5293 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5294 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5295 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5296 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5297 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5298 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5299 { } /* end */
5303 * initialization verbs
5305 static struct hda_verb alc260_init_verbs[] = {
5306 /* Line In pin widget for input */
5307 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5308 /* CD pin widget for input */
5309 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5310 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5311 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5312 /* Mic2 (front panel) pin widget for input and vref at 80% */
5313 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5314 /* LINE-2 is used for line-out in rear */
5315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5316 /* select line-out */
5317 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
5318 /* LINE-OUT pin */
5319 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5320 /* enable HP */
5321 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5322 /* enable Mono */
5323 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5324 /* mute capture amp left and right */
5325 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5326 /* set connection select to line in (default select for this ADC) */
5327 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5328 /* mute capture amp left and right */
5329 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5330 /* set connection select to line in (default select for this ADC) */
5331 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
5332 /* set vol=0 Line-Out mixer amp left and right */
5333 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5334 /* unmute pin widget amp left and right (no gain on this amp) */
5335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5336 /* set vol=0 HP mixer amp left and right */
5337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5338 /* unmute pin widget amp left and right (no gain on this amp) */
5339 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5340 /* set vol=0 Mono mixer amp left and right */
5341 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5342 /* unmute pin widget amp left and right (no gain on this amp) */
5343 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5344 /* unmute LINE-2 out pin */
5345 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5346 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5347 * Line In 2 = 0x03
5349 /* mute analog inputs */
5350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5355 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5356 /* mute Front out path */
5357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5359 /* mute Headphone out path */
5360 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5361 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5362 /* mute Mono out path */
5363 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5364 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5368 #if 0 /* should be identical with alc260_init_verbs? */
5369 static struct hda_verb alc260_hp_init_verbs[] = {
5370 /* Headphone and output */
5371 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5372 /* mono output */
5373 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5374 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5375 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5376 /* Mic2 (front panel) pin widget for input and vref at 80% */
5377 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5378 /* Line In pin widget for input */
5379 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5380 /* Line-2 pin widget for output */
5381 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5382 /* CD pin widget for input */
5383 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5384 /* unmute amp left and right */
5385 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5386 /* set connection select to line in (default select for this ADC) */
5387 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5388 /* unmute Line-Out mixer amp left and right (volume = 0) */
5389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5390 /* mute pin widget amp left and right (no gain on this amp) */
5391 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5392 /* unmute HP mixer amp left and right (volume = 0) */
5393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5394 /* mute pin widget amp left and right (no gain on this amp) */
5395 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5396 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5397 * Line In 2 = 0x03
5399 /* mute analog inputs */
5400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5401 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5405 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5406 /* Unmute Front out path */
5407 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5408 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5409 /* Unmute Headphone out path */
5410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5411 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5412 /* Unmute Mono out path */
5413 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5414 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5417 #endif
5419 static struct hda_verb alc260_hp_3013_init_verbs[] = {
5420 /* Line out and output */
5421 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5422 /* mono output */
5423 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5424 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5425 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5426 /* Mic2 (front panel) pin widget for input and vref at 80% */
5427 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5428 /* Line In pin widget for input */
5429 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5430 /* Headphone pin widget for output */
5431 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5432 /* CD pin widget for input */
5433 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5434 /* unmute amp left and right */
5435 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5436 /* set connection select to line in (default select for this ADC) */
5437 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5438 /* unmute Line-Out mixer amp left and right (volume = 0) */
5439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5440 /* mute pin widget amp left and right (no gain on this amp) */
5441 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5442 /* unmute HP mixer amp left and right (volume = 0) */
5443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5444 /* mute pin widget amp left and right (no gain on this amp) */
5445 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5446 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5447 * Line In 2 = 0x03
5449 /* mute analog inputs */
5450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5451 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5455 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5456 /* Unmute Front out path */
5457 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5458 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5459 /* Unmute Headphone out path */
5460 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5461 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5462 /* Unmute Mono out path */
5463 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5464 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5468 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
5469 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5470 * audio = 0x16, internal speaker = 0x10.
5472 static struct hda_verb alc260_fujitsu_init_verbs[] = {
5473 /* Disable all GPIOs */
5474 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5475 /* Internal speaker is connected to headphone pin */
5476 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5477 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5479 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5480 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5481 /* Ensure all other unused pins are disabled and muted. */
5482 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5483 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5484 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5485 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5486 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5487 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5489 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5491 /* Disable digital (SPDIF) pins */
5492 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5493 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5495 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
5496 * when acting as an output.
5498 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5500 /* Start with output sum widgets muted and their output gains at min */
5501 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5502 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5504 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5505 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5507 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5508 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5509 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5511 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5512 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5513 /* Unmute Line1 pin widget output buffer since it starts as an output.
5514 * If the pin mode is changed by the user the pin mode control will
5515 * take care of enabling the pin's input/output buffers as needed.
5516 * Therefore there's no need to enable the input buffer at this
5517 * stage.
5519 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5520 /* Unmute input buffer of pin widget used for Line-in (no equiv
5521 * mixer ctrl)
5523 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5525 /* Mute capture amp left and right */
5526 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5527 /* Set ADC connection select to match default mixer setting - line
5528 * in (on mic1 pin)
5530 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5532 /* Do the same for the second ADC: mute capture input amp and
5533 * set ADC connection to line in (on mic1 pin)
5535 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5536 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5538 /* Mute all inputs to mixer widget (even unconnected ones) */
5539 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5551 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5552 * similar laptops (adapted from Fujitsu init verbs).
5554 static struct hda_verb alc260_acer_init_verbs[] = {
5555 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5556 * the headphone jack. Turn this on and rely on the standard mute
5557 * methods whenever the user wants to turn these outputs off.
5559 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5560 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5561 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5562 /* Internal speaker/Headphone jack is connected to Line-out pin */
5563 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5564 /* Internal microphone/Mic jack is connected to Mic1 pin */
5565 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5566 /* Line In jack is connected to Line1 pin */
5567 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5568 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5569 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5570 /* Ensure all other unused pins are disabled and muted. */
5571 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5572 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5573 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5574 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5577 /* Disable digital (SPDIF) pins */
5578 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5579 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5581 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5582 * bus when acting as outputs.
5584 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5585 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5587 /* Start with output sum widgets muted and their output gains at min */
5588 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5589 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5590 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5592 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5594 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5595 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5596 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5598 /* Unmute Line-out pin widget amp left and right
5599 * (no equiv mixer ctrl)
5601 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5602 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5603 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5604 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5605 * inputs. If the pin mode is changed by the user the pin mode control
5606 * will take care of enabling the pin's input/output buffers as needed.
5607 * Therefore there's no need to enable the input buffer at this
5608 * stage.
5610 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5611 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5613 /* Mute capture amp left and right */
5614 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5615 /* Set ADC connection select to match default mixer setting - mic
5616 * (on mic1 pin)
5618 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5620 /* Do similar with the second ADC: mute capture input amp and
5621 * set ADC connection to mic to match ALSA's default state.
5623 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5624 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5626 /* Mute all inputs to mixer widget (even unconnected ones) */
5627 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5629 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5630 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5639 /* Initialisation sequence for Maxdata Favorit 100XS
5640 * (adapted from Acer init verbs).
5642 static struct hda_verb alc260_favorit100_init_verbs[] = {
5643 /* GPIO 0 enables the output jack.
5644 * Turn this on and rely on the standard mute
5645 * methods whenever the user wants to turn these outputs off.
5647 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5648 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5649 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5650 /* Line/Mic input jack is connected to Mic1 pin */
5651 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5652 /* Ensure all other unused pins are disabled and muted. */
5653 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5654 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5655 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5656 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5657 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5658 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5661 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5663 /* Disable digital (SPDIF) pins */
5664 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5665 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5667 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5668 * bus when acting as outputs.
5670 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5671 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5673 /* Start with output sum widgets muted and their output gains at min */
5674 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5675 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5676 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5677 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5678 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5679 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5680 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5681 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5682 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5684 /* Unmute Line-out pin widget amp left and right
5685 * (no equiv mixer ctrl)
5687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5688 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5689 * inputs. If the pin mode is changed by the user the pin mode control
5690 * will take care of enabling the pin's input/output buffers as needed.
5691 * Therefore there's no need to enable the input buffer at this
5692 * stage.
5694 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5696 /* Mute capture amp left and right */
5697 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5698 /* Set ADC connection select to match default mixer setting - mic
5699 * (on mic1 pin)
5701 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5703 /* Do similar with the second ADC: mute capture input amp and
5704 * set ADC connection to mic to match ALSA's default state.
5706 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5707 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5709 /* Mute all inputs to mixer widget (even unconnected ones) */
5710 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5711 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5717 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5722 static struct hda_verb alc260_will_verbs[] = {
5723 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5724 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5725 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5726 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5727 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5728 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5732 static struct hda_verb alc260_replacer_672v_verbs[] = {
5733 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5734 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5735 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5737 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5738 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5739 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5741 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5745 /* toggle speaker-output according to the hp-jack state */
5746 static void alc260_replacer_672v_automute(struct hda_codec *codec)
5748 unsigned int present;
5750 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5751 present = snd_hda_codec_read(codec, 0x0f, 0,
5752 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5753 if (present) {
5754 snd_hda_codec_write_cache(codec, 0x01, 0,
5755 AC_VERB_SET_GPIO_DATA, 1);
5756 snd_hda_codec_write_cache(codec, 0x0f, 0,
5757 AC_VERB_SET_PIN_WIDGET_CONTROL,
5758 PIN_HP);
5759 } else {
5760 snd_hda_codec_write_cache(codec, 0x01, 0,
5761 AC_VERB_SET_GPIO_DATA, 0);
5762 snd_hda_codec_write_cache(codec, 0x0f, 0,
5763 AC_VERB_SET_PIN_WIDGET_CONTROL,
5764 PIN_OUT);
5768 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5769 unsigned int res)
5771 if ((res >> 26) == ALC880_HP_EVENT)
5772 alc260_replacer_672v_automute(codec);
5775 static struct hda_verb alc260_hp_dc7600_verbs[] = {
5776 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5777 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5778 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5779 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5780 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5781 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5782 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5783 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5784 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5785 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5789 /* Test configuration for debugging, modelled after the ALC880 test
5790 * configuration.
5792 #ifdef CONFIG_SND_DEBUG
5793 static hda_nid_t alc260_test_dac_nids[1] = {
5794 0x02,
5796 static hda_nid_t alc260_test_adc_nids[2] = {
5797 0x04, 0x05,
5799 /* For testing the ALC260, each input MUX needs its own definition since
5800 * the signal assignments are different. This assumes that the first ADC
5801 * is NID 0x04.
5803 static struct hda_input_mux alc260_test_capture_sources[2] = {
5805 .num_items = 7,
5806 .items = {
5807 { "MIC1 pin", 0x0 },
5808 { "MIC2 pin", 0x1 },
5809 { "LINE1 pin", 0x2 },
5810 { "LINE2 pin", 0x3 },
5811 { "CD pin", 0x4 },
5812 { "LINE-OUT pin", 0x5 },
5813 { "HP-OUT pin", 0x6 },
5817 .num_items = 8,
5818 .items = {
5819 { "MIC1 pin", 0x0 },
5820 { "MIC2 pin", 0x1 },
5821 { "LINE1 pin", 0x2 },
5822 { "LINE2 pin", 0x3 },
5823 { "CD pin", 0x4 },
5824 { "Mixer", 0x5 },
5825 { "LINE-OUT pin", 0x6 },
5826 { "HP-OUT pin", 0x7 },
5830 static struct snd_kcontrol_new alc260_test_mixer[] = {
5831 /* Output driver widgets */
5832 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5833 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5834 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5835 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5836 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5837 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5839 /* Modes for retasking pin widgets
5840 * Note: the ALC260 doesn't seem to act on requests to enable mic
5841 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5842 * mention this restriction. At this stage it's not clear whether
5843 * this behaviour is intentional or is a hardware bug in chip
5844 * revisions available at least up until early 2006. Therefore for
5845 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5846 * choices, but if it turns out that the lack of mic bias for these
5847 * NIDs is intentional we could change their modes from
5848 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5850 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5851 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5852 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5853 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5854 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5855 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5857 /* Loopback mixer controls */
5858 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5859 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5860 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5861 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5862 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5863 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5864 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5865 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5866 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5867 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5868 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5869 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5870 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5871 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
5873 /* Controls for GPIO pins, assuming they are configured as outputs */
5874 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5875 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5876 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5877 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5879 /* Switches to allow the digital IO pins to be enabled. The datasheet
5880 * is ambigious as to which NID is which; testing on laptops which
5881 * make this output available should provide clarification.
5883 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5884 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5886 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5887 * this output to turn on an external amplifier.
5889 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5890 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5892 { } /* end */
5894 static struct hda_verb alc260_test_init_verbs[] = {
5895 /* Enable all GPIOs as outputs with an initial value of 0 */
5896 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5897 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5898 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5900 /* Enable retasking pins as output, initially without power amp */
5901 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5902 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5903 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5905 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5906 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5908 /* Disable digital (SPDIF) pins initially, but users can enable
5909 * them via a mixer switch. In the case of SPDIF-out, this initverb
5910 * payload also sets the generation to 0, output to be in "consumer"
5911 * PCM format, copyright asserted, no pre-emphasis and no validity
5912 * control.
5914 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5915 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5917 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
5918 * OUT1 sum bus when acting as an output.
5920 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5921 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5922 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5923 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5925 /* Start with output sum widgets muted and their output gains at min */
5926 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5927 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5928 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5929 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5930 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5931 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5932 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5933 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5934 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5936 /* Unmute retasking pin widget output buffers since the default
5937 * state appears to be output. As the pin mode is changed by the
5938 * user the pin mode control will take care of enabling the pin's
5939 * input/output buffers as needed.
5941 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5942 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5944 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5945 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5946 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5947 /* Also unmute the mono-out pin widget */
5948 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5950 /* Mute capture amp left and right */
5951 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5952 /* Set ADC connection select to match default mixer setting (mic1
5953 * pin)
5955 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5957 /* Do the same for the second ADC: mute capture input amp and
5958 * set ADC connection to mic1 pin
5960 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5961 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5963 /* Mute all inputs to mixer widget (even unconnected ones) */
5964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5965 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5975 #endif
5977 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5978 #define alc260_pcm_analog_capture alc880_pcm_analog_capture
5980 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
5981 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
5984 * for BIOS auto-configuration
5987 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
5988 const char *pfx, int *vol_bits)
5990 hda_nid_t nid_vol;
5991 unsigned long vol_val, sw_val;
5992 char name[32];
5993 int err;
5995 if (nid >= 0x0f && nid < 0x11) {
5996 nid_vol = nid - 0x7;
5997 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5998 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5999 } else if (nid == 0x11) {
6000 nid_vol = nid - 0x7;
6001 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6002 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6003 } else if (nid >= 0x12 && nid <= 0x15) {
6004 nid_vol = 0x08;
6005 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6006 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6007 } else
6008 return 0; /* N/A */
6010 if (!(*vol_bits & (1 << nid_vol))) {
6011 /* first control for the volume widget */
6012 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
6013 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
6014 if (err < 0)
6015 return err;
6016 *vol_bits |= (1 << nid_vol);
6018 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
6019 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
6020 if (err < 0)
6021 return err;
6022 return 1;
6025 /* add playback controls from the parsed DAC table */
6026 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6027 const struct auto_pin_cfg *cfg)
6029 hda_nid_t nid;
6030 int err;
6031 int vols = 0;
6033 spec->multiout.num_dacs = 1;
6034 spec->multiout.dac_nids = spec->private_dac_nids;
6035 spec->multiout.dac_nids[0] = 0x02;
6037 nid = cfg->line_out_pins[0];
6038 if (nid) {
6039 const char *pfx;
6040 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6041 pfx = "Master";
6042 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6043 pfx = "Speaker";
6044 else
6045 pfx = "Front";
6046 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
6047 if (err < 0)
6048 return err;
6051 nid = cfg->speaker_pins[0];
6052 if (nid) {
6053 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
6054 if (err < 0)
6055 return err;
6058 nid = cfg->hp_pins[0];
6059 if (nid) {
6060 err = alc260_add_playback_controls(spec, nid, "Headphone",
6061 &vols);
6062 if (err < 0)
6063 return err;
6065 return 0;
6068 /* create playback/capture controls for input pins */
6069 static int alc260_auto_create_input_ctls(struct hda_codec *codec,
6070 const struct auto_pin_cfg *cfg)
6072 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
6075 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6076 hda_nid_t nid, int pin_type,
6077 int sel_idx)
6079 alc_set_pin_output(codec, nid, pin_type);
6080 /* need the manual connection? */
6081 if (nid >= 0x12) {
6082 int idx = nid - 0x12;
6083 snd_hda_codec_write(codec, idx + 0x0b, 0,
6084 AC_VERB_SET_CONNECT_SEL, sel_idx);
6088 static void alc260_auto_init_multi_out(struct hda_codec *codec)
6090 struct alc_spec *spec = codec->spec;
6091 hda_nid_t nid;
6093 nid = spec->autocfg.line_out_pins[0];
6094 if (nid) {
6095 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6096 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6099 nid = spec->autocfg.speaker_pins[0];
6100 if (nid)
6101 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6103 nid = spec->autocfg.hp_pins[0];
6104 if (nid)
6105 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
6108 #define ALC260_PIN_CD_NID 0x16
6109 static void alc260_auto_init_analog_input(struct hda_codec *codec)
6111 struct alc_spec *spec = codec->spec;
6112 int i;
6114 for (i = 0; i < AUTO_PIN_LAST; i++) {
6115 hda_nid_t nid = spec->autocfg.input_pins[i];
6116 if (nid >= 0x12) {
6117 alc_set_input_pin(codec, nid, i);
6118 if (nid != ALC260_PIN_CD_NID &&
6119 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
6120 snd_hda_codec_write(codec, nid, 0,
6121 AC_VERB_SET_AMP_GAIN_MUTE,
6122 AMP_OUT_MUTE);
6128 * generic initialization of ADC, input mixers and output mixers
6130 static struct hda_verb alc260_volume_init_verbs[] = {
6132 * Unmute ADC0-1 and set the default input to mic-in
6134 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6135 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6136 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6137 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6139 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6140 * mixer widget
6141 * Note: PASD motherboards uses the Line In 2 as the input for
6142 * front panel mic (mic 2)
6144 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6145 /* mute analog inputs */
6146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6150 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6153 * Set up output mixers (0x08 - 0x0a)
6155 /* set vol=0 to output mixers */
6156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6157 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6158 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6159 /* set up input amps for analog loopback */
6160 /* Amp Indices: DAC = 0, mixer = 1 */
6161 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6162 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6163 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6164 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6165 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6166 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6171 static int alc260_parse_auto_config(struct hda_codec *codec)
6173 struct alc_spec *spec = codec->spec;
6174 int err;
6175 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6177 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6178 alc260_ignore);
6179 if (err < 0)
6180 return err;
6181 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6182 if (err < 0)
6183 return err;
6184 if (!spec->kctls.list)
6185 return 0; /* can't find valid BIOS pin config */
6186 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
6187 if (err < 0)
6188 return err;
6190 spec->multiout.max_channels = 2;
6192 if (spec->autocfg.dig_outs)
6193 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
6194 if (spec->kctls.list)
6195 add_mixer(spec, spec->kctls.list);
6197 add_verb(spec, alc260_volume_init_verbs);
6199 spec->num_mux_defs = 1;
6200 spec->input_mux = &spec->private_imux[0];
6202 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6204 return 1;
6207 /* additional initialization for auto-configuration model */
6208 static void alc260_auto_init(struct hda_codec *codec)
6210 struct alc_spec *spec = codec->spec;
6211 alc260_auto_init_multi_out(codec);
6212 alc260_auto_init_analog_input(codec);
6213 if (spec->unsol_event)
6214 alc_inithook(codec);
6217 #ifdef CONFIG_SND_HDA_POWER_SAVE
6218 static struct hda_amp_list alc260_loopbacks[] = {
6219 { 0x07, HDA_INPUT, 0 },
6220 { 0x07, HDA_INPUT, 1 },
6221 { 0x07, HDA_INPUT, 2 },
6222 { 0x07, HDA_INPUT, 3 },
6223 { 0x07, HDA_INPUT, 4 },
6224 { } /* end */
6226 #endif
6229 * ALC260 configurations
6231 static const char *alc260_models[ALC260_MODEL_LAST] = {
6232 [ALC260_BASIC] = "basic",
6233 [ALC260_HP] = "hp",
6234 [ALC260_HP_3013] = "hp-3013",
6235 [ALC260_HP_DC7600] = "hp-dc7600",
6236 [ALC260_FUJITSU_S702X] = "fujitsu",
6237 [ALC260_ACER] = "acer",
6238 [ALC260_WILL] = "will",
6239 [ALC260_REPLACER_672V] = "replacer",
6240 [ALC260_FAVORIT100] = "favorit100",
6241 #ifdef CONFIG_SND_DEBUG
6242 [ALC260_TEST] = "test",
6243 #endif
6244 [ALC260_AUTO] = "auto",
6247 static struct snd_pci_quirk alc260_cfg_tbl[] = {
6248 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
6249 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
6250 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
6251 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
6252 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
6253 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
6254 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
6255 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
6256 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6257 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6258 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6259 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6260 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6261 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6262 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6263 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6264 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
6265 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
6266 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
6270 static struct alc_config_preset alc260_presets[] = {
6271 [ALC260_BASIC] = {
6272 .mixers = { alc260_base_output_mixer,
6273 alc260_input_mixer },
6274 .init_verbs = { alc260_init_verbs },
6275 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6276 .dac_nids = alc260_dac_nids,
6277 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6278 .adc_nids = alc260_adc_nids,
6279 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6280 .channel_mode = alc260_modes,
6281 .input_mux = &alc260_capture_source,
6283 [ALC260_HP] = {
6284 .mixers = { alc260_hp_output_mixer,
6285 alc260_input_mixer },
6286 .init_verbs = { alc260_init_verbs,
6287 alc260_hp_unsol_verbs },
6288 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6289 .dac_nids = alc260_dac_nids,
6290 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6291 .adc_nids = alc260_adc_nids_alt,
6292 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6293 .channel_mode = alc260_modes,
6294 .input_mux = &alc260_capture_source,
6295 .unsol_event = alc260_hp_unsol_event,
6296 .init_hook = alc260_hp_automute,
6298 [ALC260_HP_DC7600] = {
6299 .mixers = { alc260_hp_dc7600_mixer,
6300 alc260_input_mixer },
6301 .init_verbs = { alc260_init_verbs,
6302 alc260_hp_dc7600_verbs },
6303 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6304 .dac_nids = alc260_dac_nids,
6305 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6306 .adc_nids = alc260_adc_nids_alt,
6307 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6308 .channel_mode = alc260_modes,
6309 .input_mux = &alc260_capture_source,
6310 .unsol_event = alc260_hp_3012_unsol_event,
6311 .init_hook = alc260_hp_3012_automute,
6313 [ALC260_HP_3013] = {
6314 .mixers = { alc260_hp_3013_mixer,
6315 alc260_input_mixer },
6316 .init_verbs = { alc260_hp_3013_init_verbs,
6317 alc260_hp_3013_unsol_verbs },
6318 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6319 .dac_nids = alc260_dac_nids,
6320 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6321 .adc_nids = alc260_adc_nids_alt,
6322 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6323 .channel_mode = alc260_modes,
6324 .input_mux = &alc260_capture_source,
6325 .unsol_event = alc260_hp_3013_unsol_event,
6326 .init_hook = alc260_hp_3013_automute,
6328 [ALC260_FUJITSU_S702X] = {
6329 .mixers = { alc260_fujitsu_mixer },
6330 .init_verbs = { alc260_fujitsu_init_verbs },
6331 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6332 .dac_nids = alc260_dac_nids,
6333 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6334 .adc_nids = alc260_dual_adc_nids,
6335 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6336 .channel_mode = alc260_modes,
6337 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6338 .input_mux = alc260_fujitsu_capture_sources,
6340 [ALC260_ACER] = {
6341 .mixers = { alc260_acer_mixer },
6342 .init_verbs = { alc260_acer_init_verbs },
6343 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6344 .dac_nids = alc260_dac_nids,
6345 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6346 .adc_nids = alc260_dual_adc_nids,
6347 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6348 .channel_mode = alc260_modes,
6349 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6350 .input_mux = alc260_acer_capture_sources,
6352 [ALC260_FAVORIT100] = {
6353 .mixers = { alc260_favorit100_mixer },
6354 .init_verbs = { alc260_favorit100_init_verbs },
6355 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6356 .dac_nids = alc260_dac_nids,
6357 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6358 .adc_nids = alc260_dual_adc_nids,
6359 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6360 .channel_mode = alc260_modes,
6361 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6362 .input_mux = alc260_favorit100_capture_sources,
6364 [ALC260_WILL] = {
6365 .mixers = { alc260_will_mixer },
6366 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6367 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6368 .dac_nids = alc260_dac_nids,
6369 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6370 .adc_nids = alc260_adc_nids,
6371 .dig_out_nid = ALC260_DIGOUT_NID,
6372 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6373 .channel_mode = alc260_modes,
6374 .input_mux = &alc260_capture_source,
6376 [ALC260_REPLACER_672V] = {
6377 .mixers = { alc260_replacer_672v_mixer },
6378 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6379 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6380 .dac_nids = alc260_dac_nids,
6381 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6382 .adc_nids = alc260_adc_nids,
6383 .dig_out_nid = ALC260_DIGOUT_NID,
6384 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6385 .channel_mode = alc260_modes,
6386 .input_mux = &alc260_capture_source,
6387 .unsol_event = alc260_replacer_672v_unsol_event,
6388 .init_hook = alc260_replacer_672v_automute,
6390 #ifdef CONFIG_SND_DEBUG
6391 [ALC260_TEST] = {
6392 .mixers = { alc260_test_mixer },
6393 .init_verbs = { alc260_test_init_verbs },
6394 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6395 .dac_nids = alc260_test_dac_nids,
6396 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6397 .adc_nids = alc260_test_adc_nids,
6398 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6399 .channel_mode = alc260_modes,
6400 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6401 .input_mux = alc260_test_capture_sources,
6403 #endif
6406 static int patch_alc260(struct hda_codec *codec)
6408 struct alc_spec *spec;
6409 int err, board_config;
6411 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6412 if (spec == NULL)
6413 return -ENOMEM;
6415 codec->spec = spec;
6417 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6418 alc260_models,
6419 alc260_cfg_tbl);
6420 if (board_config < 0) {
6421 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6422 codec->chip_name);
6423 board_config = ALC260_AUTO;
6426 if (board_config == ALC260_AUTO) {
6427 /* automatic parse from the BIOS config */
6428 err = alc260_parse_auto_config(codec);
6429 if (err < 0) {
6430 alc_free(codec);
6431 return err;
6432 } else if (!err) {
6433 printk(KERN_INFO
6434 "hda_codec: Cannot set up configuration "
6435 "from BIOS. Using base mode...\n");
6436 board_config = ALC260_BASIC;
6440 err = snd_hda_attach_beep_device(codec, 0x1);
6441 if (err < 0) {
6442 alc_free(codec);
6443 return err;
6446 if (board_config != ALC260_AUTO)
6447 setup_preset(codec, &alc260_presets[board_config]);
6449 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6450 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6452 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6453 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6455 if (!spec->adc_nids && spec->input_mux) {
6456 /* check whether NID 0x04 is valid */
6457 unsigned int wcap = get_wcaps(codec, 0x04);
6458 wcap = get_wcaps_type(wcap);
6459 /* get type */
6460 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6461 spec->adc_nids = alc260_adc_nids_alt;
6462 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6463 } else {
6464 spec->adc_nids = alc260_adc_nids;
6465 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6468 set_capture_mixer(codec);
6469 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
6471 spec->vmaster_nid = 0x08;
6473 codec->patch_ops = alc_patch_ops;
6474 if (board_config == ALC260_AUTO)
6475 spec->init_hook = alc260_auto_init;
6476 #ifdef CONFIG_SND_HDA_POWER_SAVE
6477 if (!spec->loopback.amplist)
6478 spec->loopback.amplist = alc260_loopbacks;
6479 #endif
6480 codec->proc_widget_hook = print_realtek_coef;
6482 return 0;
6487 * ALC882/883/885/888/889 support
6489 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6490 * configuration. Each pin widget can choose any input DACs and a mixer.
6491 * Each ADC is connected from a mixer of all inputs. This makes possible
6492 * 6-channel independent captures.
6494 * In addition, an independent DAC for the multi-playback (not used in this
6495 * driver yet).
6497 #define ALC882_DIGOUT_NID 0x06
6498 #define ALC882_DIGIN_NID 0x0a
6499 #define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6500 #define ALC883_DIGIN_NID ALC882_DIGIN_NID
6501 #define ALC1200_DIGOUT_NID 0x10
6504 static struct hda_channel_mode alc882_ch_modes[1] = {
6505 { 8, NULL }
6508 /* DACs */
6509 static hda_nid_t alc882_dac_nids[4] = {
6510 /* front, rear, clfe, rear_surr */
6511 0x02, 0x03, 0x04, 0x05
6513 #define alc883_dac_nids alc882_dac_nids
6515 /* ADCs */
6516 #define alc882_adc_nids alc880_adc_nids
6517 #define alc882_adc_nids_alt alc880_adc_nids_alt
6518 #define alc883_adc_nids alc882_adc_nids_alt
6519 static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6520 static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6521 #define alc889_adc_nids alc880_adc_nids
6523 static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6524 static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6525 #define alc883_capsrc_nids alc882_capsrc_nids_alt
6526 static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6527 #define alc889_capsrc_nids alc882_capsrc_nids
6529 /* input MUX */
6530 /* FIXME: should be a matrix-type input source selection */
6532 static struct hda_input_mux alc882_capture_source = {
6533 .num_items = 4,
6534 .items = {
6535 { "Mic", 0x0 },
6536 { "Front Mic", 0x1 },
6537 { "Line", 0x2 },
6538 { "CD", 0x4 },
6542 #define alc883_capture_source alc882_capture_source
6544 static struct hda_input_mux alc889_capture_source = {
6545 .num_items = 3,
6546 .items = {
6547 { "Front Mic", 0x0 },
6548 { "Mic", 0x3 },
6549 { "Line", 0x2 },
6553 static struct hda_input_mux mb5_capture_source = {
6554 .num_items = 3,
6555 .items = {
6556 { "Mic", 0x1 },
6557 { "Line", 0x2 },
6558 { "CD", 0x4 },
6562 static struct hda_input_mux alc883_3stack_6ch_intel = {
6563 .num_items = 4,
6564 .items = {
6565 { "Mic", 0x1 },
6566 { "Front Mic", 0x0 },
6567 { "Line", 0x2 },
6568 { "CD", 0x4 },
6572 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6573 .num_items = 2,
6574 .items = {
6575 { "Mic", 0x1 },
6576 { "Line", 0x2 },
6580 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6581 .num_items = 4,
6582 .items = {
6583 { "Mic", 0x0 },
6584 { "iMic", 0x1 },
6585 { "Line", 0x2 },
6586 { "CD", 0x4 },
6590 static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6591 .num_items = 2,
6592 .items = {
6593 { "Mic", 0x0 },
6594 { "Int Mic", 0x1 },
6598 static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6599 .num_items = 3,
6600 .items = {
6601 { "Mic", 0x0 },
6602 { "Front Mic", 0x1 },
6603 { "Line", 0x4 },
6607 static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6608 .num_items = 2,
6609 .items = {
6610 { "Mic", 0x0 },
6611 { "Line", 0x2 },
6615 static struct hda_input_mux alc889A_mb31_capture_source = {
6616 .num_items = 2,
6617 .items = {
6618 { "Mic", 0x0 },
6619 /* Front Mic (0x01) unused */
6620 { "Line", 0x2 },
6621 /* Line 2 (0x03) unused */
6622 /* CD (0x04) unsused? */
6627 * 2ch mode
6629 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6630 { 2, NULL }
6634 * 2ch mode
6636 static struct hda_verb alc882_3ST_ch2_init[] = {
6637 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6638 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6639 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6640 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6641 { } /* end */
6645 * 4ch mode
6647 static struct hda_verb alc882_3ST_ch4_init[] = {
6648 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6649 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6650 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6651 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6652 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6653 { } /* end */
6657 * 6ch mode
6659 static struct hda_verb alc882_3ST_ch6_init[] = {
6660 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6661 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6662 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6663 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6664 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6665 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6666 { } /* end */
6669 static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
6670 { 2, alc882_3ST_ch2_init },
6671 { 4, alc882_3ST_ch4_init },
6672 { 6, alc882_3ST_ch6_init },
6675 #define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6678 * 2ch mode
6680 static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6681 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6682 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6683 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6684 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6685 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6686 { } /* end */
6690 * 4ch mode
6692 static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6693 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6694 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6695 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6696 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6697 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6698 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6699 { } /* end */
6703 * 6ch mode
6705 static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6706 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6707 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6708 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6709 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6710 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6711 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6712 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6713 { } /* end */
6716 static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6717 { 2, alc883_3ST_ch2_clevo_init },
6718 { 4, alc883_3ST_ch4_clevo_init },
6719 { 6, alc883_3ST_ch6_clevo_init },
6724 * 6ch mode
6726 static struct hda_verb alc882_sixstack_ch6_init[] = {
6727 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6728 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6729 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6730 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6731 { } /* end */
6735 * 8ch mode
6737 static struct hda_verb alc882_sixstack_ch8_init[] = {
6738 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6739 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6740 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6741 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6742 { } /* end */
6745 static struct hda_channel_mode alc882_sixstack_modes[2] = {
6746 { 6, alc882_sixstack_ch6_init },
6747 { 8, alc882_sixstack_ch8_init },
6751 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
6755 * 2ch mode
6757 static struct hda_verb alc885_mbp_ch2_init[] = {
6758 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6759 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6760 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6761 { } /* end */
6765 * 4ch mode
6767 static struct hda_verb alc885_mbp_ch4_init[] = {
6768 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6769 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6770 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6771 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6772 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6773 { } /* end */
6776 static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
6777 { 2, alc885_mbp_ch2_init },
6778 { 4, alc885_mbp_ch4_init },
6782 * 2ch
6783 * Speakers/Woofer/HP = Front
6784 * LineIn = Input
6786 static struct hda_verb alc885_mb5_ch2_init[] = {
6787 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6788 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6789 { } /* end */
6793 * 6ch mode
6794 * Speakers/HP = Front
6795 * Woofer = LFE
6796 * LineIn = Surround
6798 static struct hda_verb alc885_mb5_ch6_init[] = {
6799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6802 { } /* end */
6805 static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6806 { 2, alc885_mb5_ch2_init },
6807 { 6, alc885_mb5_ch6_init },
6812 * 2ch mode
6814 static struct hda_verb alc883_4ST_ch2_init[] = {
6815 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6816 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6817 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6818 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6819 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6820 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6821 { } /* end */
6825 * 4ch mode
6827 static struct hda_verb alc883_4ST_ch4_init[] = {
6828 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6829 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6830 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6831 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6832 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6833 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6834 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6835 { } /* end */
6839 * 6ch mode
6841 static struct hda_verb alc883_4ST_ch6_init[] = {
6842 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6843 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6844 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6845 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6846 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6847 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6848 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6849 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6850 { } /* end */
6854 * 8ch mode
6856 static struct hda_verb alc883_4ST_ch8_init[] = {
6857 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6858 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6859 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6860 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6861 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6862 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6865 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6866 { } /* end */
6869 static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6870 { 2, alc883_4ST_ch2_init },
6871 { 4, alc883_4ST_ch4_init },
6872 { 6, alc883_4ST_ch6_init },
6873 { 8, alc883_4ST_ch8_init },
6878 * 2ch mode
6880 static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6881 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6882 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6883 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6884 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6885 { } /* end */
6889 * 4ch mode
6891 static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6892 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6893 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6894 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6895 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6896 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6897 { } /* end */
6901 * 6ch mode
6903 static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6904 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6905 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6906 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6907 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6908 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6909 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6910 { } /* end */
6913 static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6914 { 2, alc883_3ST_ch2_intel_init },
6915 { 4, alc883_3ST_ch4_intel_init },
6916 { 6, alc883_3ST_ch6_intel_init },
6920 * 2ch mode
6922 static struct hda_verb alc889_ch2_intel_init[] = {
6923 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6924 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6925 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6926 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6927 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6928 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6929 { } /* end */
6933 * 6ch mode
6935 static struct hda_verb alc889_ch6_intel_init[] = {
6936 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6937 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6938 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6939 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6940 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6941 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6942 { } /* end */
6946 * 8ch mode
6948 static struct hda_verb alc889_ch8_intel_init[] = {
6949 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6950 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6951 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6952 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6953 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
6954 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6955 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6956 { } /* end */
6959 static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6960 { 2, alc889_ch2_intel_init },
6961 { 6, alc889_ch6_intel_init },
6962 { 8, alc889_ch8_intel_init },
6966 * 6ch mode
6968 static struct hda_verb alc883_sixstack_ch6_init[] = {
6969 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6970 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6971 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6972 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6973 { } /* end */
6977 * 8ch mode
6979 static struct hda_verb alc883_sixstack_ch8_init[] = {
6980 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6981 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6982 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6983 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6984 { } /* end */
6987 static struct hda_channel_mode alc883_sixstack_modes[2] = {
6988 { 6, alc883_sixstack_ch6_init },
6989 { 8, alc883_sixstack_ch8_init },
6993 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6994 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6996 static struct snd_kcontrol_new alc882_base_mixer[] = {
6997 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6998 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6999 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7000 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7001 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7002 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7003 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7004 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7005 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7006 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7008 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7009 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7011 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7012 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7013 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7016 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7018 { } /* end */
7021 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
7022 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7023 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7025 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7026 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7028 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7030 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7031 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
7032 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7033 { } /* end */
7036 static struct snd_kcontrol_new alc885_mb5_mixer[] = {
7037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7038 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7039 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7040 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7041 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7042 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7043 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7044 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
7045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7046 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7048 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7050 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7051 { } /* end */
7054 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7055 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7056 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7060 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7062 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7064 { } /* end */
7067 static struct snd_kcontrol_new alc882_targa_mixer[] = {
7068 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7069 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7070 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7071 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7072 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7073 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7074 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7078 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7079 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7080 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7081 { } /* end */
7084 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7085 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7087 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7089 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7091 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7092 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7093 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7094 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7095 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7096 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7097 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7101 { } /* end */
7104 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7105 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7106 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7107 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7115 { } /* end */
7118 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7120 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7121 .name = "Channel Mode",
7122 .info = alc_ch_mode_info,
7123 .get = alc_ch_mode_get,
7124 .put = alc_ch_mode_put,
7126 { } /* end */
7129 static struct hda_verb alc882_base_init_verbs[] = {
7130 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7133 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7134 /* Rear mixer */
7135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7136 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7137 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7138 /* CLFE mixer */
7139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7141 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7142 /* Side mixer */
7143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7144 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7145 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7147 /* mute analog input loopbacks */
7148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7154 /* Front Pin: output 0 (0x0c) */
7155 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7156 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7157 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7158 /* Rear Pin: output 1 (0x0d) */
7159 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7160 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7162 /* CLFE Pin: output 2 (0x0e) */
7163 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7164 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7165 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7166 /* Side Pin: output 3 (0x0f) */
7167 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7168 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7169 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7170 /* Mic (rear) pin: input vref at 80% */
7171 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7172 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7173 /* Front Mic pin: input vref at 80% */
7174 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7175 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7176 /* Line In pin: input */
7177 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7178 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7179 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7180 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7181 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7182 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7183 /* CD pin widget for input */
7184 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7186 /* FIXME: use matrix-type input source selection */
7187 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7188 /* Input mixer2 */
7189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7192 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7193 /* Input mixer3 */
7194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7198 /* ADC2: mute amp left and right */
7199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7200 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7201 /* ADC3: mute amp left and right */
7202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7203 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7208 static struct hda_verb alc882_adc1_init_verbs[] = {
7209 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7213 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7214 /* ADC1: mute amp left and right */
7215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7216 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7220 static struct hda_verb alc882_eapd_verbs[] = {
7221 /* change to EAPD mode */
7222 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7223 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
7227 static struct hda_verb alc889_eapd_verbs[] = {
7228 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7229 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7233 static struct hda_verb alc_hp15_unsol_verbs[] = {
7234 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7239 static struct hda_verb alc885_init_verbs[] = {
7240 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7244 /* Rear mixer */
7245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7247 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7248 /* CLFE mixer */
7249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7252 /* Side mixer */
7253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7255 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7257 /* mute analog input loopbacks */
7258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7262 /* Front HP Pin: output 0 (0x0c) */
7263 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7265 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7266 /* Front Pin: output 0 (0x0c) */
7267 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7268 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7269 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7270 /* Rear Pin: output 1 (0x0d) */
7271 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7272 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7273 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7274 /* CLFE Pin: output 2 (0x0e) */
7275 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7276 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7277 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7278 /* Side Pin: output 3 (0x0f) */
7279 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7280 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7281 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7282 /* Mic (rear) pin: input vref at 80% */
7283 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7284 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7285 /* Front Mic pin: input vref at 80% */
7286 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7287 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7288 /* Line In pin: input */
7289 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7290 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7292 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7293 /* Input mixer1 */
7294 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7296 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7297 /* Input mixer2 */
7298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7300 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7301 /* Input mixer3 */
7302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7305 /* ADC2: mute amp left and right */
7306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7307 /* ADC3: mute amp left and right */
7308 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7313 static struct hda_verb alc885_init_input_verbs[] = {
7314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7321 /* Unmute Selector 24h and set the default input to front mic */
7322 static struct hda_verb alc889_init_input_verbs[] = {
7323 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7329 #define alc883_init_verbs alc882_base_init_verbs
7331 /* Mac Pro test */
7332 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7333 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7334 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7335 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7336 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7337 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7338 /* FIXME: this looks suspicious...
7339 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7340 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
7342 { } /* end */
7345 static struct hda_verb alc882_macpro_init_verbs[] = {
7346 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7348 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7350 /* Front Pin: output 0 (0x0c) */
7351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7353 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7354 /* Front Mic pin: input vref at 80% */
7355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7357 /* Speaker: output */
7358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7359 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7360 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7361 /* Headphone output (output 0 - 0x0c) */
7362 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7363 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7364 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7366 /* FIXME: use matrix-type input source selection */
7367 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7368 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7371 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7373 /* Input mixer2 */
7374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7377 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7378 /* Input mixer3 */
7379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7382 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7383 /* ADC1: mute amp left and right */
7384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7385 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7386 /* ADC2: mute amp left and right */
7387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7388 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7389 /* ADC3: mute amp left and right */
7390 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7391 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7396 /* Macbook 5,1 */
7397 static struct hda_verb alc885_mb5_init_verbs[] = {
7398 /* DACs */
7399 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7400 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7401 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7402 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7403 /* Front mixer */
7404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7405 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7406 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7407 /* Surround mixer */
7408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7410 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7411 /* LFE mixer */
7412 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7414 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7415 /* HP mixer */
7416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7417 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7418 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7419 /* Front Pin (0x0c) */
7420 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7421 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7422 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7423 /* LFE Pin (0x0e) */
7424 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7425 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7426 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7427 /* HP Pin (0x0f) */
7428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7429 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7430 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7431 /* Front Mic pin: input vref at 80% */
7432 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7433 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7434 /* Line In pin */
7435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7441 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7445 /* Macbook Pro rev3 */
7446 static struct hda_verb alc885_mbp3_init_verbs[] = {
7447 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7450 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7451 /* Rear mixer */
7452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7454 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7455 /* HP mixer */
7456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7458 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7459 /* Front Pin: output 0 (0x0c) */
7460 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7461 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7462 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7463 /* HP Pin: output 0 (0x0e) */
7464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7466 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
7467 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7468 /* Mic (rear) pin: input vref at 80% */
7469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7471 /* Front Mic pin: input vref at 80% */
7472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7474 /* Line In pin: use output 1 when in LineOut mode */
7475 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7476 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7477 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7479 /* FIXME: use matrix-type input source selection */
7480 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7481 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7485 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7486 /* Input mixer2 */
7487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7490 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7491 /* Input mixer3 */
7492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7495 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7496 /* ADC1: mute amp left and right */
7497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7498 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7499 /* ADC2: mute amp left and right */
7500 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7501 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7502 /* ADC3: mute amp left and right */
7503 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7504 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7509 /* iMac 24 mixer. */
7510 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7511 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7512 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7513 { } /* end */
7516 /* iMac 24 init verbs. */
7517 static struct hda_verb alc885_imac24_init_verbs[] = {
7518 /* Internal speakers: output 0 (0x0c) */
7519 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7520 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7521 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7522 /* Internal speakers: output 0 (0x0c) */
7523 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7524 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7525 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7526 /* Headphone: output 0 (0x0c) */
7527 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7528 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7529 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7530 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7531 /* Front Mic: input vref at 80% */
7532 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7533 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7537 /* Toggle speaker-output according to the hp-jack state */
7538 static void alc885_imac24_setup(struct hda_codec *codec)
7540 struct alc_spec *spec = codec->spec;
7542 spec->autocfg.hp_pins[0] = 0x14;
7543 spec->autocfg.speaker_pins[0] = 0x18;
7544 spec->autocfg.speaker_pins[1] = 0x1a;
7547 static void alc885_mbp3_setup(struct hda_codec *codec)
7549 struct alc_spec *spec = codec->spec;
7551 spec->autocfg.hp_pins[0] = 0x15;
7552 spec->autocfg.speaker_pins[0] = 0x14;
7556 static struct hda_verb alc882_targa_verbs[] = {
7557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7560 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7561 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7563 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7564 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7565 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7567 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7568 { } /* end */
7571 /* toggle speaker-output according to the hp-jack state */
7572 static void alc882_targa_automute(struct hda_codec *codec)
7574 struct alc_spec *spec = codec->spec;
7575 alc_automute_amp(codec);
7576 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7577 spec->jack_present ? 1 : 3);
7580 static void alc882_targa_setup(struct hda_codec *codec)
7582 struct alc_spec *spec = codec->spec;
7584 spec->autocfg.hp_pins[0] = 0x14;
7585 spec->autocfg.speaker_pins[0] = 0x1b;
7588 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7590 if ((res >> 26) == ALC880_HP_EVENT)
7591 alc882_targa_automute(codec);
7594 static struct hda_verb alc882_asus_a7j_verbs[] = {
7595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7596 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7598 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7600 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7602 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7603 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7604 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7606 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7607 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7608 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7609 { } /* end */
7612 static struct hda_verb alc882_asus_a7m_verbs[] = {
7613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7614 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7616 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7617 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7618 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7620 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7621 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7622 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7624 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7625 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7626 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7627 { } /* end */
7630 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7632 unsigned int gpiostate, gpiomask, gpiodir;
7634 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7635 AC_VERB_GET_GPIO_DATA, 0);
7637 if (!muted)
7638 gpiostate |= (1 << pin);
7639 else
7640 gpiostate &= ~(1 << pin);
7642 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7643 AC_VERB_GET_GPIO_MASK, 0);
7644 gpiomask |= (1 << pin);
7646 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7647 AC_VERB_GET_GPIO_DIRECTION, 0);
7648 gpiodir |= (1 << pin);
7651 snd_hda_codec_write(codec, codec->afg, 0,
7652 AC_VERB_SET_GPIO_MASK, gpiomask);
7653 snd_hda_codec_write(codec, codec->afg, 0,
7654 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7656 msleep(1);
7658 snd_hda_codec_write(codec, codec->afg, 0,
7659 AC_VERB_SET_GPIO_DATA, gpiostate);
7662 /* set up GPIO at initialization */
7663 static void alc885_macpro_init_hook(struct hda_codec *codec)
7665 alc882_gpio_mute(codec, 0, 0);
7666 alc882_gpio_mute(codec, 1, 0);
7669 /* set up GPIO and update auto-muting at initialization */
7670 static void alc885_imac24_init_hook(struct hda_codec *codec)
7672 alc885_macpro_init_hook(codec);
7673 alc_automute_amp(codec);
7677 * generic initialization of ADC, input mixers and output mixers
7679 static struct hda_verb alc883_auto_init_verbs[] = {
7681 * Unmute ADC0-2 and set the default input to mic-in
7683 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7684 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7685 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7686 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7688 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7689 * mixer widget
7690 * Note: PASD motherboards uses the Line In 2 as the input for
7691 * front panel mic (mic 2)
7693 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7698 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7701 * Set up output mixers (0x0c - 0x0f)
7703 /* set vol=0 to output mixers */
7704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7705 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7707 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7708 /* set up input amps for analog loopback */
7709 /* Amp Indices: DAC = 0, mixer = 1 */
7710 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7712 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7713 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7714 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7716 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7717 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7718 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7719 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7721 /* FIXME: use matrix-type input source selection */
7722 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7723 /* Input mixer2 */
7724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7726 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7727 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7728 /* Input mixer3 */
7729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7732 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7737 /* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7738 static struct hda_verb alc889A_mb31_ch2_init[] = {
7739 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7740 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7741 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7742 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7743 { } /* end */
7746 /* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7747 static struct hda_verb alc889A_mb31_ch4_init[] = {
7748 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7749 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7750 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7751 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7752 { } /* end */
7755 /* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7756 static struct hda_verb alc889A_mb31_ch5_init[] = {
7757 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7758 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7759 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7760 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7761 { } /* end */
7764 /* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7765 static struct hda_verb alc889A_mb31_ch6_init[] = {
7766 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7767 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7768 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7769 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7770 { } /* end */
7773 static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7774 { 2, alc889A_mb31_ch2_init },
7775 { 4, alc889A_mb31_ch4_init },
7776 { 5, alc889A_mb31_ch5_init },
7777 { 6, alc889A_mb31_ch6_init },
7780 static struct hda_verb alc883_medion_eapd_verbs[] = {
7781 /* eanable EAPD on medion laptop */
7782 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7783 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7787 #define alc883_base_mixer alc882_base_mixer
7789 static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7791 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7792 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7793 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7794 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7795 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7796 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7798 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7800 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7801 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7802 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7803 { } /* end */
7806 static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
7807 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7808 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7810 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7812 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7814 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7815 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7816 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7817 { } /* end */
7820 static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7821 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7822 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7823 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7824 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7826 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7828 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7829 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7830 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7831 { } /* end */
7834 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7835 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7836 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7837 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7838 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7839 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7840 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7841 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7843 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7845 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7846 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7847 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7848 { } /* end */
7851 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7852 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7853 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7854 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7855 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7856 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7857 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7858 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7859 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7860 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7862 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7863 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7864 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7865 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7866 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7868 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7869 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7870 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7871 { } /* end */
7874 static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7875 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7876 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7877 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7878 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7879 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7880 HDA_OUTPUT),
7881 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7882 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7883 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7884 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7885 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7886 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7887 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7888 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7890 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7892 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7893 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7894 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7895 { } /* end */
7898 static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7899 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7900 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7901 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7902 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7903 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7904 HDA_OUTPUT),
7905 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7906 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7907 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7908 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7909 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7910 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7914 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7916 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7919 { } /* end */
7922 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
7923 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7924 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7925 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7926 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7927 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7928 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7929 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7930 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7932 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7933 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7934 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7935 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7937 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7939 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7940 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7941 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7942 { } /* end */
7945 static struct snd_kcontrol_new alc883_targa_mixer[] = {
7946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7948 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7949 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7950 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7951 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7952 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7953 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7954 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7955 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7956 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7957 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7958 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7959 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7961 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7962 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7963 { } /* end */
7966 static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
7967 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7968 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7970 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7971 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7972 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7974 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7976 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7977 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7978 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7979 { } /* end */
7982 static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
7983 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7984 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7986 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7987 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7988 { } /* end */
7991 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7993 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7994 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7995 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7996 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7998 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8000 { } /* end */
8003 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8005 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8008 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8011 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8012 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8013 { } /* end */
8016 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8017 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8019 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8024 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8025 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8026 { } /* end */
8029 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
8030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8031 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8032 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8033 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8034 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8035 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8036 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8037 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8038 { } /* end */
8041 static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8042 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8043 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8044 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8045 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
8046 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8047 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8048 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8049 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8051 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8052 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8053 { } /* end */
8056 static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8057 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8058 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8059 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8060 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8061 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8062 0x0d, 1, 0x0, HDA_OUTPUT),
8063 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8064 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8065 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8066 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8067 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8068 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8069 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8070 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8071 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8074 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8075 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8076 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8077 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8078 { } /* end */
8081 static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8082 /* Output mixers */
8083 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8084 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8085 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8086 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8087 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8088 HDA_OUTPUT),
8089 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8090 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8091 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8092 /* Output switches */
8093 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8094 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8095 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8096 /* Boost mixers */
8097 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8098 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8099 /* Input mixers */
8100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8102 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8103 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8104 { } /* end */
8107 static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8108 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8109 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8110 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8112 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8114 { } /* end */
8117 static struct hda_bind_ctls alc883_bind_cap_vol = {
8118 .ops = &snd_hda_bind_vol,
8119 .values = {
8120 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8121 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8126 static struct hda_bind_ctls alc883_bind_cap_switch = {
8127 .ops = &snd_hda_bind_sw,
8128 .values = {
8129 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8130 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8135 static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8136 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8137 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8139 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8140 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8142 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8144 { } /* end */
8147 static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
8148 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8149 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8151 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8152 /* .name = "Capture Source", */
8153 .name = "Input Source",
8154 .count = 1,
8155 .info = alc_mux_enum_info,
8156 .get = alc_mux_enum_get,
8157 .put = alc_mux_enum_put,
8159 { } /* end */
8162 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8164 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8165 .name = "Channel Mode",
8166 .info = alc_ch_mode_info,
8167 .get = alc_ch_mode_get,
8168 .put = alc_ch_mode_put,
8170 { } /* end */
8173 /* toggle speaker-output according to the hp-jack state */
8174 static void alc883_mitac_setup(struct hda_codec *codec)
8176 struct alc_spec *spec = codec->spec;
8178 spec->autocfg.hp_pins[0] = 0x15;
8179 spec->autocfg.speaker_pins[0] = 0x14;
8180 spec->autocfg.speaker_pins[1] = 0x17;
8183 /* auto-toggle front mic */
8185 static void alc883_mitac_mic_automute(struct hda_codec *codec)
8187 unsigned int present;
8188 unsigned char bits;
8190 present = snd_hda_codec_read(codec, 0x18, 0,
8191 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8192 bits = present ? HDA_AMP_MUTE : 0;
8193 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8197 static struct hda_verb alc883_mitac_verbs[] = {
8198 /* HP */
8199 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8200 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8201 /* Subwoofer */
8202 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8203 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8205 /* enable unsolicited event */
8206 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8207 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8209 { } /* end */
8212 static struct hda_verb alc883_clevo_m540r_verbs[] = {
8213 /* HP */
8214 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8216 /* Int speaker */
8217 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8219 /* enable unsolicited event */
8221 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8222 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8225 { } /* end */
8228 static struct hda_verb alc883_clevo_m720_verbs[] = {
8229 /* HP */
8230 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8232 /* Int speaker */
8233 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8236 /* enable unsolicited event */
8237 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8238 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8240 { } /* end */
8243 static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8244 /* HP */
8245 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8247 /* Subwoofer */
8248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8249 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8251 /* enable unsolicited event */
8252 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8254 { } /* end */
8257 static struct hda_verb alc883_targa_verbs[] = {
8258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8259 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8262 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8264 /* Connect Line-Out side jack (SPDIF) to Side */
8265 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8266 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8267 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8268 /* Connect Mic jack to CLFE */
8269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8270 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8271 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8272 /* Connect Line-in jack to Surround */
8273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8275 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8276 /* Connect HP out jack to Front */
8277 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8278 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8279 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8281 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8283 { } /* end */
8286 static struct hda_verb alc883_lenovo_101e_verbs[] = {
8287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8288 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8289 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8290 { } /* end */
8293 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8296 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8297 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8298 { } /* end */
8301 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8303 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8304 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8305 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8306 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8307 { } /* end */
8310 static struct hda_verb alc883_haier_w66_verbs[] = {
8311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8312 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8316 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8317 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8318 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8319 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8320 { } /* end */
8323 static struct hda_verb alc888_lenovo_sky_verbs[] = {
8324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8327 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8328 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8329 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8330 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8331 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8332 { } /* end */
8335 static struct hda_verb alc888_6st_dell_verbs[] = {
8336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8340 static struct hda_verb alc883_vaiott_verbs[] = {
8341 /* HP */
8342 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8345 /* enable unsolicited event */
8346 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8348 { } /* end */
8351 static void alc888_3st_hp_setup(struct hda_codec *codec)
8353 struct alc_spec *spec = codec->spec;
8355 spec->autocfg.hp_pins[0] = 0x1b;
8356 spec->autocfg.speaker_pins[0] = 0x14;
8357 spec->autocfg.speaker_pins[1] = 0x16;
8358 spec->autocfg.speaker_pins[2] = 0x18;
8361 static struct hda_verb alc888_3st_hp_verbs[] = {
8362 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
8363 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8364 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
8365 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8366 { } /* end */
8370 * 2ch mode
8372 static struct hda_verb alc888_3st_hp_2ch_init[] = {
8373 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8374 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8375 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8376 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8377 { } /* end */
8381 * 4ch mode
8383 static struct hda_verb alc888_3st_hp_4ch_init[] = {
8384 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8385 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8386 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8387 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8388 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8389 { } /* end */
8393 * 6ch mode
8395 static struct hda_verb alc888_3st_hp_6ch_init[] = {
8396 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8397 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8398 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
8399 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8400 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8401 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8402 { } /* end */
8405 static struct hda_channel_mode alc888_3st_hp_modes[3] = {
8406 { 2, alc888_3st_hp_2ch_init },
8407 { 4, alc888_3st_hp_4ch_init },
8408 { 6, alc888_3st_hp_6ch_init },
8411 /* toggle front-jack and RCA according to the hp-jack state */
8412 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8414 unsigned int present;
8416 present = snd_hda_codec_read(codec, 0x1b, 0,
8417 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8418 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8419 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8420 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8421 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8424 /* toggle RCA according to the front-jack state */
8425 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8427 unsigned int present;
8429 present = snd_hda_codec_read(codec, 0x14, 0,
8430 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8431 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8432 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8435 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8436 unsigned int res)
8438 if ((res >> 26) == ALC880_HP_EVENT)
8439 alc888_lenovo_ms7195_front_automute(codec);
8440 if ((res >> 26) == ALC880_FRONT_EVENT)
8441 alc888_lenovo_ms7195_rca_automute(codec);
8444 static struct hda_verb alc883_medion_md2_verbs[] = {
8445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8446 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8450 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8451 { } /* end */
8454 /* toggle speaker-output according to the hp-jack state */
8455 static void alc883_medion_md2_setup(struct hda_codec *codec)
8457 struct alc_spec *spec = codec->spec;
8459 spec->autocfg.hp_pins[0] = 0x14;
8460 spec->autocfg.speaker_pins[0] = 0x15;
8463 /* toggle speaker-output according to the hp-jack state */
8464 #define alc883_targa_init_hook alc882_targa_init_hook
8465 #define alc883_targa_unsol_event alc882_targa_unsol_event
8467 static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8469 unsigned int present;
8471 present = snd_hda_codec_read(codec, 0x18, 0,
8472 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8473 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8474 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8477 static void alc883_clevo_m720_setup(struct hda_codec *codec)
8479 struct alc_spec *spec = codec->spec;
8481 spec->autocfg.hp_pins[0] = 0x15;
8482 spec->autocfg.speaker_pins[0] = 0x14;
8485 static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8487 alc_automute_amp(codec);
8488 alc883_clevo_m720_mic_automute(codec);
8491 static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
8492 unsigned int res)
8494 switch (res >> 26) {
8495 case ALC880_MIC_EVENT:
8496 alc883_clevo_m720_mic_automute(codec);
8497 break;
8498 default:
8499 alc_automute_amp_unsol_event(codec, res);
8500 break;
8504 /* toggle speaker-output according to the hp-jack state */
8505 static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
8507 struct alc_spec *spec = codec->spec;
8509 spec->autocfg.hp_pins[0] = 0x14;
8510 spec->autocfg.speaker_pins[0] = 0x15;
8513 static void alc883_haier_w66_setup(struct hda_codec *codec)
8515 struct alc_spec *spec = codec->spec;
8517 spec->autocfg.hp_pins[0] = 0x1b;
8518 spec->autocfg.speaker_pins[0] = 0x14;
8521 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8523 unsigned int present;
8524 unsigned char bits;
8526 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8527 & AC_PINSENSE_PRESENCE;
8528 bits = present ? HDA_AMP_MUTE : 0;
8529 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8530 HDA_AMP_MUTE, bits);
8533 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8535 unsigned int present;
8536 unsigned char bits;
8538 present = snd_hda_codec_read(codec, 0x1b, 0,
8539 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8540 bits = present ? HDA_AMP_MUTE : 0;
8541 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8542 HDA_AMP_MUTE, bits);
8543 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8544 HDA_AMP_MUTE, bits);
8547 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8548 unsigned int res)
8550 if ((res >> 26) == ALC880_HP_EVENT)
8551 alc883_lenovo_101e_all_automute(codec);
8552 if ((res >> 26) == ALC880_FRONT_EVENT)
8553 alc883_lenovo_101e_ispeaker_automute(codec);
8556 /* toggle speaker-output according to the hp-jack state */
8557 static void alc883_acer_aspire_setup(struct hda_codec *codec)
8559 struct alc_spec *spec = codec->spec;
8561 spec->autocfg.hp_pins[0] = 0x14;
8562 spec->autocfg.speaker_pins[0] = 0x15;
8563 spec->autocfg.speaker_pins[1] = 0x16;
8566 static struct hda_verb alc883_acer_eapd_verbs[] = {
8567 /* HP Pin: output 0 (0x0c) */
8568 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8569 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8570 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8571 /* Front Pin: output 0 (0x0c) */
8572 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8573 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8574 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8575 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8576 /* eanable EAPD on medion laptop */
8577 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8578 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8579 /* enable unsolicited event */
8580 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8584 static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8585 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8586 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8587 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8588 { } /* end */
8591 static void alc888_6st_dell_setup(struct hda_codec *codec)
8593 struct alc_spec *spec = codec->spec;
8595 spec->autocfg.hp_pins[0] = 0x1b;
8596 spec->autocfg.speaker_pins[0] = 0x14;
8597 spec->autocfg.speaker_pins[1] = 0x15;
8598 spec->autocfg.speaker_pins[2] = 0x16;
8599 spec->autocfg.speaker_pins[3] = 0x17;
8602 static void alc888_lenovo_sky_setup(struct hda_codec *codec)
8604 struct alc_spec *spec = codec->spec;
8606 spec->autocfg.hp_pins[0] = 0x1b;
8607 spec->autocfg.speaker_pins[0] = 0x14;
8608 spec->autocfg.speaker_pins[1] = 0x15;
8609 spec->autocfg.speaker_pins[2] = 0x16;
8610 spec->autocfg.speaker_pins[3] = 0x17;
8611 spec->autocfg.speaker_pins[4] = 0x1a;
8614 static void alc883_vaiott_setup(struct hda_codec *codec)
8616 struct alc_spec *spec = codec->spec;
8618 spec->autocfg.hp_pins[0] = 0x15;
8619 spec->autocfg.speaker_pins[0] = 0x14;
8620 spec->autocfg.speaker_pins[1] = 0x17;
8623 static struct hda_verb alc888_asus_m90v_verbs[] = {
8624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8626 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8627 /* enable unsolicited event */
8628 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8629 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8630 { } /* end */
8633 static void alc883_mode2_setup(struct hda_codec *codec)
8635 struct alc_spec *spec = codec->spec;
8637 spec->autocfg.hp_pins[0] = 0x1b;
8638 spec->autocfg.speaker_pins[0] = 0x14;
8639 spec->autocfg.speaker_pins[1] = 0x15;
8640 spec->autocfg.speaker_pins[2] = 0x16;
8641 spec->ext_mic.pin = 0x18;
8642 spec->int_mic.pin = 0x19;
8643 spec->ext_mic.mux_idx = 0;
8644 spec->int_mic.mux_idx = 1;
8645 spec->auto_mic = 1;
8648 static struct hda_verb alc888_asus_eee1601_verbs[] = {
8649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8653 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8654 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8655 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8656 /* enable unsolicited event */
8657 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8658 { } /* end */
8661 static void alc883_eee1601_inithook(struct hda_codec *codec)
8663 struct alc_spec *spec = codec->spec;
8665 spec->autocfg.hp_pins[0] = 0x14;
8666 spec->autocfg.speaker_pins[0] = 0x1b;
8667 alc_automute_pin(codec);
8670 static struct hda_verb alc889A_mb31_verbs[] = {
8671 /* Init rear pin (used as headphone output) */
8672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8673 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8674 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8675 /* Init line pin (used as output in 4ch and 6ch mode) */
8676 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8677 /* Init line 2 pin (used as headphone out by default) */
8678 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8680 { } /* end */
8683 /* Mute speakers according to the headphone jack state */
8684 static void alc889A_mb31_automute(struct hda_codec *codec)
8686 unsigned int present;
8688 /* Mute only in 2ch or 4ch mode */
8689 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8690 == 0x00) {
8691 present = snd_hda_codec_read(codec, 0x15, 0,
8692 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8693 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8694 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8695 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8696 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8700 static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8702 if ((res >> 26) == ALC880_HP_EVENT)
8703 alc889A_mb31_automute(codec);
8707 #ifdef CONFIG_SND_HDA_POWER_SAVE
8708 #define alc882_loopbacks alc880_loopbacks
8709 #endif
8711 /* pcm configuration: identical with ALC880 */
8712 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
8713 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
8714 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
8715 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
8717 static hda_nid_t alc883_slave_dig_outs[] = {
8718 ALC1200_DIGOUT_NID, 0,
8721 static hda_nid_t alc1200_slave_dig_outs[] = {
8722 ALC883_DIGOUT_NID, 0,
8726 * configuration and preset
8728 static const char *alc882_models[ALC882_MODEL_LAST] = {
8729 [ALC882_3ST_DIG] = "3stack-dig",
8730 [ALC882_6ST_DIG] = "6stack-dig",
8731 [ALC882_ARIMA] = "arima",
8732 [ALC882_W2JC] = "w2jc",
8733 [ALC882_TARGA] = "targa",
8734 [ALC882_ASUS_A7J] = "asus-a7j",
8735 [ALC882_ASUS_A7M] = "asus-a7m",
8736 [ALC885_MACPRO] = "macpro",
8737 [ALC885_MB5] = "mb5",
8738 [ALC885_MBP3] = "mbp3",
8739 [ALC885_IMAC24] = "imac24",
8740 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
8741 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8742 [ALC883_3ST_6ch] = "3stack-6ch",
8743 [ALC883_6ST_DIG] = "alc883-6stack-dig",
8744 [ALC883_TARGA_DIG] = "targa-dig",
8745 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
8746 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
8747 [ALC883_ACER] = "acer",
8748 [ALC883_ACER_ASPIRE] = "acer-aspire",
8749 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
8750 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
8751 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
8752 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
8753 [ALC883_MEDION] = "medion",
8754 [ALC883_MEDION_MD2] = "medion-md2",
8755 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
8756 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
8757 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8758 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
8759 [ALC888_LENOVO_SKY] = "lenovo-sky",
8760 [ALC883_HAIER_W66] = "haier-w66",
8761 [ALC888_3ST_HP] = "3stack-hp",
8762 [ALC888_6ST_DELL] = "6stack-dell",
8763 [ALC883_MITAC] = "mitac",
8764 [ALC883_CLEVO_M540R] = "clevo-m540r",
8765 [ALC883_CLEVO_M720] = "clevo-m720",
8766 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
8767 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
8768 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
8769 [ALC889A_INTEL] = "intel-alc889a",
8770 [ALC889_INTEL] = "intel-x58",
8771 [ALC1200_ASUS_P5Q] = "asus-p5q",
8772 [ALC889A_MB31] = "mb31",
8773 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
8774 [ALC882_AUTO] = "auto",
8777 static struct snd_pci_quirk alc882_cfg_tbl[] = {
8778 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8780 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8781 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
8782 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
8783 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8784 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
8785 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
8786 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8787 ALC888_ACER_ASPIRE_4930G),
8788 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8789 ALC888_ACER_ASPIRE_4930G),
8790 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8791 ALC888_ACER_ASPIRE_8930G),
8792 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8793 ALC888_ACER_ASPIRE_8930G),
8794 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8795 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
8796 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8797 ALC888_ACER_ASPIRE_6530G),
8798 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8799 ALC888_ACER_ASPIRE_6530G),
8800 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8801 ALC888_ACER_ASPIRE_7730G),
8802 /* default Acer -- disabled as it causes more problems.
8803 * model=auto should work fine now
8805 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
8807 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8809 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
8810 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8811 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
8812 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
8813 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
8814 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
8816 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8817 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8818 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
8819 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8820 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8821 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8822 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
8823 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8824 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
8825 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
8826 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8828 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
8829 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
8830 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
8831 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
8832 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8833 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
8834 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
8835 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
8836 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8838 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8839 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8840 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
8841 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
8842 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
8843 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
8844 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
8845 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
8846 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8847 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8848 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8849 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8850 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8851 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8852 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
8853 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8854 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8855 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
8856 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
8857 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8858 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
8859 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
8860 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
8861 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
8862 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
8863 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
8864 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
8865 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
8866 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
8868 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
8869 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8870 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
8871 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
8872 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
8873 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8874 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
8875 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
8876 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
8877 ALC883_FUJITSU_PI2515),
8878 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
8879 ALC888_FUJITSU_XA3530),
8880 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
8881 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8882 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8883 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8884 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
8885 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
8886 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
8887 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
8888 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
8890 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8891 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
8892 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
8893 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8894 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8895 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
8896 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
8901 /* codec SSID table for Intel Mac */
8902 static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8903 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8904 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8905 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8906 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8907 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8908 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8909 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8910 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8911 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8912 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8913 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8914 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8915 * no perfect solution yet
8917 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8918 {} /* terminator */
8921 static struct alc_config_preset alc882_presets[] = {
8922 [ALC882_3ST_DIG] = {
8923 .mixers = { alc882_base_mixer },
8924 .init_verbs = { alc882_base_init_verbs,
8925 alc882_adc1_init_verbs },
8926 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8927 .dac_nids = alc882_dac_nids,
8928 .dig_out_nid = ALC882_DIGOUT_NID,
8929 .dig_in_nid = ALC882_DIGIN_NID,
8930 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8931 .channel_mode = alc882_ch_modes,
8932 .need_dac_fix = 1,
8933 .input_mux = &alc882_capture_source,
8935 [ALC882_6ST_DIG] = {
8936 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8937 .init_verbs = { alc882_base_init_verbs,
8938 alc882_adc1_init_verbs },
8939 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8940 .dac_nids = alc882_dac_nids,
8941 .dig_out_nid = ALC882_DIGOUT_NID,
8942 .dig_in_nid = ALC882_DIGIN_NID,
8943 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8944 .channel_mode = alc882_sixstack_modes,
8945 .input_mux = &alc882_capture_source,
8947 [ALC882_ARIMA] = {
8948 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8949 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8950 alc882_eapd_verbs },
8951 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8952 .dac_nids = alc882_dac_nids,
8953 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8954 .channel_mode = alc882_sixstack_modes,
8955 .input_mux = &alc882_capture_source,
8957 [ALC882_W2JC] = {
8958 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
8959 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8960 alc882_eapd_verbs, alc880_gpio1_init_verbs },
8961 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8962 .dac_nids = alc882_dac_nids,
8963 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8964 .channel_mode = alc880_threestack_modes,
8965 .need_dac_fix = 1,
8966 .input_mux = &alc882_capture_source,
8967 .dig_out_nid = ALC882_DIGOUT_NID,
8969 [ALC885_MBP3] = {
8970 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8971 .init_verbs = { alc885_mbp3_init_verbs,
8972 alc880_gpio1_init_verbs },
8973 .num_dacs = 2,
8974 .dac_nids = alc882_dac_nids,
8975 .hp_nid = 0x04,
8976 .channel_mode = alc885_mbp_4ch_modes,
8977 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
8978 .input_mux = &alc882_capture_source,
8979 .dig_out_nid = ALC882_DIGOUT_NID,
8980 .dig_in_nid = ALC882_DIGIN_NID,
8981 .unsol_event = alc_automute_amp_unsol_event,
8982 .setup = alc885_mbp3_setup,
8983 .init_hook = alc_automute_amp,
8985 [ALC885_MB5] = {
8986 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8987 .init_verbs = { alc885_mb5_init_verbs,
8988 alc880_gpio1_init_verbs },
8989 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8990 .dac_nids = alc882_dac_nids,
8991 .channel_mode = alc885_mb5_6ch_modes,
8992 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8993 .input_mux = &mb5_capture_source,
8994 .dig_out_nid = ALC882_DIGOUT_NID,
8995 .dig_in_nid = ALC882_DIGIN_NID,
8997 [ALC885_MACPRO] = {
8998 .mixers = { alc882_macpro_mixer },
8999 .init_verbs = { alc882_macpro_init_verbs },
9000 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9001 .dac_nids = alc882_dac_nids,
9002 .dig_out_nid = ALC882_DIGOUT_NID,
9003 .dig_in_nid = ALC882_DIGIN_NID,
9004 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9005 .channel_mode = alc882_ch_modes,
9006 .input_mux = &alc882_capture_source,
9007 .init_hook = alc885_macpro_init_hook,
9009 [ALC885_IMAC24] = {
9010 .mixers = { alc885_imac24_mixer },
9011 .init_verbs = { alc885_imac24_init_verbs },
9012 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9013 .dac_nids = alc882_dac_nids,
9014 .dig_out_nid = ALC882_DIGOUT_NID,
9015 .dig_in_nid = ALC882_DIGIN_NID,
9016 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9017 .channel_mode = alc882_ch_modes,
9018 .input_mux = &alc882_capture_source,
9019 .unsol_event = alc_automute_amp_unsol_event,
9020 .setup = alc885_imac24_setup,
9021 .init_hook = alc885_imac24_init_hook,
9023 [ALC882_TARGA] = {
9024 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
9025 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9026 alc880_gpio3_init_verbs, alc882_targa_verbs},
9027 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9028 .dac_nids = alc882_dac_nids,
9029 .dig_out_nid = ALC882_DIGOUT_NID,
9030 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9031 .adc_nids = alc882_adc_nids,
9032 .capsrc_nids = alc882_capsrc_nids,
9033 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9034 .channel_mode = alc882_3ST_6ch_modes,
9035 .need_dac_fix = 1,
9036 .input_mux = &alc882_capture_source,
9037 .unsol_event = alc882_targa_unsol_event,
9038 .setup = alc882_targa_setup,
9039 .init_hook = alc882_targa_automute,
9041 [ALC882_ASUS_A7J] = {
9042 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
9043 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9044 alc882_asus_a7j_verbs},
9045 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9046 .dac_nids = alc882_dac_nids,
9047 .dig_out_nid = ALC882_DIGOUT_NID,
9048 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9049 .adc_nids = alc882_adc_nids,
9050 .capsrc_nids = alc882_capsrc_nids,
9051 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9052 .channel_mode = alc882_3ST_6ch_modes,
9053 .need_dac_fix = 1,
9054 .input_mux = &alc882_capture_source,
9056 [ALC882_ASUS_A7M] = {
9057 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
9058 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9059 alc882_eapd_verbs, alc880_gpio1_init_verbs,
9060 alc882_asus_a7m_verbs },
9061 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9062 .dac_nids = alc882_dac_nids,
9063 .dig_out_nid = ALC882_DIGOUT_NID,
9064 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9065 .channel_mode = alc880_threestack_modes,
9066 .need_dac_fix = 1,
9067 .input_mux = &alc882_capture_source,
9069 [ALC883_3ST_2ch_DIG] = {
9070 .mixers = { alc883_3ST_2ch_mixer },
9071 .init_verbs = { alc883_init_verbs },
9072 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9073 .dac_nids = alc883_dac_nids,
9074 .dig_out_nid = ALC883_DIGOUT_NID,
9075 .dig_in_nid = ALC883_DIGIN_NID,
9076 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9077 .channel_mode = alc883_3ST_2ch_modes,
9078 .input_mux = &alc883_capture_source,
9080 [ALC883_3ST_6ch_DIG] = {
9081 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9082 .init_verbs = { alc883_init_verbs },
9083 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9084 .dac_nids = alc883_dac_nids,
9085 .dig_out_nid = ALC883_DIGOUT_NID,
9086 .dig_in_nid = ALC883_DIGIN_NID,
9087 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9088 .channel_mode = alc883_3ST_6ch_modes,
9089 .need_dac_fix = 1,
9090 .input_mux = &alc883_capture_source,
9092 [ALC883_3ST_6ch] = {
9093 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9094 .init_verbs = { alc883_init_verbs },
9095 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9096 .dac_nids = alc883_dac_nids,
9097 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9098 .channel_mode = alc883_3ST_6ch_modes,
9099 .need_dac_fix = 1,
9100 .input_mux = &alc883_capture_source,
9102 [ALC883_3ST_6ch_INTEL] = {
9103 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9104 .init_verbs = { alc883_init_verbs },
9105 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9106 .dac_nids = alc883_dac_nids,
9107 .dig_out_nid = ALC883_DIGOUT_NID,
9108 .dig_in_nid = ALC883_DIGIN_NID,
9109 .slave_dig_outs = alc883_slave_dig_outs,
9110 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9111 .channel_mode = alc883_3ST_6ch_intel_modes,
9112 .need_dac_fix = 1,
9113 .input_mux = &alc883_3stack_6ch_intel,
9115 [ALC889A_INTEL] = {
9116 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9117 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9118 alc_hp15_unsol_verbs },
9119 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9120 .dac_nids = alc883_dac_nids,
9121 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9122 .adc_nids = alc889_adc_nids,
9123 .dig_out_nid = ALC883_DIGOUT_NID,
9124 .dig_in_nid = ALC883_DIGIN_NID,
9125 .slave_dig_outs = alc883_slave_dig_outs,
9126 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9127 .channel_mode = alc889_8ch_intel_modes,
9128 .capsrc_nids = alc889_capsrc_nids,
9129 .input_mux = &alc889_capture_source,
9130 .setup = alc889_automute_setup,
9131 .init_hook = alc_automute_amp,
9132 .unsol_event = alc_automute_amp_unsol_event,
9133 .need_dac_fix = 1,
9135 [ALC889_INTEL] = {
9136 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9137 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
9138 alc889_eapd_verbs, alc_hp15_unsol_verbs},
9139 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9140 .dac_nids = alc883_dac_nids,
9141 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9142 .adc_nids = alc889_adc_nids,
9143 .dig_out_nid = ALC883_DIGOUT_NID,
9144 .dig_in_nid = ALC883_DIGIN_NID,
9145 .slave_dig_outs = alc883_slave_dig_outs,
9146 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9147 .channel_mode = alc889_8ch_intel_modes,
9148 .capsrc_nids = alc889_capsrc_nids,
9149 .input_mux = &alc889_capture_source,
9150 .setup = alc889_automute_setup,
9151 .init_hook = alc889_intel_init_hook,
9152 .unsol_event = alc_automute_amp_unsol_event,
9153 .need_dac_fix = 1,
9155 [ALC883_6ST_DIG] = {
9156 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9157 .init_verbs = { alc883_init_verbs },
9158 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9159 .dac_nids = alc883_dac_nids,
9160 .dig_out_nid = ALC883_DIGOUT_NID,
9161 .dig_in_nid = ALC883_DIGIN_NID,
9162 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9163 .channel_mode = alc883_sixstack_modes,
9164 .input_mux = &alc883_capture_source,
9166 [ALC883_TARGA_DIG] = {
9167 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
9168 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9169 alc883_targa_verbs},
9170 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9171 .dac_nids = alc883_dac_nids,
9172 .dig_out_nid = ALC883_DIGOUT_NID,
9173 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9174 .channel_mode = alc883_3ST_6ch_modes,
9175 .need_dac_fix = 1,
9176 .input_mux = &alc883_capture_source,
9177 .unsol_event = alc883_targa_unsol_event,
9178 .setup = alc882_targa_setup,
9179 .init_hook = alc882_targa_automute,
9181 [ALC883_TARGA_2ch_DIG] = {
9182 .mixers = { alc883_targa_2ch_mixer},
9183 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9184 alc883_targa_verbs},
9185 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9186 .dac_nids = alc883_dac_nids,
9187 .adc_nids = alc883_adc_nids_alt,
9188 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
9189 .dig_out_nid = ALC883_DIGOUT_NID,
9190 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9191 .channel_mode = alc883_3ST_2ch_modes,
9192 .input_mux = &alc883_capture_source,
9193 .unsol_event = alc883_targa_unsol_event,
9194 .setup = alc882_targa_setup,
9195 .init_hook = alc882_targa_automute,
9197 [ALC883_TARGA_8ch_DIG] = {
9198 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9199 alc883_chmode_mixer },
9200 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9201 alc883_targa_verbs },
9202 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9203 .dac_nids = alc883_dac_nids,
9204 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9205 .adc_nids = alc883_adc_nids_rev,
9206 .capsrc_nids = alc883_capsrc_nids_rev,
9207 .dig_out_nid = ALC883_DIGOUT_NID,
9208 .dig_in_nid = ALC883_DIGIN_NID,
9209 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9210 .channel_mode = alc883_4ST_8ch_modes,
9211 .need_dac_fix = 1,
9212 .input_mux = &alc883_capture_source,
9213 .unsol_event = alc883_targa_unsol_event,
9214 .setup = alc882_targa_setup,
9215 .init_hook = alc882_targa_automute,
9217 [ALC883_ACER] = {
9218 .mixers = { alc883_base_mixer },
9219 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9220 * and the headphone jack. Turn this on and rely on the
9221 * standard mute methods whenever the user wants to turn
9222 * these outputs off.
9224 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9225 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9226 .dac_nids = alc883_dac_nids,
9227 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9228 .channel_mode = alc883_3ST_2ch_modes,
9229 .input_mux = &alc883_capture_source,
9231 [ALC883_ACER_ASPIRE] = {
9232 .mixers = { alc883_acer_aspire_mixer },
9233 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
9234 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9235 .dac_nids = alc883_dac_nids,
9236 .dig_out_nid = ALC883_DIGOUT_NID,
9237 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9238 .channel_mode = alc883_3ST_2ch_modes,
9239 .input_mux = &alc883_capture_source,
9240 .unsol_event = alc_automute_amp_unsol_event,
9241 .setup = alc883_acer_aspire_setup,
9242 .init_hook = alc_automute_amp,
9244 [ALC888_ACER_ASPIRE_4930G] = {
9245 .mixers = { alc888_base_mixer,
9246 alc883_chmode_mixer },
9247 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9248 alc888_acer_aspire_4930g_verbs },
9249 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9250 .dac_nids = alc883_dac_nids,
9251 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9252 .adc_nids = alc883_adc_nids_rev,
9253 .capsrc_nids = alc883_capsrc_nids_rev,
9254 .dig_out_nid = ALC883_DIGOUT_NID,
9255 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9256 .channel_mode = alc883_3ST_6ch_modes,
9257 .need_dac_fix = 1,
9258 .num_mux_defs =
9259 ARRAY_SIZE(alc888_2_capture_sources),
9260 .input_mux = alc888_2_capture_sources,
9261 .unsol_event = alc_automute_amp_unsol_event,
9262 .setup = alc888_acer_aspire_4930g_setup,
9263 .init_hook = alc_automute_amp,
9265 [ALC888_ACER_ASPIRE_6530G] = {
9266 .mixers = { alc888_acer_aspire_6530_mixer },
9267 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9268 alc888_acer_aspire_6530g_verbs },
9269 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9270 .dac_nids = alc883_dac_nids,
9271 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9272 .adc_nids = alc883_adc_nids_rev,
9273 .capsrc_nids = alc883_capsrc_nids_rev,
9274 .dig_out_nid = ALC883_DIGOUT_NID,
9275 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9276 .channel_mode = alc883_3ST_2ch_modes,
9277 .num_mux_defs =
9278 ARRAY_SIZE(alc888_2_capture_sources),
9279 .input_mux = alc888_acer_aspire_6530_sources,
9280 .unsol_event = alc_automute_amp_unsol_event,
9281 .setup = alc888_acer_aspire_6530g_setup,
9282 .init_hook = alc_automute_amp,
9284 [ALC888_ACER_ASPIRE_8930G] = {
9285 .mixers = { alc888_base_mixer,
9286 alc883_chmode_mixer },
9287 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9288 alc889_acer_aspire_8930g_verbs },
9289 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9290 .dac_nids = alc883_dac_nids,
9291 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9292 .adc_nids = alc889_adc_nids,
9293 .capsrc_nids = alc889_capsrc_nids,
9294 .dig_out_nid = ALC883_DIGOUT_NID,
9295 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9296 .channel_mode = alc883_3ST_6ch_modes,
9297 .need_dac_fix = 1,
9298 .const_channel_count = 6,
9299 .num_mux_defs =
9300 ARRAY_SIZE(alc889_capture_sources),
9301 .input_mux = alc889_capture_sources,
9302 .unsol_event = alc_automute_amp_unsol_event,
9303 .setup = alc889_acer_aspire_8930g_setup,
9304 .init_hook = alc_automute_amp,
9306 [ALC888_ACER_ASPIRE_7730G] = {
9307 .mixers = { alc883_3ST_6ch_mixer,
9308 alc883_chmode_mixer },
9309 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9310 alc888_acer_aspire_7730G_verbs },
9311 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9312 .dac_nids = alc883_dac_nids,
9313 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9314 .adc_nids = alc883_adc_nids_rev,
9315 .capsrc_nids = alc883_capsrc_nids_rev,
9316 .dig_out_nid = ALC883_DIGOUT_NID,
9317 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9318 .channel_mode = alc883_3ST_6ch_modes,
9319 .need_dac_fix = 1,
9320 .const_channel_count = 6,
9321 .input_mux = &alc883_capture_source,
9322 .unsol_event = alc_automute_amp_unsol_event,
9323 .setup = alc888_acer_aspire_6530g_setup,
9324 .init_hook = alc_automute_amp,
9326 [ALC883_MEDION] = {
9327 .mixers = { alc883_fivestack_mixer,
9328 alc883_chmode_mixer },
9329 .init_verbs = { alc883_init_verbs,
9330 alc883_medion_eapd_verbs },
9331 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9332 .dac_nids = alc883_dac_nids,
9333 .adc_nids = alc883_adc_nids_alt,
9334 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
9335 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9336 .channel_mode = alc883_sixstack_modes,
9337 .input_mux = &alc883_capture_source,
9339 [ALC883_MEDION_MD2] = {
9340 .mixers = { alc883_medion_md2_mixer},
9341 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9342 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9343 .dac_nids = alc883_dac_nids,
9344 .dig_out_nid = ALC883_DIGOUT_NID,
9345 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9346 .channel_mode = alc883_3ST_2ch_modes,
9347 .input_mux = &alc883_capture_source,
9348 .unsol_event = alc_automute_amp_unsol_event,
9349 .setup = alc883_medion_md2_setup,
9350 .init_hook = alc_automute_amp,
9352 [ALC883_LAPTOP_EAPD] = {
9353 .mixers = { alc883_base_mixer },
9354 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9355 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9356 .dac_nids = alc883_dac_nids,
9357 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9358 .channel_mode = alc883_3ST_2ch_modes,
9359 .input_mux = &alc883_capture_source,
9361 [ALC883_CLEVO_M540R] = {
9362 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9363 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9364 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9365 .dac_nids = alc883_dac_nids,
9366 .dig_out_nid = ALC883_DIGOUT_NID,
9367 .dig_in_nid = ALC883_DIGIN_NID,
9368 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9369 .channel_mode = alc883_3ST_6ch_clevo_modes,
9370 .need_dac_fix = 1,
9371 .input_mux = &alc883_capture_source,
9372 /* This machine has the hardware HP auto-muting, thus
9373 * we need no software mute via unsol event
9376 [ALC883_CLEVO_M720] = {
9377 .mixers = { alc883_clevo_m720_mixer },
9378 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
9379 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9380 .dac_nids = alc883_dac_nids,
9381 .dig_out_nid = ALC883_DIGOUT_NID,
9382 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9383 .channel_mode = alc883_3ST_2ch_modes,
9384 .input_mux = &alc883_capture_source,
9385 .unsol_event = alc883_clevo_m720_unsol_event,
9386 .setup = alc883_clevo_m720_setup,
9387 .init_hook = alc883_clevo_m720_init_hook,
9389 [ALC883_LENOVO_101E_2ch] = {
9390 .mixers = { alc883_lenovo_101e_2ch_mixer},
9391 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9392 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9393 .dac_nids = alc883_dac_nids,
9394 .adc_nids = alc883_adc_nids_alt,
9395 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
9396 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9397 .channel_mode = alc883_3ST_2ch_modes,
9398 .input_mux = &alc883_lenovo_101e_capture_source,
9399 .unsol_event = alc883_lenovo_101e_unsol_event,
9400 .init_hook = alc883_lenovo_101e_all_automute,
9402 [ALC883_LENOVO_NB0763] = {
9403 .mixers = { alc883_lenovo_nb0763_mixer },
9404 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9405 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9406 .dac_nids = alc883_dac_nids,
9407 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9408 .channel_mode = alc883_3ST_2ch_modes,
9409 .need_dac_fix = 1,
9410 .input_mux = &alc883_lenovo_nb0763_capture_source,
9411 .unsol_event = alc_automute_amp_unsol_event,
9412 .setup = alc883_medion_md2_setup,
9413 .init_hook = alc_automute_amp,
9415 [ALC888_LENOVO_MS7195_DIG] = {
9416 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9417 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9418 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9419 .dac_nids = alc883_dac_nids,
9420 .dig_out_nid = ALC883_DIGOUT_NID,
9421 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9422 .channel_mode = alc883_3ST_6ch_modes,
9423 .need_dac_fix = 1,
9424 .input_mux = &alc883_capture_source,
9425 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9426 .init_hook = alc888_lenovo_ms7195_front_automute,
9428 [ALC883_HAIER_W66] = {
9429 .mixers = { alc883_targa_2ch_mixer},
9430 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9431 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9432 .dac_nids = alc883_dac_nids,
9433 .dig_out_nid = ALC883_DIGOUT_NID,
9434 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9435 .channel_mode = alc883_3ST_2ch_modes,
9436 .input_mux = &alc883_capture_source,
9437 .unsol_event = alc_automute_amp_unsol_event,
9438 .setup = alc883_haier_w66_setup,
9439 .init_hook = alc_automute_amp,
9441 [ALC888_3ST_HP] = {
9442 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9443 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
9444 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9445 .dac_nids = alc883_dac_nids,
9446 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9447 .channel_mode = alc888_3st_hp_modes,
9448 .need_dac_fix = 1,
9449 .input_mux = &alc883_capture_source,
9450 .unsol_event = alc_automute_amp_unsol_event,
9451 .setup = alc888_3st_hp_setup,
9452 .init_hook = alc_automute_amp,
9454 [ALC888_6ST_DELL] = {
9455 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9456 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9457 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9458 .dac_nids = alc883_dac_nids,
9459 .dig_out_nid = ALC883_DIGOUT_NID,
9460 .dig_in_nid = ALC883_DIGIN_NID,
9461 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9462 .channel_mode = alc883_sixstack_modes,
9463 .input_mux = &alc883_capture_source,
9464 .unsol_event = alc_automute_amp_unsol_event,
9465 .setup = alc888_6st_dell_setup,
9466 .init_hook = alc_automute_amp,
9468 [ALC883_MITAC] = {
9469 .mixers = { alc883_mitac_mixer },
9470 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9471 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9472 .dac_nids = alc883_dac_nids,
9473 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9474 .channel_mode = alc883_3ST_2ch_modes,
9475 .input_mux = &alc883_capture_source,
9476 .unsol_event = alc_automute_amp_unsol_event,
9477 .setup = alc883_mitac_setup,
9478 .init_hook = alc_automute_amp,
9480 [ALC883_FUJITSU_PI2515] = {
9481 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9482 .init_verbs = { alc883_init_verbs,
9483 alc883_2ch_fujitsu_pi2515_verbs},
9484 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9485 .dac_nids = alc883_dac_nids,
9486 .dig_out_nid = ALC883_DIGOUT_NID,
9487 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9488 .channel_mode = alc883_3ST_2ch_modes,
9489 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9490 .unsol_event = alc_automute_amp_unsol_event,
9491 .setup = alc883_2ch_fujitsu_pi2515_setup,
9492 .init_hook = alc_automute_amp,
9494 [ALC888_FUJITSU_XA3530] = {
9495 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9496 .init_verbs = { alc883_init_verbs,
9497 alc888_fujitsu_xa3530_verbs },
9498 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9499 .dac_nids = alc883_dac_nids,
9500 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9501 .adc_nids = alc883_adc_nids_rev,
9502 .capsrc_nids = alc883_capsrc_nids_rev,
9503 .dig_out_nid = ALC883_DIGOUT_NID,
9504 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9505 .channel_mode = alc888_4ST_8ch_intel_modes,
9506 .num_mux_defs =
9507 ARRAY_SIZE(alc888_2_capture_sources),
9508 .input_mux = alc888_2_capture_sources,
9509 .unsol_event = alc_automute_amp_unsol_event,
9510 .setup = alc888_fujitsu_xa3530_setup,
9511 .init_hook = alc_automute_amp,
9513 [ALC888_LENOVO_SKY] = {
9514 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9515 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9516 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9517 .dac_nids = alc883_dac_nids,
9518 .dig_out_nid = ALC883_DIGOUT_NID,
9519 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9520 .channel_mode = alc883_sixstack_modes,
9521 .need_dac_fix = 1,
9522 .input_mux = &alc883_lenovo_sky_capture_source,
9523 .unsol_event = alc_automute_amp_unsol_event,
9524 .setup = alc888_lenovo_sky_setup,
9525 .init_hook = alc_automute_amp,
9527 [ALC888_ASUS_M90V] = {
9528 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9529 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9530 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9531 .dac_nids = alc883_dac_nids,
9532 .dig_out_nid = ALC883_DIGOUT_NID,
9533 .dig_in_nid = ALC883_DIGIN_NID,
9534 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9535 .channel_mode = alc883_3ST_6ch_modes,
9536 .need_dac_fix = 1,
9537 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9538 .unsol_event = alc_sku_unsol_event,
9539 .setup = alc883_mode2_setup,
9540 .init_hook = alc_inithook,
9542 [ALC888_ASUS_EEE1601] = {
9543 .mixers = { alc883_asus_eee1601_mixer },
9544 .cap_mixer = alc883_asus_eee1601_cap_mixer,
9545 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9546 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9547 .dac_nids = alc883_dac_nids,
9548 .dig_out_nid = ALC883_DIGOUT_NID,
9549 .dig_in_nid = ALC883_DIGIN_NID,
9550 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9551 .channel_mode = alc883_3ST_2ch_modes,
9552 .need_dac_fix = 1,
9553 .input_mux = &alc883_asus_eee1601_capture_source,
9554 .unsol_event = alc_sku_unsol_event,
9555 .init_hook = alc883_eee1601_inithook,
9557 [ALC1200_ASUS_P5Q] = {
9558 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9559 .init_verbs = { alc883_init_verbs },
9560 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9561 .dac_nids = alc883_dac_nids,
9562 .dig_out_nid = ALC1200_DIGOUT_NID,
9563 .dig_in_nid = ALC883_DIGIN_NID,
9564 .slave_dig_outs = alc1200_slave_dig_outs,
9565 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9566 .channel_mode = alc883_sixstack_modes,
9567 .input_mux = &alc883_capture_source,
9569 [ALC889A_MB31] = {
9570 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9571 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9572 alc880_gpio1_init_verbs },
9573 .adc_nids = alc883_adc_nids,
9574 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9575 .dac_nids = alc883_dac_nids,
9576 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9577 .channel_mode = alc889A_mb31_6ch_modes,
9578 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9579 .input_mux = &alc889A_mb31_capture_source,
9580 .dig_out_nid = ALC883_DIGOUT_NID,
9581 .unsol_event = alc889A_mb31_unsol_event,
9582 .init_hook = alc889A_mb31_automute,
9584 [ALC883_SONY_VAIO_TT] = {
9585 .mixers = { alc883_vaiott_mixer },
9586 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9587 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9588 .dac_nids = alc883_dac_nids,
9589 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9590 .channel_mode = alc883_3ST_2ch_modes,
9591 .input_mux = &alc883_capture_source,
9592 .unsol_event = alc_automute_amp_unsol_event,
9593 .setup = alc883_vaiott_setup,
9594 .init_hook = alc_automute_amp,
9600 * Pin config fixes
9602 enum {
9603 PINFIX_ABIT_AW9D_MAX
9606 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9607 { 0x15, 0x01080104 }, /* side */
9608 { 0x16, 0x01011012 }, /* rear */
9609 { 0x17, 0x01016011 }, /* clfe */
9613 static const struct alc_fixup alc882_fixups[] = {
9614 [PINFIX_ABIT_AW9D_MAX] = {
9615 .pins = alc882_abit_aw9d_pinfix
9619 static struct snd_pci_quirk alc882_fixup_tbl[] = {
9620 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9625 * BIOS auto configuration
9627 static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9628 const struct auto_pin_cfg *cfg)
9630 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9633 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
9634 hda_nid_t nid, int pin_type,
9635 int dac_idx)
9637 /* set as output */
9638 struct alc_spec *spec = codec->spec;
9639 int idx;
9641 alc_set_pin_output(codec, nid, pin_type);
9642 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9643 idx = 4;
9644 else
9645 idx = spec->multiout.dac_nids[dac_idx] - 2;
9646 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9650 static void alc882_auto_init_multi_out(struct hda_codec *codec)
9652 struct alc_spec *spec = codec->spec;
9653 int i;
9655 for (i = 0; i <= HDA_SIDE; i++) {
9656 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9657 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9658 if (nid)
9659 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
9664 static void alc882_auto_init_hp_out(struct hda_codec *codec)
9666 struct alc_spec *spec = codec->spec;
9667 hda_nid_t pin;
9669 pin = spec->autocfg.hp_pins[0];
9670 if (pin) /* connect to front */
9671 /* use dac 0 */
9672 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
9673 pin = spec->autocfg.speaker_pins[0];
9674 if (pin)
9675 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
9678 static void alc882_auto_init_analog_input(struct hda_codec *codec)
9680 struct alc_spec *spec = codec->spec;
9681 int i;
9683 for (i = 0; i < AUTO_PIN_LAST; i++) {
9684 hda_nid_t nid = spec->autocfg.input_pins[i];
9685 if (!nid)
9686 continue;
9687 alc_set_input_pin(codec, nid, i);
9688 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9689 snd_hda_codec_write(codec, nid, 0,
9690 AC_VERB_SET_AMP_GAIN_MUTE,
9691 AMP_OUT_MUTE);
9695 static void alc882_auto_init_input_src(struct hda_codec *codec)
9697 struct alc_spec *spec = codec->spec;
9698 int c;
9700 for (c = 0; c < spec->num_adc_nids; c++) {
9701 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9702 hda_nid_t nid = spec->capsrc_nids[c];
9703 unsigned int mux_idx;
9704 const struct hda_input_mux *imux;
9705 int conns, mute, idx, item;
9707 conns = snd_hda_get_connections(codec, nid, conn_list,
9708 ARRAY_SIZE(conn_list));
9709 if (conns < 0)
9710 continue;
9711 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9712 imux = &spec->input_mux[mux_idx];
9713 for (idx = 0; idx < conns; idx++) {
9714 /* if the current connection is the selected one,
9715 * unmute it as default - otherwise mute it
9717 mute = AMP_IN_MUTE(idx);
9718 for (item = 0; item < imux->num_items; item++) {
9719 if (imux->items[item].index == idx) {
9720 if (spec->cur_mux[c] == item)
9721 mute = AMP_IN_UNMUTE(idx);
9722 break;
9725 /* check if we have a selector or mixer
9726 * we could check for the widget type instead, but
9727 * just check for Amp-In presence (in case of mixer
9728 * without amp-in there is something wrong, this
9729 * function shouldn't be used or capsrc nid is wrong)
9731 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
9732 snd_hda_codec_write(codec, nid, 0,
9733 AC_VERB_SET_AMP_GAIN_MUTE,
9734 mute);
9735 else if (mute != AMP_IN_MUTE(idx))
9736 snd_hda_codec_write(codec, nid, 0,
9737 AC_VERB_SET_CONNECT_SEL,
9738 idx);
9743 /* add mic boosts if needed */
9744 static int alc_auto_add_mic_boost(struct hda_codec *codec)
9746 struct alc_spec *spec = codec->spec;
9747 int err;
9748 hda_nid_t nid;
9750 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9751 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9752 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9753 "Mic Boost",
9754 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9755 if (err < 0)
9756 return err;
9758 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9759 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9760 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9761 "Front Mic Boost",
9762 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9763 if (err < 0)
9764 return err;
9766 return 0;
9769 /* almost identical with ALC880 parser... */
9770 static int alc882_parse_auto_config(struct hda_codec *codec)
9772 struct alc_spec *spec = codec->spec;
9773 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9774 int i, err;
9776 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9777 alc882_ignore);
9778 if (err < 0)
9779 return err;
9780 if (!spec->autocfg.line_outs)
9781 return 0; /* can't find valid BIOS pin config */
9783 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9784 if (err < 0)
9785 return err;
9786 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9787 if (err < 0)
9788 return err;
9789 err = alc880_auto_create_extra_out(spec,
9790 spec->autocfg.speaker_pins[0],
9791 "Speaker");
9792 if (err < 0)
9793 return err;
9794 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9795 "Headphone");
9796 if (err < 0)
9797 return err;
9798 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9799 if (err < 0)
9800 return err;
9802 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9804 /* check multiple SPDIF-out (for recent codecs) */
9805 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9806 hda_nid_t dig_nid;
9807 err = snd_hda_get_connections(codec,
9808 spec->autocfg.dig_out_pins[i],
9809 &dig_nid, 1);
9810 if (err < 0)
9811 continue;
9812 if (!i)
9813 spec->multiout.dig_out_nid = dig_nid;
9814 else {
9815 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
9816 spec->slave_dig_outs[i - 1] = dig_nid;
9817 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
9818 break;
9821 if (spec->autocfg.dig_in_pin)
9822 spec->dig_in_nid = ALC880_DIGIN_NID;
9824 if (spec->kctls.list)
9825 add_mixer(spec, spec->kctls.list);
9827 add_verb(spec, alc883_auto_init_verbs);
9828 /* if ADC 0x07 is available, initialize it, too */
9829 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9830 add_verb(spec, alc882_adc1_init_verbs);
9832 spec->num_mux_defs = 1;
9833 spec->input_mux = &spec->private_imux[0];
9835 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
9837 err = alc_auto_add_mic_boost(codec);
9838 if (err < 0)
9839 return err;
9841 return 1; /* config found */
9844 /* additional initialization for auto-configuration model */
9845 static void alc882_auto_init(struct hda_codec *codec)
9847 struct alc_spec *spec = codec->spec;
9848 alc882_auto_init_multi_out(codec);
9849 alc882_auto_init_hp_out(codec);
9850 alc882_auto_init_analog_input(codec);
9851 alc882_auto_init_input_src(codec);
9852 if (spec->unsol_event)
9853 alc_inithook(codec);
9856 static int patch_alc882(struct hda_codec *codec)
9858 struct alc_spec *spec;
9859 int err, board_config;
9861 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9862 if (spec == NULL)
9863 return -ENOMEM;
9865 codec->spec = spec;
9867 switch (codec->vendor_id) {
9868 case 0x10ec0882:
9869 case 0x10ec0885:
9870 break;
9871 default:
9872 /* ALC883 and variants */
9873 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9874 break;
9877 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9878 alc882_models,
9879 alc882_cfg_tbl);
9881 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9882 board_config = snd_hda_check_board_codec_sid_config(codec,
9883 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9885 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
9886 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
9887 codec->chip_name);
9888 board_config = ALC882_AUTO;
9891 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
9893 if (board_config == ALC882_AUTO) {
9894 /* automatic parse from the BIOS config */
9895 err = alc882_parse_auto_config(codec);
9896 if (err < 0) {
9897 alc_free(codec);
9898 return err;
9899 } else if (!err) {
9900 printk(KERN_INFO
9901 "hda_codec: Cannot set up configuration "
9902 "from BIOS. Using base mode...\n");
9903 board_config = ALC882_3ST_DIG;
9907 err = snd_hda_attach_beep_device(codec, 0x1);
9908 if (err < 0) {
9909 alc_free(codec);
9910 return err;
9913 if (board_config != ALC882_AUTO)
9914 setup_preset(codec, &alc882_presets[board_config]);
9916 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9917 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9918 /* FIXME: setup DAC5 */
9919 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9920 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9922 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9923 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9925 if (codec->vendor_id == 0x10ec0888)
9926 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
9928 if (!spec->adc_nids && spec->input_mux) {
9929 int i;
9930 spec->num_adc_nids = 0;
9931 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9932 hda_nid_t cap;
9933 hda_nid_t nid = alc882_adc_nids[i];
9934 unsigned int wcap = get_wcaps(codec, nid);
9935 /* get type */
9936 wcap = get_wcaps_type(wcap);
9937 if (wcap != AC_WID_AUD_IN)
9938 continue;
9939 spec->private_adc_nids[spec->num_adc_nids] = nid;
9940 err = snd_hda_get_connections(codec, nid, &cap, 1);
9941 if (err < 0)
9942 continue;
9943 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9944 spec->num_adc_nids++;
9946 spec->adc_nids = spec->private_adc_nids;
9947 spec->capsrc_nids = spec->private_capsrc_nids;
9950 set_capture_mixer(codec);
9951 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9953 spec->vmaster_nid = 0x0c;
9955 codec->patch_ops = alc_patch_ops;
9956 if (board_config == ALC882_AUTO)
9957 spec->init_hook = alc882_auto_init;
9958 #ifdef CONFIG_SND_HDA_POWER_SAVE
9959 if (!spec->loopback.amplist)
9960 spec->loopback.amplist = alc882_loopbacks;
9961 #endif
9962 codec->proc_widget_hook = print_realtek_coef;
9964 return 0;
9969 * ALC262 support
9972 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9973 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
9975 #define alc262_dac_nids alc260_dac_nids
9976 #define alc262_adc_nids alc882_adc_nids
9977 #define alc262_adc_nids_alt alc882_adc_nids_alt
9978 #define alc262_capsrc_nids alc882_capsrc_nids
9979 #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
9981 #define alc262_modes alc260_modes
9982 #define alc262_capture_source alc882_capture_source
9984 static hda_nid_t alc262_dmic_adc_nids[1] = {
9985 /* ADC0 */
9986 0x09
9989 static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9991 static struct snd_kcontrol_new alc262_base_mixer[] = {
9992 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9993 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9994 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9995 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9996 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9997 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10000 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10001 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10002 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10003 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10004 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10006 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10007 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10008 { } /* end */
10011 /* update HP, line and mono-out pins according to the master switch */
10012 static void alc262_hp_master_update(struct hda_codec *codec)
10014 struct alc_spec *spec = codec->spec;
10015 int val = spec->master_sw;
10017 /* HP & line-out */
10018 snd_hda_codec_write_cache(codec, 0x1b, 0,
10019 AC_VERB_SET_PIN_WIDGET_CONTROL,
10020 val ? PIN_HP : 0);
10021 snd_hda_codec_write_cache(codec, 0x15, 0,
10022 AC_VERB_SET_PIN_WIDGET_CONTROL,
10023 val ? PIN_HP : 0);
10024 /* mono (speaker) depending on the HP jack sense */
10025 val = val && !spec->jack_present;
10026 snd_hda_codec_write_cache(codec, 0x16, 0,
10027 AC_VERB_SET_PIN_WIDGET_CONTROL,
10028 val ? PIN_OUT : 0);
10031 static void alc262_hp_bpc_automute(struct hda_codec *codec)
10033 struct alc_spec *spec = codec->spec;
10034 unsigned int presence;
10035 presence = snd_hda_codec_read(codec, 0x1b, 0,
10036 AC_VERB_GET_PIN_SENSE, 0);
10037 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10038 alc262_hp_master_update(codec);
10041 static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10043 if ((res >> 26) != ALC880_HP_EVENT)
10044 return;
10045 alc262_hp_bpc_automute(codec);
10048 static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10050 struct alc_spec *spec = codec->spec;
10051 unsigned int presence;
10052 presence = snd_hda_codec_read(codec, 0x15, 0,
10053 AC_VERB_GET_PIN_SENSE, 0);
10054 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10055 alc262_hp_master_update(codec);
10058 static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10059 unsigned int res)
10061 if ((res >> 26) != ALC880_HP_EVENT)
10062 return;
10063 alc262_hp_wildwest_automute(codec);
10066 #define alc262_hp_master_sw_get alc260_hp_master_sw_get
10068 static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10069 struct snd_ctl_elem_value *ucontrol)
10071 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10072 struct alc_spec *spec = codec->spec;
10073 int val = !!*ucontrol->value.integer.value;
10075 if (val == spec->master_sw)
10076 return 0;
10077 spec->master_sw = val;
10078 alc262_hp_master_update(codec);
10079 return 1;
10082 #define ALC262_HP_MASTER_SWITCH \
10084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10085 .name = "Master Playback Switch", \
10086 .info = snd_ctl_boolean_mono_info, \
10087 .get = alc262_hp_master_sw_get, \
10088 .put = alc262_hp_master_sw_put, \
10091 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
10092 ALC262_HP_MASTER_SWITCH,
10093 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10094 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10095 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10096 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10097 HDA_OUTPUT),
10098 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10099 HDA_OUTPUT),
10100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10102 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10103 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10104 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10105 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10110 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10111 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10112 { } /* end */
10115 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
10116 ALC262_HP_MASTER_SWITCH,
10117 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10118 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10119 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10121 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10122 HDA_OUTPUT),
10123 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10124 HDA_OUTPUT),
10125 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10126 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
10127 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
10128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10130 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10131 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10132 { } /* end */
10135 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10136 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10137 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10138 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
10139 { } /* end */
10142 /* mute/unmute internal speaker according to the hp jack and mute state */
10143 static void alc262_hp_t5735_setup(struct hda_codec *codec)
10145 struct alc_spec *spec = codec->spec;
10147 spec->autocfg.hp_pins[0] = 0x15;
10148 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10151 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
10152 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10153 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10154 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10155 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10158 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10159 { } /* end */
10162 static struct hda_verb alc262_hp_t5735_verbs[] = {
10163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10164 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10166 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10170 static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
10171 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10173 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10174 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
10175 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10176 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10177 { } /* end */
10180 static struct hda_verb alc262_hp_rp5700_verbs[] = {
10181 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10182 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10183 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10185 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10186 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10190 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10194 static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10195 .num_items = 1,
10196 .items = {
10197 { "Line", 0x1 },
10201 /* bind hp and internal speaker mute (with plug check) as master switch */
10202 static void alc262_hippo_master_update(struct hda_codec *codec)
10204 struct alc_spec *spec = codec->spec;
10205 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10206 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10207 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10208 unsigned int mute;
10210 /* HP */
10211 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10212 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10213 HDA_AMP_MUTE, mute);
10214 /* mute internal speaker per jack sense */
10215 if (spec->jack_present)
10216 mute = HDA_AMP_MUTE;
10217 if (line_nid)
10218 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10219 HDA_AMP_MUTE, mute);
10220 if (speaker_nid && speaker_nid != line_nid)
10221 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10222 HDA_AMP_MUTE, mute);
10225 #define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10227 static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10228 struct snd_ctl_elem_value *ucontrol)
10230 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10231 struct alc_spec *spec = codec->spec;
10232 int val = !!*ucontrol->value.integer.value;
10234 if (val == spec->master_sw)
10235 return 0;
10236 spec->master_sw = val;
10237 alc262_hippo_master_update(codec);
10238 return 1;
10241 #define ALC262_HIPPO_MASTER_SWITCH \
10243 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10244 .name = "Master Playback Switch", \
10245 .info = snd_ctl_boolean_mono_info, \
10246 .get = alc262_hippo_master_sw_get, \
10247 .put = alc262_hippo_master_sw_put, \
10250 static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10251 ALC262_HIPPO_MASTER_SWITCH,
10252 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10253 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10254 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10255 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10256 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10258 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10259 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10260 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10261 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10262 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10263 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10264 { } /* end */
10267 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10268 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10269 ALC262_HIPPO_MASTER_SWITCH,
10270 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10271 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10273 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10275 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10276 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10277 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10278 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10279 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10280 { } /* end */
10283 /* mute/unmute internal speaker according to the hp jack and mute state */
10284 static void alc262_hippo_automute(struct hda_codec *codec)
10286 struct alc_spec *spec = codec->spec;
10287 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10288 unsigned int present;
10290 /* need to execute and sync at first */
10291 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10292 present = snd_hda_codec_read(codec, hp_nid, 0,
10293 AC_VERB_GET_PIN_SENSE, 0);
10294 spec->jack_present = (present & 0x80000000) != 0;
10295 alc262_hippo_master_update(codec);
10298 static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10300 if ((res >> 26) != ALC880_HP_EVENT)
10301 return;
10302 alc262_hippo_automute(codec);
10305 static void alc262_hippo_setup(struct hda_codec *codec)
10307 struct alc_spec *spec = codec->spec;
10309 spec->autocfg.hp_pins[0] = 0x15;
10310 spec->autocfg.speaker_pins[0] = 0x14;
10313 static void alc262_hippo1_setup(struct hda_codec *codec)
10315 struct alc_spec *spec = codec->spec;
10317 spec->autocfg.hp_pins[0] = 0x1b;
10318 spec->autocfg.speaker_pins[0] = 0x14;
10322 static struct snd_kcontrol_new alc262_sony_mixer[] = {
10323 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10324 ALC262_HIPPO_MASTER_SWITCH,
10325 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10326 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10327 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10328 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10329 { } /* end */
10332 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
10333 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10334 ALC262_HIPPO_MASTER_SWITCH,
10335 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10336 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10337 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10338 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10339 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10340 { } /* end */
10343 static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10344 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10345 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10346 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10347 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10348 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10349 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10351 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10352 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10353 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10354 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10355 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10356 { } /* end */
10359 static struct hda_verb alc262_tyan_verbs[] = {
10360 /* Headphone automute */
10361 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10362 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10363 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10365 /* P11 AUX_IN, white 4-pin connector */
10366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10367 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10368 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10369 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10374 /* unsolicited event for HP jack sensing */
10375 static void alc262_tyan_setup(struct hda_codec *codec)
10377 struct alc_spec *spec = codec->spec;
10379 spec->autocfg.hp_pins[0] = 0x1b;
10380 spec->autocfg.speaker_pins[0] = 0x15;
10384 #define alc262_capture_mixer alc882_capture_mixer
10385 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
10388 * generic initialization of ADC, input mixers and output mixers
10390 static struct hda_verb alc262_init_verbs[] = {
10392 * Unmute ADC0-2 and set the default input to mic-in
10394 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10396 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10397 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10398 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10399 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10401 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10402 * mixer widget
10403 * Note: PASD motherboards uses the Line In 2 as the input for
10404 * front panel mic (mic 2)
10406 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10407 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10408 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10409 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10411 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10414 * Set up output mixers (0x0c - 0x0e)
10416 /* set vol=0 to output mixers */
10417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10418 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10419 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10420 /* set up input amps for analog loopback */
10421 /* Amp Indices: DAC = 0, mixer = 1 */
10422 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10423 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10424 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10425 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10426 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10427 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10429 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10430 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10431 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10432 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10433 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10434 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10436 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10437 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10438 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10439 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10442 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10443 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10445 /* FIXME: use matrix-type input source selection */
10446 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10447 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10452 /* Input mixer2 */
10453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10456 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10457 /* Input mixer3 */
10458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10461 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10466 static struct hda_verb alc262_eapd_verbs[] = {
10467 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10468 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10472 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10473 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10474 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10475 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10477 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10478 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10482 static struct hda_verb alc262_sony_unsol_verbs[] = {
10483 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10484 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10487 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10492 static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10493 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10494 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10495 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10497 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10498 { } /* end */
10501 static struct hda_verb alc262_toshiba_s06_verbs[] = {
10502 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10503 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10504 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10505 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10506 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10507 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10508 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10509 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10513 static void alc262_toshiba_s06_setup(struct hda_codec *codec)
10515 struct alc_spec *spec = codec->spec;
10517 spec->autocfg.hp_pins[0] = 0x15;
10518 spec->autocfg.speaker_pins[0] = 0x14;
10519 spec->ext_mic.pin = 0x18;
10520 spec->ext_mic.mux_idx = 0;
10521 spec->int_mic.pin = 0x12;
10522 spec->int_mic.mux_idx = 9;
10523 spec->auto_mic = 1;
10527 * nec model
10528 * 0x15 = headphone
10529 * 0x16 = internal speaker
10530 * 0x18 = external mic
10533 static struct snd_kcontrol_new alc262_nec_mixer[] = {
10534 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10535 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10537 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10538 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10539 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10541 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10542 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10543 { } /* end */
10546 static struct hda_verb alc262_nec_verbs[] = {
10547 /* Unmute Speaker */
10548 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10550 /* Headphone */
10551 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10552 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10554 /* External mic to headphone */
10555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10556 /* External mic to speaker */
10557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10562 * fujitsu model
10563 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10564 * 0x1b = port replicator headphone out
10567 #define ALC_HP_EVENT 0x37
10569 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10570 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10571 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10572 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10573 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10577 static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10578 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10579 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10583 static struct hda_input_mux alc262_fujitsu_capture_source = {
10584 .num_items = 3,
10585 .items = {
10586 { "Mic", 0x0 },
10587 { "Int Mic", 0x1 },
10588 { "CD", 0x4 },
10592 static struct hda_input_mux alc262_HP_capture_source = {
10593 .num_items = 5,
10594 .items = {
10595 { "Mic", 0x0 },
10596 { "Front Mic", 0x1 },
10597 { "Line", 0x2 },
10598 { "CD", 0x4 },
10599 { "AUX IN", 0x6 },
10603 static struct hda_input_mux alc262_HP_D7000_capture_source = {
10604 .num_items = 4,
10605 .items = {
10606 { "Mic", 0x0 },
10607 { "Front Mic", 0x2 },
10608 { "Line", 0x1 },
10609 { "CD", 0x4 },
10613 /* mute/unmute internal speaker according to the hp jacks and mute state */
10614 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10616 struct alc_spec *spec = codec->spec;
10617 unsigned int mute;
10619 if (force || !spec->sense_updated) {
10620 unsigned int present;
10621 /* need to execute and sync at first */
10622 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
10623 /* check laptop HP jack */
10624 present = snd_hda_codec_read(codec, 0x14, 0,
10625 AC_VERB_GET_PIN_SENSE, 0);
10626 /* need to execute and sync at first */
10627 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10628 /* check docking HP jack */
10629 present |= snd_hda_codec_read(codec, 0x1b, 0,
10630 AC_VERB_GET_PIN_SENSE, 0);
10631 if (present & AC_PINSENSE_PRESENCE)
10632 spec->jack_present = 1;
10633 else
10634 spec->jack_present = 0;
10635 spec->sense_updated = 1;
10637 /* unmute internal speaker only if both HPs are unplugged and
10638 * master switch is on
10640 if (spec->jack_present)
10641 mute = HDA_AMP_MUTE;
10642 else
10643 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10644 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10645 HDA_AMP_MUTE, mute);
10648 /* unsolicited event for HP jack sensing */
10649 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10650 unsigned int res)
10652 if ((res >> 26) != ALC_HP_EVENT)
10653 return;
10654 alc262_fujitsu_automute(codec, 1);
10657 static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10659 alc262_fujitsu_automute(codec, 1);
10662 /* bind volumes of both NID 0x0c and 0x0d */
10663 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10664 .ops = &snd_hda_bind_vol,
10665 .values = {
10666 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10667 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10672 /* mute/unmute internal speaker according to the hp jack and mute state */
10673 static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10675 struct alc_spec *spec = codec->spec;
10676 unsigned int mute;
10678 if (force || !spec->sense_updated) {
10679 unsigned int present_int_hp;
10680 /* need to execute and sync at first */
10681 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10682 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10683 AC_VERB_GET_PIN_SENSE, 0);
10684 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10685 spec->sense_updated = 1;
10687 if (spec->jack_present) {
10688 /* mute internal speaker */
10689 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10690 HDA_AMP_MUTE, HDA_AMP_MUTE);
10691 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10692 HDA_AMP_MUTE, HDA_AMP_MUTE);
10693 } else {
10694 /* unmute internal speaker if necessary */
10695 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10696 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10697 HDA_AMP_MUTE, mute);
10698 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10699 HDA_AMP_MUTE, mute);
10703 /* unsolicited event for HP jack sensing */
10704 static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10705 unsigned int res)
10707 if ((res >> 26) != ALC_HP_EVENT)
10708 return;
10709 alc262_lenovo_3000_automute(codec, 1);
10712 static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10713 int dir, int idx, long *valp)
10715 int i, change = 0;
10717 for (i = 0; i < 2; i++, valp++)
10718 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10719 HDA_AMP_MUTE,
10720 *valp ? 0 : HDA_AMP_MUTE);
10721 return change;
10724 /* bind hp and internal speaker mute (with plug check) */
10725 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10726 struct snd_ctl_elem_value *ucontrol)
10728 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10729 long *valp = ucontrol->value.integer.value;
10730 int change;
10732 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10733 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
10734 if (change)
10735 alc262_fujitsu_automute(codec, 0);
10736 return change;
10739 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
10740 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10742 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10743 .name = "Master Playback Switch",
10744 .info = snd_hda_mixer_amp_switch_info,
10745 .get = snd_hda_mixer_amp_switch_get,
10746 .put = alc262_fujitsu_master_sw_put,
10747 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10749 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10750 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10751 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10754 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10755 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10756 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10757 { } /* end */
10760 /* bind hp and internal speaker mute (with plug check) */
10761 static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10762 struct snd_ctl_elem_value *ucontrol)
10764 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10765 long *valp = ucontrol->value.integer.value;
10766 int change;
10768 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
10769 if (change)
10770 alc262_lenovo_3000_automute(codec, 0);
10771 return change;
10774 static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10775 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10777 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10778 .name = "Master Playback Switch",
10779 .info = snd_hda_mixer_amp_switch_info,
10780 .get = snd_hda_mixer_amp_switch_get,
10781 .put = alc262_lenovo_3000_master_sw_put,
10782 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10784 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10785 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10786 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10789 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10790 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10791 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10792 { } /* end */
10795 static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10796 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10797 ALC262_HIPPO_MASTER_SWITCH,
10798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10800 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10801 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10802 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10803 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10804 { } /* end */
10807 /* additional init verbs for Benq laptops */
10808 static struct hda_verb alc262_EAPD_verbs[] = {
10809 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10810 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10814 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10815 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10816 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10818 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10819 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10823 /* Samsung Q1 Ultra Vista model setup */
10824 static struct snd_kcontrol_new alc262_ultra_mixer[] = {
10825 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10826 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10827 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10828 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10829 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
10830 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
10831 { } /* end */
10834 static struct hda_verb alc262_ultra_verbs[] = {
10835 /* output mixer */
10836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10839 /* speaker */
10840 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10842 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10843 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10844 /* HP */
10845 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10848 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10849 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10850 /* internal mic */
10851 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10852 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10853 /* ADC, choose mic */
10854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10855 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
10867 /* mute/unmute internal speaker according to the hp jack and mute state */
10868 static void alc262_ultra_automute(struct hda_codec *codec)
10870 struct alc_spec *spec = codec->spec;
10871 unsigned int mute;
10873 mute = 0;
10874 /* auto-mute only when HP is used as HP */
10875 if (!spec->cur_mux[0]) {
10876 unsigned int present;
10877 /* need to execute and sync at first */
10878 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10879 present = snd_hda_codec_read(codec, 0x15, 0,
10880 AC_VERB_GET_PIN_SENSE, 0);
10881 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10882 if (spec->jack_present)
10883 mute = HDA_AMP_MUTE;
10885 /* mute/unmute internal speaker */
10886 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10887 HDA_AMP_MUTE, mute);
10888 /* mute/unmute HP */
10889 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10890 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
10893 /* unsolicited event for HP jack sensing */
10894 static void alc262_ultra_unsol_event(struct hda_codec *codec,
10895 unsigned int res)
10897 if ((res >> 26) != ALC880_HP_EVENT)
10898 return;
10899 alc262_ultra_automute(codec);
10902 static struct hda_input_mux alc262_ultra_capture_source = {
10903 .num_items = 2,
10904 .items = {
10905 { "Mic", 0x1 },
10906 { "Headphone", 0x7 },
10910 static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10911 struct snd_ctl_elem_value *ucontrol)
10913 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10914 struct alc_spec *spec = codec->spec;
10915 int ret;
10917 ret = alc_mux_enum_put(kcontrol, ucontrol);
10918 if (!ret)
10919 return 0;
10920 /* reprogram the HP pin as mic or HP according to the input source */
10921 snd_hda_codec_write_cache(codec, 0x15, 0,
10922 AC_VERB_SET_PIN_WIDGET_CONTROL,
10923 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10924 alc262_ultra_automute(codec); /* mute/unmute HP */
10925 return ret;
10928 static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10929 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10930 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10933 .name = "Capture Source",
10934 .info = alc_mux_enum_info,
10935 .get = alc_mux_enum_get,
10936 .put = alc262_ultra_mux_enum_put,
10938 { } /* end */
10941 /* We use two mixers depending on the output pin; 0x16 is a mono output
10942 * and thus it's bound with a different mixer.
10943 * This function returns which mixer amp should be used.
10945 static int alc262_check_volbit(hda_nid_t nid)
10947 if (!nid)
10948 return 0;
10949 else if (nid == 0x16)
10950 return 2;
10951 else
10952 return 1;
10955 static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10956 const char *pfx, int *vbits)
10958 char name[32];
10959 unsigned long val;
10960 int vbit;
10962 vbit = alc262_check_volbit(nid);
10963 if (!vbit)
10964 return 0;
10965 if (*vbits & vbit) /* a volume control for this mixer already there */
10966 return 0;
10967 *vbits |= vbit;
10968 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
10969 if (vbit == 2)
10970 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10971 else
10972 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
10973 return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
10976 static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10977 const char *pfx)
10979 char name[32];
10980 unsigned long val;
10982 if (!nid)
10983 return 0;
10984 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
10985 if (nid == 0x16)
10986 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10987 else
10988 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
10989 return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
10992 /* add playback controls from the parsed DAC table */
10993 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10994 const struct auto_pin_cfg *cfg)
10996 const char *pfx;
10997 int vbits;
10998 int err;
11000 spec->multiout.num_dacs = 1; /* only use one dac */
11001 spec->multiout.dac_nids = spec->private_dac_nids;
11002 spec->multiout.dac_nids[0] = 2;
11004 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11005 pfx = "Master";
11006 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11007 pfx = "Speaker";
11008 else
11009 pfx = "Front";
11010 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11011 if (err < 0)
11012 return err;
11013 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11014 if (err < 0)
11015 return err;
11016 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11017 if (err < 0)
11018 return err;
11020 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11021 alc262_check_volbit(cfg->speaker_pins[0]) |
11022 alc262_check_volbit(cfg->hp_pins[0]);
11023 if (vbits == 1 || vbits == 2)
11024 pfx = "Master"; /* only one mixer is used */
11025 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11026 pfx = "Speaker";
11027 else
11028 pfx = "Front";
11029 vbits = 0;
11030 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11031 if (err < 0)
11032 return err;
11033 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11034 &vbits);
11035 if (err < 0)
11036 return err;
11037 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11038 &vbits);
11039 if (err < 0)
11040 return err;
11041 return 0;
11044 #define alc262_auto_create_input_ctls \
11045 alc880_auto_create_input_ctls
11048 * generic initialization of ADC, input mixers and output mixers
11050 static struct hda_verb alc262_volume_init_verbs[] = {
11052 * Unmute ADC0-2 and set the default input to mic-in
11054 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11056 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11057 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11058 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11061 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11062 * mixer widget
11063 * Note: PASD motherboards uses the Line In 2 as the input for
11064 * front panel mic (mic 2)
11066 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11074 * Set up output mixers (0x0c - 0x0f)
11076 /* set vol=0 to output mixers */
11077 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11078 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11081 /* set up input amps for analog loopback */
11082 /* Amp Indices: DAC = 0, mixer = 1 */
11083 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11084 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11085 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11086 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11087 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11088 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11090 /* FIXME: use matrix-type input source selection */
11091 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11092 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11093 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11094 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11095 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11096 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11097 /* Input mixer2 */
11098 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11099 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11100 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11102 /* Input mixer3 */
11103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11111 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11113 * Unmute ADC0-2 and set the default input to mic-in
11115 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11117 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11118 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11119 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11122 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11123 * mixer widget
11124 * Note: PASD motherboards uses the Line In 2 as the input for
11125 * front panel mic (mic 2)
11127 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11137 * Set up output mixers (0x0c - 0x0e)
11139 /* set vol=0 to output mixers */
11140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11141 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11142 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11144 /* set up input amps for analog loopback */
11145 /* Amp Indices: DAC = 0, mixer = 1 */
11146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11148 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11149 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11150 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11151 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11153 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11154 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11155 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11157 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11158 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11160 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11163 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11164 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11165 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11166 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11167 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11169 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11170 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11171 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11172 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11173 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11174 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11177 /* FIXME: use matrix-type input source selection */
11178 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11179 /* Input mixer1: only unmute Mic */
11180 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11181 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11182 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11183 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11184 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11185 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11186 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11187 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
11189 /* Input mixer2 */
11190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11192 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11193 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11194 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11195 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11196 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11197 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11198 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
11199 /* Input mixer3 */
11200 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11201 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11202 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11205 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
11210 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11215 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11217 * Unmute ADC0-2 and set the default input to mic-in
11219 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11220 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11221 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11223 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11226 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11227 * mixer widget
11228 * Note: PASD motherboards uses the Line In 2 as the input for front
11229 * panel mic (mic 2)
11231 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11236 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11237 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11238 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11239 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11241 * Set up output mixers (0x0c - 0x0e)
11243 /* set vol=0 to output mixers */
11244 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11246 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11248 /* set up input amps for analog loopback */
11249 /* Amp Indices: DAC = 0, mixer = 1 */
11250 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11252 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11253 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11254 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11255 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11259 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11260 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11261 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11262 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11263 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11264 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11266 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11269 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11270 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11272 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11273 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11274 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11275 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11276 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11277 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11279 /* FIXME: use matrix-type input source selection */
11280 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11281 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11282 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11284 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11285 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11287 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11289 /* Input mixer2 */
11290 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11293 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11295 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11296 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11297 /* Input mixer3 */
11298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11303 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11304 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11306 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11311 static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11314 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11315 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11317 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11318 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11320 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11322 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11323 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11324 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11329 #ifdef CONFIG_SND_HDA_POWER_SAVE
11330 #define alc262_loopbacks alc880_loopbacks
11331 #endif
11333 /* pcm configuration: identical with ALC880 */
11334 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
11335 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
11336 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
11337 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
11340 * BIOS auto configuration
11342 static int alc262_parse_auto_config(struct hda_codec *codec)
11344 struct alc_spec *spec = codec->spec;
11345 int err;
11346 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11348 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11349 alc262_ignore);
11350 if (err < 0)
11351 return err;
11352 if (!spec->autocfg.line_outs) {
11353 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11354 spec->multiout.max_channels = 2;
11355 spec->no_analog = 1;
11356 goto dig_only;
11358 return 0; /* can't find valid BIOS pin config */
11360 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11361 if (err < 0)
11362 return err;
11363 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
11364 if (err < 0)
11365 return err;
11367 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11369 dig_only:
11370 if (spec->autocfg.dig_outs) {
11371 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
11372 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11374 if (spec->autocfg.dig_in_pin)
11375 spec->dig_in_nid = ALC262_DIGIN_NID;
11377 if (spec->kctls.list)
11378 add_mixer(spec, spec->kctls.list);
11380 add_verb(spec, alc262_volume_init_verbs);
11381 spec->num_mux_defs = 1;
11382 spec->input_mux = &spec->private_imux[0];
11384 err = alc_auto_add_mic_boost(codec);
11385 if (err < 0)
11386 return err;
11388 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11390 return 1;
11393 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
11394 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
11395 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
11396 #define alc262_auto_init_input_src alc882_auto_init_input_src
11399 /* init callback for auto-configuration model -- overriding the default init */
11400 static void alc262_auto_init(struct hda_codec *codec)
11402 struct alc_spec *spec = codec->spec;
11403 alc262_auto_init_multi_out(codec);
11404 alc262_auto_init_hp_out(codec);
11405 alc262_auto_init_analog_input(codec);
11406 alc262_auto_init_input_src(codec);
11407 if (spec->unsol_event)
11408 alc_inithook(codec);
11412 * configuration and preset
11414 static const char *alc262_models[ALC262_MODEL_LAST] = {
11415 [ALC262_BASIC] = "basic",
11416 [ALC262_HIPPO] = "hippo",
11417 [ALC262_HIPPO_1] = "hippo_1",
11418 [ALC262_FUJITSU] = "fujitsu",
11419 [ALC262_HP_BPC] = "hp-bpc",
11420 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
11421 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
11422 [ALC262_HP_RP5700] = "hp-rp5700",
11423 [ALC262_BENQ_ED8] = "benq",
11424 [ALC262_BENQ_T31] = "benq-t31",
11425 [ALC262_SONY_ASSAMD] = "sony-assamd",
11426 [ALC262_TOSHIBA_S06] = "toshiba-s06",
11427 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
11428 [ALC262_ULTRA] = "ultra",
11429 [ALC262_LENOVO_3000] = "lenovo-3000",
11430 [ALC262_NEC] = "nec",
11431 [ALC262_TYAN] = "tyan",
11432 [ALC262_AUTO] = "auto",
11435 static struct snd_pci_quirk alc262_cfg_tbl[] = {
11436 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
11437 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
11438 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11439 ALC262_HP_BPC),
11440 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11441 ALC262_HP_BPC),
11442 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11443 ALC262_HP_BPC),
11444 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
11445 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
11446 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
11447 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
11448 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
11449 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
11450 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
11451 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
11452 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11453 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11454 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
11455 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11456 ALC262_HP_TC_T5735),
11457 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
11458 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
11459 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
11460 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
11461 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
11462 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
11463 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11464 ALC262_SONY_ASSAMD),
11465 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
11466 ALC262_TOSHIBA_RX1),
11467 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
11468 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
11469 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
11470 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
11471 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11472 ALC262_ULTRA),
11473 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
11474 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
11475 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
11476 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
11477 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
11481 static struct alc_config_preset alc262_presets[] = {
11482 [ALC262_BASIC] = {
11483 .mixers = { alc262_base_mixer },
11484 .init_verbs = { alc262_init_verbs },
11485 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11486 .dac_nids = alc262_dac_nids,
11487 .hp_nid = 0x03,
11488 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11489 .channel_mode = alc262_modes,
11490 .input_mux = &alc262_capture_source,
11492 [ALC262_HIPPO] = {
11493 .mixers = { alc262_hippo_mixer },
11494 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
11495 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11496 .dac_nids = alc262_dac_nids,
11497 .hp_nid = 0x03,
11498 .dig_out_nid = ALC262_DIGOUT_NID,
11499 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11500 .channel_mode = alc262_modes,
11501 .input_mux = &alc262_capture_source,
11502 .unsol_event = alc262_hippo_unsol_event,
11503 .setup = alc262_hippo_setup,
11504 .init_hook = alc262_hippo_automute,
11506 [ALC262_HIPPO_1] = {
11507 .mixers = { alc262_hippo1_mixer },
11508 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11509 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11510 .dac_nids = alc262_dac_nids,
11511 .hp_nid = 0x02,
11512 .dig_out_nid = ALC262_DIGOUT_NID,
11513 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11514 .channel_mode = alc262_modes,
11515 .input_mux = &alc262_capture_source,
11516 .unsol_event = alc262_hippo_unsol_event,
11517 .setup = alc262_hippo1_setup,
11518 .init_hook = alc262_hippo_automute,
11520 [ALC262_FUJITSU] = {
11521 .mixers = { alc262_fujitsu_mixer },
11522 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11523 alc262_fujitsu_unsol_verbs },
11524 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11525 .dac_nids = alc262_dac_nids,
11526 .hp_nid = 0x03,
11527 .dig_out_nid = ALC262_DIGOUT_NID,
11528 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11529 .channel_mode = alc262_modes,
11530 .input_mux = &alc262_fujitsu_capture_source,
11531 .unsol_event = alc262_fujitsu_unsol_event,
11532 .init_hook = alc262_fujitsu_init_hook,
11534 [ALC262_HP_BPC] = {
11535 .mixers = { alc262_HP_BPC_mixer },
11536 .init_verbs = { alc262_HP_BPC_init_verbs },
11537 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11538 .dac_nids = alc262_dac_nids,
11539 .hp_nid = 0x03,
11540 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11541 .channel_mode = alc262_modes,
11542 .input_mux = &alc262_HP_capture_source,
11543 .unsol_event = alc262_hp_bpc_unsol_event,
11544 .init_hook = alc262_hp_bpc_automute,
11546 [ALC262_HP_BPC_D7000_WF] = {
11547 .mixers = { alc262_HP_BPC_WildWest_mixer },
11548 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11549 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11550 .dac_nids = alc262_dac_nids,
11551 .hp_nid = 0x03,
11552 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11553 .channel_mode = alc262_modes,
11554 .input_mux = &alc262_HP_D7000_capture_source,
11555 .unsol_event = alc262_hp_wildwest_unsol_event,
11556 .init_hook = alc262_hp_wildwest_automute,
11558 [ALC262_HP_BPC_D7000_WL] = {
11559 .mixers = { alc262_HP_BPC_WildWest_mixer,
11560 alc262_HP_BPC_WildWest_option_mixer },
11561 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11562 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11563 .dac_nids = alc262_dac_nids,
11564 .hp_nid = 0x03,
11565 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11566 .channel_mode = alc262_modes,
11567 .input_mux = &alc262_HP_D7000_capture_source,
11568 .unsol_event = alc262_hp_wildwest_unsol_event,
11569 .init_hook = alc262_hp_wildwest_automute,
11571 [ALC262_HP_TC_T5735] = {
11572 .mixers = { alc262_hp_t5735_mixer },
11573 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11574 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11575 .dac_nids = alc262_dac_nids,
11576 .hp_nid = 0x03,
11577 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11578 .channel_mode = alc262_modes,
11579 .input_mux = &alc262_capture_source,
11580 .unsol_event = alc_automute_amp_unsol_event,
11581 .setup = alc262_hp_t5735_setup,
11582 .init_hook = alc_automute_amp,
11584 [ALC262_HP_RP5700] = {
11585 .mixers = { alc262_hp_rp5700_mixer },
11586 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11587 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11588 .dac_nids = alc262_dac_nids,
11589 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11590 .channel_mode = alc262_modes,
11591 .input_mux = &alc262_hp_rp5700_capture_source,
11593 [ALC262_BENQ_ED8] = {
11594 .mixers = { alc262_base_mixer },
11595 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11596 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11597 .dac_nids = alc262_dac_nids,
11598 .hp_nid = 0x03,
11599 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11600 .channel_mode = alc262_modes,
11601 .input_mux = &alc262_capture_source,
11603 [ALC262_SONY_ASSAMD] = {
11604 .mixers = { alc262_sony_mixer },
11605 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11606 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11607 .dac_nids = alc262_dac_nids,
11608 .hp_nid = 0x02,
11609 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11610 .channel_mode = alc262_modes,
11611 .input_mux = &alc262_capture_source,
11612 .unsol_event = alc262_hippo_unsol_event,
11613 .setup = alc262_hippo_setup,
11614 .init_hook = alc262_hippo_automute,
11616 [ALC262_BENQ_T31] = {
11617 .mixers = { alc262_benq_t31_mixer },
11618 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11619 alc_hp15_unsol_verbs },
11620 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11621 .dac_nids = alc262_dac_nids,
11622 .hp_nid = 0x03,
11623 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11624 .channel_mode = alc262_modes,
11625 .input_mux = &alc262_capture_source,
11626 .unsol_event = alc262_hippo_unsol_event,
11627 .setup = alc262_hippo_setup,
11628 .init_hook = alc262_hippo_automute,
11630 [ALC262_ULTRA] = {
11631 .mixers = { alc262_ultra_mixer },
11632 .cap_mixer = alc262_ultra_capture_mixer,
11633 .init_verbs = { alc262_ultra_verbs },
11634 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11635 .dac_nids = alc262_dac_nids,
11636 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11637 .channel_mode = alc262_modes,
11638 .input_mux = &alc262_ultra_capture_source,
11639 .adc_nids = alc262_adc_nids, /* ADC0 */
11640 .capsrc_nids = alc262_capsrc_nids,
11641 .num_adc_nids = 1, /* single ADC */
11642 .unsol_event = alc262_ultra_unsol_event,
11643 .init_hook = alc262_ultra_automute,
11645 [ALC262_LENOVO_3000] = {
11646 .mixers = { alc262_lenovo_3000_mixer },
11647 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11648 alc262_lenovo_3000_unsol_verbs },
11649 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11650 .dac_nids = alc262_dac_nids,
11651 .hp_nid = 0x03,
11652 .dig_out_nid = ALC262_DIGOUT_NID,
11653 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11654 .channel_mode = alc262_modes,
11655 .input_mux = &alc262_fujitsu_capture_source,
11656 .unsol_event = alc262_lenovo_3000_unsol_event,
11658 [ALC262_NEC] = {
11659 .mixers = { alc262_nec_mixer },
11660 .init_verbs = { alc262_nec_verbs },
11661 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11662 .dac_nids = alc262_dac_nids,
11663 .hp_nid = 0x03,
11664 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11665 .channel_mode = alc262_modes,
11666 .input_mux = &alc262_capture_source,
11668 [ALC262_TOSHIBA_S06] = {
11669 .mixers = { alc262_toshiba_s06_mixer },
11670 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11671 alc262_eapd_verbs },
11672 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11673 .capsrc_nids = alc262_dmic_capsrc_nids,
11674 .dac_nids = alc262_dac_nids,
11675 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11676 .num_adc_nids = 1, /* single ADC */
11677 .dig_out_nid = ALC262_DIGOUT_NID,
11678 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11679 .channel_mode = alc262_modes,
11680 .unsol_event = alc_sku_unsol_event,
11681 .setup = alc262_toshiba_s06_setup,
11682 .init_hook = alc_inithook,
11684 [ALC262_TOSHIBA_RX1] = {
11685 .mixers = { alc262_toshiba_rx1_mixer },
11686 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11687 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11688 .dac_nids = alc262_dac_nids,
11689 .hp_nid = 0x03,
11690 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11691 .channel_mode = alc262_modes,
11692 .input_mux = &alc262_capture_source,
11693 .unsol_event = alc262_hippo_unsol_event,
11694 .setup = alc262_hippo_setup,
11695 .init_hook = alc262_hippo_automute,
11697 [ALC262_TYAN] = {
11698 .mixers = { alc262_tyan_mixer },
11699 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11700 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11701 .dac_nids = alc262_dac_nids,
11702 .hp_nid = 0x02,
11703 .dig_out_nid = ALC262_DIGOUT_NID,
11704 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11705 .channel_mode = alc262_modes,
11706 .input_mux = &alc262_capture_source,
11707 .unsol_event = alc_automute_amp_unsol_event,
11708 .setup = alc262_tyan_setup,
11709 .init_hook = alc_automute_amp,
11713 static int patch_alc262(struct hda_codec *codec)
11715 struct alc_spec *spec;
11716 int board_config;
11717 int err;
11719 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11720 if (spec == NULL)
11721 return -ENOMEM;
11723 codec->spec = spec;
11724 #if 0
11725 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11726 * under-run
11729 int tmp;
11730 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11731 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11732 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11733 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11735 #endif
11737 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11739 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11740 alc262_models,
11741 alc262_cfg_tbl);
11743 if (board_config < 0) {
11744 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11745 codec->chip_name);
11746 board_config = ALC262_AUTO;
11749 if (board_config == ALC262_AUTO) {
11750 /* automatic parse from the BIOS config */
11751 err = alc262_parse_auto_config(codec);
11752 if (err < 0) {
11753 alc_free(codec);
11754 return err;
11755 } else if (!err) {
11756 printk(KERN_INFO
11757 "hda_codec: Cannot set up configuration "
11758 "from BIOS. Using base mode...\n");
11759 board_config = ALC262_BASIC;
11763 if (!spec->no_analog) {
11764 err = snd_hda_attach_beep_device(codec, 0x1);
11765 if (err < 0) {
11766 alc_free(codec);
11767 return err;
11771 if (board_config != ALC262_AUTO)
11772 setup_preset(codec, &alc262_presets[board_config]);
11774 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11775 spec->stream_analog_capture = &alc262_pcm_analog_capture;
11777 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11778 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11780 if (!spec->adc_nids && spec->input_mux) {
11781 int i;
11782 /* check whether the digital-mic has to be supported */
11783 for (i = 0; i < spec->input_mux->num_items; i++) {
11784 if (spec->input_mux->items[i].index >= 9)
11785 break;
11787 if (i < spec->input_mux->num_items) {
11788 /* use only ADC0 */
11789 spec->adc_nids = alc262_dmic_adc_nids;
11790 spec->num_adc_nids = 1;
11791 spec->capsrc_nids = alc262_dmic_capsrc_nids;
11792 } else {
11793 /* all analog inputs */
11794 /* check whether NID 0x07 is valid */
11795 unsigned int wcap = get_wcaps(codec, 0x07);
11797 /* get type */
11798 wcap = get_wcaps_type(wcap);
11799 if (wcap != AC_WID_AUD_IN) {
11800 spec->adc_nids = alc262_adc_nids_alt;
11801 spec->num_adc_nids =
11802 ARRAY_SIZE(alc262_adc_nids_alt);
11803 spec->capsrc_nids = alc262_capsrc_nids_alt;
11804 } else {
11805 spec->adc_nids = alc262_adc_nids;
11806 spec->num_adc_nids =
11807 ARRAY_SIZE(alc262_adc_nids);
11808 spec->capsrc_nids = alc262_capsrc_nids;
11812 if (!spec->cap_mixer && !spec->no_analog)
11813 set_capture_mixer(codec);
11814 if (!spec->no_analog)
11815 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
11817 spec->vmaster_nid = 0x0c;
11819 codec->patch_ops = alc_patch_ops;
11820 if (board_config == ALC262_AUTO)
11821 spec->init_hook = alc262_auto_init;
11822 #ifdef CONFIG_SND_HDA_POWER_SAVE
11823 if (!spec->loopback.amplist)
11824 spec->loopback.amplist = alc262_loopbacks;
11825 #endif
11826 codec->proc_widget_hook = print_realtek_coef;
11828 return 0;
11832 * ALC268 channel source setting (2 channel)
11834 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11835 #define alc268_modes alc260_modes
11837 static hda_nid_t alc268_dac_nids[2] = {
11838 /* front, hp */
11839 0x02, 0x03
11842 static hda_nid_t alc268_adc_nids[2] = {
11843 /* ADC0-1 */
11844 0x08, 0x07
11847 static hda_nid_t alc268_adc_nids_alt[1] = {
11848 /* ADC0 */
11849 0x08
11852 static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11854 static struct snd_kcontrol_new alc268_base_mixer[] = {
11855 /* output mixer control */
11856 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11857 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11858 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11860 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11861 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11862 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11866 static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11867 /* output mixer control */
11868 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11869 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11870 ALC262_HIPPO_MASTER_SWITCH,
11871 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11872 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11873 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11877 /* bind Beep switches of both NID 0x0f and 0x10 */
11878 static struct hda_bind_ctls alc268_bind_beep_sw = {
11879 .ops = &snd_hda_bind_sw,
11880 .values = {
11881 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11882 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11887 static struct snd_kcontrol_new alc268_beep_mixer[] = {
11888 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11889 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11893 static struct hda_verb alc268_eapd_verbs[] = {
11894 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11895 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11899 /* Toshiba specific */
11900 static struct hda_verb alc268_toshiba_verbs[] = {
11901 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11902 { } /* end */
11905 /* Acer specific */
11906 /* bind volumes of both NID 0x02 and 0x03 */
11907 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11908 .ops = &snd_hda_bind_vol,
11909 .values = {
11910 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11911 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11916 /* mute/unmute internal speaker according to the hp jack and mute state */
11917 static void alc268_acer_automute(struct hda_codec *codec, int force)
11919 struct alc_spec *spec = codec->spec;
11920 unsigned int mute;
11922 if (force || !spec->sense_updated) {
11923 unsigned int present;
11924 present = snd_hda_codec_read(codec, 0x14, 0,
11925 AC_VERB_GET_PIN_SENSE, 0);
11926 spec->jack_present = (present & 0x80000000) != 0;
11927 spec->sense_updated = 1;
11929 if (spec->jack_present)
11930 mute = HDA_AMP_MUTE; /* mute internal speaker */
11931 else /* unmute internal speaker if necessary */
11932 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11933 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11934 HDA_AMP_MUTE, mute);
11938 /* bind hp and internal speaker mute (with plug check) */
11939 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11940 struct snd_ctl_elem_value *ucontrol)
11942 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11943 long *valp = ucontrol->value.integer.value;
11944 int change;
11946 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11947 if (change)
11948 alc268_acer_automute(codec, 0);
11949 return change;
11952 static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11953 /* output mixer control */
11954 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11956 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11957 .name = "Master Playback Switch",
11958 .info = snd_hda_mixer_amp_switch_info,
11959 .get = snd_hda_mixer_amp_switch_get,
11960 .put = alc268_acer_master_sw_put,
11961 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11963 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11967 static struct snd_kcontrol_new alc268_acer_mixer[] = {
11968 /* output mixer control */
11969 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11971 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11972 .name = "Master Playback Switch",
11973 .info = snd_hda_mixer_amp_switch_info,
11974 .get = snd_hda_mixer_amp_switch_get,
11975 .put = alc268_acer_master_sw_put,
11976 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11978 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11979 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11980 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11984 static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11985 /* output mixer control */
11986 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11989 .name = "Master Playback Switch",
11990 .info = snd_hda_mixer_amp_switch_info,
11991 .get = snd_hda_mixer_amp_switch_get,
11992 .put = alc268_acer_master_sw_put,
11993 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11995 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11996 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12000 static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12001 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12002 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12003 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12004 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12005 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12010 static struct hda_verb alc268_acer_verbs[] = {
12011 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12012 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12013 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12014 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12015 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12016 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12017 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12021 /* unsolicited event for HP jack sensing */
12022 #define alc268_toshiba_unsol_event alc262_hippo_unsol_event
12023 #define alc268_toshiba_setup alc262_hippo_setup
12024 #define alc268_toshiba_automute alc262_hippo_automute
12026 static void alc268_acer_unsol_event(struct hda_codec *codec,
12027 unsigned int res)
12029 if ((res >> 26) != ALC880_HP_EVENT)
12030 return;
12031 alc268_acer_automute(codec, 1);
12034 static void alc268_acer_init_hook(struct hda_codec *codec)
12036 alc268_acer_automute(codec, 1);
12039 /* toggle speaker-output according to the hp-jack state */
12040 static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12042 unsigned int present;
12043 unsigned char bits;
12045 present = snd_hda_codec_read(codec, 0x15, 0,
12046 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12047 bits = present ? AMP_IN_MUTE(0) : 0;
12048 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12049 AMP_IN_MUTE(0), bits);
12050 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12051 AMP_IN_MUTE(0), bits);
12054 static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12055 unsigned int res)
12057 switch (res >> 26) {
12058 case ALC880_HP_EVENT:
12059 alc268_aspire_one_speaker_automute(codec);
12060 break;
12061 case ALC880_MIC_EVENT:
12062 alc_mic_automute(codec);
12063 break;
12067 static void alc268_acer_lc_setup(struct hda_codec *codec)
12069 struct alc_spec *spec = codec->spec;
12070 spec->ext_mic.pin = 0x18;
12071 spec->ext_mic.mux_idx = 0;
12072 spec->int_mic.pin = 0x12;
12073 spec->int_mic.mux_idx = 6;
12074 spec->auto_mic = 1;
12077 static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12079 alc268_aspire_one_speaker_automute(codec);
12080 alc_mic_automute(codec);
12083 static struct snd_kcontrol_new alc268_dell_mixer[] = {
12084 /* output mixer control */
12085 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12086 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12087 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12088 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12089 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12090 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12094 static struct hda_verb alc268_dell_verbs[] = {
12095 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12096 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12097 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12098 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12102 /* mute/unmute internal speaker according to the hp jack and mute state */
12103 static void alc268_dell_setup(struct hda_codec *codec)
12105 struct alc_spec *spec = codec->spec;
12107 spec->autocfg.hp_pins[0] = 0x15;
12108 spec->autocfg.speaker_pins[0] = 0x14;
12109 spec->ext_mic.pin = 0x18;
12110 spec->ext_mic.mux_idx = 0;
12111 spec->int_mic.pin = 0x19;
12112 spec->int_mic.mux_idx = 1;
12113 spec->auto_mic = 1;
12116 static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12117 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12118 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12119 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12121 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12122 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12123 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12124 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12128 static struct hda_verb alc267_quanta_il1_verbs[] = {
12129 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12130 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12134 static void alc267_quanta_il1_setup(struct hda_codec *codec)
12136 struct alc_spec *spec = codec->spec;
12137 spec->autocfg.hp_pins[0] = 0x15;
12138 spec->autocfg.speaker_pins[0] = 0x14;
12139 spec->ext_mic.pin = 0x18;
12140 spec->ext_mic.mux_idx = 0;
12141 spec->int_mic.pin = 0x19;
12142 spec->int_mic.mux_idx = 1;
12143 spec->auto_mic = 1;
12147 * generic initialization of ADC, input mixers and output mixers
12149 static struct hda_verb alc268_base_init_verbs[] = {
12150 /* Unmute DAC0-1 and set vol = 0 */
12151 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12152 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12155 * Set up output mixers (0x0c - 0x0e)
12157 /* set vol=0 to output mixers */
12158 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12159 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12161 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12162 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12166 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12167 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12168 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12169 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12170 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12171 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12173 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12174 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12175 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12176 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12179 /* set PCBEEP vol = 0, mute connections */
12180 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12181 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12182 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12184 /* Unmute Selector 23h,24h and set the default input to mic-in */
12186 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12188 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12195 * generic initialization of ADC, input mixers and output mixers
12197 static struct hda_verb alc268_volume_init_verbs[] = {
12198 /* set output DAC */
12199 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12200 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12202 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12203 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12204 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12205 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12206 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12208 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12209 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12210 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12212 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12213 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12215 /* set PCBEEP vol = 0, mute connections */
12216 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12217 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12218 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12223 static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12224 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12225 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12226 { } /* end */
12229 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12230 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12231 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12232 _DEFINE_CAPSRC(1),
12233 { } /* end */
12236 static struct snd_kcontrol_new alc268_capture_mixer[] = {
12237 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12238 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12239 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12240 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12241 _DEFINE_CAPSRC(2),
12242 { } /* end */
12245 static struct hda_input_mux alc268_capture_source = {
12246 .num_items = 4,
12247 .items = {
12248 { "Mic", 0x0 },
12249 { "Front Mic", 0x1 },
12250 { "Line", 0x2 },
12251 { "CD", 0x3 },
12255 static struct hda_input_mux alc268_acer_capture_source = {
12256 .num_items = 3,
12257 .items = {
12258 { "Mic", 0x0 },
12259 { "Internal Mic", 0x1 },
12260 { "Line", 0x2 },
12264 static struct hda_input_mux alc268_acer_dmic_capture_source = {
12265 .num_items = 3,
12266 .items = {
12267 { "Mic", 0x0 },
12268 { "Internal Mic", 0x6 },
12269 { "Line", 0x2 },
12273 #ifdef CONFIG_SND_DEBUG
12274 static struct snd_kcontrol_new alc268_test_mixer[] = {
12275 /* Volume widgets */
12276 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12277 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12278 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12279 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12280 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12281 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12282 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12283 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12284 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12285 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12286 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12287 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12288 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
12289 /* The below appears problematic on some hardwares */
12290 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
12291 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12292 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12293 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12294 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12296 /* Modes for retasking pin widgets */
12297 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12298 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12299 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12300 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12302 /* Controls for GPIO pins, assuming they are configured as outputs */
12303 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12304 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12305 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12306 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12308 /* Switches to allow the digital SPDIF output pin to be enabled.
12309 * The ALC268 does not have an SPDIF input.
12311 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12313 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12314 * this output to turn on an external amplifier.
12316 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12317 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12319 { } /* end */
12321 #endif
12323 /* create input playback/capture controls for the given pin */
12324 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12325 const char *ctlname, int idx)
12327 char name[32];
12328 hda_nid_t dac;
12329 int err;
12331 sprintf(name, "%s Playback Volume", ctlname);
12332 switch (nid) {
12333 case 0x14:
12334 case 0x16:
12335 dac = 0x02;
12336 break;
12337 case 0x15:
12338 dac = 0x03;
12339 break;
12340 default:
12341 return 0;
12343 if (spec->multiout.dac_nids[0] != dac &&
12344 spec->multiout.dac_nids[1] != dac) {
12345 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12346 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
12347 HDA_OUTPUT));
12348 if (err < 0)
12349 return err;
12350 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12353 sprintf(name, "%s Playback Switch", ctlname);
12354 if (nid != 0x16)
12355 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12356 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12357 else /* mono */
12358 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12359 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
12360 if (err < 0)
12361 return err;
12362 return 0;
12365 /* add playback controls from the parsed DAC table */
12366 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12367 const struct auto_pin_cfg *cfg)
12369 hda_nid_t nid;
12370 int err;
12372 spec->multiout.dac_nids = spec->private_dac_nids;
12374 nid = cfg->line_out_pins[0];
12375 if (nid) {
12376 const char *name;
12377 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12378 name = "Speaker";
12379 else
12380 name = "Front";
12381 err = alc268_new_analog_output(spec, nid, name, 0);
12382 if (err < 0)
12383 return err;
12386 nid = cfg->speaker_pins[0];
12387 if (nid == 0x1d) {
12388 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12389 "Speaker Playback Volume",
12390 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12391 if (err < 0)
12392 return err;
12393 } else {
12394 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12395 if (err < 0)
12396 return err;
12398 nid = cfg->hp_pins[0];
12399 if (nid) {
12400 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12401 if (err < 0)
12402 return err;
12405 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12406 if (nid == 0x16) {
12407 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12408 "Mono Playback Switch",
12409 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
12410 if (err < 0)
12411 return err;
12413 return 0;
12416 /* create playback/capture controls for input pins */
12417 static int alc268_auto_create_input_ctls(struct hda_codec *codec,
12418 const struct auto_pin_cfg *cfg)
12420 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
12423 static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12424 hda_nid_t nid, int pin_type)
12426 int idx;
12428 alc_set_pin_output(codec, nid, pin_type);
12429 if (nid == 0x14 || nid == 0x16)
12430 idx = 0;
12431 else
12432 idx = 1;
12433 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12436 static void alc268_auto_init_multi_out(struct hda_codec *codec)
12438 struct alc_spec *spec = codec->spec;
12439 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12440 if (nid) {
12441 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12442 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12446 static void alc268_auto_init_hp_out(struct hda_codec *codec)
12448 struct alc_spec *spec = codec->spec;
12449 hda_nid_t pin;
12451 pin = spec->autocfg.hp_pins[0];
12452 if (pin)
12453 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12454 pin = spec->autocfg.speaker_pins[0];
12455 if (pin)
12456 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12459 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12461 struct alc_spec *spec = codec->spec;
12462 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12463 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12464 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12465 unsigned int dac_vol1, dac_vol2;
12467 if (line_nid == 0x1d || speaker_nid == 0x1d) {
12468 snd_hda_codec_write(codec, speaker_nid, 0,
12469 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12470 /* mute mixer inputs from 0x1d */
12471 snd_hda_codec_write(codec, 0x0f, 0,
12472 AC_VERB_SET_AMP_GAIN_MUTE,
12473 AMP_IN_UNMUTE(1));
12474 snd_hda_codec_write(codec, 0x10, 0,
12475 AC_VERB_SET_AMP_GAIN_MUTE,
12476 AMP_IN_UNMUTE(1));
12477 } else {
12478 /* unmute mixer inputs from 0x1d */
12479 snd_hda_codec_write(codec, 0x0f, 0,
12480 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12481 snd_hda_codec_write(codec, 0x10, 0,
12482 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12485 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
12486 if (line_nid == 0x14)
12487 dac_vol2 = AMP_OUT_ZERO;
12488 else if (line_nid == 0x15)
12489 dac_vol1 = AMP_OUT_ZERO;
12490 if (hp_nid == 0x14)
12491 dac_vol2 = AMP_OUT_ZERO;
12492 else if (hp_nid == 0x15)
12493 dac_vol1 = AMP_OUT_ZERO;
12494 if (line_nid != 0x16 || hp_nid != 0x16 ||
12495 spec->autocfg.line_out_pins[1] != 0x16 ||
12496 spec->autocfg.line_out_pins[2] != 0x16)
12497 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12499 snd_hda_codec_write(codec, 0x02, 0,
12500 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12501 snd_hda_codec_write(codec, 0x03, 0,
12502 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12505 /* pcm configuration: identical with ALC880 */
12506 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
12507 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
12508 #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
12509 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
12512 * BIOS auto configuration
12514 static int alc268_parse_auto_config(struct hda_codec *codec)
12516 struct alc_spec *spec = codec->spec;
12517 int err;
12518 static hda_nid_t alc268_ignore[] = { 0 };
12520 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12521 alc268_ignore);
12522 if (err < 0)
12523 return err;
12524 if (!spec->autocfg.line_outs) {
12525 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12526 spec->multiout.max_channels = 2;
12527 spec->no_analog = 1;
12528 goto dig_only;
12530 return 0; /* can't find valid BIOS pin config */
12532 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12533 if (err < 0)
12534 return err;
12535 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
12536 if (err < 0)
12537 return err;
12539 spec->multiout.max_channels = 2;
12541 dig_only:
12542 /* digital only support output */
12543 if (spec->autocfg.dig_outs) {
12544 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
12545 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12547 if (spec->kctls.list)
12548 add_mixer(spec, spec->kctls.list);
12550 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
12551 add_mixer(spec, alc268_beep_mixer);
12553 add_verb(spec, alc268_volume_init_verbs);
12554 spec->num_mux_defs = 2;
12555 spec->input_mux = &spec->private_imux[0];
12557 err = alc_auto_add_mic_boost(codec);
12558 if (err < 0)
12559 return err;
12561 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12563 return 1;
12566 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
12568 /* init callback for auto-configuration model -- overriding the default init */
12569 static void alc268_auto_init(struct hda_codec *codec)
12571 struct alc_spec *spec = codec->spec;
12572 alc268_auto_init_multi_out(codec);
12573 alc268_auto_init_hp_out(codec);
12574 alc268_auto_init_mono_speaker_out(codec);
12575 alc268_auto_init_analog_input(codec);
12576 if (spec->unsol_event)
12577 alc_inithook(codec);
12581 * configuration and preset
12583 static const char *alc268_models[ALC268_MODEL_LAST] = {
12584 [ALC267_QUANTA_IL1] = "quanta-il1",
12585 [ALC268_3ST] = "3stack",
12586 [ALC268_TOSHIBA] = "toshiba",
12587 [ALC268_ACER] = "acer",
12588 [ALC268_ACER_DMIC] = "acer-dmic",
12589 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
12590 [ALC268_DELL] = "dell",
12591 [ALC268_ZEPTO] = "zepto",
12592 #ifdef CONFIG_SND_DEBUG
12593 [ALC268_TEST] = "test",
12594 #endif
12595 [ALC268_AUTO] = "auto",
12598 static struct snd_pci_quirk alc268_cfg_tbl[] = {
12599 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
12600 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
12601 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
12602 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
12603 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
12604 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12605 ALC268_ACER_ASPIRE_ONE),
12606 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
12607 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
12608 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
12609 /* almost compatible with toshiba but with optional digital outs;
12610 * auto-probing seems working fine
12612 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12613 ALC268_AUTO),
12614 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
12615 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12616 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
12617 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
12618 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
12619 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
12623 /* Toshiba laptops have no unique PCI SSID but only codec SSID */
12624 static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12625 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12626 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12627 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12628 ALC268_TOSHIBA),
12632 static struct alc_config_preset alc268_presets[] = {
12633 [ALC267_QUANTA_IL1] = {
12634 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12635 alc268_capture_nosrc_mixer },
12636 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12637 alc267_quanta_il1_verbs },
12638 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12639 .dac_nids = alc268_dac_nids,
12640 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12641 .adc_nids = alc268_adc_nids_alt,
12642 .hp_nid = 0x03,
12643 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12644 .channel_mode = alc268_modes,
12645 .unsol_event = alc_sku_unsol_event,
12646 .setup = alc267_quanta_il1_setup,
12647 .init_hook = alc_inithook,
12649 [ALC268_3ST] = {
12650 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12651 alc268_beep_mixer },
12652 .init_verbs = { alc268_base_init_verbs },
12653 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12654 .dac_nids = alc268_dac_nids,
12655 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12656 .adc_nids = alc268_adc_nids_alt,
12657 .capsrc_nids = alc268_capsrc_nids,
12658 .hp_nid = 0x03,
12659 .dig_out_nid = ALC268_DIGOUT_NID,
12660 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12661 .channel_mode = alc268_modes,
12662 .input_mux = &alc268_capture_source,
12664 [ALC268_TOSHIBA] = {
12665 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
12666 alc268_beep_mixer },
12667 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12668 alc268_toshiba_verbs },
12669 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12670 .dac_nids = alc268_dac_nids,
12671 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12672 .adc_nids = alc268_adc_nids_alt,
12673 .capsrc_nids = alc268_capsrc_nids,
12674 .hp_nid = 0x03,
12675 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12676 .channel_mode = alc268_modes,
12677 .input_mux = &alc268_capture_source,
12678 .unsol_event = alc268_toshiba_unsol_event,
12679 .setup = alc268_toshiba_setup,
12680 .init_hook = alc268_toshiba_automute,
12682 [ALC268_ACER] = {
12683 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12684 alc268_beep_mixer },
12685 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12686 alc268_acer_verbs },
12687 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12688 .dac_nids = alc268_dac_nids,
12689 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12690 .adc_nids = alc268_adc_nids_alt,
12691 .capsrc_nids = alc268_capsrc_nids,
12692 .hp_nid = 0x02,
12693 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12694 .channel_mode = alc268_modes,
12695 .input_mux = &alc268_acer_capture_source,
12696 .unsol_event = alc268_acer_unsol_event,
12697 .init_hook = alc268_acer_init_hook,
12699 [ALC268_ACER_DMIC] = {
12700 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12701 alc268_beep_mixer },
12702 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12703 alc268_acer_verbs },
12704 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12705 .dac_nids = alc268_dac_nids,
12706 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12707 .adc_nids = alc268_adc_nids_alt,
12708 .capsrc_nids = alc268_capsrc_nids,
12709 .hp_nid = 0x02,
12710 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12711 .channel_mode = alc268_modes,
12712 .input_mux = &alc268_acer_dmic_capture_source,
12713 .unsol_event = alc268_acer_unsol_event,
12714 .init_hook = alc268_acer_init_hook,
12716 [ALC268_ACER_ASPIRE_ONE] = {
12717 .mixers = { alc268_acer_aspire_one_mixer,
12718 alc268_beep_mixer,
12719 alc268_capture_nosrc_mixer },
12720 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12721 alc268_acer_aspire_one_verbs },
12722 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12723 .dac_nids = alc268_dac_nids,
12724 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12725 .adc_nids = alc268_adc_nids_alt,
12726 .capsrc_nids = alc268_capsrc_nids,
12727 .hp_nid = 0x03,
12728 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12729 .channel_mode = alc268_modes,
12730 .unsol_event = alc268_acer_lc_unsol_event,
12731 .setup = alc268_acer_lc_setup,
12732 .init_hook = alc268_acer_lc_init_hook,
12734 [ALC268_DELL] = {
12735 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12736 alc268_capture_nosrc_mixer },
12737 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12738 alc268_dell_verbs },
12739 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12740 .dac_nids = alc268_dac_nids,
12741 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12742 .adc_nids = alc268_adc_nids_alt,
12743 .capsrc_nids = alc268_capsrc_nids,
12744 .hp_nid = 0x02,
12745 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12746 .channel_mode = alc268_modes,
12747 .unsol_event = alc_sku_unsol_event,
12748 .setup = alc268_dell_setup,
12749 .init_hook = alc_inithook,
12751 [ALC268_ZEPTO] = {
12752 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12753 alc268_beep_mixer },
12754 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12755 alc268_toshiba_verbs },
12756 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12757 .dac_nids = alc268_dac_nids,
12758 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12759 .adc_nids = alc268_adc_nids_alt,
12760 .capsrc_nids = alc268_capsrc_nids,
12761 .hp_nid = 0x03,
12762 .dig_out_nid = ALC268_DIGOUT_NID,
12763 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12764 .channel_mode = alc268_modes,
12765 .input_mux = &alc268_capture_source,
12766 .setup = alc268_toshiba_setup,
12767 .init_hook = alc268_toshiba_automute,
12769 #ifdef CONFIG_SND_DEBUG
12770 [ALC268_TEST] = {
12771 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12772 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12773 alc268_volume_init_verbs },
12774 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12775 .dac_nids = alc268_dac_nids,
12776 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12777 .adc_nids = alc268_adc_nids_alt,
12778 .capsrc_nids = alc268_capsrc_nids,
12779 .hp_nid = 0x03,
12780 .dig_out_nid = ALC268_DIGOUT_NID,
12781 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12782 .channel_mode = alc268_modes,
12783 .input_mux = &alc268_capture_source,
12785 #endif
12788 static int patch_alc268(struct hda_codec *codec)
12790 struct alc_spec *spec;
12791 int board_config;
12792 int i, has_beep, err;
12794 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12795 if (spec == NULL)
12796 return -ENOMEM;
12798 codec->spec = spec;
12800 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12801 alc268_models,
12802 alc268_cfg_tbl);
12804 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12805 board_config = snd_hda_check_board_codec_sid_config(codec,
12806 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12808 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12809 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12810 codec->chip_name);
12811 board_config = ALC268_AUTO;
12814 if (board_config == ALC268_AUTO) {
12815 /* automatic parse from the BIOS config */
12816 err = alc268_parse_auto_config(codec);
12817 if (err < 0) {
12818 alc_free(codec);
12819 return err;
12820 } else if (!err) {
12821 printk(KERN_INFO
12822 "hda_codec: Cannot set up configuration "
12823 "from BIOS. Using base mode...\n");
12824 board_config = ALC268_3ST;
12828 if (board_config != ALC268_AUTO)
12829 setup_preset(codec, &alc268_presets[board_config]);
12831 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12832 spec->stream_analog_capture = &alc268_pcm_analog_capture;
12833 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
12835 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12837 has_beep = 0;
12838 for (i = 0; i < spec->num_mixers; i++) {
12839 if (spec->mixers[i] == alc268_beep_mixer) {
12840 has_beep = 1;
12841 break;
12845 if (has_beep) {
12846 err = snd_hda_attach_beep_device(codec, 0x1);
12847 if (err < 0) {
12848 alc_free(codec);
12849 return err;
12851 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12852 /* override the amp caps for beep generator */
12853 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
12854 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12855 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12856 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12857 (0 << AC_AMPCAP_MUTE_SHIFT));
12860 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
12861 /* check whether NID 0x07 is valid */
12862 unsigned int wcap = get_wcaps(codec, 0x07);
12863 int i;
12865 spec->capsrc_nids = alc268_capsrc_nids;
12866 /* get type */
12867 wcap = get_wcaps_type(wcap);
12868 if (spec->auto_mic ||
12869 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
12870 spec->adc_nids = alc268_adc_nids_alt;
12871 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
12872 if (spec->auto_mic)
12873 fixup_automic_adc(codec);
12874 if (spec->auto_mic || spec->input_mux->num_items == 1)
12875 add_mixer(spec, alc268_capture_nosrc_mixer);
12876 else
12877 add_mixer(spec, alc268_capture_alt_mixer);
12878 } else {
12879 spec->adc_nids = alc268_adc_nids;
12880 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
12881 add_mixer(spec, alc268_capture_mixer);
12883 /* set default input source */
12884 for (i = 0; i < spec->num_adc_nids; i++)
12885 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12886 0, AC_VERB_SET_CONNECT_SEL,
12887 i < spec->num_mux_defs ?
12888 spec->input_mux[i].items[0].index :
12889 spec->input_mux->items[0].index);
12892 spec->vmaster_nid = 0x02;
12894 codec->patch_ops = alc_patch_ops;
12895 if (board_config == ALC268_AUTO)
12896 spec->init_hook = alc268_auto_init;
12898 codec->proc_widget_hook = print_realtek_coef;
12900 return 0;
12904 * ALC269 channel source setting (2 channel)
12906 #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12908 #define alc269_dac_nids alc260_dac_nids
12910 static hda_nid_t alc269_adc_nids[1] = {
12911 /* ADC1 */
12912 0x08,
12915 static hda_nid_t alc269_capsrc_nids[1] = {
12916 0x23,
12919 /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12920 * not a mux!
12923 #define alc269_modes alc260_modes
12924 #define alc269_capture_source alc880_lg_lw_capture_source
12926 static struct snd_kcontrol_new alc269_base_mixer[] = {
12927 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12928 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12929 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12930 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12931 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12932 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12933 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12934 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12935 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12936 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12937 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12938 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12939 { } /* end */
12942 static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12943 /* output mixer control */
12944 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12946 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12947 .name = "Master Playback Switch",
12948 .info = snd_hda_mixer_amp_switch_info,
12949 .get = snd_hda_mixer_amp_switch_get,
12950 .put = alc268_acer_master_sw_put,
12951 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12955 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12956 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12957 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12958 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12962 static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12963 /* output mixer control */
12964 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12967 .name = "Master Playback Switch",
12968 .info = snd_hda_mixer_amp_switch_info,
12969 .get = snd_hda_mixer_amp_switch_get,
12970 .put = alc268_acer_master_sw_put,
12971 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12975 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12976 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12977 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12978 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12979 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12980 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12981 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12985 static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12986 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12987 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12989 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12990 { } /* end */
12993 /* capture mixer elements */
12994 static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12995 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12996 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12998 { } /* end */
13001 /* FSC amilo */
13002 #define alc269_fujitsu_mixer alc269_eeepc_mixer
13004 static struct hda_verb alc269_quanta_fl1_verbs[] = {
13005 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13006 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13008 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13009 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13010 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13014 static struct hda_verb alc269_lifebook_verbs[] = {
13015 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13016 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13017 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13018 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13019 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13020 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13021 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13022 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13023 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13024 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13028 /* toggle speaker-output according to the hp-jack state */
13029 static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13031 unsigned int present;
13032 unsigned char bits;
13034 present = snd_hda_codec_read(codec, 0x15, 0,
13035 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13036 bits = present ? AMP_IN_MUTE(0) : 0;
13037 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13038 AMP_IN_MUTE(0), bits);
13039 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13040 AMP_IN_MUTE(0), bits);
13042 snd_hda_codec_write(codec, 0x20, 0,
13043 AC_VERB_SET_COEF_INDEX, 0x0c);
13044 snd_hda_codec_write(codec, 0x20, 0,
13045 AC_VERB_SET_PROC_COEF, 0x680);
13047 snd_hda_codec_write(codec, 0x20, 0,
13048 AC_VERB_SET_COEF_INDEX, 0x0c);
13049 snd_hda_codec_write(codec, 0x20, 0,
13050 AC_VERB_SET_PROC_COEF, 0x480);
13053 /* toggle speaker-output according to the hp-jacks state */
13054 static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13056 unsigned int present;
13057 unsigned char bits;
13059 /* Check laptop headphone socket */
13060 present = snd_hda_codec_read(codec, 0x15, 0,
13061 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13063 /* Check port replicator headphone socket */
13064 present |= snd_hda_codec_read(codec, 0x1a, 0,
13065 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13067 bits = present ? AMP_IN_MUTE(0) : 0;
13068 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13069 AMP_IN_MUTE(0), bits);
13070 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13071 AMP_IN_MUTE(0), bits);
13073 snd_hda_codec_write(codec, 0x20, 0,
13074 AC_VERB_SET_COEF_INDEX, 0x0c);
13075 snd_hda_codec_write(codec, 0x20, 0,
13076 AC_VERB_SET_PROC_COEF, 0x680);
13078 snd_hda_codec_write(codec, 0x20, 0,
13079 AC_VERB_SET_COEF_INDEX, 0x0c);
13080 snd_hda_codec_write(codec, 0x20, 0,
13081 AC_VERB_SET_PROC_COEF, 0x480);
13084 static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13086 unsigned int present_laptop;
13087 unsigned int present_dock;
13089 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
13090 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13092 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
13093 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13095 /* Laptop mic port overrides dock mic port, design decision */
13096 if (present_dock)
13097 snd_hda_codec_write(codec, 0x23, 0,
13098 AC_VERB_SET_CONNECT_SEL, 0x3);
13099 if (present_laptop)
13100 snd_hda_codec_write(codec, 0x23, 0,
13101 AC_VERB_SET_CONNECT_SEL, 0x0);
13102 if (!present_dock && !present_laptop)
13103 snd_hda_codec_write(codec, 0x23, 0,
13104 AC_VERB_SET_CONNECT_SEL, 0x1);
13107 static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13108 unsigned int res)
13110 switch (res >> 26) {
13111 case ALC880_HP_EVENT:
13112 alc269_quanta_fl1_speaker_automute(codec);
13113 break;
13114 case ALC880_MIC_EVENT:
13115 alc_mic_automute(codec);
13116 break;
13120 static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13121 unsigned int res)
13123 if ((res >> 26) == ALC880_HP_EVENT)
13124 alc269_lifebook_speaker_automute(codec);
13125 if ((res >> 26) == ALC880_MIC_EVENT)
13126 alc269_lifebook_mic_autoswitch(codec);
13129 static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13131 struct alc_spec *spec = codec->spec;
13132 spec->ext_mic.pin = 0x18;
13133 spec->ext_mic.mux_idx = 0;
13134 spec->int_mic.pin = 0x19;
13135 spec->int_mic.mux_idx = 1;
13136 spec->auto_mic = 1;
13139 static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13141 alc269_quanta_fl1_speaker_automute(codec);
13142 alc_mic_automute(codec);
13145 static void alc269_lifebook_init_hook(struct hda_codec *codec)
13147 alc269_lifebook_speaker_automute(codec);
13148 alc269_lifebook_mic_autoswitch(codec);
13151 static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13152 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13153 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13154 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13155 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13156 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13157 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13158 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13162 static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13163 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13164 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13165 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13167 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13168 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13172 /* toggle speaker-output according to the hp-jack state */
13173 static void alc269_speaker_automute(struct hda_codec *codec)
13175 unsigned int present;
13176 unsigned char bits;
13178 present = snd_hda_codec_read(codec, 0x15, 0,
13179 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13180 bits = present ? AMP_IN_MUTE(0) : 0;
13181 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13182 AMP_IN_MUTE(0), bits);
13183 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13184 AMP_IN_MUTE(0), bits);
13187 /* unsolicited event for HP jack sensing */
13188 static void alc269_eeepc_unsol_event(struct hda_codec *codec,
13189 unsigned int res)
13191 switch (res >> 26) {
13192 case ALC880_HP_EVENT:
13193 alc269_speaker_automute(codec);
13194 break;
13195 case ALC880_MIC_EVENT:
13196 alc_mic_automute(codec);
13197 break;
13201 static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13203 struct alc_spec *spec = codec->spec;
13204 spec->ext_mic.pin = 0x18;
13205 spec->ext_mic.mux_idx = 0;
13206 spec->int_mic.pin = 0x12;
13207 spec->int_mic.mux_idx = 5;
13208 spec->auto_mic = 1;
13211 static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13213 struct alc_spec *spec = codec->spec;
13214 spec->ext_mic.pin = 0x18;
13215 spec->ext_mic.mux_idx = 0;
13216 spec->int_mic.pin = 0x19;
13217 spec->int_mic.mux_idx = 1;
13218 spec->auto_mic = 1;
13221 static void alc269_eeepc_inithook(struct hda_codec *codec)
13223 alc269_speaker_automute(codec);
13224 alc_mic_automute(codec);
13228 * generic initialization of ADC, input mixers and output mixers
13230 static struct hda_verb alc269_init_verbs[] = {
13232 * Unmute ADC0 and set the default input to mic-in
13234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13236 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13237 * analog-loopback mixer widget
13238 * Note: PASD motherboards uses the Line In 2 as the input for
13239 * front panel mic (mic 2)
13241 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13242 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13243 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13244 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13249 * Set up output mixers (0x0c - 0x0e)
13251 /* set vol=0 to output mixers */
13252 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13253 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13255 /* set up input amps for analog loopback */
13256 /* Amp Indices: DAC = 0, mixer = 1 */
13257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13259 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13260 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13261 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13262 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13265 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13266 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13268 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13270 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13272 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13273 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13274 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13276 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13277 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13278 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13280 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13281 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13283 /* FIXME: use matrix-type input source selection */
13284 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13285 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13291 /* set EAPD */
13292 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13293 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13297 #define alc269_auto_create_multi_out_ctls \
13298 alc268_auto_create_multi_out_ctls
13299 #define alc269_auto_create_input_ctls \
13300 alc268_auto_create_input_ctls
13302 #ifdef CONFIG_SND_HDA_POWER_SAVE
13303 #define alc269_loopbacks alc880_loopbacks
13304 #endif
13306 /* pcm configuration: identical with ALC880 */
13307 #define alc269_pcm_analog_playback alc880_pcm_analog_playback
13308 #define alc269_pcm_analog_capture alc880_pcm_analog_capture
13309 #define alc269_pcm_digital_playback alc880_pcm_digital_playback
13310 #define alc269_pcm_digital_capture alc880_pcm_digital_capture
13312 static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13313 .substreams = 1,
13314 .channels_min = 2,
13315 .channels_max = 8,
13316 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13317 /* NID is set in alc_build_pcms */
13318 .ops = {
13319 .open = alc880_playback_pcm_open,
13320 .prepare = alc880_playback_pcm_prepare,
13321 .cleanup = alc880_playback_pcm_cleanup
13325 static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13326 .substreams = 1,
13327 .channels_min = 2,
13328 .channels_max = 2,
13329 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13330 /* NID is set in alc_build_pcms */
13334 * BIOS auto configuration
13336 static int alc269_parse_auto_config(struct hda_codec *codec)
13338 struct alc_spec *spec = codec->spec;
13339 int err;
13340 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13342 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13343 alc269_ignore);
13344 if (err < 0)
13345 return err;
13347 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13348 if (err < 0)
13349 return err;
13350 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
13351 if (err < 0)
13352 return err;
13354 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13356 if (spec->autocfg.dig_outs)
13357 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13359 if (spec->kctls.list)
13360 add_mixer(spec, spec->kctls.list);
13362 add_verb(spec, alc269_init_verbs);
13363 spec->num_mux_defs = 1;
13364 spec->input_mux = &spec->private_imux[0];
13365 /* set default input source */
13366 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13367 0, AC_VERB_SET_CONNECT_SEL,
13368 spec->input_mux->items[0].index);
13370 err = alc_auto_add_mic_boost(codec);
13371 if (err < 0)
13372 return err;
13374 if (!spec->cap_mixer && !spec->no_analog)
13375 set_capture_mixer(codec);
13377 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13379 return 1;
13382 #define alc269_auto_init_multi_out alc268_auto_init_multi_out
13383 #define alc269_auto_init_hp_out alc268_auto_init_hp_out
13384 #define alc269_auto_init_analog_input alc882_auto_init_analog_input
13387 /* init callback for auto-configuration model -- overriding the default init */
13388 static void alc269_auto_init(struct hda_codec *codec)
13390 struct alc_spec *spec = codec->spec;
13391 alc269_auto_init_multi_out(codec);
13392 alc269_auto_init_hp_out(codec);
13393 alc269_auto_init_analog_input(codec);
13394 if (spec->unsol_event)
13395 alc_inithook(codec);
13399 * configuration and preset
13401 static const char *alc269_models[ALC269_MODEL_LAST] = {
13402 [ALC269_BASIC] = "basic",
13403 [ALC269_QUANTA_FL1] = "quanta",
13404 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
13405 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
13406 [ALC269_FUJITSU] = "fujitsu",
13407 [ALC269_LIFEBOOK] = "lifebook",
13408 [ALC269_AUTO] = "auto",
13411 static struct snd_pci_quirk alc269_cfg_tbl[] = {
13412 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
13413 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13414 ALC269_ASUS_EEEPC_P703),
13415 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13416 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13417 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13418 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13419 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13420 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
13421 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13422 ALC269_ASUS_EEEPC_P901),
13423 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13424 ALC269_ASUS_EEEPC_P901),
13425 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
13426 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
13427 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
13431 static struct alc_config_preset alc269_presets[] = {
13432 [ALC269_BASIC] = {
13433 .mixers = { alc269_base_mixer },
13434 .init_verbs = { alc269_init_verbs },
13435 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13436 .dac_nids = alc269_dac_nids,
13437 .hp_nid = 0x03,
13438 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13439 .channel_mode = alc269_modes,
13440 .input_mux = &alc269_capture_source,
13442 [ALC269_QUANTA_FL1] = {
13443 .mixers = { alc269_quanta_fl1_mixer },
13444 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13445 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13446 .dac_nids = alc269_dac_nids,
13447 .hp_nid = 0x03,
13448 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13449 .channel_mode = alc269_modes,
13450 .input_mux = &alc269_capture_source,
13451 .unsol_event = alc269_quanta_fl1_unsol_event,
13452 .setup = alc269_quanta_fl1_setup,
13453 .init_hook = alc269_quanta_fl1_init_hook,
13455 [ALC269_ASUS_EEEPC_P703] = {
13456 .mixers = { alc269_eeepc_mixer },
13457 .cap_mixer = alc269_epc_capture_mixer,
13458 .init_verbs = { alc269_init_verbs,
13459 alc269_eeepc_amic_init_verbs },
13460 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13461 .dac_nids = alc269_dac_nids,
13462 .hp_nid = 0x03,
13463 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13464 .channel_mode = alc269_modes,
13465 .unsol_event = alc269_eeepc_unsol_event,
13466 .setup = alc269_eeepc_amic_setup,
13467 .init_hook = alc269_eeepc_inithook,
13469 [ALC269_ASUS_EEEPC_P901] = {
13470 .mixers = { alc269_eeepc_mixer },
13471 .cap_mixer = alc269_epc_capture_mixer,
13472 .init_verbs = { alc269_init_verbs,
13473 alc269_eeepc_dmic_init_verbs },
13474 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13475 .dac_nids = alc269_dac_nids,
13476 .hp_nid = 0x03,
13477 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13478 .channel_mode = alc269_modes,
13479 .unsol_event = alc269_eeepc_unsol_event,
13480 .setup = alc269_eeepc_dmic_setup,
13481 .init_hook = alc269_eeepc_inithook,
13483 [ALC269_FUJITSU] = {
13484 .mixers = { alc269_fujitsu_mixer },
13485 .cap_mixer = alc269_epc_capture_mixer,
13486 .init_verbs = { alc269_init_verbs,
13487 alc269_eeepc_dmic_init_verbs },
13488 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13489 .dac_nids = alc269_dac_nids,
13490 .hp_nid = 0x03,
13491 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13492 .channel_mode = alc269_modes,
13493 .unsol_event = alc269_eeepc_unsol_event,
13494 .setup = alc269_eeepc_dmic_setup,
13495 .init_hook = alc269_eeepc_inithook,
13497 [ALC269_LIFEBOOK] = {
13498 .mixers = { alc269_lifebook_mixer },
13499 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13500 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13501 .dac_nids = alc269_dac_nids,
13502 .hp_nid = 0x03,
13503 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13504 .channel_mode = alc269_modes,
13505 .input_mux = &alc269_capture_source,
13506 .unsol_event = alc269_lifebook_unsol_event,
13507 .init_hook = alc269_lifebook_init_hook,
13511 static int patch_alc269(struct hda_codec *codec)
13513 struct alc_spec *spec;
13514 int board_config;
13515 int err;
13517 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13518 if (spec == NULL)
13519 return -ENOMEM;
13521 codec->spec = spec;
13523 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13525 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13526 alc269_models,
13527 alc269_cfg_tbl);
13529 if (board_config < 0) {
13530 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13531 codec->chip_name);
13532 board_config = ALC269_AUTO;
13535 if (board_config == ALC269_AUTO) {
13536 /* automatic parse from the BIOS config */
13537 err = alc269_parse_auto_config(codec);
13538 if (err < 0) {
13539 alc_free(codec);
13540 return err;
13541 } else if (!err) {
13542 printk(KERN_INFO
13543 "hda_codec: Cannot set up configuration "
13544 "from BIOS. Using base mode...\n");
13545 board_config = ALC269_BASIC;
13549 err = snd_hda_attach_beep_device(codec, 0x1);
13550 if (err < 0) {
13551 alc_free(codec);
13552 return err;
13555 if (board_config != ALC269_AUTO)
13556 setup_preset(codec, &alc269_presets[board_config]);
13558 if (codec->subsystem_id == 0x17aa3bf8) {
13559 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13560 * fix the sample rate of analog I/O to 44.1kHz
13562 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13563 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13564 } else {
13565 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13566 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13568 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13569 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13571 spec->adc_nids = alc269_adc_nids;
13572 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
13573 spec->capsrc_nids = alc269_capsrc_nids;
13574 if (!spec->cap_mixer)
13575 set_capture_mixer(codec);
13576 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
13578 spec->vmaster_nid = 0x02;
13580 codec->patch_ops = alc_patch_ops;
13581 if (board_config == ALC269_AUTO)
13582 spec->init_hook = alc269_auto_init;
13583 #ifdef CONFIG_SND_HDA_POWER_SAVE
13584 if (!spec->loopback.amplist)
13585 spec->loopback.amplist = alc269_loopbacks;
13586 #endif
13587 codec->proc_widget_hook = print_realtek_coef;
13589 return 0;
13593 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13597 * set the path ways for 2 channel output
13598 * need to set the codec line out and mic 1 pin widgets to inputs
13600 static struct hda_verb alc861_threestack_ch2_init[] = {
13601 /* set pin widget 1Ah (line in) for input */
13602 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13603 /* set pin widget 18h (mic1/2) for input, for mic also enable
13604 * the vref
13606 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13608 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13609 #if 0
13610 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13611 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13612 #endif
13613 { } /* end */
13616 * 6ch mode
13617 * need to set the codec line out and mic 1 pin widgets to outputs
13619 static struct hda_verb alc861_threestack_ch6_init[] = {
13620 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13621 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13622 /* set pin widget 18h (mic1) for output (CLFE)*/
13623 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13625 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13626 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13628 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13629 #if 0
13630 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13631 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13632 #endif
13633 { } /* end */
13636 static struct hda_channel_mode alc861_threestack_modes[2] = {
13637 { 2, alc861_threestack_ch2_init },
13638 { 6, alc861_threestack_ch6_init },
13640 /* Set mic1 as input and unmute the mixer */
13641 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13642 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13643 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13644 { } /* end */
13646 /* Set mic1 as output and mute mixer */
13647 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13648 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13649 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13650 { } /* end */
13653 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13654 { 2, alc861_uniwill_m31_ch2_init },
13655 { 4, alc861_uniwill_m31_ch4_init },
13658 /* Set mic1 and line-in as input and unmute the mixer */
13659 static struct hda_verb alc861_asus_ch2_init[] = {
13660 /* set pin widget 1Ah (line in) for input */
13661 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13662 /* set pin widget 18h (mic1/2) for input, for mic also enable
13663 * the vref
13665 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13667 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13668 #if 0
13669 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13670 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13671 #endif
13672 { } /* end */
13674 /* Set mic1 nad line-in as output and mute mixer */
13675 static struct hda_verb alc861_asus_ch6_init[] = {
13676 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13677 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13678 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13679 /* set pin widget 18h (mic1) for output (CLFE)*/
13680 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13681 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13682 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13683 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13685 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13686 #if 0
13687 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13688 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13689 #endif
13690 { } /* end */
13693 static struct hda_channel_mode alc861_asus_modes[2] = {
13694 { 2, alc861_asus_ch2_init },
13695 { 6, alc861_asus_ch6_init },
13698 /* patch-ALC861 */
13700 static struct snd_kcontrol_new alc861_base_mixer[] = {
13701 /* output mixer control */
13702 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13703 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13704 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13705 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13706 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13708 /*Input mixer control */
13709 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13710 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13711 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13712 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13713 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13714 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13715 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13716 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13717 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13720 { } /* end */
13723 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13724 /* output mixer control */
13725 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13726 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13727 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13728 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13729 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13731 /* Input mixer control */
13732 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13733 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13734 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13735 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13736 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13737 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13738 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13739 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13740 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13741 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13744 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13745 .name = "Channel Mode",
13746 .info = alc_ch_mode_info,
13747 .get = alc_ch_mode_get,
13748 .put = alc_ch_mode_put,
13749 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13751 { } /* end */
13754 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
13755 /* output mixer control */
13756 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13757 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13758 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13760 { } /* end */
13763 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13764 /* output mixer control */
13765 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13766 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13767 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13768 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13769 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13771 /* Input mixer control */
13772 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13773 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13774 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13775 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13776 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13777 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13779 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13781 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13784 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13785 .name = "Channel Mode",
13786 .info = alc_ch_mode_info,
13787 .get = alc_ch_mode_get,
13788 .put = alc_ch_mode_put,
13789 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13791 { } /* end */
13794 static struct snd_kcontrol_new alc861_asus_mixer[] = {
13795 /* output mixer control */
13796 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13797 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13798 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13799 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13800 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13802 /* Input mixer control */
13803 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13804 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13805 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13806 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13807 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13808 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13810 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13815 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13816 .name = "Channel Mode",
13817 .info = alc_ch_mode_info,
13818 .get = alc_ch_mode_get,
13819 .put = alc_ch_mode_put,
13820 .private_value = ARRAY_SIZE(alc861_asus_modes),
13825 /* additional mixer */
13826 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
13827 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13828 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13833 * generic initialization of ADC, input mixers and output mixers
13835 static struct hda_verb alc861_base_init_verbs[] = {
13837 * Unmute ADC0 and set the default input to mic-in
13839 /* port-A for surround (rear panel) */
13840 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13841 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13842 /* port-B for mic-in (rear panel) with vref */
13843 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13844 /* port-C for line-in (rear panel) */
13845 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13846 /* port-D for Front */
13847 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13848 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13849 /* port-E for HP out (front panel) */
13850 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13851 /* route front PCM to HP */
13852 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13853 /* port-F for mic-in (front panel) with vref */
13854 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13855 /* port-G for CLFE (rear panel) */
13856 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13857 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13858 /* port-H for side (rear panel) */
13859 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13860 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13861 /* CD-in */
13862 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13863 /* route front mic to ADC1*/
13864 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13865 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13867 /* Unmute DAC0~3 & spdif out*/
13868 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13869 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13870 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13871 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13872 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13874 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13875 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13876 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13877 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13878 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13880 /* Unmute Stereo Mixer 15 */
13881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13883 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13886 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13887 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13888 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13889 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13890 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13891 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13892 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13893 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13894 /* hp used DAC 3 (Front) */
13895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13896 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13901 static struct hda_verb alc861_threestack_init_verbs[] = {
13903 * Unmute ADC0 and set the default input to mic-in
13905 /* port-A for surround (rear panel) */
13906 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13907 /* port-B for mic-in (rear panel) with vref */
13908 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13909 /* port-C for line-in (rear panel) */
13910 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13911 /* port-D for Front */
13912 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13913 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13914 /* port-E for HP out (front panel) */
13915 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13916 /* route front PCM to HP */
13917 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13918 /* port-F for mic-in (front panel) with vref */
13919 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13920 /* port-G for CLFE (rear panel) */
13921 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13922 /* port-H for side (rear panel) */
13923 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13924 /* CD-in */
13925 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13926 /* route front mic to ADC1*/
13927 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13928 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13929 /* Unmute DAC0~3 & spdif out*/
13930 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13931 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13932 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13933 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13936 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13937 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13938 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13939 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13940 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13942 /* Unmute Stereo Mixer 15 */
13943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13944 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13946 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13948 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13949 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13950 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13951 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13952 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13953 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13954 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13955 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13956 /* hp used DAC 3 (Front) */
13957 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13958 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13962 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13964 * Unmute ADC0 and set the default input to mic-in
13966 /* port-A for surround (rear panel) */
13967 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13968 /* port-B for mic-in (rear panel) with vref */
13969 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13970 /* port-C for line-in (rear panel) */
13971 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13972 /* port-D for Front */
13973 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13974 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13975 /* port-E for HP out (front panel) */
13976 /* this has to be set to VREF80 */
13977 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13978 /* route front PCM to HP */
13979 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13980 /* port-F for mic-in (front panel) with vref */
13981 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13982 /* port-G for CLFE (rear panel) */
13983 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13984 /* port-H for side (rear panel) */
13985 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13986 /* CD-in */
13987 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13988 /* route front mic to ADC1*/
13989 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13990 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13991 /* Unmute DAC0~3 & spdif out*/
13992 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13993 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13994 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13995 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13998 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13999 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14000 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14001 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14002 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14004 /* Unmute Stereo Mixer 15 */
14005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14007 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14008 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
14010 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14011 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14012 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14013 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14014 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14015 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14016 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14017 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14018 /* hp used DAC 3 (Front) */
14019 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
14020 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14024 static struct hda_verb alc861_asus_init_verbs[] = {
14026 * Unmute ADC0 and set the default input to mic-in
14028 /* port-A for surround (rear panel)
14029 * according to codec#0 this is the HP jack
14031 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14032 /* route front PCM to HP */
14033 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14034 /* port-B for mic-in (rear panel) with vref */
14035 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14036 /* port-C for line-in (rear panel) */
14037 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14038 /* port-D for Front */
14039 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14040 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14041 /* port-E for HP out (front panel) */
14042 /* this has to be set to VREF80 */
14043 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14044 /* route front PCM to HP */
14045 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14046 /* port-F for mic-in (front panel) with vref */
14047 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14048 /* port-G for CLFE (rear panel) */
14049 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14050 /* port-H for side (rear panel) */
14051 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14052 /* CD-in */
14053 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14054 /* route front mic to ADC1*/
14055 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14056 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14057 /* Unmute DAC0~3 & spdif out*/
14058 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14059 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14060 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14061 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14062 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14063 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14064 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14065 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14066 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14067 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14069 /* Unmute Stereo Mixer 15 */
14070 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14071 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14072 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
14075 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14076 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14077 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14078 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14079 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14080 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14082 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14083 /* hp used DAC 3 (Front) */
14084 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
14085 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14089 /* additional init verbs for ASUS laptops */
14090 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14091 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14092 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14097 * generic initialization of ADC, input mixers and output mixers
14099 static struct hda_verb alc861_auto_init_verbs[] = {
14101 * Unmute ADC0 and set the default input to mic-in
14103 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
14104 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14106 /* Unmute DAC0~3 & spdif out*/
14107 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14108 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14109 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14110 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14113 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14114 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14115 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14116 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14117 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14119 /* Unmute Stereo Mixer 15 */
14120 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14121 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14122 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14123 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14125 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14126 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14127 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14128 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14129 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14130 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14131 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14132 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14134 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14135 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14136 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14137 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14138 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14140 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14143 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
14148 static struct hda_verb alc861_toshiba_init_verbs[] = {
14149 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14154 /* toggle speaker-output according to the hp-jack state */
14155 static void alc861_toshiba_automute(struct hda_codec *codec)
14157 unsigned int present;
14159 present = snd_hda_codec_read(codec, 0x0f, 0,
14160 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14161 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14162 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14163 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14164 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
14167 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14168 unsigned int res)
14170 if ((res >> 26) == ALC880_HP_EVENT)
14171 alc861_toshiba_automute(codec);
14174 /* pcm configuration: identical with ALC880 */
14175 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
14176 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
14177 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
14178 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
14181 #define ALC861_DIGOUT_NID 0x07
14183 static struct hda_channel_mode alc861_8ch_modes[1] = {
14184 { 8, NULL }
14187 static hda_nid_t alc861_dac_nids[4] = {
14188 /* front, surround, clfe, side */
14189 0x03, 0x06, 0x05, 0x04
14192 static hda_nid_t alc660_dac_nids[3] = {
14193 /* front, clfe, surround */
14194 0x03, 0x05, 0x06
14197 static hda_nid_t alc861_adc_nids[1] = {
14198 /* ADC0-2 */
14199 0x08,
14202 static struct hda_input_mux alc861_capture_source = {
14203 .num_items = 5,
14204 .items = {
14205 { "Mic", 0x0 },
14206 { "Front Mic", 0x3 },
14207 { "Line", 0x1 },
14208 { "CD", 0x4 },
14209 { "Mixer", 0x5 },
14213 static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14215 struct alc_spec *spec = codec->spec;
14216 hda_nid_t mix, srcs[5];
14217 int i, j, num;
14219 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14220 return 0;
14221 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14222 if (num < 0)
14223 return 0;
14224 for (i = 0; i < num; i++) {
14225 unsigned int type;
14226 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
14227 if (type != AC_WID_AUD_OUT)
14228 continue;
14229 for (j = 0; j < spec->multiout.num_dacs; j++)
14230 if (spec->multiout.dac_nids[j] == srcs[i])
14231 break;
14232 if (j >= spec->multiout.num_dacs)
14233 return srcs[i];
14235 return 0;
14238 /* fill in the dac_nids table from the parsed pin configuration */
14239 static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
14240 const struct auto_pin_cfg *cfg)
14242 struct alc_spec *spec = codec->spec;
14243 int i;
14244 hda_nid_t nid, dac;
14246 spec->multiout.dac_nids = spec->private_dac_nids;
14247 for (i = 0; i < cfg->line_outs; i++) {
14248 nid = cfg->line_out_pins[i];
14249 dac = alc861_look_for_dac(codec, nid);
14250 if (!dac)
14251 continue;
14252 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
14254 return 0;
14257 static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14258 hda_nid_t nid, unsigned int chs)
14260 char name[32];
14261 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14262 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14263 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14266 /* add playback controls from the parsed DAC table */
14267 static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14268 const struct auto_pin_cfg *cfg)
14270 struct alc_spec *spec = codec->spec;
14271 static const char *chname[4] = {
14272 "Front", "Surround", NULL /*CLFE*/, "Side"
14274 hda_nid_t nid;
14275 int i, err;
14277 if (cfg->line_outs == 1) {
14278 const char *pfx = NULL;
14279 if (!cfg->hp_outs)
14280 pfx = "Master";
14281 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14282 pfx = "Speaker";
14283 if (pfx) {
14284 nid = spec->multiout.dac_nids[0];
14285 return alc861_create_out_sw(codec, pfx, nid, 3);
14289 for (i = 0; i < cfg->line_outs; i++) {
14290 nid = spec->multiout.dac_nids[i];
14291 if (!nid)
14292 continue;
14293 if (i == 2) {
14294 /* Center/LFE */
14295 err = alc861_create_out_sw(codec, "Center", nid, 1);
14296 if (err < 0)
14297 return err;
14298 err = alc861_create_out_sw(codec, "LFE", nid, 2);
14299 if (err < 0)
14300 return err;
14301 } else {
14302 err = alc861_create_out_sw(codec, chname[i], nid, 3);
14303 if (err < 0)
14304 return err;
14307 return 0;
14310 static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
14312 struct alc_spec *spec = codec->spec;
14313 int err;
14314 hda_nid_t nid;
14316 if (!pin)
14317 return 0;
14319 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14320 nid = alc861_look_for_dac(codec, pin);
14321 if (nid) {
14322 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14323 if (err < 0)
14324 return err;
14325 spec->multiout.hp_nid = nid;
14328 return 0;
14331 /* create playback/capture controls for input pins */
14332 static int alc861_auto_create_input_ctls(struct hda_codec *codec,
14333 const struct auto_pin_cfg *cfg)
14335 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
14338 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14339 hda_nid_t nid,
14340 int pin_type, hda_nid_t dac)
14342 hda_nid_t mix, srcs[5];
14343 int i, num;
14345 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14346 pin_type);
14347 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14348 AMP_OUT_UNMUTE);
14349 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14350 return;
14351 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14352 if (num < 0)
14353 return;
14354 for (i = 0; i < num; i++) {
14355 unsigned int mute;
14356 if (srcs[i] == dac || srcs[i] == 0x15)
14357 mute = AMP_IN_UNMUTE(i);
14358 else
14359 mute = AMP_IN_MUTE(i);
14360 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14361 mute);
14365 static void alc861_auto_init_multi_out(struct hda_codec *codec)
14367 struct alc_spec *spec = codec->spec;
14368 int i;
14370 for (i = 0; i < spec->autocfg.line_outs; i++) {
14371 hda_nid_t nid = spec->autocfg.line_out_pins[i];
14372 int pin_type = get_pin_type(spec->autocfg.line_out_type);
14373 if (nid)
14374 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
14375 spec->multiout.dac_nids[i]);
14379 static void alc861_auto_init_hp_out(struct hda_codec *codec)
14381 struct alc_spec *spec = codec->spec;
14383 if (spec->autocfg.hp_outs)
14384 alc861_auto_set_output_and_unmute(codec,
14385 spec->autocfg.hp_pins[0],
14386 PIN_HP,
14387 spec->multiout.hp_nid);
14388 if (spec->autocfg.speaker_outs)
14389 alc861_auto_set_output_and_unmute(codec,
14390 spec->autocfg.speaker_pins[0],
14391 PIN_OUT,
14392 spec->multiout.dac_nids[0]);
14395 static void alc861_auto_init_analog_input(struct hda_codec *codec)
14397 struct alc_spec *spec = codec->spec;
14398 int i;
14400 for (i = 0; i < AUTO_PIN_LAST; i++) {
14401 hda_nid_t nid = spec->autocfg.input_pins[i];
14402 if (nid >= 0x0c && nid <= 0x11)
14403 alc_set_input_pin(codec, nid, i);
14407 /* parse the BIOS configuration and set up the alc_spec */
14408 /* return 1 if successful, 0 if the proper config is not found,
14409 * or a negative error code
14411 static int alc861_parse_auto_config(struct hda_codec *codec)
14413 struct alc_spec *spec = codec->spec;
14414 int err;
14415 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14417 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14418 alc861_ignore);
14419 if (err < 0)
14420 return err;
14421 if (!spec->autocfg.line_outs)
14422 return 0; /* can't find valid BIOS pin config */
14424 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
14425 if (err < 0)
14426 return err;
14427 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
14428 if (err < 0)
14429 return err;
14430 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
14431 if (err < 0)
14432 return err;
14433 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
14434 if (err < 0)
14435 return err;
14437 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14439 if (spec->autocfg.dig_outs)
14440 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14442 if (spec->kctls.list)
14443 add_mixer(spec, spec->kctls.list);
14445 add_verb(spec, alc861_auto_init_verbs);
14447 spec->num_mux_defs = 1;
14448 spec->input_mux = &spec->private_imux[0];
14450 spec->adc_nids = alc861_adc_nids;
14451 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
14452 set_capture_mixer(codec);
14454 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14456 return 1;
14459 /* additional initialization for auto-configuration model */
14460 static void alc861_auto_init(struct hda_codec *codec)
14462 struct alc_spec *spec = codec->spec;
14463 alc861_auto_init_multi_out(codec);
14464 alc861_auto_init_hp_out(codec);
14465 alc861_auto_init_analog_input(codec);
14466 if (spec->unsol_event)
14467 alc_inithook(codec);
14470 #ifdef CONFIG_SND_HDA_POWER_SAVE
14471 static struct hda_amp_list alc861_loopbacks[] = {
14472 { 0x15, HDA_INPUT, 0 },
14473 { 0x15, HDA_INPUT, 1 },
14474 { 0x15, HDA_INPUT, 2 },
14475 { 0x15, HDA_INPUT, 3 },
14476 { } /* end */
14478 #endif
14482 * configuration and preset
14484 static const char *alc861_models[ALC861_MODEL_LAST] = {
14485 [ALC861_3ST] = "3stack",
14486 [ALC660_3ST] = "3stack-660",
14487 [ALC861_3ST_DIG] = "3stack-dig",
14488 [ALC861_6ST_DIG] = "6stack-dig",
14489 [ALC861_UNIWILL_M31] = "uniwill-m31",
14490 [ALC861_TOSHIBA] = "toshiba",
14491 [ALC861_ASUS] = "asus",
14492 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14493 [ALC861_AUTO] = "auto",
14496 static struct snd_pci_quirk alc861_cfg_tbl[] = {
14497 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
14498 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14499 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14500 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
14501 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
14502 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
14503 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
14504 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14505 * Any other models that need this preset?
14507 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
14508 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14509 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
14510 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14511 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14512 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14513 /* FIXME: the below seems conflict */
14514 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14515 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14516 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
14520 static struct alc_config_preset alc861_presets[] = {
14521 [ALC861_3ST] = {
14522 .mixers = { alc861_3ST_mixer },
14523 .init_verbs = { alc861_threestack_init_verbs },
14524 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14525 .dac_nids = alc861_dac_nids,
14526 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14527 .channel_mode = alc861_threestack_modes,
14528 .need_dac_fix = 1,
14529 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14530 .adc_nids = alc861_adc_nids,
14531 .input_mux = &alc861_capture_source,
14533 [ALC861_3ST_DIG] = {
14534 .mixers = { alc861_base_mixer },
14535 .init_verbs = { alc861_threestack_init_verbs },
14536 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14537 .dac_nids = alc861_dac_nids,
14538 .dig_out_nid = ALC861_DIGOUT_NID,
14539 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14540 .channel_mode = alc861_threestack_modes,
14541 .need_dac_fix = 1,
14542 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14543 .adc_nids = alc861_adc_nids,
14544 .input_mux = &alc861_capture_source,
14546 [ALC861_6ST_DIG] = {
14547 .mixers = { alc861_base_mixer },
14548 .init_verbs = { alc861_base_init_verbs },
14549 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14550 .dac_nids = alc861_dac_nids,
14551 .dig_out_nid = ALC861_DIGOUT_NID,
14552 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14553 .channel_mode = alc861_8ch_modes,
14554 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14555 .adc_nids = alc861_adc_nids,
14556 .input_mux = &alc861_capture_source,
14558 [ALC660_3ST] = {
14559 .mixers = { alc861_3ST_mixer },
14560 .init_verbs = { alc861_threestack_init_verbs },
14561 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14562 .dac_nids = alc660_dac_nids,
14563 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14564 .channel_mode = alc861_threestack_modes,
14565 .need_dac_fix = 1,
14566 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14567 .adc_nids = alc861_adc_nids,
14568 .input_mux = &alc861_capture_source,
14570 [ALC861_UNIWILL_M31] = {
14571 .mixers = { alc861_uniwill_m31_mixer },
14572 .init_verbs = { alc861_uniwill_m31_init_verbs },
14573 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14574 .dac_nids = alc861_dac_nids,
14575 .dig_out_nid = ALC861_DIGOUT_NID,
14576 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14577 .channel_mode = alc861_uniwill_m31_modes,
14578 .need_dac_fix = 1,
14579 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14580 .adc_nids = alc861_adc_nids,
14581 .input_mux = &alc861_capture_source,
14583 [ALC861_TOSHIBA] = {
14584 .mixers = { alc861_toshiba_mixer },
14585 .init_verbs = { alc861_base_init_verbs,
14586 alc861_toshiba_init_verbs },
14587 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14588 .dac_nids = alc861_dac_nids,
14589 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14590 .channel_mode = alc883_3ST_2ch_modes,
14591 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14592 .adc_nids = alc861_adc_nids,
14593 .input_mux = &alc861_capture_source,
14594 .unsol_event = alc861_toshiba_unsol_event,
14595 .init_hook = alc861_toshiba_automute,
14597 [ALC861_ASUS] = {
14598 .mixers = { alc861_asus_mixer },
14599 .init_verbs = { alc861_asus_init_verbs },
14600 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14601 .dac_nids = alc861_dac_nids,
14602 .dig_out_nid = ALC861_DIGOUT_NID,
14603 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14604 .channel_mode = alc861_asus_modes,
14605 .need_dac_fix = 1,
14606 .hp_nid = 0x06,
14607 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14608 .adc_nids = alc861_adc_nids,
14609 .input_mux = &alc861_capture_source,
14611 [ALC861_ASUS_LAPTOP] = {
14612 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14613 .init_verbs = { alc861_asus_init_verbs,
14614 alc861_asus_laptop_init_verbs },
14615 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14616 .dac_nids = alc861_dac_nids,
14617 .dig_out_nid = ALC861_DIGOUT_NID,
14618 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14619 .channel_mode = alc883_3ST_2ch_modes,
14620 .need_dac_fix = 1,
14621 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14622 .adc_nids = alc861_adc_nids,
14623 .input_mux = &alc861_capture_source,
14628 static int patch_alc861(struct hda_codec *codec)
14630 struct alc_spec *spec;
14631 int board_config;
14632 int err;
14634 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14635 if (spec == NULL)
14636 return -ENOMEM;
14638 codec->spec = spec;
14640 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14641 alc861_models,
14642 alc861_cfg_tbl);
14644 if (board_config < 0) {
14645 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14646 codec->chip_name);
14647 board_config = ALC861_AUTO;
14650 if (board_config == ALC861_AUTO) {
14651 /* automatic parse from the BIOS config */
14652 err = alc861_parse_auto_config(codec);
14653 if (err < 0) {
14654 alc_free(codec);
14655 return err;
14656 } else if (!err) {
14657 printk(KERN_INFO
14658 "hda_codec: Cannot set up configuration "
14659 "from BIOS. Using base mode...\n");
14660 board_config = ALC861_3ST_DIG;
14664 err = snd_hda_attach_beep_device(codec, 0x23);
14665 if (err < 0) {
14666 alc_free(codec);
14667 return err;
14670 if (board_config != ALC861_AUTO)
14671 setup_preset(codec, &alc861_presets[board_config]);
14673 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14674 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14676 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14677 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14679 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14681 spec->vmaster_nid = 0x03;
14683 codec->patch_ops = alc_patch_ops;
14684 if (board_config == ALC861_AUTO)
14685 spec->init_hook = alc861_auto_init;
14686 #ifdef CONFIG_SND_HDA_POWER_SAVE
14687 if (!spec->loopback.amplist)
14688 spec->loopback.amplist = alc861_loopbacks;
14689 #endif
14690 codec->proc_widget_hook = print_realtek_coef;
14692 return 0;
14696 * ALC861-VD support
14698 * Based on ALC882
14700 * In addition, an independent DAC
14702 #define ALC861VD_DIGOUT_NID 0x06
14704 static hda_nid_t alc861vd_dac_nids[4] = {
14705 /* front, surr, clfe, side surr */
14706 0x02, 0x03, 0x04, 0x05
14709 /* dac_nids for ALC660vd are in a different order - according to
14710 * Realtek's driver.
14711 * This should probably result in a different mixer for 6stack models
14712 * of ALC660vd codecs, but for now there is only 3stack mixer
14713 * - and it is the same as in 861vd.
14714 * adc_nids in ALC660vd are (is) the same as in 861vd
14716 static hda_nid_t alc660vd_dac_nids[3] = {
14717 /* front, rear, clfe, rear_surr */
14718 0x02, 0x04, 0x03
14721 static hda_nid_t alc861vd_adc_nids[1] = {
14722 /* ADC0 */
14723 0x09,
14726 static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14728 /* input MUX */
14729 /* FIXME: should be a matrix-type input source selection */
14730 static struct hda_input_mux alc861vd_capture_source = {
14731 .num_items = 4,
14732 .items = {
14733 { "Mic", 0x0 },
14734 { "Front Mic", 0x1 },
14735 { "Line", 0x2 },
14736 { "CD", 0x4 },
14740 static struct hda_input_mux alc861vd_dallas_capture_source = {
14741 .num_items = 2,
14742 .items = {
14743 { "Ext Mic", 0x0 },
14744 { "Int Mic", 0x1 },
14748 static struct hda_input_mux alc861vd_hp_capture_source = {
14749 .num_items = 2,
14750 .items = {
14751 { "Front Mic", 0x0 },
14752 { "ATAPI Mic", 0x1 },
14757 * 2ch mode
14759 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14760 { 2, NULL }
14764 * 6ch mode
14766 static struct hda_verb alc861vd_6stack_ch6_init[] = {
14767 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14768 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14769 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14770 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14771 { } /* end */
14775 * 8ch mode
14777 static struct hda_verb alc861vd_6stack_ch8_init[] = {
14778 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14779 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14780 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14781 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14782 { } /* end */
14785 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14786 { 6, alc861vd_6stack_ch6_init },
14787 { 8, alc861vd_6stack_ch8_init },
14790 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14792 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14793 .name = "Channel Mode",
14794 .info = alc_ch_mode_info,
14795 .get = alc_ch_mode_get,
14796 .put = alc_ch_mode_put,
14798 { } /* end */
14801 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14802 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14804 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14805 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14806 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14808 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14809 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14811 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14812 HDA_OUTPUT),
14813 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14814 HDA_OUTPUT),
14815 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14816 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14818 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14819 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14821 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14823 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14827 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14828 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14829 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14831 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14832 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14837 { } /* end */
14840 static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14841 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14842 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14846 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14850 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14851 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14852 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14854 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14855 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14857 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14858 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14860 { } /* end */
14863 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14864 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14865 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14866 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14868 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14870 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14871 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14874 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14875 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14876 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14878 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14879 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14881 { } /* end */
14884 /* Pin assignment: Speaker=0x14, HP = 0x15,
14885 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
14887 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
14888 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14889 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
14890 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14891 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14892 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14893 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14894 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14895 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14896 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14897 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14898 { } /* end */
14901 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
14902 * Front Mic=0x18, ATAPI Mic = 0x19,
14904 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14905 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14906 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14907 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14908 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14909 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14910 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14911 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14912 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14914 { } /* end */
14918 * generic initialization of ADC, input mixers and output mixers
14920 static struct hda_verb alc861vd_volume_init_verbs[] = {
14922 * Unmute ADC0 and set the default input to mic-in
14924 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14925 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14927 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14928 * the analog-loopback mixer widget
14930 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
14931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14937 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
14938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
14944 * Set up output mixers (0x02 - 0x05)
14946 /* set vol=0 to output mixers */
14947 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14948 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14949 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14950 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14952 /* set up input amps for analog loopback */
14953 /* Amp Indices: DAC = 0, mixer = 1 */
14954 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14955 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14956 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14957 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14958 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14959 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14960 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14961 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14967 * 3-stack pin configuration:
14968 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14970 static struct hda_verb alc861vd_3stack_init_verbs[] = {
14972 * Set pin mode and muting
14974 /* set front pin widgets 0x14 for output */
14975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14976 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14977 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14979 /* Mic (rear) pin: input vref at 80% */
14980 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14981 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14982 /* Front Mic pin: input vref at 80% */
14983 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14984 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14985 /* Line In pin: input */
14986 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14987 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14988 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14990 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14991 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14992 /* CD pin widget for input */
14993 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14999 * 6-stack pin configuration:
15001 static struct hda_verb alc861vd_6stack_init_verbs[] = {
15003 * Set pin mode and muting
15005 /* set front pin widgets 0x14 for output */
15006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15007 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15008 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15010 /* Rear Pin: output 1 (0x0d) */
15011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15014 /* CLFE Pin: output 2 (0x0e) */
15015 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15016 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15017 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15018 /* Side Pin: output 3 (0x0f) */
15019 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15020 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15021 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15023 /* Mic (rear) pin: input vref at 80% */
15024 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15025 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15026 /* Front Mic pin: input vref at 80% */
15027 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15028 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15029 /* Line In pin: input */
15030 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15031 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15032 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15033 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15034 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15035 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15036 /* CD pin widget for input */
15037 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15042 static struct hda_verb alc861vd_eapd_verbs[] = {
15043 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15047 static struct hda_verb alc660vd_eapd_verbs[] = {
15048 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15049 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15053 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15057 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15058 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15062 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15064 unsigned int present;
15065 unsigned char bits;
15067 present = snd_hda_codec_read(codec, 0x18, 0,
15068 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15069 bits = present ? HDA_AMP_MUTE : 0;
15070 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15071 HDA_AMP_MUTE, bits);
15074 static void alc861vd_lenovo_setup(struct hda_codec *codec)
15076 struct alc_spec *spec = codec->spec;
15077 spec->autocfg.hp_pins[0] = 0x1b;
15078 spec->autocfg.speaker_pins[0] = 0x14;
15081 static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15083 alc_automute_amp(codec);
15084 alc861vd_lenovo_mic_automute(codec);
15087 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15088 unsigned int res)
15090 switch (res >> 26) {
15091 case ALC880_MIC_EVENT:
15092 alc861vd_lenovo_mic_automute(codec);
15093 break;
15094 default:
15095 alc_automute_amp_unsol_event(codec, res);
15096 break;
15100 static struct hda_verb alc861vd_dallas_verbs[] = {
15101 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15102 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15103 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15104 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15108 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15109 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15113 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15115 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15116 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15117 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15118 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15119 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15120 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15121 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15122 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15124 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15125 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15126 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15127 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15128 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15129 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15130 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15131 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15133 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15134 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15135 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15136 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15138 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15139 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15140 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15142 { } /* end */
15145 /* toggle speaker-output according to the hp-jack state */
15146 static void alc861vd_dallas_setup(struct hda_codec *codec)
15148 struct alc_spec *spec = codec->spec;
15150 spec->autocfg.hp_pins[0] = 0x15;
15151 spec->autocfg.speaker_pins[0] = 0x14;
15154 #ifdef CONFIG_SND_HDA_POWER_SAVE
15155 #define alc861vd_loopbacks alc880_loopbacks
15156 #endif
15158 /* pcm configuration: identical with ALC880 */
15159 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15160 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15161 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15162 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15165 * configuration and preset
15167 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15168 [ALC660VD_3ST] = "3stack-660",
15169 [ALC660VD_3ST_DIG] = "3stack-660-digout",
15170 [ALC660VD_ASUS_V1S] = "asus-v1s",
15171 [ALC861VD_3ST] = "3stack",
15172 [ALC861VD_3ST_DIG] = "3stack-digout",
15173 [ALC861VD_6ST_DIG] = "6stack-digout",
15174 [ALC861VD_LENOVO] = "lenovo",
15175 [ALC861VD_DALLAS] = "dallas",
15176 [ALC861VD_HP] = "hp",
15177 [ALC861VD_AUTO] = "auto",
15180 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
15181 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15182 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
15183 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
15184 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
15185 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
15186 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
15187 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
15188 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
15189 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
15190 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
15191 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
15192 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
15193 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
15194 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
15195 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
15199 static struct alc_config_preset alc861vd_presets[] = {
15200 [ALC660VD_3ST] = {
15201 .mixers = { alc861vd_3st_mixer },
15202 .init_verbs = { alc861vd_volume_init_verbs,
15203 alc861vd_3stack_init_verbs },
15204 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15205 .dac_nids = alc660vd_dac_nids,
15206 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15207 .channel_mode = alc861vd_3stack_2ch_modes,
15208 .input_mux = &alc861vd_capture_source,
15210 [ALC660VD_3ST_DIG] = {
15211 .mixers = { alc861vd_3st_mixer },
15212 .init_verbs = { alc861vd_volume_init_verbs,
15213 alc861vd_3stack_init_verbs },
15214 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15215 .dac_nids = alc660vd_dac_nids,
15216 .dig_out_nid = ALC861VD_DIGOUT_NID,
15217 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15218 .channel_mode = alc861vd_3stack_2ch_modes,
15219 .input_mux = &alc861vd_capture_source,
15221 [ALC861VD_3ST] = {
15222 .mixers = { alc861vd_3st_mixer },
15223 .init_verbs = { alc861vd_volume_init_verbs,
15224 alc861vd_3stack_init_verbs },
15225 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15226 .dac_nids = alc861vd_dac_nids,
15227 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15228 .channel_mode = alc861vd_3stack_2ch_modes,
15229 .input_mux = &alc861vd_capture_source,
15231 [ALC861VD_3ST_DIG] = {
15232 .mixers = { alc861vd_3st_mixer },
15233 .init_verbs = { alc861vd_volume_init_verbs,
15234 alc861vd_3stack_init_verbs },
15235 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15236 .dac_nids = alc861vd_dac_nids,
15237 .dig_out_nid = ALC861VD_DIGOUT_NID,
15238 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15239 .channel_mode = alc861vd_3stack_2ch_modes,
15240 .input_mux = &alc861vd_capture_source,
15242 [ALC861VD_6ST_DIG] = {
15243 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15244 .init_verbs = { alc861vd_volume_init_verbs,
15245 alc861vd_6stack_init_verbs },
15246 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15247 .dac_nids = alc861vd_dac_nids,
15248 .dig_out_nid = ALC861VD_DIGOUT_NID,
15249 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15250 .channel_mode = alc861vd_6stack_modes,
15251 .input_mux = &alc861vd_capture_source,
15253 [ALC861VD_LENOVO] = {
15254 .mixers = { alc861vd_lenovo_mixer },
15255 .init_verbs = { alc861vd_volume_init_verbs,
15256 alc861vd_3stack_init_verbs,
15257 alc861vd_eapd_verbs,
15258 alc861vd_lenovo_unsol_verbs },
15259 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15260 .dac_nids = alc660vd_dac_nids,
15261 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15262 .channel_mode = alc861vd_3stack_2ch_modes,
15263 .input_mux = &alc861vd_capture_source,
15264 .unsol_event = alc861vd_lenovo_unsol_event,
15265 .setup = alc861vd_lenovo_setup,
15266 .init_hook = alc861vd_lenovo_init_hook,
15268 [ALC861VD_DALLAS] = {
15269 .mixers = { alc861vd_dallas_mixer },
15270 .init_verbs = { alc861vd_dallas_verbs },
15271 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15272 .dac_nids = alc861vd_dac_nids,
15273 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15274 .channel_mode = alc861vd_3stack_2ch_modes,
15275 .input_mux = &alc861vd_dallas_capture_source,
15276 .unsol_event = alc_automute_amp_unsol_event,
15277 .setup = alc861vd_dallas_setup,
15278 .init_hook = alc_automute_amp,
15280 [ALC861VD_HP] = {
15281 .mixers = { alc861vd_hp_mixer },
15282 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15283 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15284 .dac_nids = alc861vd_dac_nids,
15285 .dig_out_nid = ALC861VD_DIGOUT_NID,
15286 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15287 .channel_mode = alc861vd_3stack_2ch_modes,
15288 .input_mux = &alc861vd_hp_capture_source,
15289 .unsol_event = alc_automute_amp_unsol_event,
15290 .setup = alc861vd_dallas_setup,
15291 .init_hook = alc_automute_amp,
15293 [ALC660VD_ASUS_V1S] = {
15294 .mixers = { alc861vd_lenovo_mixer },
15295 .init_verbs = { alc861vd_volume_init_verbs,
15296 alc861vd_3stack_init_verbs,
15297 alc861vd_eapd_verbs,
15298 alc861vd_lenovo_unsol_verbs },
15299 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15300 .dac_nids = alc660vd_dac_nids,
15301 .dig_out_nid = ALC861VD_DIGOUT_NID,
15302 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15303 .channel_mode = alc861vd_3stack_2ch_modes,
15304 .input_mux = &alc861vd_capture_source,
15305 .unsol_event = alc861vd_lenovo_unsol_event,
15306 .setup = alc861vd_lenovo_setup,
15307 .init_hook = alc861vd_lenovo_init_hook,
15312 * BIOS auto configuration
15314 static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15315 const struct auto_pin_cfg *cfg)
15317 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15321 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15322 hda_nid_t nid, int pin_type, int dac_idx)
15324 alc_set_pin_output(codec, nid, pin_type);
15327 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15329 struct alc_spec *spec = codec->spec;
15330 int i;
15332 for (i = 0; i <= HDA_SIDE; i++) {
15333 hda_nid_t nid = spec->autocfg.line_out_pins[i];
15334 int pin_type = get_pin_type(spec->autocfg.line_out_type);
15335 if (nid)
15336 alc861vd_auto_set_output_and_unmute(codec, nid,
15337 pin_type, i);
15342 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15344 struct alc_spec *spec = codec->spec;
15345 hda_nid_t pin;
15347 pin = spec->autocfg.hp_pins[0];
15348 if (pin) /* connect to front and use dac 0 */
15349 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
15350 pin = spec->autocfg.speaker_pins[0];
15351 if (pin)
15352 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
15355 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15357 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15359 struct alc_spec *spec = codec->spec;
15360 int i;
15362 for (i = 0; i < AUTO_PIN_LAST; i++) {
15363 hda_nid_t nid = spec->autocfg.input_pins[i];
15364 if (alc_is_input_pin(codec, nid)) {
15365 alc_set_input_pin(codec, nid, i);
15366 if (nid != ALC861VD_PIN_CD_NID &&
15367 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
15368 snd_hda_codec_write(codec, nid, 0,
15369 AC_VERB_SET_AMP_GAIN_MUTE,
15370 AMP_OUT_MUTE);
15375 #define alc861vd_auto_init_input_src alc882_auto_init_input_src
15377 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15378 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15380 /* add playback controls from the parsed DAC table */
15381 /* Based on ALC880 version. But ALC861VD has separate,
15382 * different NIDs for mute/unmute switch and volume control */
15383 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15384 const struct auto_pin_cfg *cfg)
15386 char name[32];
15387 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15388 hda_nid_t nid_v, nid_s;
15389 int i, err;
15391 for (i = 0; i < cfg->line_outs; i++) {
15392 if (!spec->multiout.dac_nids[i])
15393 continue;
15394 nid_v = alc861vd_idx_to_mixer_vol(
15395 alc880_dac_to_idx(
15396 spec->multiout.dac_nids[i]));
15397 nid_s = alc861vd_idx_to_mixer_switch(
15398 alc880_dac_to_idx(
15399 spec->multiout.dac_nids[i]));
15401 if (i == 2) {
15402 /* Center/LFE */
15403 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15404 "Center Playback Volume",
15405 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15406 HDA_OUTPUT));
15407 if (err < 0)
15408 return err;
15409 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15410 "LFE Playback Volume",
15411 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15412 HDA_OUTPUT));
15413 if (err < 0)
15414 return err;
15415 err = add_control(spec, ALC_CTL_BIND_MUTE,
15416 "Center Playback Switch",
15417 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15418 HDA_INPUT));
15419 if (err < 0)
15420 return err;
15421 err = add_control(spec, ALC_CTL_BIND_MUTE,
15422 "LFE Playback Switch",
15423 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15424 HDA_INPUT));
15425 if (err < 0)
15426 return err;
15427 } else {
15428 const char *pfx;
15429 if (cfg->line_outs == 1 &&
15430 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15431 if (!cfg->hp_pins)
15432 pfx = "Speaker";
15433 else
15434 pfx = "PCM";
15435 } else
15436 pfx = chname[i];
15437 sprintf(name, "%s Playback Volume", pfx);
15438 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15439 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15440 HDA_OUTPUT));
15441 if (err < 0)
15442 return err;
15443 if (cfg->line_outs == 1 &&
15444 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15445 pfx = "Speaker";
15446 sprintf(name, "%s Playback Switch", pfx);
15447 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15448 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
15449 HDA_INPUT));
15450 if (err < 0)
15451 return err;
15454 return 0;
15457 /* add playback controls for speaker and HP outputs */
15458 /* Based on ALC880 version. But ALC861VD has separate,
15459 * different NIDs for mute/unmute switch and volume control */
15460 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15461 hda_nid_t pin, const char *pfx)
15463 hda_nid_t nid_v, nid_s;
15464 int err;
15465 char name[32];
15467 if (!pin)
15468 return 0;
15470 if (alc880_is_fixed_pin(pin)) {
15471 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15472 /* specify the DAC as the extra output */
15473 if (!spec->multiout.hp_nid)
15474 spec->multiout.hp_nid = nid_v;
15475 else
15476 spec->multiout.extra_out_nid[0] = nid_v;
15477 /* control HP volume/switch on the output mixer amp */
15478 nid_v = alc861vd_idx_to_mixer_vol(
15479 alc880_fixed_pin_idx(pin));
15480 nid_s = alc861vd_idx_to_mixer_switch(
15481 alc880_fixed_pin_idx(pin));
15483 sprintf(name, "%s Playback Volume", pfx);
15484 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15485 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15486 if (err < 0)
15487 return err;
15488 sprintf(name, "%s Playback Switch", pfx);
15489 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15490 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15491 if (err < 0)
15492 return err;
15493 } else if (alc880_is_multi_pin(pin)) {
15494 /* set manual connection */
15495 /* we have only a switch on HP-out PIN */
15496 sprintf(name, "%s Playback Switch", pfx);
15497 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15498 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15499 if (err < 0)
15500 return err;
15502 return 0;
15505 /* parse the BIOS configuration and set up the alc_spec
15506 * return 1 if successful, 0 if the proper config is not found,
15507 * or a negative error code
15508 * Based on ALC880 version - had to change it to override
15509 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15510 static int alc861vd_parse_auto_config(struct hda_codec *codec)
15512 struct alc_spec *spec = codec->spec;
15513 int err;
15514 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15516 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15517 alc861vd_ignore);
15518 if (err < 0)
15519 return err;
15520 if (!spec->autocfg.line_outs)
15521 return 0; /* can't find valid BIOS pin config */
15523 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15524 if (err < 0)
15525 return err;
15526 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15527 if (err < 0)
15528 return err;
15529 err = alc861vd_auto_create_extra_out(spec,
15530 spec->autocfg.speaker_pins[0],
15531 "Speaker");
15532 if (err < 0)
15533 return err;
15534 err = alc861vd_auto_create_extra_out(spec,
15535 spec->autocfg.hp_pins[0],
15536 "Headphone");
15537 if (err < 0)
15538 return err;
15539 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
15540 if (err < 0)
15541 return err;
15543 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15545 if (spec->autocfg.dig_outs)
15546 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15548 if (spec->kctls.list)
15549 add_mixer(spec, spec->kctls.list);
15551 add_verb(spec, alc861vd_volume_init_verbs);
15553 spec->num_mux_defs = 1;
15554 spec->input_mux = &spec->private_imux[0];
15556 err = alc_auto_add_mic_boost(codec);
15557 if (err < 0)
15558 return err;
15560 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15562 return 1;
15565 /* additional initialization for auto-configuration model */
15566 static void alc861vd_auto_init(struct hda_codec *codec)
15568 struct alc_spec *spec = codec->spec;
15569 alc861vd_auto_init_multi_out(codec);
15570 alc861vd_auto_init_hp_out(codec);
15571 alc861vd_auto_init_analog_input(codec);
15572 alc861vd_auto_init_input_src(codec);
15573 if (spec->unsol_event)
15574 alc_inithook(codec);
15577 enum {
15578 ALC660VD_FIX_ASUS_GPIO1
15581 /* reset GPIO1 */
15582 static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15583 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15584 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15585 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15589 static const struct alc_fixup alc861vd_fixups[] = {
15590 [ALC660VD_FIX_ASUS_GPIO1] = {
15591 .verbs = alc660vd_fix_asus_gpio1_verbs,
15595 static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15596 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15600 static int patch_alc861vd(struct hda_codec *codec)
15602 struct alc_spec *spec;
15603 int err, board_config;
15605 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15606 if (spec == NULL)
15607 return -ENOMEM;
15609 codec->spec = spec;
15611 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15612 alc861vd_models,
15613 alc861vd_cfg_tbl);
15615 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15616 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15617 codec->chip_name);
15618 board_config = ALC861VD_AUTO;
15621 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15623 if (board_config == ALC861VD_AUTO) {
15624 /* automatic parse from the BIOS config */
15625 err = alc861vd_parse_auto_config(codec);
15626 if (err < 0) {
15627 alc_free(codec);
15628 return err;
15629 } else if (!err) {
15630 printk(KERN_INFO
15631 "hda_codec: Cannot set up configuration "
15632 "from BIOS. Using base mode...\n");
15633 board_config = ALC861VD_3ST;
15637 err = snd_hda_attach_beep_device(codec, 0x23);
15638 if (err < 0) {
15639 alc_free(codec);
15640 return err;
15643 if (board_config != ALC861VD_AUTO)
15644 setup_preset(codec, &alc861vd_presets[board_config]);
15646 if (codec->vendor_id == 0x10ec0660) {
15647 /* always turn on EAPD */
15648 add_verb(spec, alc660vd_eapd_verbs);
15651 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15652 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15654 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15655 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15657 if (!spec->adc_nids) {
15658 spec->adc_nids = alc861vd_adc_nids;
15659 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15661 if (!spec->capsrc_nids)
15662 spec->capsrc_nids = alc861vd_capsrc_nids;
15664 set_capture_mixer(codec);
15665 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
15667 spec->vmaster_nid = 0x02;
15669 codec->patch_ops = alc_patch_ops;
15671 if (board_config == ALC861VD_AUTO)
15672 spec->init_hook = alc861vd_auto_init;
15673 #ifdef CONFIG_SND_HDA_POWER_SAVE
15674 if (!spec->loopback.amplist)
15675 spec->loopback.amplist = alc861vd_loopbacks;
15676 #endif
15677 codec->proc_widget_hook = print_realtek_coef;
15679 return 0;
15683 * ALC662 support
15685 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15686 * configuration. Each pin widget can choose any input DACs and a mixer.
15687 * Each ADC is connected from a mixer of all inputs. This makes possible
15688 * 6-channel independent captures.
15690 * In addition, an independent DAC for the multi-playback (not used in this
15691 * driver yet).
15693 #define ALC662_DIGOUT_NID 0x06
15694 #define ALC662_DIGIN_NID 0x0a
15696 static hda_nid_t alc662_dac_nids[4] = {
15697 /* front, rear, clfe, rear_surr */
15698 0x02, 0x03, 0x04
15701 static hda_nid_t alc272_dac_nids[2] = {
15702 0x02, 0x03
15705 static hda_nid_t alc662_adc_nids[2] = {
15706 /* ADC1-2 */
15707 0x09, 0x08
15710 static hda_nid_t alc272_adc_nids[1] = {
15711 /* ADC1-2 */
15712 0x08,
15715 static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
15716 static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15719 /* input MUX */
15720 /* FIXME: should be a matrix-type input source selection */
15721 static struct hda_input_mux alc662_capture_source = {
15722 .num_items = 4,
15723 .items = {
15724 { "Mic", 0x0 },
15725 { "Front Mic", 0x1 },
15726 { "Line", 0x2 },
15727 { "CD", 0x4 },
15731 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15732 .num_items = 2,
15733 .items = {
15734 { "Mic", 0x1 },
15735 { "Line", 0x2 },
15739 static struct hda_input_mux alc663_capture_source = {
15740 .num_items = 3,
15741 .items = {
15742 { "Mic", 0x0 },
15743 { "Front Mic", 0x1 },
15744 { "Line", 0x2 },
15748 #if 0 /* set to 1 for testing other input sources below */
15749 static struct hda_input_mux alc272_nc10_capture_source = {
15750 .num_items = 16,
15751 .items = {
15752 { "Autoselect Mic", 0x0 },
15753 { "Internal Mic", 0x1 },
15754 { "In-0x02", 0x2 },
15755 { "In-0x03", 0x3 },
15756 { "In-0x04", 0x4 },
15757 { "In-0x05", 0x5 },
15758 { "In-0x06", 0x6 },
15759 { "In-0x07", 0x7 },
15760 { "In-0x08", 0x8 },
15761 { "In-0x09", 0x9 },
15762 { "In-0x0a", 0x0a },
15763 { "In-0x0b", 0x0b },
15764 { "In-0x0c", 0x0c },
15765 { "In-0x0d", 0x0d },
15766 { "In-0x0e", 0x0e },
15767 { "In-0x0f", 0x0f },
15770 #endif
15773 * 2ch mode
15775 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15776 { 2, NULL }
15780 * 2ch mode
15782 static struct hda_verb alc662_3ST_ch2_init[] = {
15783 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15784 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15785 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15786 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15787 { } /* end */
15791 * 6ch mode
15793 static struct hda_verb alc662_3ST_ch6_init[] = {
15794 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15795 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15796 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15797 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15798 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15799 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15800 { } /* end */
15803 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15804 { 2, alc662_3ST_ch2_init },
15805 { 6, alc662_3ST_ch6_init },
15809 * 2ch mode
15811 static struct hda_verb alc662_sixstack_ch6_init[] = {
15812 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15813 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15814 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15815 { } /* end */
15819 * 6ch mode
15821 static struct hda_verb alc662_sixstack_ch8_init[] = {
15822 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15823 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15824 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15825 { } /* end */
15828 static struct hda_channel_mode alc662_5stack_modes[2] = {
15829 { 2, alc662_sixstack_ch6_init },
15830 { 6, alc662_sixstack_ch8_init },
15833 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15834 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15837 static struct snd_kcontrol_new alc662_base_mixer[] = {
15838 /* output mixer control */
15839 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
15840 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15841 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
15842 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
15843 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15844 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15845 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15846 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
15847 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15849 /*Input mixer control */
15850 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15851 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15852 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15853 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15854 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15855 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15856 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15857 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
15858 { } /* end */
15861 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15862 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15863 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15864 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15865 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15866 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15867 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15868 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15870 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15871 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15872 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15873 { } /* end */
15876 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15877 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15878 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15879 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15880 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
15881 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15882 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15883 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15884 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
15885 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15886 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15887 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15888 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15889 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15892 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15893 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15894 { } /* end */
15897 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15898 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15899 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
15900 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15901 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
15902 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15903 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15904 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15907 { } /* end */
15910 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
15911 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15912 ALC262_HIPPO_MASTER_SWITCH,
15914 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15915 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15916 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15918 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15919 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15920 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15921 { } /* end */
15924 static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
15925 ALC262_HIPPO_MASTER_SWITCH,
15926 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15927 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15928 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15929 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15930 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15931 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15932 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15934 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15935 { } /* end */
15938 static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15939 .ops = &snd_hda_bind_vol,
15940 .values = {
15941 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15942 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15947 static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15948 .ops = &snd_hda_bind_sw,
15949 .values = {
15950 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15951 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15956 static struct snd_kcontrol_new alc663_m51va_mixer[] = {
15957 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15958 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15961 { } /* end */
15964 static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15965 .ops = &snd_hda_bind_sw,
15966 .values = {
15967 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15968 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15969 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15974 static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15975 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15976 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15977 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15979 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15980 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15982 { } /* end */
15985 static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15986 .ops = &snd_hda_bind_sw,
15987 .values = {
15988 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15989 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15990 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15995 static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15996 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15997 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16000 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16001 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16002 { } /* end */
16005 static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
16006 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16007 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16011 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16012 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16013 { } /* end */
16016 static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16017 .ops = &snd_hda_bind_vol,
16018 .values = {
16019 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16020 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16025 static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16026 .ops = &snd_hda_bind_sw,
16027 .values = {
16028 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16029 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16034 static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16035 HDA_BIND_VOL("Master Playback Volume",
16036 &alc663_asus_two_bind_master_vol),
16037 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16038 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16040 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16041 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16042 { } /* end */
16045 static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16046 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16047 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16048 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16049 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16050 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16052 { } /* end */
16055 static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16056 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16057 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16058 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16059 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16060 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16062 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16064 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16065 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16066 { } /* end */
16069 static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16070 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16071 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16072 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16075 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16076 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16077 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16078 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16079 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16080 { } /* end */
16083 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16086 .name = "Channel Mode",
16087 .info = alc_ch_mode_info,
16088 .get = alc_ch_mode_get,
16089 .put = alc_ch_mode_put,
16091 { } /* end */
16094 static struct hda_verb alc662_init_verbs[] = {
16095 /* ADC: mute amp left and right */
16096 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16097 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16098 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16108 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16109 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16113 /* Front Pin: output 0 (0x0c) */
16114 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16115 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16117 /* Rear Pin: output 1 (0x0d) */
16118 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16119 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16121 /* CLFE Pin: output 2 (0x0e) */
16122 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16123 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16125 /* Mic (rear) pin: input vref at 80% */
16126 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16127 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16128 /* Front Mic pin: input vref at 80% */
16129 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16130 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16131 /* Line In pin: input */
16132 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16133 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16134 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16135 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16136 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16137 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16138 /* CD pin widget for input */
16139 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16141 /* FIXME: use matrix-type input source selection */
16142 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16143 /* Input mixer */
16144 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16145 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16147 /* always trun on EAPD */
16148 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16149 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16154 static struct hda_verb alc662_sue_init_verbs[] = {
16155 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16156 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16160 static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16161 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16162 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16166 /* Set Unsolicited Event*/
16167 static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16168 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16169 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16174 * generic initialization of ADC, input mixers and output mixers
16176 static struct hda_verb alc662_auto_init_verbs[] = {
16178 * Unmute ADC and set the default input to mic-in
16180 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16181 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16183 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16184 * mixer widget
16185 * Note: PASD motherboards uses the Line In 2 as the input for front
16186 * panel mic (mic 2)
16188 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
16189 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16190 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16191 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16192 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16196 * Set up output mixers (0x0c - 0x0f)
16198 /* set vol=0 to output mixers */
16199 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16200 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16201 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16203 /* set up input amps for analog loopback */
16204 /* Amp Indices: DAC = 0, mixer = 1 */
16205 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16207 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16209 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16213 /* FIXME: use matrix-type input source selection */
16214 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16215 /* Input mixer */
16216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16221 /* additional verbs for ALC663 */
16222 static struct hda_verb alc663_auto_init_verbs[] = {
16223 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16224 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16228 static struct hda_verb alc663_m51va_init_verbs[] = {
16229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16230 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16231 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16232 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16233 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16234 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16235 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16236 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16237 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16241 static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16242 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16243 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16244 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16245 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16246 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16247 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16248 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16252 static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16253 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16254 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16255 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16256 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16257 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16258 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16259 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16260 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16264 static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16265 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16266 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16267 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16270 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16271 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16275 static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16276 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16277 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16278 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16279 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16282 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16285 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16286 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16287 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16291 static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16292 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16293 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16294 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16295 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16298 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16301 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16302 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16303 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16307 static struct hda_verb alc663_g71v_init_verbs[] = {
16308 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16309 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16310 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16312 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16313 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16314 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16316 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16317 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16318 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16322 static struct hda_verb alc663_g50v_init_verbs[] = {
16323 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16324 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16325 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16327 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16328 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16332 static struct hda_verb alc662_ecs_init_verbs[] = {
16333 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16335 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16340 static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16341 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16342 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16344 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16345 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16346 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16347 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16348 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16349 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16350 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16351 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16355 static struct hda_verb alc272_dell_init_verbs[] = {
16356 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16357 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16359 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16360 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16361 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16362 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16363 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16364 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16365 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16366 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16370 static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16371 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16372 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16373 { } /* end */
16376 static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16377 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16378 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16379 { } /* end */
16382 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16384 unsigned int present;
16385 unsigned char bits;
16387 present = snd_hda_codec_read(codec, 0x14, 0,
16388 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16389 bits = present ? HDA_AMP_MUTE : 0;
16390 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16391 HDA_AMP_MUTE, bits);
16394 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16396 unsigned int present;
16397 unsigned char bits;
16399 present = snd_hda_codec_read(codec, 0x1b, 0,
16400 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16401 bits = present ? HDA_AMP_MUTE : 0;
16402 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16403 HDA_AMP_MUTE, bits);
16404 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16405 HDA_AMP_MUTE, bits);
16408 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16409 unsigned int res)
16411 if ((res >> 26) == ALC880_HP_EVENT)
16412 alc662_lenovo_101e_all_automute(codec);
16413 if ((res >> 26) == ALC880_FRONT_EVENT)
16414 alc662_lenovo_101e_ispeaker_automute(codec);
16417 /* unsolicited event for HP jack sensing */
16418 static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16419 unsigned int res)
16421 if ((res >> 26) == ALC880_MIC_EVENT)
16422 alc_mic_automute(codec);
16423 else
16424 alc262_hippo_unsol_event(codec, res);
16427 static void alc662_eeepc_setup(struct hda_codec *codec)
16429 struct alc_spec *spec = codec->spec;
16431 alc262_hippo1_setup(codec);
16432 spec->ext_mic.pin = 0x18;
16433 spec->ext_mic.mux_idx = 0;
16434 spec->int_mic.pin = 0x19;
16435 spec->int_mic.mux_idx = 1;
16436 spec->auto_mic = 1;
16439 static void alc662_eeepc_inithook(struct hda_codec *codec)
16441 alc262_hippo_automute(codec);
16442 alc_mic_automute(codec);
16445 static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
16447 struct alc_spec *spec = codec->spec;
16449 spec->autocfg.hp_pins[0] = 0x14;
16450 spec->autocfg.speaker_pins[0] = 0x1b;
16453 #define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16455 static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16457 unsigned int present;
16458 unsigned char bits;
16460 present = snd_hda_codec_read(codec, 0x21, 0,
16461 AC_VERB_GET_PIN_SENSE, 0)
16462 & AC_PINSENSE_PRESENCE;
16463 bits = present ? HDA_AMP_MUTE : 0;
16464 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16465 AMP_IN_MUTE(0), bits);
16466 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16467 AMP_IN_MUTE(0), bits);
16470 static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16472 unsigned int present;
16473 unsigned char bits;
16475 present = snd_hda_codec_read(codec, 0x21, 0,
16476 AC_VERB_GET_PIN_SENSE, 0)
16477 & AC_PINSENSE_PRESENCE;
16478 bits = present ? HDA_AMP_MUTE : 0;
16479 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16480 AMP_IN_MUTE(0), bits);
16481 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16482 AMP_IN_MUTE(0), bits);
16483 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16484 AMP_IN_MUTE(0), bits);
16485 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16486 AMP_IN_MUTE(0), bits);
16489 static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16491 unsigned int present;
16492 unsigned char bits;
16494 present = snd_hda_codec_read(codec, 0x15, 0,
16495 AC_VERB_GET_PIN_SENSE, 0)
16496 & AC_PINSENSE_PRESENCE;
16497 bits = present ? HDA_AMP_MUTE : 0;
16498 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16499 AMP_IN_MUTE(0), bits);
16500 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16501 AMP_IN_MUTE(0), bits);
16502 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16503 AMP_IN_MUTE(0), bits);
16504 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16505 AMP_IN_MUTE(0), bits);
16508 static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16510 unsigned int present;
16511 unsigned char bits;
16513 present = snd_hda_codec_read(codec, 0x1b, 0,
16514 AC_VERB_GET_PIN_SENSE, 0)
16515 & AC_PINSENSE_PRESENCE;
16516 bits = present ? 0 : PIN_OUT;
16517 snd_hda_codec_write(codec, 0x14, 0,
16518 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16521 static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16523 unsigned int present1, present2;
16525 present1 = snd_hda_codec_read(codec, 0x21, 0,
16526 AC_VERB_GET_PIN_SENSE, 0)
16527 & AC_PINSENSE_PRESENCE;
16528 present2 = snd_hda_codec_read(codec, 0x15, 0,
16529 AC_VERB_GET_PIN_SENSE, 0)
16530 & AC_PINSENSE_PRESENCE;
16532 if (present1 || present2) {
16533 snd_hda_codec_write_cache(codec, 0x14, 0,
16534 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16535 } else {
16536 snd_hda_codec_write_cache(codec, 0x14, 0,
16537 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16541 static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16543 unsigned int present1, present2;
16545 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16546 AC_VERB_GET_PIN_SENSE, 0)
16547 & AC_PINSENSE_PRESENCE;
16548 present2 = snd_hda_codec_read(codec, 0x15, 0,
16549 AC_VERB_GET_PIN_SENSE, 0)
16550 & AC_PINSENSE_PRESENCE;
16552 if (present1 || present2) {
16553 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16554 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16555 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16556 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16557 } else {
16558 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16559 AMP_IN_MUTE(0), 0);
16560 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16561 AMP_IN_MUTE(0), 0);
16565 static void alc663_m51va_unsol_event(struct hda_codec *codec,
16566 unsigned int res)
16568 switch (res >> 26) {
16569 case ALC880_HP_EVENT:
16570 alc663_m51va_speaker_automute(codec);
16571 break;
16572 case ALC880_MIC_EVENT:
16573 alc_mic_automute(codec);
16574 break;
16578 static void alc663_m51va_setup(struct hda_codec *codec)
16580 struct alc_spec *spec = codec->spec;
16581 spec->ext_mic.pin = 0x18;
16582 spec->ext_mic.mux_idx = 0;
16583 spec->int_mic.pin = 0x12;
16584 spec->int_mic.mux_idx = 1;
16585 spec->auto_mic = 1;
16588 static void alc663_m51va_inithook(struct hda_codec *codec)
16590 alc663_m51va_speaker_automute(codec);
16591 alc_mic_automute(codec);
16594 /* ***************** Mode1 ******************************/
16595 #define alc663_mode1_unsol_event alc663_m51va_unsol_event
16596 #define alc663_mode1_setup alc663_m51va_setup
16597 #define alc663_mode1_inithook alc663_m51va_inithook
16599 /* ***************** Mode2 ******************************/
16600 static void alc662_mode2_unsol_event(struct hda_codec *codec,
16601 unsigned int res)
16603 switch (res >> 26) {
16604 case ALC880_HP_EVENT:
16605 alc662_f5z_speaker_automute(codec);
16606 break;
16607 case ALC880_MIC_EVENT:
16608 alc_mic_automute(codec);
16609 break;
16613 #define alc662_mode2_setup alc663_m51va_setup
16615 static void alc662_mode2_inithook(struct hda_codec *codec)
16617 alc662_f5z_speaker_automute(codec);
16618 alc_mic_automute(codec);
16620 /* ***************** Mode3 ******************************/
16621 static void alc663_mode3_unsol_event(struct hda_codec *codec,
16622 unsigned int res)
16624 switch (res >> 26) {
16625 case ALC880_HP_EVENT:
16626 alc663_two_hp_m1_speaker_automute(codec);
16627 break;
16628 case ALC880_MIC_EVENT:
16629 alc_mic_automute(codec);
16630 break;
16634 #define alc663_mode3_setup alc663_m51va_setup
16636 static void alc663_mode3_inithook(struct hda_codec *codec)
16638 alc663_two_hp_m1_speaker_automute(codec);
16639 alc_mic_automute(codec);
16641 /* ***************** Mode4 ******************************/
16642 static void alc663_mode4_unsol_event(struct hda_codec *codec,
16643 unsigned int res)
16645 switch (res >> 26) {
16646 case ALC880_HP_EVENT:
16647 alc663_21jd_two_speaker_automute(codec);
16648 break;
16649 case ALC880_MIC_EVENT:
16650 alc_mic_automute(codec);
16651 break;
16655 #define alc663_mode4_setup alc663_m51va_setup
16657 static void alc663_mode4_inithook(struct hda_codec *codec)
16659 alc663_21jd_two_speaker_automute(codec);
16660 alc_mic_automute(codec);
16662 /* ***************** Mode5 ******************************/
16663 static void alc663_mode5_unsol_event(struct hda_codec *codec,
16664 unsigned int res)
16666 switch (res >> 26) {
16667 case ALC880_HP_EVENT:
16668 alc663_15jd_two_speaker_automute(codec);
16669 break;
16670 case ALC880_MIC_EVENT:
16671 alc_mic_automute(codec);
16672 break;
16676 #define alc663_mode5_setup alc663_m51va_setup
16678 static void alc663_mode5_inithook(struct hda_codec *codec)
16680 alc663_15jd_two_speaker_automute(codec);
16681 alc_mic_automute(codec);
16683 /* ***************** Mode6 ******************************/
16684 static void alc663_mode6_unsol_event(struct hda_codec *codec,
16685 unsigned int res)
16687 switch (res >> 26) {
16688 case ALC880_HP_EVENT:
16689 alc663_two_hp_m2_speaker_automute(codec);
16690 break;
16691 case ALC880_MIC_EVENT:
16692 alc_mic_automute(codec);
16693 break;
16697 #define alc663_mode6_setup alc663_m51va_setup
16699 static void alc663_mode6_inithook(struct hda_codec *codec)
16701 alc663_two_hp_m2_speaker_automute(codec);
16702 alc_mic_automute(codec);
16705 static void alc663_g71v_hp_automute(struct hda_codec *codec)
16707 unsigned int present;
16708 unsigned char bits;
16710 present = snd_hda_codec_read(codec, 0x21, 0,
16711 AC_VERB_GET_PIN_SENSE, 0)
16712 & AC_PINSENSE_PRESENCE;
16713 bits = present ? HDA_AMP_MUTE : 0;
16714 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16715 HDA_AMP_MUTE, bits);
16716 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16717 HDA_AMP_MUTE, bits);
16720 static void alc663_g71v_front_automute(struct hda_codec *codec)
16722 unsigned int present;
16723 unsigned char bits;
16725 present = snd_hda_codec_read(codec, 0x15, 0,
16726 AC_VERB_GET_PIN_SENSE, 0)
16727 & AC_PINSENSE_PRESENCE;
16728 bits = present ? HDA_AMP_MUTE : 0;
16729 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16730 HDA_AMP_MUTE, bits);
16733 static void alc663_g71v_unsol_event(struct hda_codec *codec,
16734 unsigned int res)
16736 switch (res >> 26) {
16737 case ALC880_HP_EVENT:
16738 alc663_g71v_hp_automute(codec);
16739 break;
16740 case ALC880_FRONT_EVENT:
16741 alc663_g71v_front_automute(codec);
16742 break;
16743 case ALC880_MIC_EVENT:
16744 alc_mic_automute(codec);
16745 break;
16749 #define alc663_g71v_setup alc663_m51va_setup
16751 static void alc663_g71v_inithook(struct hda_codec *codec)
16753 alc663_g71v_front_automute(codec);
16754 alc663_g71v_hp_automute(codec);
16755 alc_mic_automute(codec);
16758 static void alc663_g50v_unsol_event(struct hda_codec *codec,
16759 unsigned int res)
16761 switch (res >> 26) {
16762 case ALC880_HP_EVENT:
16763 alc663_m51va_speaker_automute(codec);
16764 break;
16765 case ALC880_MIC_EVENT:
16766 alc_mic_automute(codec);
16767 break;
16771 #define alc663_g50v_setup alc663_m51va_setup
16773 static void alc663_g50v_inithook(struct hda_codec *codec)
16775 alc663_m51va_speaker_automute(codec);
16776 alc_mic_automute(codec);
16779 static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16780 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16781 ALC262_HIPPO_MASTER_SWITCH,
16783 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16784 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16785 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16787 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16788 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16789 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16790 { } /* end */
16793 static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16794 /* Master Playback automatically created from Speaker and Headphone */
16795 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16796 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16797 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16798 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16800 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16801 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16802 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16804 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16805 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16806 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16807 { } /* end */
16810 #ifdef CONFIG_SND_HDA_POWER_SAVE
16811 #define alc662_loopbacks alc880_loopbacks
16812 #endif
16815 /* pcm configuration: identical with ALC880 */
16816 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
16817 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
16818 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
16819 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
16822 * configuration and preset
16824 static const char *alc662_models[ALC662_MODEL_LAST] = {
16825 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16826 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16827 [ALC662_3ST_6ch] = "3stack-6ch",
16828 [ALC662_5ST_DIG] = "6stack-dig",
16829 [ALC662_LENOVO_101E] = "lenovo-101e",
16830 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
16831 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
16832 [ALC662_ECS] = "ecs",
16833 [ALC663_ASUS_M51VA] = "m51va",
16834 [ALC663_ASUS_G71V] = "g71v",
16835 [ALC663_ASUS_H13] = "h13",
16836 [ALC663_ASUS_G50V] = "g50v",
16837 [ALC663_ASUS_MODE1] = "asus-mode1",
16838 [ALC662_ASUS_MODE2] = "asus-mode2",
16839 [ALC663_ASUS_MODE3] = "asus-mode3",
16840 [ALC663_ASUS_MODE4] = "asus-mode4",
16841 [ALC663_ASUS_MODE5] = "asus-mode5",
16842 [ALC663_ASUS_MODE6] = "asus-mode6",
16843 [ALC272_DELL] = "dell",
16844 [ALC272_DELL_ZM1] = "dell-zm1",
16845 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
16846 [ALC662_AUTO] = "auto",
16849 static struct snd_pci_quirk alc662_cfg_tbl[] = {
16850 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16851 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16852 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
16853 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16854 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16855 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16856 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16857 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16858 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16859 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16860 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16861 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16862 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16863 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16864 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16865 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16866 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16867 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
16868 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16869 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16870 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16871 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16872 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
16873 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16874 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16875 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
16876 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16877 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16878 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16879 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16880 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16881 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
16882 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16883 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16884 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16885 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
16886 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16887 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16888 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
16889 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
16890 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
16891 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16892 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16893 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16894 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
16895 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16896 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16897 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
16898 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
16899 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
16900 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
16901 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16902 ALC662_3ST_6ch_DIG),
16903 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4),
16904 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
16905 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16906 ALC662_3ST_6ch_DIG),
16907 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
16908 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
16909 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
16910 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
16911 ALC662_3ST_6ch_DIG),
16912 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16913 ALC663_ASUS_H13),
16917 static struct alc_config_preset alc662_presets[] = {
16918 [ALC662_3ST_2ch_DIG] = {
16919 .mixers = { alc662_3ST_2ch_mixer },
16920 .init_verbs = { alc662_init_verbs },
16921 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16922 .dac_nids = alc662_dac_nids,
16923 .dig_out_nid = ALC662_DIGOUT_NID,
16924 .dig_in_nid = ALC662_DIGIN_NID,
16925 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16926 .channel_mode = alc662_3ST_2ch_modes,
16927 .input_mux = &alc662_capture_source,
16929 [ALC662_3ST_6ch_DIG] = {
16930 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
16931 .init_verbs = { alc662_init_verbs },
16932 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16933 .dac_nids = alc662_dac_nids,
16934 .dig_out_nid = ALC662_DIGOUT_NID,
16935 .dig_in_nid = ALC662_DIGIN_NID,
16936 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16937 .channel_mode = alc662_3ST_6ch_modes,
16938 .need_dac_fix = 1,
16939 .input_mux = &alc662_capture_source,
16941 [ALC662_3ST_6ch] = {
16942 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
16943 .init_verbs = { alc662_init_verbs },
16944 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16945 .dac_nids = alc662_dac_nids,
16946 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16947 .channel_mode = alc662_3ST_6ch_modes,
16948 .need_dac_fix = 1,
16949 .input_mux = &alc662_capture_source,
16951 [ALC662_5ST_DIG] = {
16952 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
16953 .init_verbs = { alc662_init_verbs },
16954 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16955 .dac_nids = alc662_dac_nids,
16956 .dig_out_nid = ALC662_DIGOUT_NID,
16957 .dig_in_nid = ALC662_DIGIN_NID,
16958 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16959 .channel_mode = alc662_5stack_modes,
16960 .input_mux = &alc662_capture_source,
16962 [ALC662_LENOVO_101E] = {
16963 .mixers = { alc662_lenovo_101e_mixer },
16964 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16965 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16966 .dac_nids = alc662_dac_nids,
16967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16968 .channel_mode = alc662_3ST_2ch_modes,
16969 .input_mux = &alc662_lenovo_101e_capture_source,
16970 .unsol_event = alc662_lenovo_101e_unsol_event,
16971 .init_hook = alc662_lenovo_101e_all_automute,
16973 [ALC662_ASUS_EEEPC_P701] = {
16974 .mixers = { alc662_eeepc_p701_mixer },
16975 .init_verbs = { alc662_init_verbs,
16976 alc662_eeepc_sue_init_verbs },
16977 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16978 .dac_nids = alc662_dac_nids,
16979 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16980 .channel_mode = alc662_3ST_2ch_modes,
16981 .unsol_event = alc662_eeepc_unsol_event,
16982 .setup = alc662_eeepc_setup,
16983 .init_hook = alc662_eeepc_inithook,
16985 [ALC662_ASUS_EEEPC_EP20] = {
16986 .mixers = { alc662_eeepc_ep20_mixer,
16987 alc662_chmode_mixer },
16988 .init_verbs = { alc662_init_verbs,
16989 alc662_eeepc_ep20_sue_init_verbs },
16990 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16991 .dac_nids = alc662_dac_nids,
16992 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16993 .channel_mode = alc662_3ST_6ch_modes,
16994 .input_mux = &alc662_lenovo_101e_capture_source,
16995 .unsol_event = alc662_eeepc_unsol_event,
16996 .setup = alc662_eeepc_ep20_setup,
16997 .init_hook = alc662_eeepc_ep20_inithook,
16999 [ALC662_ECS] = {
17000 .mixers = { alc662_ecs_mixer },
17001 .init_verbs = { alc662_init_verbs,
17002 alc662_ecs_init_verbs },
17003 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17004 .dac_nids = alc662_dac_nids,
17005 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17006 .channel_mode = alc662_3ST_2ch_modes,
17007 .unsol_event = alc662_eeepc_unsol_event,
17008 .setup = alc662_eeepc_setup,
17009 .init_hook = alc662_eeepc_inithook,
17011 [ALC663_ASUS_M51VA] = {
17012 .mixers = { alc663_m51va_mixer },
17013 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17014 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17015 .dac_nids = alc662_dac_nids,
17016 .dig_out_nid = ALC662_DIGOUT_NID,
17017 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17018 .channel_mode = alc662_3ST_2ch_modes,
17019 .unsol_event = alc663_m51va_unsol_event,
17020 .setup = alc663_m51va_setup,
17021 .init_hook = alc663_m51va_inithook,
17023 [ALC663_ASUS_G71V] = {
17024 .mixers = { alc663_g71v_mixer },
17025 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17026 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17027 .dac_nids = alc662_dac_nids,
17028 .dig_out_nid = ALC662_DIGOUT_NID,
17029 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17030 .channel_mode = alc662_3ST_2ch_modes,
17031 .unsol_event = alc663_g71v_unsol_event,
17032 .setup = alc663_g71v_setup,
17033 .init_hook = alc663_g71v_inithook,
17035 [ALC663_ASUS_H13] = {
17036 .mixers = { alc663_m51va_mixer },
17037 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17038 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17039 .dac_nids = alc662_dac_nids,
17040 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17041 .channel_mode = alc662_3ST_2ch_modes,
17042 .unsol_event = alc663_m51va_unsol_event,
17043 .init_hook = alc663_m51va_inithook,
17045 [ALC663_ASUS_G50V] = {
17046 .mixers = { alc663_g50v_mixer },
17047 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17048 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17049 .dac_nids = alc662_dac_nids,
17050 .dig_out_nid = ALC662_DIGOUT_NID,
17051 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17052 .channel_mode = alc662_3ST_6ch_modes,
17053 .input_mux = &alc663_capture_source,
17054 .unsol_event = alc663_g50v_unsol_event,
17055 .setup = alc663_g50v_setup,
17056 .init_hook = alc663_g50v_inithook,
17058 [ALC663_ASUS_MODE1] = {
17059 .mixers = { alc663_m51va_mixer },
17060 .cap_mixer = alc662_auto_capture_mixer,
17061 .init_verbs = { alc662_init_verbs,
17062 alc663_21jd_amic_init_verbs },
17063 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17064 .hp_nid = 0x03,
17065 .dac_nids = alc662_dac_nids,
17066 .dig_out_nid = ALC662_DIGOUT_NID,
17067 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17068 .channel_mode = alc662_3ST_2ch_modes,
17069 .unsol_event = alc663_mode1_unsol_event,
17070 .setup = alc663_mode1_setup,
17071 .init_hook = alc663_mode1_inithook,
17073 [ALC662_ASUS_MODE2] = {
17074 .mixers = { alc662_1bjd_mixer },
17075 .cap_mixer = alc662_auto_capture_mixer,
17076 .init_verbs = { alc662_init_verbs,
17077 alc662_1bjd_amic_init_verbs },
17078 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17079 .dac_nids = alc662_dac_nids,
17080 .dig_out_nid = ALC662_DIGOUT_NID,
17081 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17082 .channel_mode = alc662_3ST_2ch_modes,
17083 .unsol_event = alc662_mode2_unsol_event,
17084 .setup = alc662_mode2_setup,
17085 .init_hook = alc662_mode2_inithook,
17087 [ALC663_ASUS_MODE3] = {
17088 .mixers = { alc663_two_hp_m1_mixer },
17089 .cap_mixer = alc662_auto_capture_mixer,
17090 .init_verbs = { alc662_init_verbs,
17091 alc663_two_hp_amic_m1_init_verbs },
17092 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17093 .hp_nid = 0x03,
17094 .dac_nids = alc662_dac_nids,
17095 .dig_out_nid = ALC662_DIGOUT_NID,
17096 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17097 .channel_mode = alc662_3ST_2ch_modes,
17098 .unsol_event = alc663_mode3_unsol_event,
17099 .setup = alc663_mode3_setup,
17100 .init_hook = alc663_mode3_inithook,
17102 [ALC663_ASUS_MODE4] = {
17103 .mixers = { alc663_asus_21jd_clfe_mixer },
17104 .cap_mixer = alc662_auto_capture_mixer,
17105 .init_verbs = { alc662_init_verbs,
17106 alc663_21jd_amic_init_verbs},
17107 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17108 .hp_nid = 0x03,
17109 .dac_nids = alc662_dac_nids,
17110 .dig_out_nid = ALC662_DIGOUT_NID,
17111 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17112 .channel_mode = alc662_3ST_2ch_modes,
17113 .unsol_event = alc663_mode4_unsol_event,
17114 .setup = alc663_mode4_setup,
17115 .init_hook = alc663_mode4_inithook,
17117 [ALC663_ASUS_MODE5] = {
17118 .mixers = { alc663_asus_15jd_clfe_mixer },
17119 .cap_mixer = alc662_auto_capture_mixer,
17120 .init_verbs = { alc662_init_verbs,
17121 alc663_15jd_amic_init_verbs },
17122 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17123 .hp_nid = 0x03,
17124 .dac_nids = alc662_dac_nids,
17125 .dig_out_nid = ALC662_DIGOUT_NID,
17126 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17127 .channel_mode = alc662_3ST_2ch_modes,
17128 .unsol_event = alc663_mode5_unsol_event,
17129 .setup = alc663_mode5_setup,
17130 .init_hook = alc663_mode5_inithook,
17132 [ALC663_ASUS_MODE6] = {
17133 .mixers = { alc663_two_hp_m2_mixer },
17134 .cap_mixer = alc662_auto_capture_mixer,
17135 .init_verbs = { alc662_init_verbs,
17136 alc663_two_hp_amic_m2_init_verbs },
17137 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17138 .hp_nid = 0x03,
17139 .dac_nids = alc662_dac_nids,
17140 .dig_out_nid = ALC662_DIGOUT_NID,
17141 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17142 .channel_mode = alc662_3ST_2ch_modes,
17143 .unsol_event = alc663_mode6_unsol_event,
17144 .setup = alc663_mode6_setup,
17145 .init_hook = alc663_mode6_inithook,
17147 [ALC272_DELL] = {
17148 .mixers = { alc663_m51va_mixer },
17149 .cap_mixer = alc272_auto_capture_mixer,
17150 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17151 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17152 .dac_nids = alc662_dac_nids,
17153 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17154 .adc_nids = alc272_adc_nids,
17155 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17156 .capsrc_nids = alc272_capsrc_nids,
17157 .channel_mode = alc662_3ST_2ch_modes,
17158 .unsol_event = alc663_m51va_unsol_event,
17159 .setup = alc663_m51va_setup,
17160 .init_hook = alc663_m51va_inithook,
17162 [ALC272_DELL_ZM1] = {
17163 .mixers = { alc663_m51va_mixer },
17164 .cap_mixer = alc662_auto_capture_mixer,
17165 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17166 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17167 .dac_nids = alc662_dac_nids,
17168 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17169 .adc_nids = alc662_adc_nids,
17170 .num_adc_nids = 1,
17171 .capsrc_nids = alc662_capsrc_nids,
17172 .channel_mode = alc662_3ST_2ch_modes,
17173 .unsol_event = alc663_m51va_unsol_event,
17174 .setup = alc663_m51va_setup,
17175 .init_hook = alc663_m51va_inithook,
17177 [ALC272_SAMSUNG_NC10] = {
17178 .mixers = { alc272_nc10_mixer },
17179 .init_verbs = { alc662_init_verbs,
17180 alc663_21jd_amic_init_verbs },
17181 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17182 .dac_nids = alc272_dac_nids,
17183 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17184 .channel_mode = alc662_3ST_2ch_modes,
17185 /*.input_mux = &alc272_nc10_capture_source,*/
17186 .unsol_event = alc663_mode4_unsol_event,
17187 .setup = alc663_mode4_setup,
17188 .init_hook = alc663_mode4_inithook,
17194 * BIOS auto configuration
17197 /* convert from MIX nid to DAC */
17198 static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17200 if (nid == 0x0f)
17201 return 0x02;
17202 else if (nid >= 0x0c && nid <= 0x0e)
17203 return nid - 0x0c + 0x02;
17204 else
17205 return 0;
17208 /* get MIX nid connected to the given pin targeted to DAC */
17209 static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17210 hda_nid_t dac)
17212 hda_nid_t mix[4];
17213 int i, num;
17215 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17216 for (i = 0; i < num; i++) {
17217 if (alc662_mix_to_dac(mix[i]) == dac)
17218 return mix[i];
17220 return 0;
17223 /* look for an empty DAC slot */
17224 static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17226 struct alc_spec *spec = codec->spec;
17227 hda_nid_t srcs[5];
17228 int i, j, num;
17230 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17231 if (num < 0)
17232 return 0;
17233 for (i = 0; i < num; i++) {
17234 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17235 if (!nid)
17236 continue;
17237 for (j = 0; j < spec->multiout.num_dacs; j++)
17238 if (spec->multiout.dac_nids[j] == nid)
17239 break;
17240 if (j >= spec->multiout.num_dacs)
17241 return nid;
17243 return 0;
17246 /* fill in the dac_nids table from the parsed pin configuration */
17247 static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17248 const struct auto_pin_cfg *cfg)
17250 struct alc_spec *spec = codec->spec;
17251 int i;
17252 hda_nid_t dac;
17254 spec->multiout.dac_nids = spec->private_dac_nids;
17255 for (i = 0; i < cfg->line_outs; i++) {
17256 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17257 if (!dac)
17258 continue;
17259 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17261 return 0;
17264 static int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
17265 hda_nid_t nid, unsigned int chs)
17267 char name[32];
17268 sprintf(name, "%s Playback Volume", pfx);
17269 return add_control(spec, ALC_CTL_WIDGET_VOL, name,
17270 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17273 static int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
17274 hda_nid_t nid, unsigned int chs)
17276 char name[32];
17277 sprintf(name, "%s Playback Switch", pfx);
17278 return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17279 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17282 #define alc662_add_stereo_vol(spec, pfx, nid) \
17283 alc662_add_vol_ctl(spec, pfx, nid, 3)
17284 #define alc662_add_stereo_sw(spec, pfx, nid) \
17285 alc662_add_sw_ctl(spec, pfx, nid, 3)
17287 /* add playback controls from the parsed DAC table */
17288 static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17289 const struct auto_pin_cfg *cfg)
17291 struct alc_spec *spec = codec->spec;
17292 static const char *chname[4] = {
17293 "Front", "Surround", NULL /*CLFE*/, "Side"
17295 hda_nid_t nid, mix;
17296 int i, err;
17298 for (i = 0; i < cfg->line_outs; i++) {
17299 nid = spec->multiout.dac_nids[i];
17300 if (!nid)
17301 continue;
17302 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17303 if (!mix)
17304 continue;
17305 if (i == 2) {
17306 /* Center/LFE */
17307 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
17308 if (err < 0)
17309 return err;
17310 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
17311 if (err < 0)
17312 return err;
17313 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
17314 if (err < 0)
17315 return err;
17316 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
17317 if (err < 0)
17318 return err;
17319 } else {
17320 const char *pfx;
17321 if (cfg->line_outs == 1 &&
17322 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17323 if (cfg->hp_outs)
17324 pfx = "Speaker";
17325 else
17326 pfx = "PCM";
17327 } else
17328 pfx = chname[i];
17329 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17330 if (err < 0)
17331 return err;
17332 if (cfg->line_outs == 1 &&
17333 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17334 pfx = "Speaker";
17335 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17336 if (err < 0)
17337 return err;
17340 return 0;
17343 /* add playback controls for speaker and HP outputs */
17344 /* return DAC nid if any new DAC is assigned */
17345 static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
17346 const char *pfx)
17348 struct alc_spec *spec = codec->spec;
17349 hda_nid_t nid, mix;
17350 int err;
17352 if (!pin)
17353 return 0;
17354 nid = alc662_look_for_dac(codec, pin);
17355 if (!nid) {
17356 char name[32];
17357 /* the corresponding DAC is already occupied */
17358 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17359 return 0; /* no way */
17360 /* create a switch only */
17361 sprintf(name, "%s Playback Switch", pfx);
17362 return add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17363 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17366 mix = alc662_dac_to_mix(codec, pin, nid);
17367 if (!mix)
17368 return 0;
17369 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17370 if (err < 0)
17371 return err;
17372 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17373 if (err < 0)
17374 return err;
17375 return nid;
17378 /* create playback/capture controls for input pins */
17379 #define alc662_auto_create_input_ctls \
17380 alc882_auto_create_input_ctls
17382 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17383 hda_nid_t nid, int pin_type,
17384 hda_nid_t dac)
17386 int i, num;
17387 hda_nid_t srcs[4];
17389 alc_set_pin_output(codec, nid, pin_type);
17390 /* need the manual connection? */
17391 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17392 if (num <= 1)
17393 return;
17394 for (i = 0; i < num; i++) {
17395 if (alc662_mix_to_dac(srcs[i]) != dac)
17396 continue;
17397 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17398 return;
17402 static void alc662_auto_init_multi_out(struct hda_codec *codec)
17404 struct alc_spec *spec = codec->spec;
17405 int pin_type = get_pin_type(spec->autocfg.line_out_type);
17406 int i;
17408 for (i = 0; i <= HDA_SIDE; i++) {
17409 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17410 if (nid)
17411 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
17412 spec->multiout.dac_nids[i]);
17416 static void alc662_auto_init_hp_out(struct hda_codec *codec)
17418 struct alc_spec *spec = codec->spec;
17419 hda_nid_t pin;
17421 pin = spec->autocfg.hp_pins[0];
17422 if (pin)
17423 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17424 spec->multiout.hp_nid);
17425 pin = spec->autocfg.speaker_pins[0];
17426 if (pin)
17427 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17428 spec->multiout.extra_out_nid[0]);
17431 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17433 static void alc662_auto_init_analog_input(struct hda_codec *codec)
17435 struct alc_spec *spec = codec->spec;
17436 int i;
17438 for (i = 0; i < AUTO_PIN_LAST; i++) {
17439 hda_nid_t nid = spec->autocfg.input_pins[i];
17440 if (alc_is_input_pin(codec, nid)) {
17441 alc_set_input_pin(codec, nid, i);
17442 if (nid != ALC662_PIN_CD_NID &&
17443 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
17444 snd_hda_codec_write(codec, nid, 0,
17445 AC_VERB_SET_AMP_GAIN_MUTE,
17446 AMP_OUT_MUTE);
17451 #define alc662_auto_init_input_src alc882_auto_init_input_src
17453 static int alc662_parse_auto_config(struct hda_codec *codec)
17455 struct alc_spec *spec = codec->spec;
17456 int err;
17457 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17459 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17460 alc662_ignore);
17461 if (err < 0)
17462 return err;
17463 if (!spec->autocfg.line_outs)
17464 return 0; /* can't find valid BIOS pin config */
17466 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
17467 if (err < 0)
17468 return err;
17469 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
17470 if (err < 0)
17471 return err;
17472 err = alc662_auto_create_extra_out(codec,
17473 spec->autocfg.speaker_pins[0],
17474 "Speaker");
17475 if (err < 0)
17476 return err;
17477 if (err)
17478 spec->multiout.extra_out_nid[0] = err;
17479 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
17480 "Headphone");
17481 if (err < 0)
17482 return err;
17483 if (err)
17484 spec->multiout.hp_nid = err;
17485 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
17486 if (err < 0)
17487 return err;
17489 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17491 if (spec->autocfg.dig_outs)
17492 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17494 if (spec->kctls.list)
17495 add_mixer(spec, spec->kctls.list);
17497 spec->num_mux_defs = 1;
17498 spec->input_mux = &spec->private_imux[0];
17500 add_verb(spec, alc662_auto_init_verbs);
17501 if (codec->vendor_id == 0x10ec0663)
17502 add_verb(spec, alc663_auto_init_verbs);
17504 err = alc_auto_add_mic_boost(codec);
17505 if (err < 0)
17506 return err;
17508 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17510 return 1;
17513 /* additional initialization for auto-configuration model */
17514 static void alc662_auto_init(struct hda_codec *codec)
17516 struct alc_spec *spec = codec->spec;
17517 alc662_auto_init_multi_out(codec);
17518 alc662_auto_init_hp_out(codec);
17519 alc662_auto_init_analog_input(codec);
17520 alc662_auto_init_input_src(codec);
17521 if (spec->unsol_event)
17522 alc_inithook(codec);
17525 static int patch_alc662(struct hda_codec *codec)
17527 struct alc_spec *spec;
17528 int err, board_config;
17530 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17531 if (!spec)
17532 return -ENOMEM;
17534 codec->spec = spec;
17536 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17538 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17539 alc662_models,
17540 alc662_cfg_tbl);
17541 if (board_config < 0) {
17542 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17543 codec->chip_name);
17544 board_config = ALC662_AUTO;
17547 if (board_config == ALC662_AUTO) {
17548 /* automatic parse from the BIOS config */
17549 err = alc662_parse_auto_config(codec);
17550 if (err < 0) {
17551 alc_free(codec);
17552 return err;
17553 } else if (!err) {
17554 printk(KERN_INFO
17555 "hda_codec: Cannot set up configuration "
17556 "from BIOS. Using base mode...\n");
17557 board_config = ALC662_3ST_2ch_DIG;
17561 err = snd_hda_attach_beep_device(codec, 0x1);
17562 if (err < 0) {
17563 alc_free(codec);
17564 return err;
17567 if (board_config != ALC662_AUTO)
17568 setup_preset(codec, &alc662_presets[board_config]);
17570 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17571 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17573 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17574 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17576 if (!spec->adc_nids) {
17577 spec->adc_nids = alc662_adc_nids;
17578 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17580 if (!spec->capsrc_nids)
17581 spec->capsrc_nids = alc662_capsrc_nids;
17583 if (!spec->cap_mixer)
17584 set_capture_mixer(codec);
17585 if (codec->vendor_id == 0x10ec0662)
17586 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17587 else
17588 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
17590 spec->vmaster_nid = 0x02;
17592 codec->patch_ops = alc_patch_ops;
17593 if (board_config == ALC662_AUTO)
17594 spec->init_hook = alc662_auto_init;
17595 #ifdef CONFIG_SND_HDA_POWER_SAVE
17596 if (!spec->loopback.amplist)
17597 spec->loopback.amplist = alc662_loopbacks;
17598 #endif
17599 codec->proc_widget_hook = print_realtek_coef;
17601 return 0;
17605 * patch entries
17607 static struct hda_codec_preset snd_hda_preset_realtek[] = {
17608 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
17609 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
17610 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
17611 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
17612 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
17613 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
17614 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
17615 .patch = patch_alc861 },
17616 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17617 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17618 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
17619 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17620 .patch = patch_alc882 },
17621 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17622 .patch = patch_alc662 },
17623 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
17624 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
17625 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
17626 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
17627 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17628 .patch = patch_alc882 },
17629 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
17630 .patch = patch_alc882 },
17631 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
17632 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
17633 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17634 .patch = patch_alc882 },
17635 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17636 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
17637 {} /* terminator */
17640 MODULE_ALIAS("snd-hda-codec-id:10ec*");
17642 MODULE_LICENSE("GPL");
17643 MODULE_DESCRIPTION("Realtek HD-audio codec");
17645 static struct hda_codec_preset_list realtek_list = {
17646 .preset = snd_hda_preset_realtek,
17647 .owner = THIS_MODULE,
17650 static int __init patch_realtek_init(void)
17652 return snd_hda_add_codec_preset(&realtek_list);
17655 static void __exit patch_realtek_exit(void)
17657 snd_hda_delete_codec_preset(&realtek_list);
17660 module_init(patch_realtek_init)
17661 module_exit(patch_realtek_exit)