writeback: add comments to bdi_work structure
[linux-2.6/next.git] / sound / pci / hda / patch_realtek.c
blob7ed47f66ddd1fe8a6f09f24b548536ff04fd8660
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[5]; /* 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 pincap = snd_hda_query_pin_caps(codec, nid);
969 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
970 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
971 present = snd_hda_codec_read(codec, nid, 0,
972 AC_VERB_GET_PIN_SENSE, 0);
973 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
974 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
975 nid = spec->autocfg.speaker_pins[i];
976 if (!nid)
977 break;
978 snd_hda_codec_write(codec, nid, 0,
979 AC_VERB_SET_PIN_WIDGET_CONTROL,
980 spec->jack_present ? 0 : PIN_OUT);
984 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
985 hda_nid_t nid)
987 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
988 int i, nums;
990 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
991 for (i = 0; i < nums; i++)
992 if (conn[i] == nid)
993 return i;
994 return -1;
997 static void alc_mic_automute(struct hda_codec *codec)
999 struct alc_spec *spec = codec->spec;
1000 struct alc_mic_route *dead, *alive;
1001 unsigned int present, type;
1002 hda_nid_t cap_nid;
1004 if (!spec->auto_mic)
1005 return;
1006 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1007 return;
1008 if (snd_BUG_ON(!spec->adc_nids))
1009 return;
1011 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1013 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1014 AC_VERB_GET_PIN_SENSE, 0);
1015 present &= AC_PINSENSE_PRESENCE;
1016 if (present) {
1017 alive = &spec->ext_mic;
1018 dead = &spec->int_mic;
1019 } else {
1020 alive = &spec->int_mic;
1021 dead = &spec->ext_mic;
1024 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1025 if (type == AC_WID_AUD_MIX) {
1026 /* Matrix-mixer style (e.g. ALC882) */
1027 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1028 alive->mux_idx,
1029 HDA_AMP_MUTE, 0);
1030 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1031 dead->mux_idx,
1032 HDA_AMP_MUTE, HDA_AMP_MUTE);
1033 } else {
1034 /* MUX style (e.g. ALC880) */
1035 snd_hda_codec_write_cache(codec, cap_nid, 0,
1036 AC_VERB_SET_CONNECT_SEL,
1037 alive->mux_idx);
1040 /* FIXME: analog mixer */
1043 /* unsolicited event for HP jack sensing */
1044 static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1046 if (codec->vendor_id == 0x10ec0880)
1047 res >>= 28;
1048 else
1049 res >>= 26;
1050 switch (res) {
1051 case ALC880_HP_EVENT:
1052 alc_automute_pin(codec);
1053 break;
1054 case ALC880_MIC_EVENT:
1055 alc_mic_automute(codec);
1056 break;
1060 static void alc_inithook(struct hda_codec *codec)
1062 alc_automute_pin(codec);
1063 alc_mic_automute(codec);
1066 /* additional initialization for ALC888 variants */
1067 static void alc888_coef_init(struct hda_codec *codec)
1069 unsigned int tmp;
1071 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1072 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1073 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1074 if ((tmp & 0xf0) == 0x20)
1075 /* alc888S-VC */
1076 snd_hda_codec_read(codec, 0x20, 0,
1077 AC_VERB_SET_PROC_COEF, 0x830);
1078 else
1079 /* alc888-VB */
1080 snd_hda_codec_read(codec, 0x20, 0,
1081 AC_VERB_SET_PROC_COEF, 0x3030);
1084 static void alc889_coef_init(struct hda_codec *codec)
1086 unsigned int tmp;
1088 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1089 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1090 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1091 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1094 static void alc_auto_init_amp(struct hda_codec *codec, int type)
1096 unsigned int tmp;
1098 switch (type) {
1099 case ALC_INIT_GPIO1:
1100 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1101 break;
1102 case ALC_INIT_GPIO2:
1103 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1104 break;
1105 case ALC_INIT_GPIO3:
1106 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1107 break;
1108 case ALC_INIT_DEFAULT:
1109 switch (codec->vendor_id) {
1110 case 0x10ec0260:
1111 snd_hda_codec_write(codec, 0x0f, 0,
1112 AC_VERB_SET_EAPD_BTLENABLE, 2);
1113 snd_hda_codec_write(codec, 0x10, 0,
1114 AC_VERB_SET_EAPD_BTLENABLE, 2);
1115 break;
1116 case 0x10ec0262:
1117 case 0x10ec0267:
1118 case 0x10ec0268:
1119 case 0x10ec0269:
1120 case 0x10ec0272:
1121 case 0x10ec0660:
1122 case 0x10ec0662:
1123 case 0x10ec0663:
1124 case 0x10ec0862:
1125 case 0x10ec0889:
1126 snd_hda_codec_write(codec, 0x14, 0,
1127 AC_VERB_SET_EAPD_BTLENABLE, 2);
1128 snd_hda_codec_write(codec, 0x15, 0,
1129 AC_VERB_SET_EAPD_BTLENABLE, 2);
1130 break;
1132 switch (codec->vendor_id) {
1133 case 0x10ec0260:
1134 snd_hda_codec_write(codec, 0x1a, 0,
1135 AC_VERB_SET_COEF_INDEX, 7);
1136 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1137 AC_VERB_GET_PROC_COEF, 0);
1138 snd_hda_codec_write(codec, 0x1a, 0,
1139 AC_VERB_SET_COEF_INDEX, 7);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_PROC_COEF,
1142 tmp | 0x2010);
1143 break;
1144 case 0x10ec0262:
1145 case 0x10ec0880:
1146 case 0x10ec0882:
1147 case 0x10ec0883:
1148 case 0x10ec0885:
1149 case 0x10ec0887:
1150 case 0x10ec0889:
1151 alc889_coef_init(codec);
1152 break;
1153 case 0x10ec0888:
1154 alc888_coef_init(codec);
1155 break;
1156 case 0x10ec0267:
1157 case 0x10ec0268:
1158 snd_hda_codec_write(codec, 0x20, 0,
1159 AC_VERB_SET_COEF_INDEX, 7);
1160 tmp = snd_hda_codec_read(codec, 0x20, 0,
1161 AC_VERB_GET_PROC_COEF, 0);
1162 snd_hda_codec_write(codec, 0x20, 0,
1163 AC_VERB_SET_COEF_INDEX, 7);
1164 snd_hda_codec_write(codec, 0x20, 0,
1165 AC_VERB_SET_PROC_COEF,
1166 tmp | 0x3000);
1167 break;
1169 break;
1173 static void alc_init_auto_hp(struct hda_codec *codec)
1175 struct alc_spec *spec = codec->spec;
1177 if (!spec->autocfg.hp_pins[0])
1178 return;
1180 if (!spec->autocfg.speaker_pins[0]) {
1181 if (spec->autocfg.line_out_pins[0] &&
1182 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
1183 spec->autocfg.speaker_pins[0] =
1184 spec->autocfg.line_out_pins[0];
1185 else
1186 return;
1189 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1190 spec->autocfg.hp_pins[0]);
1191 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1192 AC_VERB_SET_UNSOLICITED_ENABLE,
1193 AC_USRSP_EN | ALC880_HP_EVENT);
1194 spec->unsol_event = alc_sku_unsol_event;
1197 static void alc_init_auto_mic(struct hda_codec *codec)
1199 struct alc_spec *spec = codec->spec;
1200 struct auto_pin_cfg *cfg = &spec->autocfg;
1201 hda_nid_t fixed, ext;
1202 int i;
1204 /* there must be only two mic inputs exclusively */
1205 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1206 if (cfg->input_pins[i])
1207 return;
1209 fixed = ext = 0;
1210 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1211 hda_nid_t nid = cfg->input_pins[i];
1212 unsigned int defcfg;
1213 if (!nid)
1214 return;
1215 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1216 switch (get_defcfg_connect(defcfg)) {
1217 case AC_JACK_PORT_FIXED:
1218 if (fixed)
1219 return; /* already occupied */
1220 fixed = nid;
1221 break;
1222 case AC_JACK_PORT_COMPLEX:
1223 if (ext)
1224 return; /* already occupied */
1225 ext = nid;
1226 break;
1227 default:
1228 return; /* invalid entry */
1231 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1232 return; /* no unsol support */
1233 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1234 ext, fixed);
1235 spec->ext_mic.pin = ext;
1236 spec->int_mic.pin = fixed;
1237 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1238 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1239 spec->auto_mic = 1;
1240 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1241 AC_VERB_SET_UNSOLICITED_ENABLE,
1242 AC_USRSP_EN | ALC880_MIC_EVENT);
1243 spec->unsol_event = alc_sku_unsol_event;
1246 /* check subsystem ID and set up device-specific initialization;
1247 * return 1 if initialized, 0 if invalid SSID
1249 /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1250 * 31 ~ 16 : Manufacture ID
1251 * 15 ~ 8 : SKU ID
1252 * 7 ~ 0 : Assembly ID
1253 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1255 static int alc_subsystem_id(struct hda_codec *codec,
1256 hda_nid_t porta, hda_nid_t porte,
1257 hda_nid_t portd)
1259 unsigned int ass, tmp, i;
1260 unsigned nid;
1261 struct alc_spec *spec = codec->spec;
1263 ass = codec->subsystem_id & 0xffff;
1264 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1265 goto do_sku;
1267 /* invalid SSID, check the special NID pin defcfg instead */
1269 * 31~30 : port connectivity
1270 * 29~21 : reserve
1271 * 20 : PCBEEP input
1272 * 19~16 : Check sum (15:1)
1273 * 15~1 : Custom
1274 * 0 : override
1276 nid = 0x1d;
1277 if (codec->vendor_id == 0x10ec0260)
1278 nid = 0x17;
1279 ass = snd_hda_codec_get_pincfg(codec, nid);
1280 snd_printd("realtek: No valid SSID, "
1281 "checking pincfg 0x%08x for NID 0x%x\n",
1282 ass, nid);
1283 if (!(ass & 1) && !(ass & 0x100000))
1284 return 0;
1285 if ((ass >> 30) != 1) /* no physical connection */
1286 return 0;
1288 /* check sum */
1289 tmp = 0;
1290 for (i = 1; i < 16; i++) {
1291 if ((ass >> i) & 1)
1292 tmp++;
1294 if (((ass >> 16) & 0xf) != tmp)
1295 return 0;
1296 do_sku:
1297 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1298 ass & 0xffff, codec->vendor_id);
1300 * 0 : override
1301 * 1 : Swap Jack
1302 * 2 : 0 --> Desktop, 1 --> Laptop
1303 * 3~5 : External Amplifier control
1304 * 7~6 : Reserved
1306 tmp = (ass & 0x38) >> 3; /* external Amp control */
1307 switch (tmp) {
1308 case 1:
1309 spec->init_amp = ALC_INIT_GPIO1;
1310 break;
1311 case 3:
1312 spec->init_amp = ALC_INIT_GPIO2;
1313 break;
1314 case 7:
1315 spec->init_amp = ALC_INIT_GPIO3;
1316 break;
1317 case 5:
1318 spec->init_amp = ALC_INIT_DEFAULT;
1319 break;
1322 /* is laptop or Desktop and enable the function "Mute internal speaker
1323 * when the external headphone out jack is plugged"
1325 if (!(ass & 0x8000))
1326 return 1;
1328 * 10~8 : Jack location
1329 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1330 * 14~13: Resvered
1331 * 15 : 1 --> enable the function "Mute internal speaker
1332 * when the external headphone out jack is plugged"
1334 if (!spec->autocfg.hp_pins[0]) {
1335 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1336 if (tmp == 0)
1337 spec->autocfg.hp_pins[0] = porta;
1338 else if (tmp == 1)
1339 spec->autocfg.hp_pins[0] = porte;
1340 else if (tmp == 2)
1341 spec->autocfg.hp_pins[0] = portd;
1342 else
1343 return 1;
1346 alc_init_auto_hp(codec);
1347 alc_init_auto_mic(codec);
1348 return 1;
1351 static void alc_ssid_check(struct hda_codec *codec,
1352 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1354 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1355 struct alc_spec *spec = codec->spec;
1356 snd_printd("realtek: "
1357 "Enable default setup for auto mode as fallback\n");
1358 spec->init_amp = ALC_INIT_DEFAULT;
1359 alc_init_auto_hp(codec);
1360 alc_init_auto_mic(codec);
1365 * Fix-up pin default configurations
1368 struct alc_pincfg {
1369 hda_nid_t nid;
1370 u32 val;
1373 static void alc_fix_pincfg(struct hda_codec *codec,
1374 const struct snd_pci_quirk *quirk,
1375 const struct alc_pincfg **pinfix)
1377 const struct alc_pincfg *cfg;
1379 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1380 if (!quirk)
1381 return;
1383 cfg = pinfix[quirk->value];
1384 for (; cfg->nid; cfg++)
1385 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1389 * ALC888
1393 * 2ch mode
1395 static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1396 /* Mic-in jack as mic in */
1397 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1398 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1399 /* Line-in jack as Line in */
1400 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1401 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1402 /* Line-Out as Front */
1403 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1404 { } /* end */
1408 * 4ch mode
1410 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1411 /* Mic-in jack as mic in */
1412 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1413 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1414 /* Line-in jack as Surround */
1415 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1416 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1417 /* Line-Out as Front */
1418 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1419 { } /* end */
1423 * 6ch mode
1425 static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1426 /* Mic-in jack as CLFE */
1427 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1428 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1429 /* Line-in jack as Surround */
1430 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1431 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1432 /* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1433 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1434 { } /* end */
1438 * 8ch mode
1440 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1441 /* Mic-in jack as CLFE */
1442 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1443 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1444 /* Line-in jack as Surround */
1445 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1446 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1447 /* Line-Out as Side */
1448 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1449 { } /* end */
1452 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1453 { 2, alc888_4ST_ch2_intel_init },
1454 { 4, alc888_4ST_ch4_intel_init },
1455 { 6, alc888_4ST_ch6_intel_init },
1456 { 8, alc888_4ST_ch8_intel_init },
1460 * ALC888 Fujitsu Siemens Amillo xa3530
1463 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1464 /* Front Mic: set to PIN_IN (empty by default) */
1465 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1466 /* Connect Internal HP to Front */
1467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1468 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1469 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1470 /* Connect Bass HP to Front */
1471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1473 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1474 /* Connect Line-Out side jack (SPDIF) to Side */
1475 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1476 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1477 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1478 /* Connect Mic jack to CLFE */
1479 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1481 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1482 /* Connect Line-in jack to Surround */
1483 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1484 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1485 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1486 /* Connect HP out jack to Front */
1487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1488 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1490 /* Enable unsolicited event for HP jack and Line-out jack */
1491 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1492 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1496 static void alc_automute_amp(struct hda_codec *codec)
1498 struct alc_spec *spec = codec->spec;
1499 unsigned int val, mute, pincap;
1500 hda_nid_t nid;
1501 int i;
1503 spec->jack_present = 0;
1504 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1505 nid = spec->autocfg.hp_pins[i];
1506 if (!nid)
1507 break;
1508 pincap = snd_hda_query_pin_caps(codec, nid);
1509 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1510 snd_hda_codec_read(codec, nid, 0,
1511 AC_VERB_SET_PIN_SENSE, 0);
1512 val = snd_hda_codec_read(codec, nid, 0,
1513 AC_VERB_GET_PIN_SENSE, 0);
1514 if (val & AC_PINSENSE_PRESENCE) {
1515 spec->jack_present = 1;
1516 break;
1520 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1521 /* Toggle internal speakers muting */
1522 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1523 nid = spec->autocfg.speaker_pins[i];
1524 if (!nid)
1525 break;
1526 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1527 HDA_AMP_MUTE, mute);
1531 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1532 unsigned int res)
1534 if (codec->vendor_id == 0x10ec0880)
1535 res >>= 28;
1536 else
1537 res >>= 26;
1538 if (res == ALC880_HP_EVENT)
1539 alc_automute_amp(codec);
1542 static void alc889_automute_setup(struct hda_codec *codec)
1544 struct alc_spec *spec = codec->spec;
1546 spec->autocfg.hp_pins[0] = 0x15;
1547 spec->autocfg.speaker_pins[0] = 0x14;
1548 spec->autocfg.speaker_pins[1] = 0x16;
1549 spec->autocfg.speaker_pins[2] = 0x17;
1550 spec->autocfg.speaker_pins[3] = 0x19;
1551 spec->autocfg.speaker_pins[4] = 0x1a;
1554 static void alc889_intel_init_hook(struct hda_codec *codec)
1556 alc889_coef_init(codec);
1557 alc_automute_amp(codec);
1560 static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1562 struct alc_spec *spec = codec->spec;
1564 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1565 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1566 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1567 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1571 * ALC888 Acer Aspire 4930G model
1574 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1575 /* Front Mic: set to PIN_IN (empty by default) */
1576 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1577 /* Unselect Front Mic by default in input mixer 3 */
1578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1579 /* Enable unsolicited event for HP jack */
1580 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1581 /* Connect Internal HP to front */
1582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1583 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1584 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1585 /* Connect HP out to front */
1586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1587 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1588 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1593 * ALC888 Acer Aspire 6530G model
1596 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1597 /* Bias voltage on for external mic port */
1598 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1599 /* Front Mic: set to PIN_IN (empty by default) */
1600 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1601 /* Unselect Front Mic by default in input mixer 3 */
1602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1603 /* Enable unsolicited event for HP jack */
1604 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1605 /* Enable speaker output */
1606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1608 /* Enable headphone output */
1609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1611 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1616 * ALC889 Acer Aspire 8930G model
1619 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1620 /* Front Mic: set to PIN_IN (empty by default) */
1621 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1622 /* Unselect Front Mic by default in input mixer 3 */
1623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1624 /* Enable unsolicited event for HP jack */
1625 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1626 /* Connect Internal Front to Front */
1627 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1628 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1629 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1630 /* Connect Internal Rear to Rear */
1631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1632 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1633 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1634 /* Connect Internal CLFE to CLFE */
1635 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1636 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1637 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1638 /* Connect HP out to Front */
1639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1641 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1642 /* Enable all DACs */
1643 /* DAC DISABLE/MUTE 1? */
1644 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1645 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1646 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1647 /* DAC DISABLE/MUTE 2? */
1648 /* some bit here disables the other DACs. Init=0x4900 */
1649 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1650 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1651 /* Enable amplifiers */
1652 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1653 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1654 /* DMIC fix
1655 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1656 * which makes the stereo useless. However, either the mic or the ALC889
1657 * makes the signal become a difference/sum signal instead of standard
1658 * stereo, which is annoying. So instead we flip this bit which makes the
1659 * codec replicate the sum signal to both channels, turning it into a
1660 * normal mono mic.
1662 /* DMIC_CONTROL? Init value = 0x0001 */
1663 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1664 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
1668 static struct hda_input_mux alc888_2_capture_sources[2] = {
1669 /* Front mic only available on one ADC */
1671 .num_items = 4,
1672 .items = {
1673 { "Mic", 0x0 },
1674 { "Line", 0x2 },
1675 { "CD", 0x4 },
1676 { "Front Mic", 0xb },
1680 .num_items = 3,
1681 .items = {
1682 { "Mic", 0x0 },
1683 { "Line", 0x2 },
1684 { "CD", 0x4 },
1689 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1690 /* Interal mic only available on one ADC */
1692 .num_items = 5,
1693 .items = {
1694 { "Ext Mic", 0x0 },
1695 { "Line In", 0x2 },
1696 { "CD", 0x4 },
1697 { "Input Mix", 0xa },
1698 { "Int Mic", 0xb },
1702 .num_items = 4,
1703 .items = {
1704 { "Ext Mic", 0x0 },
1705 { "Line In", 0x2 },
1706 { "CD", 0x4 },
1707 { "Input Mix", 0xa },
1712 static struct hda_input_mux alc889_capture_sources[3] = {
1713 /* Digital mic only available on first "ADC" */
1715 .num_items = 5,
1716 .items = {
1717 { "Mic", 0x0 },
1718 { "Line", 0x2 },
1719 { "CD", 0x4 },
1720 { "Front Mic", 0xb },
1721 { "Input Mix", 0xa },
1725 .num_items = 4,
1726 .items = {
1727 { "Mic", 0x0 },
1728 { "Line", 0x2 },
1729 { "CD", 0x4 },
1730 { "Input Mix", 0xa },
1734 .num_items = 4,
1735 .items = {
1736 { "Mic", 0x0 },
1737 { "Line", 0x2 },
1738 { "CD", 0x4 },
1739 { "Input Mix", 0xa },
1744 static struct snd_kcontrol_new alc888_base_mixer[] = {
1745 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1746 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1747 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1748 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1749 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1750 HDA_OUTPUT),
1751 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1752 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1753 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1754 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1755 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1758 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1759 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1761 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1763 { } /* end */
1766 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
1768 struct alc_spec *spec = codec->spec;
1770 spec->autocfg.hp_pins[0] = 0x15;
1771 spec->autocfg.speaker_pins[0] = 0x14;
1774 static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
1776 struct alc_spec *spec = codec->spec;
1778 spec->autocfg.hp_pins[0] = 0x15;
1779 spec->autocfg.speaker_pins[0] = 0x14;
1780 spec->autocfg.speaker_pins[1] = 0x16;
1781 spec->autocfg.speaker_pins[2] = 0x17;
1784 static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
1786 struct alc_spec *spec = codec->spec;
1788 spec->autocfg.hp_pins[0] = 0x15;
1789 spec->autocfg.speaker_pins[0] = 0x14;
1790 spec->autocfg.speaker_pins[1] = 0x16;
1791 spec->autocfg.speaker_pins[2] = 0x1b;
1795 * ALC880 3-stack model
1797 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1798 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1799 * F-Mic = 0x1b, HP = 0x19
1802 static hda_nid_t alc880_dac_nids[4] = {
1803 /* front, rear, clfe, rear_surr */
1804 0x02, 0x05, 0x04, 0x03
1807 static hda_nid_t alc880_adc_nids[3] = {
1808 /* ADC0-2 */
1809 0x07, 0x08, 0x09,
1812 /* The datasheet says the node 0x07 is connected from inputs,
1813 * but it shows zero connection in the real implementation on some devices.
1814 * Note: this is a 915GAV bug, fixed on 915GLV
1816 static hda_nid_t alc880_adc_nids_alt[2] = {
1817 /* ADC1-2 */
1818 0x08, 0x09,
1821 #define ALC880_DIGOUT_NID 0x06
1822 #define ALC880_DIGIN_NID 0x0a
1824 static struct hda_input_mux alc880_capture_source = {
1825 .num_items = 4,
1826 .items = {
1827 { "Mic", 0x0 },
1828 { "Front Mic", 0x3 },
1829 { "Line", 0x2 },
1830 { "CD", 0x4 },
1834 /* channel source setting (2/6 channel selection for 3-stack) */
1835 /* 2ch mode */
1836 static struct hda_verb alc880_threestack_ch2_init[] = {
1837 /* set line-in to input, mute it */
1838 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1839 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1840 /* set mic-in to input vref 80%, mute it */
1841 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1842 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1843 { } /* end */
1846 /* 6ch mode */
1847 static struct hda_verb alc880_threestack_ch6_init[] = {
1848 /* set line-in to output, unmute it */
1849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1851 /* set mic-in to output, unmute it */
1852 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1853 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1854 { } /* end */
1857 static struct hda_channel_mode alc880_threestack_modes[2] = {
1858 { 2, alc880_threestack_ch2_init },
1859 { 6, alc880_threestack_ch6_init },
1862 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1863 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1864 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1865 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1866 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1867 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1868 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1869 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1870 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1871 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1872 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1873 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1874 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1875 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1876 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1877 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1878 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1881 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1882 .name = "Channel Mode",
1883 .info = alc_ch_mode_info,
1884 .get = alc_ch_mode_get,
1885 .put = alc_ch_mode_put,
1887 { } /* end */
1890 /* capture mixer elements */
1891 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1892 struct snd_ctl_elem_info *uinfo)
1894 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1895 struct alc_spec *spec = codec->spec;
1896 int err;
1898 mutex_lock(&codec->control_mutex);
1899 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1900 HDA_INPUT);
1901 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1902 mutex_unlock(&codec->control_mutex);
1903 return err;
1906 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1907 unsigned int size, unsigned int __user *tlv)
1909 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1910 struct alc_spec *spec = codec->spec;
1911 int err;
1913 mutex_lock(&codec->control_mutex);
1914 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1915 HDA_INPUT);
1916 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1917 mutex_unlock(&codec->control_mutex);
1918 return err;
1921 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1922 struct snd_ctl_elem_value *ucontrol);
1924 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1925 struct snd_ctl_elem_value *ucontrol,
1926 getput_call_t func)
1928 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1929 struct alc_spec *spec = codec->spec;
1930 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1931 int err;
1933 mutex_lock(&codec->control_mutex);
1934 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1935 3, 0, HDA_INPUT);
1936 err = func(kcontrol, ucontrol);
1937 mutex_unlock(&codec->control_mutex);
1938 return err;
1941 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1942 struct snd_ctl_elem_value *ucontrol)
1944 return alc_cap_getput_caller(kcontrol, ucontrol,
1945 snd_hda_mixer_amp_volume_get);
1948 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1949 struct snd_ctl_elem_value *ucontrol)
1951 return alc_cap_getput_caller(kcontrol, ucontrol,
1952 snd_hda_mixer_amp_volume_put);
1955 /* capture mixer elements */
1956 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1958 static int alc_cap_sw_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_switch_get);
1965 static int alc_cap_sw_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_switch_put);
1972 #define _DEFINE_CAPMIX(num) \
1974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1975 .name = "Capture Switch", \
1976 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1977 .count = num, \
1978 .info = alc_cap_sw_info, \
1979 .get = alc_cap_sw_get, \
1980 .put = alc_cap_sw_put, \
1981 }, \
1983 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1984 .name = "Capture Volume", \
1985 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1986 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1987 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1988 .count = num, \
1989 .info = alc_cap_vol_info, \
1990 .get = alc_cap_vol_get, \
1991 .put = alc_cap_vol_put, \
1992 .tlv = { .c = alc_cap_vol_tlv }, \
1995 #define _DEFINE_CAPSRC(num) \
1997 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1998 /* .name = "Capture Source", */ \
1999 .name = "Input Source", \
2000 .count = num, \
2001 .info = alc_mux_enum_info, \
2002 .get = alc_mux_enum_get, \
2003 .put = alc_mux_enum_put, \
2006 #define DEFINE_CAPMIX(num) \
2007 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2008 _DEFINE_CAPMIX(num), \
2009 _DEFINE_CAPSRC(num), \
2010 { } /* end */ \
2013 #define DEFINE_CAPMIX_NOSRC(num) \
2014 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2015 _DEFINE_CAPMIX(num), \
2016 { } /* end */ \
2019 /* up to three ADCs */
2020 DEFINE_CAPMIX(1);
2021 DEFINE_CAPMIX(2);
2022 DEFINE_CAPMIX(3);
2023 DEFINE_CAPMIX_NOSRC(1);
2024 DEFINE_CAPMIX_NOSRC(2);
2025 DEFINE_CAPMIX_NOSRC(3);
2028 * ALC880 5-stack model
2030 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2031 * Side = 0x02 (0xd)
2032 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2033 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2036 /* additional mixers to alc880_three_stack_mixer */
2037 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2038 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2039 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2040 { } /* end */
2043 /* channel source setting (6/8 channel selection for 5-stack) */
2044 /* 6ch mode */
2045 static struct hda_verb alc880_fivestack_ch6_init[] = {
2046 /* set line-in to input, mute it */
2047 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2048 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2049 { } /* end */
2052 /* 8ch mode */
2053 static struct hda_verb alc880_fivestack_ch8_init[] = {
2054 /* set line-in to output, unmute it */
2055 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2056 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2057 { } /* end */
2060 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2061 { 6, alc880_fivestack_ch6_init },
2062 { 8, alc880_fivestack_ch8_init },
2067 * ALC880 6-stack model
2069 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2070 * Side = 0x05 (0x0f)
2071 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2072 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2075 static hda_nid_t alc880_6st_dac_nids[4] = {
2076 /* front, rear, clfe, rear_surr */
2077 0x02, 0x03, 0x04, 0x05
2080 static struct hda_input_mux alc880_6stack_capture_source = {
2081 .num_items = 4,
2082 .items = {
2083 { "Mic", 0x0 },
2084 { "Front Mic", 0x1 },
2085 { "Line", 0x2 },
2086 { "CD", 0x4 },
2090 /* fixed 8-channels */
2091 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2092 { 8, NULL },
2095 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2096 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2097 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2098 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2099 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2100 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2101 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2102 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2103 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2104 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2105 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2106 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2107 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2108 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2109 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2111 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2112 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2113 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2116 .name = "Channel Mode",
2117 .info = alc_ch_mode_info,
2118 .get = alc_ch_mode_get,
2119 .put = alc_ch_mode_put,
2121 { } /* end */
2126 * ALC880 W810 model
2128 * W810 has rear IO for:
2129 * Front (DAC 02)
2130 * Surround (DAC 03)
2131 * Center/LFE (DAC 04)
2132 * Digital out (06)
2134 * The system also has a pair of internal speakers, and a headphone jack.
2135 * These are both connected to Line2 on the codec, hence to DAC 02.
2137 * There is a variable resistor to control the speaker or headphone
2138 * volume. This is a hardware-only device without a software API.
2140 * Plugging headphones in will disable the internal speakers. This is
2141 * implemented in hardware, not via the driver using jack sense. In
2142 * a similar fashion, plugging into the rear socket marked "front" will
2143 * disable both the speakers and headphones.
2145 * For input, there's a microphone jack, and an "audio in" jack.
2146 * These may not do anything useful with this driver yet, because I
2147 * haven't setup any initialization verbs for these yet...
2150 static hda_nid_t alc880_w810_dac_nids[3] = {
2151 /* front, rear/surround, clfe */
2152 0x02, 0x03, 0x04
2155 /* fixed 6 channels */
2156 static struct hda_channel_mode alc880_w810_modes[1] = {
2157 { 6, NULL }
2160 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2161 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2162 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2163 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2164 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2165 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2166 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2167 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2168 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2169 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2170 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2171 { } /* end */
2176 * Z710V model
2178 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2179 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2180 * Line = 0x1a
2183 static hda_nid_t alc880_z71v_dac_nids[1] = {
2184 0x02
2186 #define ALC880_Z71V_HP_DAC 0x03
2188 /* fixed 2 channels */
2189 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2190 { 2, NULL }
2193 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2194 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2195 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2196 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2197 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2198 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2199 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2202 { } /* end */
2207 * ALC880 F1734 model
2209 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2210 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2213 static hda_nid_t alc880_f1734_dac_nids[1] = {
2214 0x03
2216 #define ALC880_F1734_HP_DAC 0x02
2218 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2219 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2220 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2221 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2222 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2223 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2224 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2227 { } /* end */
2230 static struct hda_input_mux alc880_f1734_capture_source = {
2231 .num_items = 2,
2232 .items = {
2233 { "Mic", 0x1 },
2234 { "CD", 0x4 },
2240 * ALC880 ASUS model
2242 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2243 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2244 * Mic = 0x18, Line = 0x1a
2247 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2248 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2250 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2251 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2252 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2254 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2255 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2256 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2257 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2258 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2259 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2260 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2261 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2262 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2264 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2266 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2267 .name = "Channel Mode",
2268 .info = alc_ch_mode_info,
2269 .get = alc_ch_mode_get,
2270 .put = alc_ch_mode_put,
2272 { } /* end */
2276 * ALC880 ASUS W1V model
2278 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2279 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2280 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2283 /* additional mixers to alc880_asus_mixer */
2284 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2285 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2286 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2287 { } /* end */
2290 /* TCL S700 */
2291 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2292 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2293 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2294 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2295 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2296 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2298 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2299 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2300 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2301 { } /* end */
2304 /* Uniwill */
2305 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2306 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2307 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2308 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2309 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2310 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2311 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2312 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2313 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2314 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2315 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2317 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2318 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2320 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2321 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2324 .name = "Channel Mode",
2325 .info = alc_ch_mode_info,
2326 .get = alc_ch_mode_get,
2327 .put = alc_ch_mode_put,
2329 { } /* end */
2332 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2333 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2334 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2336 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2337 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2338 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2339 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2340 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2341 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2342 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2343 { } /* end */
2346 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2347 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2348 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2349 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2350 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2353 { } /* end */
2357 * virtual master controls
2361 * slave controls for virtual master
2363 static const char *alc_slave_vols[] = {
2364 "Front Playback Volume",
2365 "Surround Playback Volume",
2366 "Center Playback Volume",
2367 "LFE Playback Volume",
2368 "Side Playback Volume",
2369 "Headphone Playback Volume",
2370 "Speaker Playback Volume",
2371 "Mono Playback Volume",
2372 "Line-Out Playback Volume",
2373 "PCM Playback Volume",
2374 NULL,
2377 static const char *alc_slave_sws[] = {
2378 "Front Playback Switch",
2379 "Surround Playback Switch",
2380 "Center Playback Switch",
2381 "LFE Playback Switch",
2382 "Side Playback Switch",
2383 "Headphone Playback Switch",
2384 "Speaker Playback Switch",
2385 "Mono Playback Switch",
2386 "IEC958 Playback Switch",
2387 NULL,
2391 * build control elements
2394 static void alc_free_kctls(struct hda_codec *codec);
2396 /* additional beep mixers; the actual parameters are overwritten at build */
2397 static struct snd_kcontrol_new alc_beep_mixer[] = {
2398 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2399 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2400 { } /* end */
2403 static int alc_build_controls(struct hda_codec *codec)
2405 struct alc_spec *spec = codec->spec;
2406 int err;
2407 int i;
2409 for (i = 0; i < spec->num_mixers; i++) {
2410 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2411 if (err < 0)
2412 return err;
2414 if (spec->cap_mixer) {
2415 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2416 if (err < 0)
2417 return err;
2419 if (spec->multiout.dig_out_nid) {
2420 err = snd_hda_create_spdif_out_ctls(codec,
2421 spec->multiout.dig_out_nid);
2422 if (err < 0)
2423 return err;
2424 if (!spec->no_analog) {
2425 err = snd_hda_create_spdif_share_sw(codec,
2426 &spec->multiout);
2427 if (err < 0)
2428 return err;
2429 spec->multiout.share_spdif = 1;
2432 if (spec->dig_in_nid) {
2433 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2434 if (err < 0)
2435 return err;
2438 /* create beep controls if needed */
2439 if (spec->beep_amp) {
2440 struct snd_kcontrol_new *knew;
2441 for (knew = alc_beep_mixer; knew->name; knew++) {
2442 struct snd_kcontrol *kctl;
2443 kctl = snd_ctl_new1(knew, codec);
2444 if (!kctl)
2445 return -ENOMEM;
2446 kctl->private_value = spec->beep_amp;
2447 err = snd_hda_ctl_add(codec, kctl);
2448 if (err < 0)
2449 return err;
2453 /* if we have no master control, let's create it */
2454 if (!spec->no_analog &&
2455 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2456 unsigned int vmaster_tlv[4];
2457 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2458 HDA_OUTPUT, vmaster_tlv);
2459 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2460 vmaster_tlv, alc_slave_vols);
2461 if (err < 0)
2462 return err;
2464 if (!spec->no_analog &&
2465 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2466 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2467 NULL, alc_slave_sws);
2468 if (err < 0)
2469 return err;
2472 alc_free_kctls(codec); /* no longer needed */
2473 return 0;
2478 * initialize the codec volumes, etc
2482 * generic initialization of ADC, input mixers and output mixers
2484 static struct hda_verb alc880_volume_init_verbs[] = {
2486 * Unmute ADC0-2 and set the default input to mic-in
2488 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2490 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2491 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2492 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2493 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2495 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2496 * mixer widget
2497 * Note: PASD motherboards uses the Line In 2 as the input for front
2498 * panel mic (mic 2)
2500 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2510 * Set up output mixers (0x0c - 0x0f)
2512 /* set vol=0 to output mixers */
2513 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2516 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2517 /* set up input amps for analog loopback */
2518 /* Amp Indices: DAC = 0, mixer = 1 */
2519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2522 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2523 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2524 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2525 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2526 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2532 * 3-stack pin configuration:
2533 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2535 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2537 * preset connection lists of input pins
2538 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2540 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2541 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2542 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2545 * Set pin mode and muting
2547 /* set front pin widgets 0x14 for output */
2548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2549 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2550 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2551 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2552 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2553 /* Mic2 (as headphone out) for HP output */
2554 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2555 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2556 /* Line In pin widget for input */
2557 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2558 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2559 /* Line2 (as front mic) pin widget for input and vref at 80% */
2560 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2561 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2562 /* CD pin widget for input */
2563 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2569 * 5-stack pin configuration:
2570 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2571 * line-in/side = 0x1a, f-mic = 0x1b
2573 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2575 * preset connection lists of input pins
2576 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2578 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2579 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2582 * Set pin mode and muting
2584 /* set pin widgets 0x14-0x17 for output */
2585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2587 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2588 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2589 /* unmute pins for output (no gain on this amp) */
2590 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2592 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2593 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2595 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2596 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2597 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2598 /* Mic2 (as headphone out) for HP output */
2599 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2601 /* Line In pin widget for input */
2602 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2603 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2604 /* Line2 (as front mic) pin widget for input and vref at 80% */
2605 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2606 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2607 /* CD pin widget for input */
2608 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2614 * W810 pin configuration:
2615 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2617 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2618 /* hphone/speaker input selector: front DAC */
2619 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2622 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2623 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2625 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2626 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2628 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2629 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2635 * Z71V pin configuration:
2636 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2638 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2640 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2641 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2642 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2644 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2645 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2646 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2647 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2653 * 6-stack pin configuration:
2654 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2655 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2657 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2658 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2660 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2661 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2665 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2666 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2667 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2669 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2670 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2671 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2672 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2673 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2674 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2675 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2676 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2677 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2683 * Uniwill pin configuration:
2684 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2685 * line = 0x1a
2687 static struct hda_verb alc880_uniwill_init_verbs[] = {
2688 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2690 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2691 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2692 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2694 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2695 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2696 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2697 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2700 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2701 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2703 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2705 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2706 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2707 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2708 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2709 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2710 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2711 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2712 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2713 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2715 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2716 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2722 * Uniwill P53
2723 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2725 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2726 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2729 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2732 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2733 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2734 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2735 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2736 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2737 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2738 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2739 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2741 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2742 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2743 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2744 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2745 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2746 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2748 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2749 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2754 static struct hda_verb alc880_beep_init_verbs[] = {
2755 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2759 /* auto-toggle front mic */
2760 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2762 unsigned int present;
2763 unsigned char bits;
2765 present = snd_hda_codec_read(codec, 0x18, 0,
2766 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2767 bits = present ? HDA_AMP_MUTE : 0;
2768 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2771 static void alc880_uniwill_setup(struct hda_codec *codec)
2773 struct alc_spec *spec = codec->spec;
2775 spec->autocfg.hp_pins[0] = 0x14;
2776 spec->autocfg.speaker_pins[0] = 0x15;
2777 spec->autocfg.speaker_pins[0] = 0x16;
2780 static void alc880_uniwill_init_hook(struct hda_codec *codec)
2782 alc_automute_amp(codec);
2783 alc880_uniwill_mic_automute(codec);
2786 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2787 unsigned int res)
2789 /* Looks like the unsol event is incompatible with the standard
2790 * definition. 4bit tag is placed at 28 bit!
2792 switch (res >> 28) {
2793 case ALC880_MIC_EVENT:
2794 alc880_uniwill_mic_automute(codec);
2795 break;
2796 default:
2797 alc_automute_amp_unsol_event(codec, res);
2798 break;
2802 static void alc880_uniwill_p53_setup(struct hda_codec *codec)
2804 struct alc_spec *spec = codec->spec;
2806 spec->autocfg.hp_pins[0] = 0x14;
2807 spec->autocfg.speaker_pins[0] = 0x15;
2810 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2812 unsigned int present;
2814 present = snd_hda_codec_read(codec, 0x21, 0,
2815 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2816 present &= HDA_AMP_VOLMASK;
2817 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2818 HDA_AMP_VOLMASK, present);
2819 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2820 HDA_AMP_VOLMASK, present);
2823 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2824 unsigned int res)
2826 /* Looks like the unsol event is incompatible with the standard
2827 * definition. 4bit tag is placed at 28 bit!
2829 if ((res >> 28) == ALC880_DCVOL_EVENT)
2830 alc880_uniwill_p53_dcvol_automute(codec);
2831 else
2832 alc_automute_amp_unsol_event(codec, res);
2836 * F1734 pin configuration:
2837 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2839 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2840 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2841 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2842 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2843 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2844 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2851 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2853 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2854 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2855 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2857 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2858 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2859 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2861 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2862 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2868 * ASUS pin configuration:
2869 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2871 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2872 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2873 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2874 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2875 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2879 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2881 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2883 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2884 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2886 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2887 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2888 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2892 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2894 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2899 /* Enable GPIO mask and set output */
2900 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2901 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2902 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
2904 /* Clevo m520g init */
2905 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2906 /* headphone output */
2907 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2908 /* line-out */
2909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2911 /* Line-in */
2912 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2913 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2914 /* CD */
2915 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2916 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2917 /* Mic1 (rear panel) */
2918 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2919 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2920 /* Mic2 (front panel) */
2921 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2922 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2923 /* headphone */
2924 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2925 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2926 /* change to EAPD mode */
2927 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2928 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2933 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2934 /* change to EAPD mode */
2935 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2936 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2938 /* Headphone output */
2939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2940 /* Front output*/
2941 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2942 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2944 /* Line In pin widget for input */
2945 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2946 /* CD pin widget for input */
2947 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2948 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2951 /* change to EAPD mode */
2952 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2953 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2959 * LG m1 express dual
2961 * Pin assignment:
2962 * Rear Line-In/Out (blue): 0x14
2963 * Build-in Mic-In: 0x15
2964 * Speaker-out: 0x17
2965 * HP-Out (green): 0x1b
2966 * Mic-In/Out (red): 0x19
2967 * SPDIF-Out: 0x1e
2970 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2971 static hda_nid_t alc880_lg_dac_nids[3] = {
2972 0x05, 0x02, 0x03
2975 /* seems analog CD is not working */
2976 static struct hda_input_mux alc880_lg_capture_source = {
2977 .num_items = 3,
2978 .items = {
2979 { "Mic", 0x1 },
2980 { "Line", 0x5 },
2981 { "Internal Mic", 0x6 },
2985 /* 2,4,6 channel modes */
2986 static struct hda_verb alc880_lg_ch2_init[] = {
2987 /* set line-in and mic-in to input */
2988 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2989 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2993 static struct hda_verb alc880_lg_ch4_init[] = {
2994 /* set line-in to out and mic-in to input */
2995 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2996 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3000 static struct hda_verb alc880_lg_ch6_init[] = {
3001 /* set line-in and mic-in to output */
3002 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3003 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3007 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3008 { 2, alc880_lg_ch2_init },
3009 { 4, alc880_lg_ch4_init },
3010 { 6, alc880_lg_ch6_init },
3013 static struct snd_kcontrol_new alc880_lg_mixer[] = {
3014 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3015 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
3016 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3017 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3018 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3019 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3020 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3021 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3024 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3025 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3026 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3027 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3030 .name = "Channel Mode",
3031 .info = alc_ch_mode_info,
3032 .get = alc_ch_mode_get,
3033 .put = alc_ch_mode_put,
3035 { } /* end */
3038 static struct hda_verb alc880_lg_init_verbs[] = {
3039 /* set capture source to mic-in */
3040 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3041 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3043 /* mute all amp mixer inputs */
3044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
3045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3047 /* line-in to input */
3048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3050 /* built-in mic */
3051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3053 /* speaker-out */
3054 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3056 /* mic-in to input */
3057 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3058 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3059 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3060 /* HP-out */
3061 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3062 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3063 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3064 /* jack sense */
3065 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3069 /* toggle speaker-output according to the hp-jack state */
3070 static void alc880_lg_setup(struct hda_codec *codec)
3072 struct alc_spec *spec = codec->spec;
3074 spec->autocfg.hp_pins[0] = 0x1b;
3075 spec->autocfg.speaker_pins[0] = 0x17;
3079 * LG LW20
3081 * Pin assignment:
3082 * Speaker-out: 0x14
3083 * Mic-In: 0x18
3084 * Built-in Mic-In: 0x19
3085 * Line-In: 0x1b
3086 * HP-Out: 0x1a
3087 * SPDIF-Out: 0x1e
3090 static struct hda_input_mux alc880_lg_lw_capture_source = {
3091 .num_items = 3,
3092 .items = {
3093 { "Mic", 0x0 },
3094 { "Internal Mic", 0x1 },
3095 { "Line In", 0x2 },
3099 #define alc880_lg_lw_modes alc880_threestack_modes
3101 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
3102 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3103 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3104 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3105 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3106 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3107 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3108 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3109 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3114 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3115 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3118 .name = "Channel Mode",
3119 .info = alc_ch_mode_info,
3120 .get = alc_ch_mode_get,
3121 .put = alc_ch_mode_put,
3123 { } /* end */
3126 static struct hda_verb alc880_lg_lw_init_verbs[] = {
3127 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3128 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3129 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3131 /* set capture source to mic-in */
3132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3133 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3134 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3136 /* speaker-out */
3137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3138 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3139 /* HP-out */
3140 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3142 /* mic-in to input */
3143 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3144 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3145 /* built-in mic */
3146 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3148 /* jack sense */
3149 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3153 /* toggle speaker-output according to the hp-jack state */
3154 static void alc880_lg_lw_setup(struct hda_codec *codec)
3156 struct alc_spec *spec = codec->spec;
3158 spec->autocfg.hp_pins[0] = 0x1b;
3159 spec->autocfg.speaker_pins[0] = 0x14;
3162 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3163 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3164 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3166 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3167 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3168 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3169 { } /* end */
3172 static struct hda_input_mux alc880_medion_rim_capture_source = {
3173 .num_items = 2,
3174 .items = {
3175 { "Mic", 0x0 },
3176 { "Internal Mic", 0x1 },
3180 static struct hda_verb alc880_medion_rim_init_verbs[] = {
3181 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3184 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3186 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3187 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3188 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3189 /* Mic2 (as headphone out) for HP output */
3190 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3191 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3192 /* Internal Speaker */
3193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3196 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3197 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3199 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3203 /* toggle speaker-output according to the hp-jack state */
3204 static void alc880_medion_rim_automute(struct hda_codec *codec)
3206 struct alc_spec *spec = codec->spec;
3207 alc_automute_amp(codec);
3208 /* toggle EAPD */
3209 if (spec->jack_present)
3210 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3211 else
3212 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3215 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3216 unsigned int res)
3218 /* Looks like the unsol event is incompatible with the standard
3219 * definition. 4bit tag is placed at 28 bit!
3221 if ((res >> 28) == ALC880_HP_EVENT)
3222 alc880_medion_rim_automute(codec);
3225 static void alc880_medion_rim_setup(struct hda_codec *codec)
3227 struct alc_spec *spec = codec->spec;
3229 spec->autocfg.hp_pins[0] = 0x14;
3230 spec->autocfg.speaker_pins[0] = 0x1b;
3233 #ifdef CONFIG_SND_HDA_POWER_SAVE
3234 static struct hda_amp_list alc880_loopbacks[] = {
3235 { 0x0b, HDA_INPUT, 0 },
3236 { 0x0b, HDA_INPUT, 1 },
3237 { 0x0b, HDA_INPUT, 2 },
3238 { 0x0b, HDA_INPUT, 3 },
3239 { 0x0b, HDA_INPUT, 4 },
3240 { } /* end */
3243 static struct hda_amp_list alc880_lg_loopbacks[] = {
3244 { 0x0b, HDA_INPUT, 1 },
3245 { 0x0b, HDA_INPUT, 6 },
3246 { 0x0b, HDA_INPUT, 7 },
3247 { } /* end */
3249 #endif
3252 * Common callbacks
3255 static int alc_init(struct hda_codec *codec)
3257 struct alc_spec *spec = codec->spec;
3258 unsigned int i;
3260 alc_fix_pll(codec);
3261 alc_auto_init_amp(codec, spec->init_amp);
3263 for (i = 0; i < spec->num_init_verbs; i++)
3264 snd_hda_sequence_write(codec, spec->init_verbs[i]);
3266 if (spec->init_hook)
3267 spec->init_hook(codec);
3269 return 0;
3272 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3274 struct alc_spec *spec = codec->spec;
3276 if (spec->unsol_event)
3277 spec->unsol_event(codec, res);
3280 #ifdef CONFIG_SND_HDA_POWER_SAVE
3281 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3283 struct alc_spec *spec = codec->spec;
3284 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3286 #endif
3289 * Analog playback callbacks
3291 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3292 struct hda_codec *codec,
3293 struct snd_pcm_substream *substream)
3295 struct alc_spec *spec = codec->spec;
3296 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3297 hinfo);
3300 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3301 struct hda_codec *codec,
3302 unsigned int stream_tag,
3303 unsigned int format,
3304 struct snd_pcm_substream *substream)
3306 struct alc_spec *spec = codec->spec;
3307 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3308 stream_tag, format, substream);
3311 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3312 struct hda_codec *codec,
3313 struct snd_pcm_substream *substream)
3315 struct alc_spec *spec = codec->spec;
3316 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3320 * Digital out
3322 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3323 struct hda_codec *codec,
3324 struct snd_pcm_substream *substream)
3326 struct alc_spec *spec = codec->spec;
3327 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3330 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3331 struct hda_codec *codec,
3332 unsigned int stream_tag,
3333 unsigned int format,
3334 struct snd_pcm_substream *substream)
3336 struct alc_spec *spec = codec->spec;
3337 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3338 stream_tag, format, substream);
3341 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3342 struct hda_codec *codec,
3343 struct snd_pcm_substream *substream)
3345 struct alc_spec *spec = codec->spec;
3346 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3349 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3350 struct hda_codec *codec,
3351 struct snd_pcm_substream *substream)
3353 struct alc_spec *spec = codec->spec;
3354 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3358 * Analog capture
3360 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3361 struct hda_codec *codec,
3362 unsigned int stream_tag,
3363 unsigned int format,
3364 struct snd_pcm_substream *substream)
3366 struct alc_spec *spec = codec->spec;
3368 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
3369 stream_tag, 0, format);
3370 return 0;
3373 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3374 struct hda_codec *codec,
3375 struct snd_pcm_substream *substream)
3377 struct alc_spec *spec = codec->spec;
3379 snd_hda_codec_cleanup_stream(codec,
3380 spec->adc_nids[substream->number + 1]);
3381 return 0;
3387 static struct hda_pcm_stream alc880_pcm_analog_playback = {
3388 .substreams = 1,
3389 .channels_min = 2,
3390 .channels_max = 8,
3391 /* NID is set in alc_build_pcms */
3392 .ops = {
3393 .open = alc880_playback_pcm_open,
3394 .prepare = alc880_playback_pcm_prepare,
3395 .cleanup = alc880_playback_pcm_cleanup
3399 static struct hda_pcm_stream alc880_pcm_analog_capture = {
3400 .substreams = 1,
3401 .channels_min = 2,
3402 .channels_max = 2,
3403 /* NID is set in alc_build_pcms */
3406 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3407 .substreams = 1,
3408 .channels_min = 2,
3409 .channels_max = 2,
3410 /* NID is set in alc_build_pcms */
3413 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3414 .substreams = 2, /* can be overridden */
3415 .channels_min = 2,
3416 .channels_max = 2,
3417 /* NID is set in alc_build_pcms */
3418 .ops = {
3419 .prepare = alc880_alt_capture_pcm_prepare,
3420 .cleanup = alc880_alt_capture_pcm_cleanup
3424 static struct hda_pcm_stream alc880_pcm_digital_playback = {
3425 .substreams = 1,
3426 .channels_min = 2,
3427 .channels_max = 2,
3428 /* NID is set in alc_build_pcms */
3429 .ops = {
3430 .open = alc880_dig_playback_pcm_open,
3431 .close = alc880_dig_playback_pcm_close,
3432 .prepare = alc880_dig_playback_pcm_prepare,
3433 .cleanup = alc880_dig_playback_pcm_cleanup
3437 static struct hda_pcm_stream alc880_pcm_digital_capture = {
3438 .substreams = 1,
3439 .channels_min = 2,
3440 .channels_max = 2,
3441 /* NID is set in alc_build_pcms */
3444 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
3445 static struct hda_pcm_stream alc_pcm_null_stream = {
3446 .substreams = 0,
3447 .channels_min = 0,
3448 .channels_max = 0,
3451 static int alc_build_pcms(struct hda_codec *codec)
3453 struct alc_spec *spec = codec->spec;
3454 struct hda_pcm *info = spec->pcm_rec;
3455 int i;
3457 codec->num_pcms = 1;
3458 codec->pcm_info = info;
3460 if (spec->no_analog)
3461 goto skip_analog;
3463 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3464 "%s Analog", codec->chip_name);
3465 info->name = spec->stream_name_analog;
3467 if (spec->stream_analog_playback) {
3468 if (snd_BUG_ON(!spec->multiout.dac_nids))
3469 return -EINVAL;
3470 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3471 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3473 if (spec->stream_analog_capture) {
3474 if (snd_BUG_ON(!spec->adc_nids))
3475 return -EINVAL;
3476 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3477 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3480 if (spec->channel_mode) {
3481 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3482 for (i = 0; i < spec->num_channel_mode; i++) {
3483 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3484 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3489 skip_analog:
3490 /* SPDIF for stream index #1 */
3491 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3492 snprintf(spec->stream_name_digital,
3493 sizeof(spec->stream_name_digital),
3494 "%s Digital", codec->chip_name);
3495 codec->num_pcms = 2;
3496 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
3497 info = spec->pcm_rec + 1;
3498 info->name = spec->stream_name_digital;
3499 if (spec->dig_out_type)
3500 info->pcm_type = spec->dig_out_type;
3501 else
3502 info->pcm_type = HDA_PCM_TYPE_SPDIF;
3503 if (spec->multiout.dig_out_nid &&
3504 spec->stream_digital_playback) {
3505 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3506 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3508 if (spec->dig_in_nid &&
3509 spec->stream_digital_capture) {
3510 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3511 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3513 /* FIXME: do we need this for all Realtek codec models? */
3514 codec->spdif_status_reset = 1;
3517 if (spec->no_analog)
3518 return 0;
3520 /* If the use of more than one ADC is requested for the current
3521 * model, configure a second analog capture-only PCM.
3523 /* Additional Analaog capture for index #2 */
3524 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3525 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
3526 codec->num_pcms = 3;
3527 info = spec->pcm_rec + 2;
3528 info->name = spec->stream_name_analog;
3529 if (spec->alt_dac_nid) {
3530 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3531 *spec->stream_analog_alt_playback;
3532 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3533 spec->alt_dac_nid;
3534 } else {
3535 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3536 alc_pcm_null_stream;
3537 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3539 if (spec->num_adc_nids > 1) {
3540 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3541 *spec->stream_analog_alt_capture;
3542 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3543 spec->adc_nids[1];
3544 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3545 spec->num_adc_nids - 1;
3546 } else {
3547 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3548 alc_pcm_null_stream;
3549 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
3553 return 0;
3556 static void alc_free_kctls(struct hda_codec *codec)
3558 struct alc_spec *spec = codec->spec;
3560 if (spec->kctls.list) {
3561 struct snd_kcontrol_new *kctl = spec->kctls.list;
3562 int i;
3563 for (i = 0; i < spec->kctls.used; i++)
3564 kfree(kctl[i].name);
3566 snd_array_free(&spec->kctls);
3569 static void alc_free(struct hda_codec *codec)
3571 struct alc_spec *spec = codec->spec;
3573 if (!spec)
3574 return;
3576 alc_free_kctls(codec);
3577 kfree(spec);
3578 snd_hda_detach_beep_device(codec);
3581 #ifdef SND_HDA_NEEDS_RESUME
3582 static int alc_resume(struct hda_codec *codec)
3584 codec->patch_ops.init(codec);
3585 snd_hda_codec_resume_amp(codec);
3586 snd_hda_codec_resume_cache(codec);
3587 return 0;
3589 #endif
3593 static struct hda_codec_ops alc_patch_ops = {
3594 .build_controls = alc_build_controls,
3595 .build_pcms = alc_build_pcms,
3596 .init = alc_init,
3597 .free = alc_free,
3598 .unsol_event = alc_unsol_event,
3599 #ifdef SND_HDA_NEEDS_RESUME
3600 .resume = alc_resume,
3601 #endif
3602 #ifdef CONFIG_SND_HDA_POWER_SAVE
3603 .check_power_status = alc_check_power_status,
3604 #endif
3609 * Test configuration for debugging
3611 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3612 * enum controls.
3614 #ifdef CONFIG_SND_DEBUG
3615 static hda_nid_t alc880_test_dac_nids[4] = {
3616 0x02, 0x03, 0x04, 0x05
3619 static struct hda_input_mux alc880_test_capture_source = {
3620 .num_items = 7,
3621 .items = {
3622 { "In-1", 0x0 },
3623 { "In-2", 0x1 },
3624 { "In-3", 0x2 },
3625 { "In-4", 0x3 },
3626 { "CD", 0x4 },
3627 { "Front", 0x5 },
3628 { "Surround", 0x6 },
3632 static struct hda_channel_mode alc880_test_modes[4] = {
3633 { 2, NULL },
3634 { 4, NULL },
3635 { 6, NULL },
3636 { 8, NULL },
3639 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3640 struct snd_ctl_elem_info *uinfo)
3642 static char *texts[] = {
3643 "N/A", "Line Out", "HP Out",
3644 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3646 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3647 uinfo->count = 1;
3648 uinfo->value.enumerated.items = 8;
3649 if (uinfo->value.enumerated.item >= 8)
3650 uinfo->value.enumerated.item = 7;
3651 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3652 return 0;
3655 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3656 struct snd_ctl_elem_value *ucontrol)
3658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3659 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3660 unsigned int pin_ctl, item = 0;
3662 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3663 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3664 if (pin_ctl & AC_PINCTL_OUT_EN) {
3665 if (pin_ctl & AC_PINCTL_HP_EN)
3666 item = 2;
3667 else
3668 item = 1;
3669 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3670 switch (pin_ctl & AC_PINCTL_VREFEN) {
3671 case AC_PINCTL_VREF_HIZ: item = 3; break;
3672 case AC_PINCTL_VREF_50: item = 4; break;
3673 case AC_PINCTL_VREF_GRD: item = 5; break;
3674 case AC_PINCTL_VREF_80: item = 6; break;
3675 case AC_PINCTL_VREF_100: item = 7; break;
3678 ucontrol->value.enumerated.item[0] = item;
3679 return 0;
3682 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3683 struct snd_ctl_elem_value *ucontrol)
3685 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3686 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3687 static unsigned int ctls[] = {
3688 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3689 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3690 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3691 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3692 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3693 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3695 unsigned int old_ctl, new_ctl;
3697 old_ctl = snd_hda_codec_read(codec, nid, 0,
3698 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3699 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3700 if (old_ctl != new_ctl) {
3701 int val;
3702 snd_hda_codec_write_cache(codec, nid, 0,
3703 AC_VERB_SET_PIN_WIDGET_CONTROL,
3704 new_ctl);
3705 val = ucontrol->value.enumerated.item[0] >= 3 ?
3706 HDA_AMP_MUTE : 0;
3707 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3708 HDA_AMP_MUTE, val);
3709 return 1;
3711 return 0;
3714 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3715 struct snd_ctl_elem_info *uinfo)
3717 static char *texts[] = {
3718 "Front", "Surround", "CLFE", "Side"
3720 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3721 uinfo->count = 1;
3722 uinfo->value.enumerated.items = 4;
3723 if (uinfo->value.enumerated.item >= 4)
3724 uinfo->value.enumerated.item = 3;
3725 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3726 return 0;
3729 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3730 struct snd_ctl_elem_value *ucontrol)
3732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3733 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3734 unsigned int sel;
3736 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3737 ucontrol->value.enumerated.item[0] = sel & 3;
3738 return 0;
3741 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3742 struct snd_ctl_elem_value *ucontrol)
3744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3745 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3746 unsigned int sel;
3748 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3749 if (ucontrol->value.enumerated.item[0] != sel) {
3750 sel = ucontrol->value.enumerated.item[0] & 3;
3751 snd_hda_codec_write_cache(codec, nid, 0,
3752 AC_VERB_SET_CONNECT_SEL, sel);
3753 return 1;
3755 return 0;
3758 #define PIN_CTL_TEST(xname,nid) { \
3759 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3760 .name = xname, \
3761 .info = alc_test_pin_ctl_info, \
3762 .get = alc_test_pin_ctl_get, \
3763 .put = alc_test_pin_ctl_put, \
3764 .private_value = nid \
3767 #define PIN_SRC_TEST(xname,nid) { \
3768 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3769 .name = xname, \
3770 .info = alc_test_pin_src_info, \
3771 .get = alc_test_pin_src_get, \
3772 .put = alc_test_pin_src_put, \
3773 .private_value = nid \
3776 static struct snd_kcontrol_new alc880_test_mixer[] = {
3777 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3778 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3779 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3780 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3781 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3782 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3783 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3784 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
3785 PIN_CTL_TEST("Front Pin Mode", 0x14),
3786 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3787 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3788 PIN_CTL_TEST("Side Pin Mode", 0x17),
3789 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3790 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3791 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3792 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3793 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3794 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3795 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3796 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3797 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3798 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3799 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3800 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3801 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3802 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3803 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3804 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3805 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3806 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
3808 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3809 .name = "Channel Mode",
3810 .info = alc_ch_mode_info,
3811 .get = alc_ch_mode_get,
3812 .put = alc_ch_mode_put,
3814 { } /* end */
3817 static struct hda_verb alc880_test_init_verbs[] = {
3818 /* Unmute inputs of 0x0c - 0x0f */
3819 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3820 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3821 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3822 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3823 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3824 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3825 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3826 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3827 /* Vol output for 0x0c-0x0f */
3828 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3829 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3830 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3831 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3832 /* Set output pins 0x14-0x17 */
3833 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3834 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3835 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3836 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3837 /* Unmute output pins 0x14-0x17 */
3838 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3839 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3840 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3841 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3842 /* Set input pins 0x18-0x1c */
3843 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3844 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3845 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3846 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3847 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3848 /* Mute input pins 0x18-0x1b */
3849 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3850 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3851 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3852 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3853 /* ADC set up */
3854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3855 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3856 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3857 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3859 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3860 /* Analog input/passthru */
3861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3864 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3865 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3868 #endif
3873 static const char *alc880_models[ALC880_MODEL_LAST] = {
3874 [ALC880_3ST] = "3stack",
3875 [ALC880_TCL_S700] = "tcl",
3876 [ALC880_3ST_DIG] = "3stack-digout",
3877 [ALC880_CLEVO] = "clevo",
3878 [ALC880_5ST] = "5stack",
3879 [ALC880_5ST_DIG] = "5stack-digout",
3880 [ALC880_W810] = "w810",
3881 [ALC880_Z71V] = "z71v",
3882 [ALC880_6ST] = "6stack",
3883 [ALC880_6ST_DIG] = "6stack-digout",
3884 [ALC880_ASUS] = "asus",
3885 [ALC880_ASUS_W1V] = "asus-w1v",
3886 [ALC880_ASUS_DIG] = "asus-dig",
3887 [ALC880_ASUS_DIG2] = "asus-dig2",
3888 [ALC880_UNIWILL_DIG] = "uniwill",
3889 [ALC880_UNIWILL_P53] = "uniwill-p53",
3890 [ALC880_FUJITSU] = "fujitsu",
3891 [ALC880_F1734] = "F1734",
3892 [ALC880_LG] = "lg",
3893 [ALC880_LG_LW] = "lg-lw",
3894 [ALC880_MEDION_RIM] = "medion",
3895 #ifdef CONFIG_SND_DEBUG
3896 [ALC880_TEST] = "test",
3897 #endif
3898 [ALC880_AUTO] = "auto",
3901 static struct snd_pci_quirk alc880_cfg_tbl[] = {
3902 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
3903 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3904 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3905 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3906 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3907 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3908 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3909 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3910 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
3911 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3912 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
3913 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3914 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3915 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3916 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3917 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3918 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3919 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3920 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3921 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3922 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
3923 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
3924 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3925 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3926 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
3927 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
3928 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
3929 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3930 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
3931 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3932 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
3933 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3934 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3935 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3936 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
3937 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3938 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
3939 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
3940 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
3941 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
3942 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
3943 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3944 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
3945 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
3946 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
3947 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
3948 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
3949 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
3950 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
3951 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
3952 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
3953 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
3954 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3955 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
3956 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
3957 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3958 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3959 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3960 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
3961 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3962 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
3963 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
3964 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
3965 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3966 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
3967 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3968 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3969 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
3970 /* default Intel */
3971 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
3972 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3973 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
3978 * ALC880 codec presets
3980 static struct alc_config_preset alc880_presets[] = {
3981 [ALC880_3ST] = {
3982 .mixers = { alc880_three_stack_mixer },
3983 .init_verbs = { alc880_volume_init_verbs,
3984 alc880_pin_3stack_init_verbs },
3985 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3986 .dac_nids = alc880_dac_nids,
3987 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3988 .channel_mode = alc880_threestack_modes,
3989 .need_dac_fix = 1,
3990 .input_mux = &alc880_capture_source,
3992 [ALC880_3ST_DIG] = {
3993 .mixers = { alc880_three_stack_mixer },
3994 .init_verbs = { alc880_volume_init_verbs,
3995 alc880_pin_3stack_init_verbs },
3996 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3997 .dac_nids = alc880_dac_nids,
3998 .dig_out_nid = ALC880_DIGOUT_NID,
3999 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4000 .channel_mode = alc880_threestack_modes,
4001 .need_dac_fix = 1,
4002 .input_mux = &alc880_capture_source,
4004 [ALC880_TCL_S700] = {
4005 .mixers = { alc880_tcl_s700_mixer },
4006 .init_verbs = { alc880_volume_init_verbs,
4007 alc880_pin_tcl_S700_init_verbs,
4008 alc880_gpio2_init_verbs },
4009 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4010 .dac_nids = alc880_dac_nids,
4011 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4012 .num_adc_nids = 1, /* single ADC */
4013 .hp_nid = 0x03,
4014 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4015 .channel_mode = alc880_2_jack_modes,
4016 .input_mux = &alc880_capture_source,
4018 [ALC880_5ST] = {
4019 .mixers = { alc880_three_stack_mixer,
4020 alc880_five_stack_mixer},
4021 .init_verbs = { alc880_volume_init_verbs,
4022 alc880_pin_5stack_init_verbs },
4023 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4024 .dac_nids = alc880_dac_nids,
4025 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4026 .channel_mode = alc880_fivestack_modes,
4027 .input_mux = &alc880_capture_source,
4029 [ALC880_5ST_DIG] = {
4030 .mixers = { alc880_three_stack_mixer,
4031 alc880_five_stack_mixer },
4032 .init_verbs = { alc880_volume_init_verbs,
4033 alc880_pin_5stack_init_verbs },
4034 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4035 .dac_nids = alc880_dac_nids,
4036 .dig_out_nid = ALC880_DIGOUT_NID,
4037 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4038 .channel_mode = alc880_fivestack_modes,
4039 .input_mux = &alc880_capture_source,
4041 [ALC880_6ST] = {
4042 .mixers = { alc880_six_stack_mixer },
4043 .init_verbs = { alc880_volume_init_verbs,
4044 alc880_pin_6stack_init_verbs },
4045 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4046 .dac_nids = alc880_6st_dac_nids,
4047 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4048 .channel_mode = alc880_sixstack_modes,
4049 .input_mux = &alc880_6stack_capture_source,
4051 [ALC880_6ST_DIG] = {
4052 .mixers = { alc880_six_stack_mixer },
4053 .init_verbs = { alc880_volume_init_verbs,
4054 alc880_pin_6stack_init_verbs },
4055 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4056 .dac_nids = alc880_6st_dac_nids,
4057 .dig_out_nid = ALC880_DIGOUT_NID,
4058 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4059 .channel_mode = alc880_sixstack_modes,
4060 .input_mux = &alc880_6stack_capture_source,
4062 [ALC880_W810] = {
4063 .mixers = { alc880_w810_base_mixer },
4064 .init_verbs = { alc880_volume_init_verbs,
4065 alc880_pin_w810_init_verbs,
4066 alc880_gpio2_init_verbs },
4067 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4068 .dac_nids = alc880_w810_dac_nids,
4069 .dig_out_nid = ALC880_DIGOUT_NID,
4070 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4071 .channel_mode = alc880_w810_modes,
4072 .input_mux = &alc880_capture_source,
4074 [ALC880_Z71V] = {
4075 .mixers = { alc880_z71v_mixer },
4076 .init_verbs = { alc880_volume_init_verbs,
4077 alc880_pin_z71v_init_verbs },
4078 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4079 .dac_nids = alc880_z71v_dac_nids,
4080 .dig_out_nid = ALC880_DIGOUT_NID,
4081 .hp_nid = 0x03,
4082 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4083 .channel_mode = alc880_2_jack_modes,
4084 .input_mux = &alc880_capture_source,
4086 [ALC880_F1734] = {
4087 .mixers = { alc880_f1734_mixer },
4088 .init_verbs = { alc880_volume_init_verbs,
4089 alc880_pin_f1734_init_verbs },
4090 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4091 .dac_nids = alc880_f1734_dac_nids,
4092 .hp_nid = 0x02,
4093 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4094 .channel_mode = alc880_2_jack_modes,
4095 .input_mux = &alc880_f1734_capture_source,
4096 .unsol_event = alc880_uniwill_p53_unsol_event,
4097 .setup = alc880_uniwill_p53_setup,
4098 .init_hook = alc_automute_amp,
4100 [ALC880_ASUS] = {
4101 .mixers = { alc880_asus_mixer },
4102 .init_verbs = { alc880_volume_init_verbs,
4103 alc880_pin_asus_init_verbs,
4104 alc880_gpio1_init_verbs },
4105 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4106 .dac_nids = alc880_asus_dac_nids,
4107 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4108 .channel_mode = alc880_asus_modes,
4109 .need_dac_fix = 1,
4110 .input_mux = &alc880_capture_source,
4112 [ALC880_ASUS_DIG] = {
4113 .mixers = { alc880_asus_mixer },
4114 .init_verbs = { alc880_volume_init_verbs,
4115 alc880_pin_asus_init_verbs,
4116 alc880_gpio1_init_verbs },
4117 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4118 .dac_nids = alc880_asus_dac_nids,
4119 .dig_out_nid = ALC880_DIGOUT_NID,
4120 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4121 .channel_mode = alc880_asus_modes,
4122 .need_dac_fix = 1,
4123 .input_mux = &alc880_capture_source,
4125 [ALC880_ASUS_DIG2] = {
4126 .mixers = { alc880_asus_mixer },
4127 .init_verbs = { alc880_volume_init_verbs,
4128 alc880_pin_asus_init_verbs,
4129 alc880_gpio2_init_verbs }, /* use GPIO2 */
4130 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4131 .dac_nids = alc880_asus_dac_nids,
4132 .dig_out_nid = ALC880_DIGOUT_NID,
4133 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4134 .channel_mode = alc880_asus_modes,
4135 .need_dac_fix = 1,
4136 .input_mux = &alc880_capture_source,
4138 [ALC880_ASUS_W1V] = {
4139 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
4140 .init_verbs = { alc880_volume_init_verbs,
4141 alc880_pin_asus_init_verbs,
4142 alc880_gpio1_init_verbs },
4143 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4144 .dac_nids = alc880_asus_dac_nids,
4145 .dig_out_nid = ALC880_DIGOUT_NID,
4146 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4147 .channel_mode = alc880_asus_modes,
4148 .need_dac_fix = 1,
4149 .input_mux = &alc880_capture_source,
4151 [ALC880_UNIWILL_DIG] = {
4152 .mixers = { alc880_asus_mixer },
4153 .init_verbs = { alc880_volume_init_verbs,
4154 alc880_pin_asus_init_verbs },
4155 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4156 .dac_nids = alc880_asus_dac_nids,
4157 .dig_out_nid = ALC880_DIGOUT_NID,
4158 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4159 .channel_mode = alc880_asus_modes,
4160 .need_dac_fix = 1,
4161 .input_mux = &alc880_capture_source,
4163 [ALC880_UNIWILL] = {
4164 .mixers = { alc880_uniwill_mixer },
4165 .init_verbs = { alc880_volume_init_verbs,
4166 alc880_uniwill_init_verbs },
4167 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4168 .dac_nids = alc880_asus_dac_nids,
4169 .dig_out_nid = ALC880_DIGOUT_NID,
4170 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4171 .channel_mode = alc880_threestack_modes,
4172 .need_dac_fix = 1,
4173 .input_mux = &alc880_capture_source,
4174 .unsol_event = alc880_uniwill_unsol_event,
4175 .setup = alc880_uniwill_setup,
4176 .init_hook = alc880_uniwill_init_hook,
4178 [ALC880_UNIWILL_P53] = {
4179 .mixers = { alc880_uniwill_p53_mixer },
4180 .init_verbs = { alc880_volume_init_verbs,
4181 alc880_uniwill_p53_init_verbs },
4182 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4183 .dac_nids = alc880_asus_dac_nids,
4184 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4185 .channel_mode = alc880_threestack_modes,
4186 .input_mux = &alc880_capture_source,
4187 .unsol_event = alc880_uniwill_p53_unsol_event,
4188 .setup = alc880_uniwill_p53_setup,
4189 .init_hook = alc_automute_amp,
4191 [ALC880_FUJITSU] = {
4192 .mixers = { alc880_fujitsu_mixer },
4193 .init_verbs = { alc880_volume_init_verbs,
4194 alc880_uniwill_p53_init_verbs,
4195 alc880_beep_init_verbs },
4196 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4197 .dac_nids = alc880_dac_nids,
4198 .dig_out_nid = ALC880_DIGOUT_NID,
4199 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4200 .channel_mode = alc880_2_jack_modes,
4201 .input_mux = &alc880_capture_source,
4202 .unsol_event = alc880_uniwill_p53_unsol_event,
4203 .setup = alc880_uniwill_p53_setup,
4204 .init_hook = alc_automute_amp,
4206 [ALC880_CLEVO] = {
4207 .mixers = { alc880_three_stack_mixer },
4208 .init_verbs = { alc880_volume_init_verbs,
4209 alc880_pin_clevo_init_verbs },
4210 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4211 .dac_nids = alc880_dac_nids,
4212 .hp_nid = 0x03,
4213 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4214 .channel_mode = alc880_threestack_modes,
4215 .need_dac_fix = 1,
4216 .input_mux = &alc880_capture_source,
4218 [ALC880_LG] = {
4219 .mixers = { alc880_lg_mixer },
4220 .init_verbs = { alc880_volume_init_verbs,
4221 alc880_lg_init_verbs },
4222 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4223 .dac_nids = alc880_lg_dac_nids,
4224 .dig_out_nid = ALC880_DIGOUT_NID,
4225 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4226 .channel_mode = alc880_lg_ch_modes,
4227 .need_dac_fix = 1,
4228 .input_mux = &alc880_lg_capture_source,
4229 .unsol_event = alc_automute_amp_unsol_event,
4230 .setup = alc880_lg_setup,
4231 .init_hook = alc_automute_amp,
4232 #ifdef CONFIG_SND_HDA_POWER_SAVE
4233 .loopbacks = alc880_lg_loopbacks,
4234 #endif
4236 [ALC880_LG_LW] = {
4237 .mixers = { alc880_lg_lw_mixer },
4238 .init_verbs = { alc880_volume_init_verbs,
4239 alc880_lg_lw_init_verbs },
4240 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4241 .dac_nids = alc880_dac_nids,
4242 .dig_out_nid = ALC880_DIGOUT_NID,
4243 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4244 .channel_mode = alc880_lg_lw_modes,
4245 .input_mux = &alc880_lg_lw_capture_source,
4246 .unsol_event = alc_automute_amp_unsol_event,
4247 .setup = alc880_lg_lw_setup,
4248 .init_hook = alc_automute_amp,
4250 [ALC880_MEDION_RIM] = {
4251 .mixers = { alc880_medion_rim_mixer },
4252 .init_verbs = { alc880_volume_init_verbs,
4253 alc880_medion_rim_init_verbs,
4254 alc_gpio2_init_verbs },
4255 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4256 .dac_nids = alc880_dac_nids,
4257 .dig_out_nid = ALC880_DIGOUT_NID,
4258 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4259 .channel_mode = alc880_2_jack_modes,
4260 .input_mux = &alc880_medion_rim_capture_source,
4261 .unsol_event = alc880_medion_rim_unsol_event,
4262 .setup = alc880_medion_rim_setup,
4263 .init_hook = alc880_medion_rim_automute,
4265 #ifdef CONFIG_SND_DEBUG
4266 [ALC880_TEST] = {
4267 .mixers = { alc880_test_mixer },
4268 .init_verbs = { alc880_test_init_verbs },
4269 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4270 .dac_nids = alc880_test_dac_nids,
4271 .dig_out_nid = ALC880_DIGOUT_NID,
4272 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4273 .channel_mode = alc880_test_modes,
4274 .input_mux = &alc880_test_capture_source,
4276 #endif
4280 * Automatic parse of I/O pins from the BIOS configuration
4283 enum {
4284 ALC_CTL_WIDGET_VOL,
4285 ALC_CTL_WIDGET_MUTE,
4286 ALC_CTL_BIND_MUTE,
4288 static struct snd_kcontrol_new alc880_control_templates[] = {
4289 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4290 HDA_CODEC_MUTE(NULL, 0, 0, 0),
4291 HDA_BIND_MUTE(NULL, 0, 0, 0),
4294 /* add dynamic controls */
4295 static int add_control(struct alc_spec *spec, int type, const char *name,
4296 unsigned long val)
4298 struct snd_kcontrol_new *knew;
4300 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4301 knew = snd_array_new(&spec->kctls);
4302 if (!knew)
4303 return -ENOMEM;
4304 *knew = alc880_control_templates[type];
4305 knew->name = kstrdup(name, GFP_KERNEL);
4306 if (!knew->name)
4307 return -ENOMEM;
4308 knew->private_value = val;
4309 return 0;
4312 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4313 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4314 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4315 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4316 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
4317 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
4318 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4319 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
4320 #define ALC880_PIN_CD_NID 0x1c
4322 /* fill in the dac_nids table from the parsed pin configuration */
4323 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4324 const struct auto_pin_cfg *cfg)
4326 hda_nid_t nid;
4327 int assigned[4];
4328 int i, j;
4330 memset(assigned, 0, sizeof(assigned));
4331 spec->multiout.dac_nids = spec->private_dac_nids;
4333 /* check the pins hardwired to audio widget */
4334 for (i = 0; i < cfg->line_outs; i++) {
4335 nid = cfg->line_out_pins[i];
4336 if (alc880_is_fixed_pin(nid)) {
4337 int idx = alc880_fixed_pin_idx(nid);
4338 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
4339 assigned[idx] = 1;
4342 /* left pins can be connect to any audio widget */
4343 for (i = 0; i < cfg->line_outs; i++) {
4344 nid = cfg->line_out_pins[i];
4345 if (alc880_is_fixed_pin(nid))
4346 continue;
4347 /* search for an empty channel */
4348 for (j = 0; j < cfg->line_outs; j++) {
4349 if (!assigned[j]) {
4350 spec->multiout.dac_nids[i] =
4351 alc880_idx_to_dac(j);
4352 assigned[j] = 1;
4353 break;
4357 spec->multiout.num_dacs = cfg->line_outs;
4358 return 0;
4361 /* add playback controls from the parsed DAC table */
4362 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4363 const struct auto_pin_cfg *cfg)
4365 char name[32];
4366 static const char *chname[4] = {
4367 "Front", "Surround", NULL /*CLFE*/, "Side"
4369 hda_nid_t nid;
4370 int i, err;
4372 for (i = 0; i < cfg->line_outs; i++) {
4373 if (!spec->multiout.dac_nids[i])
4374 continue;
4375 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4376 if (i == 2) {
4377 /* Center/LFE */
4378 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4379 "Center Playback Volume",
4380 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4381 HDA_OUTPUT));
4382 if (err < 0)
4383 return err;
4384 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4385 "LFE Playback Volume",
4386 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4387 HDA_OUTPUT));
4388 if (err < 0)
4389 return err;
4390 err = add_control(spec, ALC_CTL_BIND_MUTE,
4391 "Center Playback Switch",
4392 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4393 HDA_INPUT));
4394 if (err < 0)
4395 return err;
4396 err = add_control(spec, ALC_CTL_BIND_MUTE,
4397 "LFE Playback Switch",
4398 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4399 HDA_INPUT));
4400 if (err < 0)
4401 return err;
4402 } else {
4403 const char *pfx;
4404 if (cfg->line_outs == 1 &&
4405 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4406 pfx = "Speaker";
4407 else
4408 pfx = chname[i];
4409 sprintf(name, "%s Playback Volume", pfx);
4410 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4411 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4412 HDA_OUTPUT));
4413 if (err < 0)
4414 return err;
4415 sprintf(name, "%s Playback Switch", pfx);
4416 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4417 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4418 HDA_INPUT));
4419 if (err < 0)
4420 return err;
4423 return 0;
4426 /* add playback controls for speaker and HP outputs */
4427 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4428 const char *pfx)
4430 hda_nid_t nid;
4431 int err;
4432 char name[32];
4434 if (!pin)
4435 return 0;
4437 if (alc880_is_fixed_pin(pin)) {
4438 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
4439 /* specify the DAC as the extra output */
4440 if (!spec->multiout.hp_nid)
4441 spec->multiout.hp_nid = nid;
4442 else
4443 spec->multiout.extra_out_nid[0] = nid;
4444 /* control HP volume/switch on the output mixer amp */
4445 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
4446 sprintf(name, "%s Playback Volume", pfx);
4447 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4448 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4449 if (err < 0)
4450 return err;
4451 sprintf(name, "%s Playback Switch", pfx);
4452 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4453 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4454 if (err < 0)
4455 return err;
4456 } else if (alc880_is_multi_pin(pin)) {
4457 /* set manual connection */
4458 /* we have only a switch on HP-out PIN */
4459 sprintf(name, "%s Playback Switch", pfx);
4460 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4461 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4462 if (err < 0)
4463 return err;
4465 return 0;
4468 /* create input playback/capture controls for the given pin */
4469 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4470 const char *ctlname,
4471 int idx, hda_nid_t mix_nid)
4473 char name[32];
4474 int err;
4476 sprintf(name, "%s Playback Volume", ctlname);
4477 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4478 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4479 if (err < 0)
4480 return err;
4481 sprintf(name, "%s Playback Switch", ctlname);
4482 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4483 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4484 if (err < 0)
4485 return err;
4486 return 0;
4489 static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
4491 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4492 return (pincap & AC_PINCAP_IN) != 0;
4495 /* create playback/capture controls for input pins */
4496 static int alc_auto_create_input_ctls(struct hda_codec *codec,
4497 const struct auto_pin_cfg *cfg,
4498 hda_nid_t mixer,
4499 hda_nid_t cap1, hda_nid_t cap2)
4501 struct alc_spec *spec = codec->spec;
4502 struct hda_input_mux *imux = &spec->private_imux[0];
4503 int i, err, idx;
4505 for (i = 0; i < AUTO_PIN_LAST; i++) {
4506 hda_nid_t pin;
4508 pin = cfg->input_pins[i];
4509 if (!alc_is_input_pin(codec, pin))
4510 continue;
4512 if (mixer) {
4513 idx = get_connection_index(codec, mixer, pin);
4514 if (idx >= 0) {
4515 err = new_analog_input(spec, pin,
4516 auto_pin_cfg_labels[i],
4517 idx, mixer);
4518 if (err < 0)
4519 return err;
4523 if (!cap1)
4524 continue;
4525 idx = get_connection_index(codec, cap1, pin);
4526 if (idx < 0 && cap2)
4527 idx = get_connection_index(codec, cap2, pin);
4528 if (idx >= 0) {
4529 imux->items[imux->num_items].label =
4530 auto_pin_cfg_labels[i];
4531 imux->items[imux->num_items].index = idx;
4532 imux->num_items++;
4535 return 0;
4538 static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4539 const struct auto_pin_cfg *cfg)
4541 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4544 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4545 unsigned int pin_type)
4547 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4548 pin_type);
4549 /* unmute pin */
4550 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4551 AMP_OUT_UNMUTE);
4554 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4555 hda_nid_t nid, int pin_type,
4556 int dac_idx)
4558 alc_set_pin_output(codec, nid, pin_type);
4559 /* need the manual connection? */
4560 if (alc880_is_multi_pin(nid)) {
4561 struct alc_spec *spec = codec->spec;
4562 int idx = alc880_multi_pin_idx(nid);
4563 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4564 AC_VERB_SET_CONNECT_SEL,
4565 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4569 static int get_pin_type(int line_out_type)
4571 if (line_out_type == AUTO_PIN_HP_OUT)
4572 return PIN_HP;
4573 else
4574 return PIN_OUT;
4577 static void alc880_auto_init_multi_out(struct hda_codec *codec)
4579 struct alc_spec *spec = codec->spec;
4580 int i;
4582 for (i = 0; i < spec->autocfg.line_outs; i++) {
4583 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4584 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4585 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
4589 static void alc880_auto_init_extra_out(struct hda_codec *codec)
4591 struct alc_spec *spec = codec->spec;
4592 hda_nid_t pin;
4594 pin = spec->autocfg.speaker_pins[0];
4595 if (pin) /* connect to front */
4596 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
4597 pin = spec->autocfg.hp_pins[0];
4598 if (pin) /* connect to front */
4599 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4602 static void alc880_auto_init_analog_input(struct hda_codec *codec)
4604 struct alc_spec *spec = codec->spec;
4605 int i;
4607 for (i = 0; i < AUTO_PIN_LAST; i++) {
4608 hda_nid_t nid = spec->autocfg.input_pins[i];
4609 if (alc_is_input_pin(codec, nid)) {
4610 alc_set_input_pin(codec, nid, i);
4611 if (nid != ALC880_PIN_CD_NID &&
4612 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
4613 snd_hda_codec_write(codec, nid, 0,
4614 AC_VERB_SET_AMP_GAIN_MUTE,
4615 AMP_OUT_MUTE);
4620 /* parse the BIOS configuration and set up the alc_spec */
4621 /* return 1 if successful, 0 if the proper config is not found,
4622 * or a negative error code
4624 static int alc880_parse_auto_config(struct hda_codec *codec)
4626 struct alc_spec *spec = codec->spec;
4627 int i, err;
4628 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
4630 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4631 alc880_ignore);
4632 if (err < 0)
4633 return err;
4634 if (!spec->autocfg.line_outs)
4635 return 0; /* can't find valid BIOS pin config */
4637 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4638 if (err < 0)
4639 return err;
4640 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4641 if (err < 0)
4642 return err;
4643 err = alc880_auto_create_extra_out(spec,
4644 spec->autocfg.speaker_pins[0],
4645 "Speaker");
4646 if (err < 0)
4647 return err;
4648 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4649 "Headphone");
4650 if (err < 0)
4651 return err;
4652 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
4653 if (err < 0)
4654 return err;
4656 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4658 /* check multiple SPDIF-out (for recent codecs) */
4659 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4660 hda_nid_t dig_nid;
4661 err = snd_hda_get_connections(codec,
4662 spec->autocfg.dig_out_pins[i],
4663 &dig_nid, 1);
4664 if (err < 0)
4665 continue;
4666 if (!i)
4667 spec->multiout.dig_out_nid = dig_nid;
4668 else {
4669 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4670 spec->slave_dig_outs[i - 1] = dig_nid;
4671 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4672 break;
4675 if (spec->autocfg.dig_in_pin)
4676 spec->dig_in_nid = ALC880_DIGIN_NID;
4678 if (spec->kctls.list)
4679 add_mixer(spec, spec->kctls.list);
4681 add_verb(spec, alc880_volume_init_verbs);
4683 spec->num_mux_defs = 1;
4684 spec->input_mux = &spec->private_imux[0];
4686 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4688 return 1;
4691 /* additional initialization for auto-configuration model */
4692 static void alc880_auto_init(struct hda_codec *codec)
4694 struct alc_spec *spec = codec->spec;
4695 alc880_auto_init_multi_out(codec);
4696 alc880_auto_init_extra_out(codec);
4697 alc880_auto_init_analog_input(codec);
4698 if (spec->unsol_event)
4699 alc_inithook(codec);
4702 /* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4703 * one of two digital mic pins, e.g. on ALC272
4705 static void fixup_automic_adc(struct hda_codec *codec)
4707 struct alc_spec *spec = codec->spec;
4708 int i;
4710 for (i = 0; i < spec->num_adc_nids; i++) {
4711 hda_nid_t cap = spec->capsrc_nids ?
4712 spec->capsrc_nids[i] : spec->adc_nids[i];
4713 int iidx, eidx;
4715 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4716 if (iidx < 0)
4717 continue;
4718 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4719 if (eidx < 0)
4720 continue;
4721 spec->int_mic.mux_idx = iidx;
4722 spec->ext_mic.mux_idx = eidx;
4723 if (spec->capsrc_nids)
4724 spec->capsrc_nids += i;
4725 spec->adc_nids += i;
4726 spec->num_adc_nids = 1;
4727 return;
4729 snd_printd(KERN_INFO "hda_codec: %s: "
4730 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4731 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4732 spec->auto_mic = 0; /* disable auto-mic to be sure */
4735 static void set_capture_mixer(struct hda_codec *codec)
4737 struct alc_spec *spec = codec->spec;
4738 static struct snd_kcontrol_new *caps[2][3] = {
4739 { alc_capture_mixer_nosrc1,
4740 alc_capture_mixer_nosrc2,
4741 alc_capture_mixer_nosrc3 },
4742 { alc_capture_mixer1,
4743 alc_capture_mixer2,
4744 alc_capture_mixer3 },
4746 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4747 int mux;
4748 if (spec->auto_mic) {
4749 mux = 0;
4750 fixup_automic_adc(codec);
4751 } else if (spec->input_mux && spec->input_mux->num_items > 1)
4752 mux = 1;
4753 else
4754 mux = 0;
4755 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4759 #define set_beep_amp(spec, nid, idx, dir) \
4760 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4763 * OK, here we have finally the patch for ALC880
4766 static int patch_alc880(struct hda_codec *codec)
4768 struct alc_spec *spec;
4769 int board_config;
4770 int err;
4772 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4773 if (spec == NULL)
4774 return -ENOMEM;
4776 codec->spec = spec;
4778 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4779 alc880_models,
4780 alc880_cfg_tbl);
4781 if (board_config < 0) {
4782 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4783 codec->chip_name);
4784 board_config = ALC880_AUTO;
4787 if (board_config == ALC880_AUTO) {
4788 /* automatic parse from the BIOS config */
4789 err = alc880_parse_auto_config(codec);
4790 if (err < 0) {
4791 alc_free(codec);
4792 return err;
4793 } else if (!err) {
4794 printk(KERN_INFO
4795 "hda_codec: Cannot set up configuration "
4796 "from BIOS. Using 3-stack mode...\n");
4797 board_config = ALC880_3ST;
4801 err = snd_hda_attach_beep_device(codec, 0x1);
4802 if (err < 0) {
4803 alc_free(codec);
4804 return err;
4807 if (board_config != ALC880_AUTO)
4808 setup_preset(codec, &alc880_presets[board_config]);
4810 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4811 spec->stream_analog_capture = &alc880_pcm_analog_capture;
4812 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
4814 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4815 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4817 if (!spec->adc_nids && spec->input_mux) {
4818 /* check whether NID 0x07 is valid */
4819 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
4820 /* get type */
4821 wcap = get_wcaps_type(wcap);
4822 if (wcap != AC_WID_AUD_IN) {
4823 spec->adc_nids = alc880_adc_nids_alt;
4824 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
4825 } else {
4826 spec->adc_nids = alc880_adc_nids;
4827 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
4830 set_capture_mixer(codec);
4831 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4833 spec->vmaster_nid = 0x0c;
4835 codec->patch_ops = alc_patch_ops;
4836 if (board_config == ALC880_AUTO)
4837 spec->init_hook = alc880_auto_init;
4838 #ifdef CONFIG_SND_HDA_POWER_SAVE
4839 if (!spec->loopback.amplist)
4840 spec->loopback.amplist = alc880_loopbacks;
4841 #endif
4842 codec->proc_widget_hook = print_realtek_coef;
4844 return 0;
4849 * ALC260 support
4852 static hda_nid_t alc260_dac_nids[1] = {
4853 /* front */
4854 0x02,
4857 static hda_nid_t alc260_adc_nids[1] = {
4858 /* ADC0 */
4859 0x04,
4862 static hda_nid_t alc260_adc_nids_alt[1] = {
4863 /* ADC1 */
4864 0x05,
4867 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
4868 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4870 static hda_nid_t alc260_dual_adc_nids[2] = {
4871 /* ADC0, ADC1 */
4872 0x04, 0x05
4875 #define ALC260_DIGOUT_NID 0x03
4876 #define ALC260_DIGIN_NID 0x06
4878 static struct hda_input_mux alc260_capture_source = {
4879 .num_items = 4,
4880 .items = {
4881 { "Mic", 0x0 },
4882 { "Front Mic", 0x1 },
4883 { "Line", 0x2 },
4884 { "CD", 0x4 },
4888 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
4889 * headphone jack and the internal CD lines since these are the only pins at
4890 * which audio can appear. For flexibility, also allow the option of
4891 * recording the mixer output on the second ADC (ADC0 doesn't have a
4892 * connection to the mixer output).
4894 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4896 .num_items = 3,
4897 .items = {
4898 { "Mic/Line", 0x0 },
4899 { "CD", 0x4 },
4900 { "Headphone", 0x2 },
4904 .num_items = 4,
4905 .items = {
4906 { "Mic/Line", 0x0 },
4907 { "CD", 0x4 },
4908 { "Headphone", 0x2 },
4909 { "Mixer", 0x5 },
4915 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4916 * the Fujitsu S702x, but jacks are marked differently.
4918 static struct hda_input_mux alc260_acer_capture_sources[2] = {
4920 .num_items = 4,
4921 .items = {
4922 { "Mic", 0x0 },
4923 { "Line", 0x2 },
4924 { "CD", 0x4 },
4925 { "Headphone", 0x5 },
4929 .num_items = 5,
4930 .items = {
4931 { "Mic", 0x0 },
4932 { "Line", 0x2 },
4933 { "CD", 0x4 },
4934 { "Headphone", 0x6 },
4935 { "Mixer", 0x5 },
4940 /* Maxdata Favorit 100XS */
4941 static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4943 .num_items = 2,
4944 .items = {
4945 { "Line/Mic", 0x0 },
4946 { "CD", 0x4 },
4950 .num_items = 3,
4951 .items = {
4952 { "Line/Mic", 0x0 },
4953 { "CD", 0x4 },
4954 { "Mixer", 0x5 },
4960 * This is just place-holder, so there's something for alc_build_pcms to look
4961 * at when it calculates the maximum number of channels. ALC260 has no mixer
4962 * element which allows changing the channel mode, so the verb list is
4963 * never used.
4965 static struct hda_channel_mode alc260_modes[1] = {
4966 { 2, NULL },
4970 /* Mixer combinations
4972 * basic: base_output + input + pc_beep + capture
4973 * HP: base_output + input + capture_alt
4974 * HP_3013: hp_3013 + input + capture
4975 * fujitsu: fujitsu + capture
4976 * acer: acer + capture
4979 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
4980 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4981 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4982 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4983 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4984 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4985 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4986 { } /* end */
4989 static struct snd_kcontrol_new alc260_input_mixer[] = {
4990 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4991 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4992 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4993 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4994 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4995 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4996 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
4998 { } /* end */
5001 /* update HP, line and mono out pins according to the master switch */
5002 static void alc260_hp_master_update(struct hda_codec *codec,
5003 hda_nid_t hp, hda_nid_t line,
5004 hda_nid_t mono)
5006 struct alc_spec *spec = codec->spec;
5007 unsigned int val = spec->master_sw ? PIN_HP : 0;
5008 /* change HP and line-out pins */
5009 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5010 val);
5011 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5012 val);
5013 /* mono (speaker) depending on the HP jack sense */
5014 val = (val && !spec->jack_present) ? PIN_OUT : 0;
5015 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5016 val);
5019 static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5020 struct snd_ctl_elem_value *ucontrol)
5022 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5023 struct alc_spec *spec = codec->spec;
5024 *ucontrol->value.integer.value = spec->master_sw;
5025 return 0;
5028 static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5029 struct snd_ctl_elem_value *ucontrol)
5031 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5032 struct alc_spec *spec = codec->spec;
5033 int val = !!*ucontrol->value.integer.value;
5034 hda_nid_t hp, line, mono;
5036 if (val == spec->master_sw)
5037 return 0;
5038 spec->master_sw = val;
5039 hp = (kcontrol->private_value >> 16) & 0xff;
5040 line = (kcontrol->private_value >> 8) & 0xff;
5041 mono = kcontrol->private_value & 0xff;
5042 alc260_hp_master_update(codec, hp, line, mono);
5043 return 1;
5046 static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5048 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5049 .name = "Master Playback Switch",
5050 .info = snd_ctl_boolean_mono_info,
5051 .get = alc260_hp_master_sw_get,
5052 .put = alc260_hp_master_sw_put,
5053 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5055 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5056 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5057 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5058 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5059 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5060 HDA_OUTPUT),
5061 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5062 { } /* end */
5065 static struct hda_verb alc260_hp_unsol_verbs[] = {
5066 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5070 static void alc260_hp_automute(struct hda_codec *codec)
5072 struct alc_spec *spec = codec->spec;
5073 unsigned int present;
5075 present = snd_hda_codec_read(codec, 0x10, 0,
5076 AC_VERB_GET_PIN_SENSE, 0);
5077 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5078 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5081 static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5083 if ((res >> 26) == ALC880_HP_EVENT)
5084 alc260_hp_automute(codec);
5087 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
5089 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5090 .name = "Master Playback Switch",
5091 .info = snd_ctl_boolean_mono_info,
5092 .get = alc260_hp_master_sw_get,
5093 .put = alc260_hp_master_sw_put,
5094 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
5096 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5097 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5098 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5099 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5100 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5102 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5103 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
5104 { } /* end */
5107 static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5108 .ops = &snd_hda_bind_vol,
5109 .values = {
5110 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5111 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5112 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5117 static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5118 .ops = &snd_hda_bind_sw,
5119 .values = {
5120 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5121 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5126 static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5127 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5128 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5129 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5130 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5131 { } /* end */
5134 static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5135 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5139 static void alc260_hp_3013_automute(struct hda_codec *codec)
5141 struct alc_spec *spec = codec->spec;
5142 unsigned int present;
5144 present = snd_hda_codec_read(codec, 0x15, 0,
5145 AC_VERB_GET_PIN_SENSE, 0);
5146 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5147 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
5150 static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5151 unsigned int res)
5153 if ((res >> 26) == ALC880_HP_EVENT)
5154 alc260_hp_3013_automute(codec);
5157 static void alc260_hp_3012_automute(struct hda_codec *codec)
5159 unsigned int present, bits;
5161 present = snd_hda_codec_read(codec, 0x10, 0,
5162 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5164 bits = present ? 0 : PIN_OUT;
5165 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5166 bits);
5167 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5168 bits);
5169 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5170 bits);
5173 static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5174 unsigned int res)
5176 if ((res >> 26) == ALC880_HP_EVENT)
5177 alc260_hp_3012_automute(codec);
5180 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
5181 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5183 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
5184 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5185 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
5186 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5187 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5188 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5189 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5190 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
5191 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
5192 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5193 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
5194 { } /* end */
5197 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5198 * versions of the ALC260 don't act on requests to enable mic bias from NID
5199 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5200 * datasheet doesn't mention this restriction. At this stage it's not clear
5201 * whether this behaviour is intentional or is a hardware bug in chip
5202 * revisions available in early 2006. Therefore for now allow the
5203 * "Headphone Jack Mode" control to span all choices, but if it turns out
5204 * that the lack of mic bias for this NID is intentional we could change the
5205 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5207 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5208 * don't appear to make the mic bias available from the "line" jack, even
5209 * though the NID used for this jack (0x14) can supply it. The theory is
5210 * that perhaps Acer have included blocking capacitors between the ALC260
5211 * and the output jack. If this turns out to be the case for all such
5212 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5213 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
5215 * The C20x Tablet series have a mono internal speaker which is controlled
5216 * via the chip's Mono sum widget and pin complex, so include the necessary
5217 * controls for such models. On models without a "mono speaker" the control
5218 * won't do anything.
5220 static struct snd_kcontrol_new alc260_acer_mixer[] = {
5221 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5222 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5223 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5224 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5225 HDA_OUTPUT),
5226 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
5227 HDA_INPUT),
5228 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5229 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5231 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5232 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5233 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5234 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5235 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5236 { } /* end */
5239 /* Maxdata Favorit 100XS: one output and one input (0x12) jack
5241 static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5242 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5243 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5244 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5245 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5246 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5247 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5248 { } /* end */
5251 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5252 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5254 static struct snd_kcontrol_new alc260_will_mixer[] = {
5255 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5256 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5257 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5258 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5259 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5260 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5261 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5262 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5263 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5264 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5265 { } /* end */
5268 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5269 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5271 static struct snd_kcontrol_new alc260_replacer_672v_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("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5278 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5279 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5280 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5281 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5282 { } /* end */
5286 * initialization verbs
5288 static struct hda_verb alc260_init_verbs[] = {
5289 /* Line In pin widget for input */
5290 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5291 /* CD pin widget for input */
5292 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5293 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5294 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5295 /* Mic2 (front panel) pin widget for input and vref at 80% */
5296 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5297 /* LINE-2 is used for line-out in rear */
5298 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5299 /* select line-out */
5300 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
5301 /* LINE-OUT pin */
5302 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5303 /* enable HP */
5304 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5305 /* enable Mono */
5306 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5307 /* mute capture amp left and right */
5308 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5309 /* set connection select to line in (default select for this ADC) */
5310 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5311 /* mute capture amp left and right */
5312 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5313 /* set connection select to line in (default select for this ADC) */
5314 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
5315 /* set vol=0 Line-Out mixer amp left and right */
5316 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5317 /* unmute pin widget amp left and right (no gain on this amp) */
5318 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5319 /* set vol=0 HP mixer amp left and right */
5320 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5321 /* unmute pin widget amp left and right (no gain on this amp) */
5322 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5323 /* set vol=0 Mono mixer amp left and right */
5324 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5325 /* unmute pin widget amp left and right (no gain on this amp) */
5326 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5327 /* unmute LINE-2 out pin */
5328 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5329 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5330 * Line In 2 = 0x03
5332 /* mute analog inputs */
5333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5338 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5339 /* mute Front out path */
5340 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5341 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5342 /* mute Headphone out path */
5343 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5344 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5345 /* mute Mono out path */
5346 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5347 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5351 #if 0 /* should be identical with alc260_init_verbs? */
5352 static struct hda_verb alc260_hp_init_verbs[] = {
5353 /* Headphone and output */
5354 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5355 /* mono output */
5356 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5357 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5358 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5359 /* Mic2 (front panel) pin widget for input and vref at 80% */
5360 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5361 /* Line In pin widget for input */
5362 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5363 /* Line-2 pin widget for output */
5364 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5365 /* CD pin widget for input */
5366 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5367 /* unmute amp left and right */
5368 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5369 /* set connection select to line in (default select for this ADC) */
5370 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5371 /* unmute Line-Out mixer amp left and right (volume = 0) */
5372 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5373 /* mute pin widget amp left and right (no gain on this amp) */
5374 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5375 /* unmute HP mixer amp left and right (volume = 0) */
5376 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5377 /* mute pin widget amp left and right (no gain on this amp) */
5378 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5379 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5380 * Line In 2 = 0x03
5382 /* mute analog inputs */
5383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5386 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5387 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5388 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5389 /* Unmute Front out path */
5390 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5391 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5392 /* Unmute Headphone out path */
5393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5394 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5395 /* Unmute Mono out path */
5396 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5397 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5400 #endif
5402 static struct hda_verb alc260_hp_3013_init_verbs[] = {
5403 /* Line out and output */
5404 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5405 /* mono output */
5406 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5407 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5408 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5409 /* Mic2 (front panel) pin widget for input and vref at 80% */
5410 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5411 /* Line In pin widget for input */
5412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5413 /* Headphone pin widget for output */
5414 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5415 /* CD pin widget for input */
5416 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5417 /* unmute amp left and right */
5418 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5419 /* set connection select to line in (default select for this ADC) */
5420 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5421 /* unmute Line-Out mixer amp left and right (volume = 0) */
5422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5423 /* mute pin widget amp left and right (no gain on this amp) */
5424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5425 /* unmute HP mixer amp left and right (volume = 0) */
5426 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5427 /* mute pin widget amp left and right (no gain on this amp) */
5428 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5429 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5430 * Line In 2 = 0x03
5432 /* mute analog inputs */
5433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5436 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5437 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5438 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5439 /* Unmute Front out path */
5440 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5441 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5442 /* Unmute Headphone out path */
5443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5444 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5445 /* Unmute Mono out path */
5446 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5447 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5451 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
5452 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5453 * audio = 0x16, internal speaker = 0x10.
5455 static struct hda_verb alc260_fujitsu_init_verbs[] = {
5456 /* Disable all GPIOs */
5457 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5458 /* Internal speaker is connected to headphone pin */
5459 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5460 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5462 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5463 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5464 /* Ensure all other unused pins are disabled and muted. */
5465 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5466 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5467 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5468 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5469 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5470 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5471 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5474 /* Disable digital (SPDIF) pins */
5475 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5476 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5478 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
5479 * when acting as an output.
5481 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5483 /* Start with output sum widgets muted and their output gains at min */
5484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5486 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5489 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5491 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5492 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5494 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5495 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5496 /* Unmute Line1 pin widget output buffer since it starts as an output.
5497 * If the pin mode is changed by the user the pin mode control will
5498 * take care of enabling the pin's input/output buffers as needed.
5499 * Therefore there's no need to enable the input buffer at this
5500 * stage.
5502 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5503 /* Unmute input buffer of pin widget used for Line-in (no equiv
5504 * mixer ctrl)
5506 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5508 /* Mute capture amp left and right */
5509 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5510 /* Set ADC connection select to match default mixer setting - line
5511 * in (on mic1 pin)
5513 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5515 /* Do the same for the second ADC: mute capture input amp and
5516 * set ADC connection to line in (on mic1 pin)
5518 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5519 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5521 /* Mute all inputs to mixer widget (even unconnected ones) */
5522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5528 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5529 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5534 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5535 * similar laptops (adapted from Fujitsu init verbs).
5537 static struct hda_verb alc260_acer_init_verbs[] = {
5538 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5539 * the headphone jack. Turn this on and rely on the standard mute
5540 * methods whenever the user wants to turn these outputs off.
5542 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5543 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5544 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5545 /* Internal speaker/Headphone jack is connected to Line-out pin */
5546 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5547 /* Internal microphone/Mic jack is connected to Mic1 pin */
5548 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5549 /* Line In jack is connected to Line1 pin */
5550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5551 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5552 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5553 /* Ensure all other unused pins are disabled and muted. */
5554 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5555 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5556 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5557 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5558 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5559 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5560 /* Disable digital (SPDIF) pins */
5561 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5562 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5564 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5565 * bus when acting as outputs.
5567 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5568 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5570 /* Start with output sum widgets muted and their output gains at min */
5571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5572 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5573 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5575 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5576 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5577 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5578 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5579 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5581 /* Unmute Line-out pin widget amp left and right
5582 * (no equiv mixer ctrl)
5584 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5585 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5586 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5587 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5588 * inputs. If the pin mode is changed by the user the pin mode control
5589 * will take care of enabling the pin's input/output buffers as needed.
5590 * Therefore there's no need to enable the input buffer at this
5591 * stage.
5593 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5594 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5596 /* Mute capture amp left and right */
5597 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5598 /* Set ADC connection select to match default mixer setting - mic
5599 * (on mic1 pin)
5601 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5603 /* Do similar with the second ADC: mute capture input amp and
5604 * set ADC connection to mic to match ALSA's default state.
5606 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5607 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5609 /* Mute all inputs to mixer widget (even unconnected ones) */
5610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5616 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5617 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5622 /* Initialisation sequence for Maxdata Favorit 100XS
5623 * (adapted from Acer init verbs).
5625 static struct hda_verb alc260_favorit100_init_verbs[] = {
5626 /* GPIO 0 enables the output jack.
5627 * Turn this on and rely on the standard mute
5628 * methods whenever the user wants to turn these outputs off.
5630 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5631 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5632 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5633 /* Line/Mic input jack is connected to Mic1 pin */
5634 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5635 /* Ensure all other unused pins are disabled and muted. */
5636 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5637 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5638 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5639 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5640 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5641 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5646 /* Disable digital (SPDIF) pins */
5647 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5648 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5650 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5651 * bus when acting as outputs.
5653 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5654 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5656 /* Start with output sum widgets muted and their output gains at min */
5657 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5658 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5659 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5660 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5661 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5662 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5663 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5664 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5665 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5667 /* Unmute Line-out pin widget amp left and right
5668 * (no equiv mixer ctrl)
5670 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5671 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5672 * inputs. If the pin mode is changed by the user the pin mode control
5673 * will take care of enabling the pin's input/output buffers as needed.
5674 * Therefore there's no need to enable the input buffer at this
5675 * stage.
5677 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5679 /* Mute capture amp left and right */
5680 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5681 /* Set ADC connection select to match default mixer setting - mic
5682 * (on mic1 pin)
5684 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5686 /* Do similar with the second ADC: mute capture input amp and
5687 * set ADC connection to mic to match ALSA's default state.
5689 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5690 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5692 /* Mute all inputs to mixer widget (even unconnected ones) */
5693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5699 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5700 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5705 static struct hda_verb alc260_will_verbs[] = {
5706 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5707 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5708 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5709 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5710 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5711 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5715 static struct hda_verb alc260_replacer_672v_verbs[] = {
5716 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5717 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5718 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5720 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5721 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5722 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5724 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5728 /* toggle speaker-output according to the hp-jack state */
5729 static void alc260_replacer_672v_automute(struct hda_codec *codec)
5731 unsigned int present;
5733 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5734 present = snd_hda_codec_read(codec, 0x0f, 0,
5735 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5736 if (present) {
5737 snd_hda_codec_write_cache(codec, 0x01, 0,
5738 AC_VERB_SET_GPIO_DATA, 1);
5739 snd_hda_codec_write_cache(codec, 0x0f, 0,
5740 AC_VERB_SET_PIN_WIDGET_CONTROL,
5741 PIN_HP);
5742 } else {
5743 snd_hda_codec_write_cache(codec, 0x01, 0,
5744 AC_VERB_SET_GPIO_DATA, 0);
5745 snd_hda_codec_write_cache(codec, 0x0f, 0,
5746 AC_VERB_SET_PIN_WIDGET_CONTROL,
5747 PIN_OUT);
5751 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5752 unsigned int res)
5754 if ((res >> 26) == ALC880_HP_EVENT)
5755 alc260_replacer_672v_automute(codec);
5758 static struct hda_verb alc260_hp_dc7600_verbs[] = {
5759 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5760 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5761 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5762 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5763 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5764 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5765 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5766 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5767 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5768 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5772 /* Test configuration for debugging, modelled after the ALC880 test
5773 * configuration.
5775 #ifdef CONFIG_SND_DEBUG
5776 static hda_nid_t alc260_test_dac_nids[1] = {
5777 0x02,
5779 static hda_nid_t alc260_test_adc_nids[2] = {
5780 0x04, 0x05,
5782 /* For testing the ALC260, each input MUX needs its own definition since
5783 * the signal assignments are different. This assumes that the first ADC
5784 * is NID 0x04.
5786 static struct hda_input_mux alc260_test_capture_sources[2] = {
5788 .num_items = 7,
5789 .items = {
5790 { "MIC1 pin", 0x0 },
5791 { "MIC2 pin", 0x1 },
5792 { "LINE1 pin", 0x2 },
5793 { "LINE2 pin", 0x3 },
5794 { "CD pin", 0x4 },
5795 { "LINE-OUT pin", 0x5 },
5796 { "HP-OUT pin", 0x6 },
5800 .num_items = 8,
5801 .items = {
5802 { "MIC1 pin", 0x0 },
5803 { "MIC2 pin", 0x1 },
5804 { "LINE1 pin", 0x2 },
5805 { "LINE2 pin", 0x3 },
5806 { "CD pin", 0x4 },
5807 { "Mixer", 0x5 },
5808 { "LINE-OUT pin", 0x6 },
5809 { "HP-OUT pin", 0x7 },
5813 static struct snd_kcontrol_new alc260_test_mixer[] = {
5814 /* Output driver widgets */
5815 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5816 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5817 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5818 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5819 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5820 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5822 /* Modes for retasking pin widgets
5823 * Note: the ALC260 doesn't seem to act on requests to enable mic
5824 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5825 * mention this restriction. At this stage it's not clear whether
5826 * this behaviour is intentional or is a hardware bug in chip
5827 * revisions available at least up until early 2006. Therefore for
5828 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5829 * choices, but if it turns out that the lack of mic bias for these
5830 * NIDs is intentional we could change their modes from
5831 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5833 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5834 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5835 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5836 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5837 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5838 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5840 /* Loopback mixer controls */
5841 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5842 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5843 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5844 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5845 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5846 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5847 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5848 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5849 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5850 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5851 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5852 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5853 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5854 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
5856 /* Controls for GPIO pins, assuming they are configured as outputs */
5857 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5858 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5859 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5860 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5862 /* Switches to allow the digital IO pins to be enabled. The datasheet
5863 * is ambigious as to which NID is which; testing on laptops which
5864 * make this output available should provide clarification.
5866 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5867 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5869 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5870 * this output to turn on an external amplifier.
5872 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5873 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5875 { } /* end */
5877 static struct hda_verb alc260_test_init_verbs[] = {
5878 /* Enable all GPIOs as outputs with an initial value of 0 */
5879 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5880 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5881 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5883 /* Enable retasking pins as output, initially without power amp */
5884 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5885 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5886 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5888 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5889 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5891 /* Disable digital (SPDIF) pins initially, but users can enable
5892 * them via a mixer switch. In the case of SPDIF-out, this initverb
5893 * payload also sets the generation to 0, output to be in "consumer"
5894 * PCM format, copyright asserted, no pre-emphasis and no validity
5895 * control.
5897 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5898 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5900 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
5901 * OUT1 sum bus when acting as an output.
5903 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5904 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5905 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5906 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5908 /* Start with output sum widgets muted and their output gains at min */
5909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5910 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5911 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5912 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5913 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5914 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5915 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5916 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5917 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5919 /* Unmute retasking pin widget output buffers since the default
5920 * state appears to be output. As the pin mode is changed by the
5921 * user the pin mode control will take care of enabling the pin's
5922 * input/output buffers as needed.
5924 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5925 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5928 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5929 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5930 /* Also unmute the mono-out pin widget */
5931 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5933 /* Mute capture amp left and right */
5934 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5935 /* Set ADC connection select to match default mixer setting (mic1
5936 * pin)
5938 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5940 /* Do the same for the second ADC: mute capture input amp and
5941 * set ADC connection to mic1 pin
5943 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5944 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5946 /* Mute all inputs to mixer widget (even unconnected ones) */
5947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5948 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5949 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5950 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5951 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5954 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5958 #endif
5960 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5961 #define alc260_pcm_analog_capture alc880_pcm_analog_capture
5963 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
5964 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
5967 * for BIOS auto-configuration
5970 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
5971 const char *pfx, int *vol_bits)
5973 hda_nid_t nid_vol;
5974 unsigned long vol_val, sw_val;
5975 char name[32];
5976 int err;
5978 if (nid >= 0x0f && nid < 0x11) {
5979 nid_vol = nid - 0x7;
5980 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5981 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5982 } else if (nid == 0x11) {
5983 nid_vol = nid - 0x7;
5984 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5985 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5986 } else if (nid >= 0x12 && nid <= 0x15) {
5987 nid_vol = 0x08;
5988 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5989 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5990 } else
5991 return 0; /* N/A */
5993 if (!(*vol_bits & (1 << nid_vol))) {
5994 /* first control for the volume widget */
5995 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5996 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5997 if (err < 0)
5998 return err;
5999 *vol_bits |= (1 << nid_vol);
6001 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
6002 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
6003 if (err < 0)
6004 return err;
6005 return 1;
6008 /* add playback controls from the parsed DAC table */
6009 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6010 const struct auto_pin_cfg *cfg)
6012 hda_nid_t nid;
6013 int err;
6014 int vols = 0;
6016 spec->multiout.num_dacs = 1;
6017 spec->multiout.dac_nids = spec->private_dac_nids;
6018 spec->multiout.dac_nids[0] = 0x02;
6020 nid = cfg->line_out_pins[0];
6021 if (nid) {
6022 const char *pfx;
6023 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6024 pfx = "Master";
6025 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6026 pfx = "Speaker";
6027 else
6028 pfx = "Front";
6029 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
6030 if (err < 0)
6031 return err;
6034 nid = cfg->speaker_pins[0];
6035 if (nid) {
6036 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
6037 if (err < 0)
6038 return err;
6041 nid = cfg->hp_pins[0];
6042 if (nid) {
6043 err = alc260_add_playback_controls(spec, nid, "Headphone",
6044 &vols);
6045 if (err < 0)
6046 return err;
6048 return 0;
6051 /* create playback/capture controls for input pins */
6052 static int alc260_auto_create_input_ctls(struct hda_codec *codec,
6053 const struct auto_pin_cfg *cfg)
6055 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
6058 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6059 hda_nid_t nid, int pin_type,
6060 int sel_idx)
6062 alc_set_pin_output(codec, nid, pin_type);
6063 /* need the manual connection? */
6064 if (nid >= 0x12) {
6065 int idx = nid - 0x12;
6066 snd_hda_codec_write(codec, idx + 0x0b, 0,
6067 AC_VERB_SET_CONNECT_SEL, sel_idx);
6071 static void alc260_auto_init_multi_out(struct hda_codec *codec)
6073 struct alc_spec *spec = codec->spec;
6074 hda_nid_t nid;
6076 nid = spec->autocfg.line_out_pins[0];
6077 if (nid) {
6078 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6079 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6082 nid = spec->autocfg.speaker_pins[0];
6083 if (nid)
6084 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6086 nid = spec->autocfg.hp_pins[0];
6087 if (nid)
6088 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
6091 #define ALC260_PIN_CD_NID 0x16
6092 static void alc260_auto_init_analog_input(struct hda_codec *codec)
6094 struct alc_spec *spec = codec->spec;
6095 int i;
6097 for (i = 0; i < AUTO_PIN_LAST; i++) {
6098 hda_nid_t nid = spec->autocfg.input_pins[i];
6099 if (nid >= 0x12) {
6100 alc_set_input_pin(codec, nid, i);
6101 if (nid != ALC260_PIN_CD_NID &&
6102 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
6103 snd_hda_codec_write(codec, nid, 0,
6104 AC_VERB_SET_AMP_GAIN_MUTE,
6105 AMP_OUT_MUTE);
6111 * generic initialization of ADC, input mixers and output mixers
6113 static struct hda_verb alc260_volume_init_verbs[] = {
6115 * Unmute ADC0-1 and set the default input to mic-in
6117 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6118 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6119 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6120 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6122 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6123 * mixer widget
6124 * Note: PASD motherboards uses the Line In 2 as the input for
6125 * front panel mic (mic 2)
6127 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6128 /* mute analog inputs */
6129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6136 * Set up output mixers (0x08 - 0x0a)
6138 /* set vol=0 to output mixers */
6139 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6140 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6141 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6142 /* set up input amps for analog loopback */
6143 /* Amp Indices: DAC = 0, mixer = 1 */
6144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6146 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6147 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6148 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6149 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6154 static int alc260_parse_auto_config(struct hda_codec *codec)
6156 struct alc_spec *spec = codec->spec;
6157 int err;
6158 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6160 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6161 alc260_ignore);
6162 if (err < 0)
6163 return err;
6164 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6165 if (err < 0)
6166 return err;
6167 if (!spec->kctls.list)
6168 return 0; /* can't find valid BIOS pin config */
6169 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
6170 if (err < 0)
6171 return err;
6173 spec->multiout.max_channels = 2;
6175 if (spec->autocfg.dig_outs)
6176 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
6177 if (spec->kctls.list)
6178 add_mixer(spec, spec->kctls.list);
6180 add_verb(spec, alc260_volume_init_verbs);
6182 spec->num_mux_defs = 1;
6183 spec->input_mux = &spec->private_imux[0];
6185 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6187 return 1;
6190 /* additional initialization for auto-configuration model */
6191 static void alc260_auto_init(struct hda_codec *codec)
6193 struct alc_spec *spec = codec->spec;
6194 alc260_auto_init_multi_out(codec);
6195 alc260_auto_init_analog_input(codec);
6196 if (spec->unsol_event)
6197 alc_inithook(codec);
6200 #ifdef CONFIG_SND_HDA_POWER_SAVE
6201 static struct hda_amp_list alc260_loopbacks[] = {
6202 { 0x07, HDA_INPUT, 0 },
6203 { 0x07, HDA_INPUT, 1 },
6204 { 0x07, HDA_INPUT, 2 },
6205 { 0x07, HDA_INPUT, 3 },
6206 { 0x07, HDA_INPUT, 4 },
6207 { } /* end */
6209 #endif
6212 * ALC260 configurations
6214 static const char *alc260_models[ALC260_MODEL_LAST] = {
6215 [ALC260_BASIC] = "basic",
6216 [ALC260_HP] = "hp",
6217 [ALC260_HP_3013] = "hp-3013",
6218 [ALC260_HP_DC7600] = "hp-dc7600",
6219 [ALC260_FUJITSU_S702X] = "fujitsu",
6220 [ALC260_ACER] = "acer",
6221 [ALC260_WILL] = "will",
6222 [ALC260_REPLACER_672V] = "replacer",
6223 [ALC260_FAVORIT100] = "favorit100",
6224 #ifdef CONFIG_SND_DEBUG
6225 [ALC260_TEST] = "test",
6226 #endif
6227 [ALC260_AUTO] = "auto",
6230 static struct snd_pci_quirk alc260_cfg_tbl[] = {
6231 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
6232 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
6233 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
6234 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
6235 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
6236 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
6237 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
6238 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
6239 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6240 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6241 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6242 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6243 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6244 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6245 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6246 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6247 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
6248 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
6249 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
6253 static struct alc_config_preset alc260_presets[] = {
6254 [ALC260_BASIC] = {
6255 .mixers = { alc260_base_output_mixer,
6256 alc260_input_mixer },
6257 .init_verbs = { alc260_init_verbs },
6258 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6259 .dac_nids = alc260_dac_nids,
6260 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6261 .adc_nids = alc260_adc_nids,
6262 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6263 .channel_mode = alc260_modes,
6264 .input_mux = &alc260_capture_source,
6266 [ALC260_HP] = {
6267 .mixers = { alc260_hp_output_mixer,
6268 alc260_input_mixer },
6269 .init_verbs = { alc260_init_verbs,
6270 alc260_hp_unsol_verbs },
6271 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6272 .dac_nids = alc260_dac_nids,
6273 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6274 .adc_nids = alc260_adc_nids_alt,
6275 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6276 .channel_mode = alc260_modes,
6277 .input_mux = &alc260_capture_source,
6278 .unsol_event = alc260_hp_unsol_event,
6279 .init_hook = alc260_hp_automute,
6281 [ALC260_HP_DC7600] = {
6282 .mixers = { alc260_hp_dc7600_mixer,
6283 alc260_input_mixer },
6284 .init_verbs = { alc260_init_verbs,
6285 alc260_hp_dc7600_verbs },
6286 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6287 .dac_nids = alc260_dac_nids,
6288 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6289 .adc_nids = alc260_adc_nids_alt,
6290 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6291 .channel_mode = alc260_modes,
6292 .input_mux = &alc260_capture_source,
6293 .unsol_event = alc260_hp_3012_unsol_event,
6294 .init_hook = alc260_hp_3012_automute,
6296 [ALC260_HP_3013] = {
6297 .mixers = { alc260_hp_3013_mixer,
6298 alc260_input_mixer },
6299 .init_verbs = { alc260_hp_3013_init_verbs,
6300 alc260_hp_3013_unsol_verbs },
6301 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6302 .dac_nids = alc260_dac_nids,
6303 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6304 .adc_nids = alc260_adc_nids_alt,
6305 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6306 .channel_mode = alc260_modes,
6307 .input_mux = &alc260_capture_source,
6308 .unsol_event = alc260_hp_3013_unsol_event,
6309 .init_hook = alc260_hp_3013_automute,
6311 [ALC260_FUJITSU_S702X] = {
6312 .mixers = { alc260_fujitsu_mixer },
6313 .init_verbs = { alc260_fujitsu_init_verbs },
6314 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6315 .dac_nids = alc260_dac_nids,
6316 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6317 .adc_nids = alc260_dual_adc_nids,
6318 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6319 .channel_mode = alc260_modes,
6320 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6321 .input_mux = alc260_fujitsu_capture_sources,
6323 [ALC260_ACER] = {
6324 .mixers = { alc260_acer_mixer },
6325 .init_verbs = { alc260_acer_init_verbs },
6326 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6327 .dac_nids = alc260_dac_nids,
6328 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6329 .adc_nids = alc260_dual_adc_nids,
6330 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6331 .channel_mode = alc260_modes,
6332 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6333 .input_mux = alc260_acer_capture_sources,
6335 [ALC260_FAVORIT100] = {
6336 .mixers = { alc260_favorit100_mixer },
6337 .init_verbs = { alc260_favorit100_init_verbs },
6338 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6339 .dac_nids = alc260_dac_nids,
6340 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6341 .adc_nids = alc260_dual_adc_nids,
6342 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6343 .channel_mode = alc260_modes,
6344 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6345 .input_mux = alc260_favorit100_capture_sources,
6347 [ALC260_WILL] = {
6348 .mixers = { alc260_will_mixer },
6349 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6350 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6351 .dac_nids = alc260_dac_nids,
6352 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6353 .adc_nids = alc260_adc_nids,
6354 .dig_out_nid = ALC260_DIGOUT_NID,
6355 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6356 .channel_mode = alc260_modes,
6357 .input_mux = &alc260_capture_source,
6359 [ALC260_REPLACER_672V] = {
6360 .mixers = { alc260_replacer_672v_mixer },
6361 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6362 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6363 .dac_nids = alc260_dac_nids,
6364 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6365 .adc_nids = alc260_adc_nids,
6366 .dig_out_nid = ALC260_DIGOUT_NID,
6367 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6368 .channel_mode = alc260_modes,
6369 .input_mux = &alc260_capture_source,
6370 .unsol_event = alc260_replacer_672v_unsol_event,
6371 .init_hook = alc260_replacer_672v_automute,
6373 #ifdef CONFIG_SND_DEBUG
6374 [ALC260_TEST] = {
6375 .mixers = { alc260_test_mixer },
6376 .init_verbs = { alc260_test_init_verbs },
6377 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6378 .dac_nids = alc260_test_dac_nids,
6379 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6380 .adc_nids = alc260_test_adc_nids,
6381 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6382 .channel_mode = alc260_modes,
6383 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6384 .input_mux = alc260_test_capture_sources,
6386 #endif
6389 static int patch_alc260(struct hda_codec *codec)
6391 struct alc_spec *spec;
6392 int err, board_config;
6394 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6395 if (spec == NULL)
6396 return -ENOMEM;
6398 codec->spec = spec;
6400 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6401 alc260_models,
6402 alc260_cfg_tbl);
6403 if (board_config < 0) {
6404 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6405 codec->chip_name);
6406 board_config = ALC260_AUTO;
6409 if (board_config == ALC260_AUTO) {
6410 /* automatic parse from the BIOS config */
6411 err = alc260_parse_auto_config(codec);
6412 if (err < 0) {
6413 alc_free(codec);
6414 return err;
6415 } else if (!err) {
6416 printk(KERN_INFO
6417 "hda_codec: Cannot set up configuration "
6418 "from BIOS. Using base mode...\n");
6419 board_config = ALC260_BASIC;
6423 err = snd_hda_attach_beep_device(codec, 0x1);
6424 if (err < 0) {
6425 alc_free(codec);
6426 return err;
6429 if (board_config != ALC260_AUTO)
6430 setup_preset(codec, &alc260_presets[board_config]);
6432 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6433 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6435 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6436 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6438 if (!spec->adc_nids && spec->input_mux) {
6439 /* check whether NID 0x04 is valid */
6440 unsigned int wcap = get_wcaps(codec, 0x04);
6441 wcap = get_wcaps_type(wcap);
6442 /* get type */
6443 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6444 spec->adc_nids = alc260_adc_nids_alt;
6445 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6446 } else {
6447 spec->adc_nids = alc260_adc_nids;
6448 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6451 set_capture_mixer(codec);
6452 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
6454 spec->vmaster_nid = 0x08;
6456 codec->patch_ops = alc_patch_ops;
6457 if (board_config == ALC260_AUTO)
6458 spec->init_hook = alc260_auto_init;
6459 #ifdef CONFIG_SND_HDA_POWER_SAVE
6460 if (!spec->loopback.amplist)
6461 spec->loopback.amplist = alc260_loopbacks;
6462 #endif
6463 codec->proc_widget_hook = print_realtek_coef;
6465 return 0;
6470 * ALC882/883/885/888/889 support
6472 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6473 * configuration. Each pin widget can choose any input DACs and a mixer.
6474 * Each ADC is connected from a mixer of all inputs. This makes possible
6475 * 6-channel independent captures.
6477 * In addition, an independent DAC for the multi-playback (not used in this
6478 * driver yet).
6480 #define ALC882_DIGOUT_NID 0x06
6481 #define ALC882_DIGIN_NID 0x0a
6482 #define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6483 #define ALC883_DIGIN_NID ALC882_DIGIN_NID
6484 #define ALC1200_DIGOUT_NID 0x10
6487 static struct hda_channel_mode alc882_ch_modes[1] = {
6488 { 8, NULL }
6491 /* DACs */
6492 static hda_nid_t alc882_dac_nids[4] = {
6493 /* front, rear, clfe, rear_surr */
6494 0x02, 0x03, 0x04, 0x05
6496 #define alc883_dac_nids alc882_dac_nids
6498 /* ADCs */
6499 #define alc882_adc_nids alc880_adc_nids
6500 #define alc882_adc_nids_alt alc880_adc_nids_alt
6501 #define alc883_adc_nids alc882_adc_nids_alt
6502 static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6503 static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6504 #define alc889_adc_nids alc880_adc_nids
6506 static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6507 static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6508 #define alc883_capsrc_nids alc882_capsrc_nids_alt
6509 static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6510 #define alc889_capsrc_nids alc882_capsrc_nids
6512 /* input MUX */
6513 /* FIXME: should be a matrix-type input source selection */
6515 static struct hda_input_mux alc882_capture_source = {
6516 .num_items = 4,
6517 .items = {
6518 { "Mic", 0x0 },
6519 { "Front Mic", 0x1 },
6520 { "Line", 0x2 },
6521 { "CD", 0x4 },
6525 #define alc883_capture_source alc882_capture_source
6527 static struct hda_input_mux alc889_capture_source = {
6528 .num_items = 3,
6529 .items = {
6530 { "Front Mic", 0x0 },
6531 { "Mic", 0x3 },
6532 { "Line", 0x2 },
6536 static struct hda_input_mux mb5_capture_source = {
6537 .num_items = 3,
6538 .items = {
6539 { "Mic", 0x1 },
6540 { "Line", 0x2 },
6541 { "CD", 0x4 },
6545 static struct hda_input_mux alc883_3stack_6ch_intel = {
6546 .num_items = 4,
6547 .items = {
6548 { "Mic", 0x1 },
6549 { "Front Mic", 0x0 },
6550 { "Line", 0x2 },
6551 { "CD", 0x4 },
6555 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6556 .num_items = 2,
6557 .items = {
6558 { "Mic", 0x1 },
6559 { "Line", 0x2 },
6563 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6564 .num_items = 4,
6565 .items = {
6566 { "Mic", 0x0 },
6567 { "iMic", 0x1 },
6568 { "Line", 0x2 },
6569 { "CD", 0x4 },
6573 static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6574 .num_items = 2,
6575 .items = {
6576 { "Mic", 0x0 },
6577 { "Int Mic", 0x1 },
6581 static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6582 .num_items = 3,
6583 .items = {
6584 { "Mic", 0x0 },
6585 { "Front Mic", 0x1 },
6586 { "Line", 0x4 },
6590 static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6591 .num_items = 2,
6592 .items = {
6593 { "Mic", 0x0 },
6594 { "Line", 0x2 },
6598 static struct hda_input_mux alc889A_mb31_capture_source = {
6599 .num_items = 2,
6600 .items = {
6601 { "Mic", 0x0 },
6602 /* Front Mic (0x01) unused */
6603 { "Line", 0x2 },
6604 /* Line 2 (0x03) unused */
6605 /* CD (0x04) unsused? */
6610 * 2ch mode
6612 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6613 { 2, NULL }
6617 * 2ch mode
6619 static struct hda_verb alc882_3ST_ch2_init[] = {
6620 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6621 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6622 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6623 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6624 { } /* end */
6628 * 4ch mode
6630 static struct hda_verb alc882_3ST_ch4_init[] = {
6631 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6632 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6633 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6634 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6635 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6636 { } /* end */
6640 * 6ch mode
6642 static struct hda_verb alc882_3ST_ch6_init[] = {
6643 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6644 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6645 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6646 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6647 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6648 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6649 { } /* end */
6652 static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
6653 { 2, alc882_3ST_ch2_init },
6654 { 4, alc882_3ST_ch4_init },
6655 { 6, alc882_3ST_ch6_init },
6658 #define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6661 * 2ch mode
6663 static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6664 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6665 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6666 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6667 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6668 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6669 { } /* end */
6673 * 4ch mode
6675 static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6676 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6677 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6678 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6679 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6680 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6681 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6682 { } /* end */
6686 * 6ch mode
6688 static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6689 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6690 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6691 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6692 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6693 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6694 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6695 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6696 { } /* end */
6699 static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6700 { 2, alc883_3ST_ch2_clevo_init },
6701 { 4, alc883_3ST_ch4_clevo_init },
6702 { 6, alc883_3ST_ch6_clevo_init },
6707 * 6ch mode
6709 static struct hda_verb alc882_sixstack_ch6_init[] = {
6710 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6711 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6712 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6713 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6714 { } /* end */
6718 * 8ch mode
6720 static struct hda_verb alc882_sixstack_ch8_init[] = {
6721 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6722 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6723 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6724 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6725 { } /* end */
6728 static struct hda_channel_mode alc882_sixstack_modes[2] = {
6729 { 6, alc882_sixstack_ch6_init },
6730 { 8, alc882_sixstack_ch8_init },
6734 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
6738 * 2ch mode
6740 static struct hda_verb alc885_mbp_ch2_init[] = {
6741 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6742 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6743 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6744 { } /* end */
6748 * 4ch mode
6750 static struct hda_verb alc885_mbp_ch4_init[] = {
6751 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6752 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6753 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6754 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6755 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6756 { } /* end */
6759 static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
6760 { 2, alc885_mbp_ch2_init },
6761 { 4, alc885_mbp_ch4_init },
6765 * 2ch
6766 * Speakers/Woofer/HP = Front
6767 * LineIn = Input
6769 static struct hda_verb alc885_mb5_ch2_init[] = {
6770 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6772 { } /* end */
6776 * 6ch mode
6777 * Speakers/HP = Front
6778 * Woofer = LFE
6779 * LineIn = Surround
6781 static struct hda_verb alc885_mb5_ch6_init[] = {
6782 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6783 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6785 { } /* end */
6788 static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6789 { 2, alc885_mb5_ch2_init },
6790 { 6, alc885_mb5_ch6_init },
6795 * 2ch mode
6797 static struct hda_verb alc883_4ST_ch2_init[] = {
6798 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6799 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6800 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6801 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6802 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6803 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6804 { } /* end */
6808 * 4ch mode
6810 static struct hda_verb alc883_4ST_ch4_init[] = {
6811 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6812 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6813 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6814 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6815 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6816 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6817 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6818 { } /* end */
6822 * 6ch mode
6824 static struct hda_verb alc883_4ST_ch6_init[] = {
6825 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6826 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6827 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6828 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6829 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6830 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6831 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6832 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6833 { } /* end */
6837 * 8ch mode
6839 static struct hda_verb alc883_4ST_ch8_init[] = {
6840 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6841 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6842 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6843 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6844 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6845 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6846 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6847 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6848 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6849 { } /* end */
6852 static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6853 { 2, alc883_4ST_ch2_init },
6854 { 4, alc883_4ST_ch4_init },
6855 { 6, alc883_4ST_ch6_init },
6856 { 8, alc883_4ST_ch8_init },
6861 * 2ch mode
6863 static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6864 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6865 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6866 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6867 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6868 { } /* end */
6872 * 4ch mode
6874 static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6875 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6876 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6877 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6878 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6879 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6880 { } /* end */
6884 * 6ch mode
6886 static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6887 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6888 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6889 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6890 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6891 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6892 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6893 { } /* end */
6896 static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6897 { 2, alc883_3ST_ch2_intel_init },
6898 { 4, alc883_3ST_ch4_intel_init },
6899 { 6, alc883_3ST_ch6_intel_init },
6903 * 2ch mode
6905 static struct hda_verb alc889_ch2_intel_init[] = {
6906 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6907 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6908 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6909 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6910 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6911 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6912 { } /* end */
6916 * 6ch mode
6918 static struct hda_verb alc889_ch6_intel_init[] = {
6919 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6920 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6921 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6922 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6923 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6924 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6925 { } /* end */
6929 * 8ch mode
6931 static struct hda_verb alc889_ch8_intel_init[] = {
6932 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6933 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6934 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6935 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6936 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
6937 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6938 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6939 { } /* end */
6942 static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6943 { 2, alc889_ch2_intel_init },
6944 { 6, alc889_ch6_intel_init },
6945 { 8, alc889_ch8_intel_init },
6949 * 6ch mode
6951 static struct hda_verb alc883_sixstack_ch6_init[] = {
6952 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6953 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6954 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6955 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6956 { } /* end */
6960 * 8ch mode
6962 static struct hda_verb alc883_sixstack_ch8_init[] = {
6963 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6964 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6965 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6966 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6967 { } /* end */
6970 static struct hda_channel_mode alc883_sixstack_modes[2] = {
6971 { 6, alc883_sixstack_ch6_init },
6972 { 8, alc883_sixstack_ch8_init },
6976 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6977 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6979 static struct snd_kcontrol_new alc882_base_mixer[] = {
6980 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6981 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6982 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6983 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6984 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6985 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6986 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6987 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6988 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6989 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6991 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6992 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6993 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6994 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6996 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6998 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6999 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7000 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7001 { } /* end */
7004 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
7005 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7006 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7007 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7008 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7009 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
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, 0x00, HDA_INPUT),
7013 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7014 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
7015 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7016 { } /* end */
7019 static struct snd_kcontrol_new alc885_mb5_mixer[] = {
7020 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7021 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7022 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7023 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7024 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7025 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7026 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7027 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
7028 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7029 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7031 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7032 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7033 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7034 { } /* end */
7037 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7038 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7039 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7040 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7041 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7042 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7043 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7045 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7047 { } /* end */
7050 static struct snd_kcontrol_new alc882_targa_mixer[] = {
7051 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7052 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7053 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7054 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7055 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7058 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7059 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7060 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7061 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7062 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7063 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7064 { } /* end */
7067 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7068 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7070 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7071 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7072 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7073 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7074 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7075 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7076 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7077 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7078 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7079 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7080 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7081 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7082 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7083 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7084 { } /* end */
7087 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7088 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7089 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7091 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7092 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7093 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7094 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7096 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7098 { } /* end */
7101 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7103 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7104 .name = "Channel Mode",
7105 .info = alc_ch_mode_info,
7106 .get = alc_ch_mode_get,
7107 .put = alc_ch_mode_put,
7109 { } /* end */
7112 static struct hda_verb alc882_base_init_verbs[] = {
7113 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7117 /* Rear mixer */
7118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7119 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7120 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7121 /* CLFE mixer */
7122 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7123 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7124 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7125 /* Side mixer */
7126 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7127 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7128 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7130 /* mute analog input loopbacks */
7131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7134 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7135 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7137 /* Front Pin: output 0 (0x0c) */
7138 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7139 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7140 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7141 /* Rear Pin: output 1 (0x0d) */
7142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7144 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7145 /* CLFE Pin: output 2 (0x0e) */
7146 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7147 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7148 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7149 /* Side Pin: output 3 (0x0f) */
7150 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7151 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7152 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7153 /* Mic (rear) pin: input vref at 80% */
7154 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7155 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7156 /* Front Mic pin: input vref at 80% */
7157 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7158 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7159 /* Line In pin: input */
7160 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7161 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7162 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7163 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7164 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7165 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7166 /* CD pin widget for input */
7167 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7169 /* FIXME: use matrix-type input source selection */
7170 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7171 /* Input mixer2 */
7172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7174 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7176 /* Input mixer3 */
7177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7179 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7181 /* ADC2: mute amp left and right */
7182 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7183 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7184 /* ADC3: mute amp left and right */
7185 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7186 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7191 static struct hda_verb alc882_adc1_init_verbs[] = {
7192 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7197 /* ADC1: mute amp left and right */
7198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7199 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7203 static struct hda_verb alc882_eapd_verbs[] = {
7204 /* change to EAPD mode */
7205 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7206 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
7210 static struct hda_verb alc889_eapd_verbs[] = {
7211 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7212 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7216 static struct hda_verb alc_hp15_unsol_verbs[] = {
7217 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7222 static struct hda_verb alc885_init_verbs[] = {
7223 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7227 /* Rear mixer */
7228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7229 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7230 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7231 /* CLFE mixer */
7232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7233 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7234 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7235 /* Side mixer */
7236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7237 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7238 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7240 /* mute analog input loopbacks */
7241 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7242 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7243 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7245 /* Front HP Pin: output 0 (0x0c) */
7246 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7247 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7248 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7249 /* Front Pin: output 0 (0x0c) */
7250 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7251 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7252 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7253 /* Rear Pin: output 1 (0x0d) */
7254 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7255 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7256 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7257 /* CLFE Pin: output 2 (0x0e) */
7258 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7260 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7261 /* Side Pin: output 3 (0x0f) */
7262 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7264 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7265 /* Mic (rear) pin: input vref at 80% */
7266 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7268 /* Front Mic pin: input vref at 80% */
7269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7270 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7271 /* Line In pin: input */
7272 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7273 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7275 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7276 /* Input mixer1 */
7277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7280 /* Input mixer2 */
7281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7284 /* Input mixer3 */
7285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7288 /* ADC2: mute amp left and right */
7289 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7290 /* ADC3: mute amp left and right */
7291 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7296 static struct hda_verb alc885_init_input_verbs[] = {
7297 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7298 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7304 /* Unmute Selector 24h and set the default input to front mic */
7305 static struct hda_verb alc889_init_input_verbs[] = {
7306 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7307 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7312 #define alc883_init_verbs alc882_base_init_verbs
7314 /* Mac Pro test */
7315 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7316 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7317 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7318 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7319 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7320 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7321 /* FIXME: this looks suspicious...
7322 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7323 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
7325 { } /* end */
7328 static struct hda_verb alc882_macpro_init_verbs[] = {
7329 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7333 /* Front Pin: output 0 (0x0c) */
7334 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7337 /* Front Mic pin: input vref at 80% */
7338 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7339 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7340 /* Speaker: output */
7341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7343 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7344 /* Headphone output (output 0 - 0x0c) */
7345 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7346 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7347 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7349 /* FIXME: use matrix-type input source selection */
7350 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7351 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7352 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7353 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7354 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7355 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7356 /* Input mixer2 */
7357 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7359 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7360 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7361 /* Input mixer3 */
7362 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7363 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7364 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7365 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7366 /* ADC1: mute amp left and right */
7367 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7368 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7369 /* ADC2: mute amp left and right */
7370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7371 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7372 /* ADC3: mute amp left and right */
7373 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7374 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7379 /* Macbook 5,1 */
7380 static struct hda_verb alc885_mb5_init_verbs[] = {
7381 /* DACs */
7382 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7383 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7384 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7385 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7386 /* Front mixer */
7387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7388 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7389 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7390 /* Surround mixer */
7391 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7392 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7394 /* LFE mixer */
7395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7398 /* HP mixer */
7399 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7400 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7401 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7402 /* Front Pin (0x0c) */
7403 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7404 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7405 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7406 /* LFE Pin (0x0e) */
7407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7408 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7409 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7410 /* HP Pin (0x0f) */
7411 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7412 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7413 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7414 /* Front Mic pin: input vref at 80% */
7415 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7416 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7417 /* Line In pin */
7418 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7419 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7421 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7422 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7423 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7424 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7428 /* Macbook Pro rev3 */
7429 static struct hda_verb alc885_mbp3_init_verbs[] = {
7430 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7432 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7433 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7434 /* Rear mixer */
7435 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7436 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7438 /* HP mixer */
7439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7441 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7442 /* Front Pin: output 0 (0x0c) */
7443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7445 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7446 /* HP Pin: output 0 (0x0e) */
7447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7449 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
7450 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7451 /* Mic (rear) pin: input vref at 80% */
7452 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7453 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7454 /* Front Mic pin: input vref at 80% */
7455 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7456 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7457 /* Line In pin: use output 1 when in LineOut mode */
7458 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7459 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7460 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7462 /* FIXME: use matrix-type input source selection */
7463 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7464 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7465 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7466 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7467 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7468 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7469 /* Input mixer2 */
7470 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7471 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7472 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7473 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7474 /* Input mixer3 */
7475 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7476 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7477 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7479 /* ADC1: mute amp left and right */
7480 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7481 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7482 /* ADC2: mute amp left and right */
7483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7484 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7485 /* ADC3: mute amp left and right */
7486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7487 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7492 /* iMac 24 mixer. */
7493 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7494 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7495 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7496 { } /* end */
7499 /* iMac 24 init verbs. */
7500 static struct hda_verb alc885_imac24_init_verbs[] = {
7501 /* Internal speakers: output 0 (0x0c) */
7502 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7503 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7504 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7505 /* Internal speakers: output 0 (0x0c) */
7506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7508 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7509 /* Headphone: output 0 (0x0c) */
7510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7511 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7512 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7513 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7514 /* Front Mic: input vref at 80% */
7515 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7516 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7520 /* Toggle speaker-output according to the hp-jack state */
7521 static void alc885_imac24_setup(struct hda_codec *codec)
7523 struct alc_spec *spec = codec->spec;
7525 spec->autocfg.hp_pins[0] = 0x14;
7526 spec->autocfg.speaker_pins[0] = 0x18;
7527 spec->autocfg.speaker_pins[1] = 0x1a;
7530 static void alc885_mbp3_setup(struct hda_codec *codec)
7532 struct alc_spec *spec = codec->spec;
7534 spec->autocfg.hp_pins[0] = 0x15;
7535 spec->autocfg.speaker_pins[0] = 0x14;
7539 static struct hda_verb alc882_targa_verbs[] = {
7540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7543 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7544 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7546 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7547 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7548 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7550 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7551 { } /* end */
7554 /* toggle speaker-output according to the hp-jack state */
7555 static void alc882_targa_automute(struct hda_codec *codec)
7557 struct alc_spec *spec = codec->spec;
7558 alc_automute_amp(codec);
7559 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7560 spec->jack_present ? 1 : 3);
7563 static void alc882_targa_setup(struct hda_codec *codec)
7565 struct alc_spec *spec = codec->spec;
7567 spec->autocfg.hp_pins[0] = 0x14;
7568 spec->autocfg.speaker_pins[0] = 0x1b;
7571 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7573 if ((res >> 26) == ALC880_HP_EVENT)
7574 alc882_targa_automute(codec);
7577 static struct hda_verb alc882_asus_a7j_verbs[] = {
7578 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7581 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7583 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7585 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7586 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7587 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7589 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7590 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7591 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7592 { } /* end */
7595 static struct hda_verb alc882_asus_a7m_verbs[] = {
7596 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7599 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7601 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7603 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7604 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7605 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7607 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7608 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7609 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7610 { } /* end */
7613 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7615 unsigned int gpiostate, gpiomask, gpiodir;
7617 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7618 AC_VERB_GET_GPIO_DATA, 0);
7620 if (!muted)
7621 gpiostate |= (1 << pin);
7622 else
7623 gpiostate &= ~(1 << pin);
7625 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7626 AC_VERB_GET_GPIO_MASK, 0);
7627 gpiomask |= (1 << pin);
7629 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7630 AC_VERB_GET_GPIO_DIRECTION, 0);
7631 gpiodir |= (1 << pin);
7634 snd_hda_codec_write(codec, codec->afg, 0,
7635 AC_VERB_SET_GPIO_MASK, gpiomask);
7636 snd_hda_codec_write(codec, codec->afg, 0,
7637 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7639 msleep(1);
7641 snd_hda_codec_write(codec, codec->afg, 0,
7642 AC_VERB_SET_GPIO_DATA, gpiostate);
7645 /* set up GPIO at initialization */
7646 static void alc885_macpro_init_hook(struct hda_codec *codec)
7648 alc882_gpio_mute(codec, 0, 0);
7649 alc882_gpio_mute(codec, 1, 0);
7652 /* set up GPIO and update auto-muting at initialization */
7653 static void alc885_imac24_init_hook(struct hda_codec *codec)
7655 alc885_macpro_init_hook(codec);
7656 alc_automute_amp(codec);
7660 * generic initialization of ADC, input mixers and output mixers
7662 static struct hda_verb alc883_auto_init_verbs[] = {
7664 * Unmute ADC0-2 and set the default input to mic-in
7666 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7667 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7668 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7669 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7671 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7672 * mixer widget
7673 * Note: PASD motherboards uses the Line In 2 as the input for
7674 * front panel mic (mic 2)
7676 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7677 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7678 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7679 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7680 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7681 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7684 * Set up output mixers (0x0c - 0x0f)
7686 /* set vol=0 to output mixers */
7687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7689 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7690 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7691 /* set up input amps for analog loopback */
7692 /* Amp Indices: DAC = 0, mixer = 1 */
7693 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7694 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7695 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7696 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7697 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7698 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7699 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7700 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7701 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7702 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7704 /* FIXME: use matrix-type input source selection */
7705 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7706 /* Input mixer2 */
7707 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7708 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7709 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7710 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7711 /* Input mixer3 */
7712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7714 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7715 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7720 /* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7721 static struct hda_verb alc889A_mb31_ch2_init[] = {
7722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7723 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7726 { } /* end */
7729 /* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7730 static struct hda_verb alc889A_mb31_ch4_init[] = {
7731 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7732 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7733 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7734 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7735 { } /* end */
7738 /* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7739 static struct hda_verb alc889A_mb31_ch5_init[] = {
7740 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7741 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7743 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7744 { } /* end */
7747 /* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7748 static struct hda_verb alc889A_mb31_ch6_init[] = {
7749 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7750 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7751 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7752 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7753 { } /* end */
7756 static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7757 { 2, alc889A_mb31_ch2_init },
7758 { 4, alc889A_mb31_ch4_init },
7759 { 5, alc889A_mb31_ch5_init },
7760 { 6, alc889A_mb31_ch6_init },
7763 static struct hda_verb alc883_medion_eapd_verbs[] = {
7764 /* eanable EAPD on medion laptop */
7765 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7766 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7770 #define alc883_base_mixer alc882_base_mixer
7772 static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7773 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7774 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7775 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7776 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7777 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7778 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7781 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7783 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7784 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7785 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7786 { } /* end */
7789 static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
7790 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7791 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7792 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7793 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7795 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7796 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7797 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7798 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7799 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7800 { } /* end */
7803 static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7804 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7805 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7806 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7807 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7812 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7813 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7814 { } /* end */
7817 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7818 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7819 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7820 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7821 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7822 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7823 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7824 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, 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("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7829 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7830 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7831 { } /* end */
7834 static struct snd_kcontrol_new alc883_3ST_6ch_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_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7838 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7839 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7840 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7841 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7842 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7843 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7844 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7845 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7846 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7847 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7848 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7849 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7851 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7852 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7853 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7854 { } /* end */
7857 static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7858 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7859 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7860 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7861 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7862 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7863 HDA_OUTPUT),
7864 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7865 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7866 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7867 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7868 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7869 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7873 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7875 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7876 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7877 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7878 { } /* end */
7881 static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7882 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7883 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7884 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7885 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7886 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7887 HDA_OUTPUT),
7888 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7889 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7890 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7891 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7892 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7894 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7895 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7897 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7899 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7900 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7902 { } /* end */
7905 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
7906 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7907 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7908 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7909 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7910 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7911 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7912 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7913 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7914 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7915 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7916 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7918 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7922 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7923 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7924 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7925 { } /* end */
7928 static struct snd_kcontrol_new alc883_targa_mixer[] = {
7929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7931 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7932 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7933 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7934 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7935 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7936 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7937 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7938 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7939 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7940 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7941 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7943 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7944 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7945 { } /* end */
7948 static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
7949 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7950 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7951 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7952 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7953 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7955 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7957 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7958 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7959 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7960 { } /* end */
7963 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7965 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7966 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7967 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7970 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7972 { } /* end */
7975 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7976 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7977 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7979 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7980 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7982 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7983 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7984 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7985 { } /* end */
7988 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7989 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7991 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7992 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7993 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7994 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7995 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7996 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7997 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7998 { } /* end */
8001 static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
8002 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8003 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8005 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8006 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8008 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8010 { } /* end */
8013 static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8014 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8015 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8016 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8017 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
8018 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8019 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8023 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8024 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8025 { } /* end */
8028 static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8029 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8030 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8031 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8032 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8033 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8034 0x0d, 1, 0x0, HDA_OUTPUT),
8035 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8036 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8037 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8038 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8039 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8040 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8041 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8042 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8043 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8044 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8045 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8046 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8047 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8048 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8049 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8050 { } /* end */
8053 static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8054 /* Output mixers */
8055 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8056 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8057 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8058 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8059 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8060 HDA_OUTPUT),
8061 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8062 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8063 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8064 /* Output switches */
8065 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8066 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8067 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8068 /* Boost mixers */
8069 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8070 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8071 /* Input mixers */
8072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8074 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8075 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8076 { } /* end */
8079 static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8080 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8081 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8082 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8084 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8085 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8086 { } /* end */
8089 static struct hda_bind_ctls alc883_bind_cap_vol = {
8090 .ops = &snd_hda_bind_vol,
8091 .values = {
8092 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8093 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8098 static struct hda_bind_ctls alc883_bind_cap_switch = {
8099 .ops = &snd_hda_bind_sw,
8100 .values = {
8101 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8102 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8107 static struct snd_kcontrol_new alc883_asus_eee1601_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", 0x14, 0x0, HDA_OUTPUT),
8111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8114 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8116 { } /* end */
8119 static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
8120 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8121 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8124 /* .name = "Capture Source", */
8125 .name = "Input Source",
8126 .count = 1,
8127 .info = alc_mux_enum_info,
8128 .get = alc_mux_enum_get,
8129 .put = alc_mux_enum_put,
8131 { } /* end */
8134 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8137 .name = "Channel Mode",
8138 .info = alc_ch_mode_info,
8139 .get = alc_ch_mode_get,
8140 .put = alc_ch_mode_put,
8142 { } /* end */
8145 /* toggle speaker-output according to the hp-jack state */
8146 static void alc883_mitac_setup(struct hda_codec *codec)
8148 struct alc_spec *spec = codec->spec;
8150 spec->autocfg.hp_pins[0] = 0x15;
8151 spec->autocfg.speaker_pins[0] = 0x14;
8152 spec->autocfg.speaker_pins[1] = 0x17;
8155 /* auto-toggle front mic */
8157 static void alc883_mitac_mic_automute(struct hda_codec *codec)
8159 unsigned int present;
8160 unsigned char bits;
8162 present = snd_hda_codec_read(codec, 0x18, 0,
8163 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8164 bits = present ? HDA_AMP_MUTE : 0;
8165 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8169 static struct hda_verb alc883_mitac_verbs[] = {
8170 /* HP */
8171 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8172 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8173 /* Subwoofer */
8174 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8175 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8177 /* enable unsolicited event */
8178 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8179 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8181 { } /* end */
8184 static struct hda_verb alc883_clevo_m540r_verbs[] = {
8185 /* HP */
8186 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8188 /* Int speaker */
8189 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8191 /* enable unsolicited event */
8193 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8194 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8197 { } /* end */
8200 static struct hda_verb alc883_clevo_m720_verbs[] = {
8201 /* HP */
8202 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8203 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8204 /* Int speaker */
8205 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8208 /* enable unsolicited event */
8209 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8210 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8212 { } /* end */
8215 static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8216 /* HP */
8217 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8219 /* Subwoofer */
8220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8223 /* enable unsolicited event */
8224 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8226 { } /* end */
8229 static struct hda_verb alc883_targa_verbs[] = {
8230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8233 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8234 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8236 /* Connect Line-Out side jack (SPDIF) to Side */
8237 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8238 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8239 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8240 /* Connect Mic jack to CLFE */
8241 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8242 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8243 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8244 /* Connect Line-in jack to Surround */
8245 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8246 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8247 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8248 /* Connect HP out jack to Front */
8249 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8250 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8251 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8253 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8255 { } /* end */
8258 static struct hda_verb alc883_lenovo_101e_verbs[] = {
8259 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8260 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8261 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8262 { } /* end */
8265 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8266 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8268 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8270 { } /* end */
8273 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8274 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8275 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8276 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8277 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8278 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8279 { } /* end */
8282 static struct hda_verb alc883_haier_w66_verbs[] = {
8283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8284 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8288 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8289 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8290 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8291 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8292 { } /* end */
8295 static struct hda_verb alc888_lenovo_sky_verbs[] = {
8296 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8297 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8298 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8300 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8302 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8303 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8304 { } /* end */
8307 static struct hda_verb alc888_6st_dell_verbs[] = {
8308 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8312 static struct hda_verb alc883_vaiott_verbs[] = {
8313 /* HP */
8314 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8315 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8317 /* enable unsolicited event */
8318 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8320 { } /* end */
8323 static void alc888_3st_hp_setup(struct hda_codec *codec)
8325 struct alc_spec *spec = codec->spec;
8327 spec->autocfg.hp_pins[0] = 0x1b;
8328 spec->autocfg.speaker_pins[0] = 0x14;
8329 spec->autocfg.speaker_pins[1] = 0x16;
8330 spec->autocfg.speaker_pins[2] = 0x18;
8333 static struct hda_verb alc888_3st_hp_verbs[] = {
8334 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
8335 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8336 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
8337 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8338 { } /* end */
8342 * 2ch mode
8344 static struct hda_verb alc888_3st_hp_2ch_init[] = {
8345 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8346 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8347 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8348 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8349 { } /* end */
8353 * 4ch mode
8355 static struct hda_verb alc888_3st_hp_4ch_init[] = {
8356 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8357 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8358 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8359 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8360 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8361 { } /* end */
8365 * 6ch mode
8367 static struct hda_verb alc888_3st_hp_6ch_init[] = {
8368 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8369 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8370 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
8371 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8372 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8373 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8374 { } /* end */
8377 static struct hda_channel_mode alc888_3st_hp_modes[3] = {
8378 { 2, alc888_3st_hp_2ch_init },
8379 { 4, alc888_3st_hp_4ch_init },
8380 { 6, alc888_3st_hp_6ch_init },
8383 /* toggle front-jack and RCA according to the hp-jack state */
8384 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8386 unsigned int present;
8388 present = snd_hda_codec_read(codec, 0x1b, 0,
8389 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8390 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8391 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8392 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8393 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8396 /* toggle RCA according to the front-jack state */
8397 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8399 unsigned int present;
8401 present = snd_hda_codec_read(codec, 0x14, 0,
8402 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8403 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8404 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8407 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8408 unsigned int res)
8410 if ((res >> 26) == ALC880_HP_EVENT)
8411 alc888_lenovo_ms7195_front_automute(codec);
8412 if ((res >> 26) == ALC880_FRONT_EVENT)
8413 alc888_lenovo_ms7195_rca_automute(codec);
8416 static struct hda_verb alc883_medion_md2_verbs[] = {
8417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8418 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8420 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8422 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8423 { } /* end */
8426 /* toggle speaker-output according to the hp-jack state */
8427 static void alc883_medion_md2_setup(struct hda_codec *codec)
8429 struct alc_spec *spec = codec->spec;
8431 spec->autocfg.hp_pins[0] = 0x14;
8432 spec->autocfg.speaker_pins[0] = 0x15;
8435 /* toggle speaker-output according to the hp-jack state */
8436 #define alc883_targa_init_hook alc882_targa_init_hook
8437 #define alc883_targa_unsol_event alc882_targa_unsol_event
8439 static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8441 unsigned int present;
8443 present = snd_hda_codec_read(codec, 0x18, 0,
8444 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8445 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8446 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8449 static void alc883_clevo_m720_setup(struct hda_codec *codec)
8451 struct alc_spec *spec = codec->spec;
8453 spec->autocfg.hp_pins[0] = 0x15;
8454 spec->autocfg.speaker_pins[0] = 0x14;
8457 static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8459 alc_automute_amp(codec);
8460 alc883_clevo_m720_mic_automute(codec);
8463 static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
8464 unsigned int res)
8466 switch (res >> 26) {
8467 case ALC880_MIC_EVENT:
8468 alc883_clevo_m720_mic_automute(codec);
8469 break;
8470 default:
8471 alc_automute_amp_unsol_event(codec, res);
8472 break;
8476 /* toggle speaker-output according to the hp-jack state */
8477 static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
8479 struct alc_spec *spec = codec->spec;
8481 spec->autocfg.hp_pins[0] = 0x14;
8482 spec->autocfg.speaker_pins[0] = 0x15;
8485 static void alc883_haier_w66_setup(struct hda_codec *codec)
8487 struct alc_spec *spec = codec->spec;
8489 spec->autocfg.hp_pins[0] = 0x1b;
8490 spec->autocfg.speaker_pins[0] = 0x14;
8493 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8495 unsigned int present;
8496 unsigned char bits;
8498 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8499 & AC_PINSENSE_PRESENCE;
8500 bits = present ? HDA_AMP_MUTE : 0;
8501 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8502 HDA_AMP_MUTE, bits);
8505 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8507 unsigned int present;
8508 unsigned char bits;
8510 present = snd_hda_codec_read(codec, 0x1b, 0,
8511 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8512 bits = present ? HDA_AMP_MUTE : 0;
8513 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8514 HDA_AMP_MUTE, bits);
8515 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8516 HDA_AMP_MUTE, bits);
8519 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8520 unsigned int res)
8522 if ((res >> 26) == ALC880_HP_EVENT)
8523 alc883_lenovo_101e_all_automute(codec);
8524 if ((res >> 26) == ALC880_FRONT_EVENT)
8525 alc883_lenovo_101e_ispeaker_automute(codec);
8528 /* toggle speaker-output according to the hp-jack state */
8529 static void alc883_acer_aspire_setup(struct hda_codec *codec)
8531 struct alc_spec *spec = codec->spec;
8533 spec->autocfg.hp_pins[0] = 0x14;
8534 spec->autocfg.speaker_pins[0] = 0x15;
8535 spec->autocfg.speaker_pins[1] = 0x16;
8538 static struct hda_verb alc883_acer_eapd_verbs[] = {
8539 /* HP Pin: output 0 (0x0c) */
8540 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8541 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8542 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8543 /* Front Pin: output 0 (0x0c) */
8544 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8545 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8546 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8547 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8548 /* eanable EAPD on medion laptop */
8549 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8550 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8551 /* enable unsolicited event */
8552 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8556 static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8557 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8558 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8559 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8560 { } /* end */
8563 static void alc888_6st_dell_setup(struct hda_codec *codec)
8565 struct alc_spec *spec = codec->spec;
8567 spec->autocfg.hp_pins[0] = 0x1b;
8568 spec->autocfg.speaker_pins[0] = 0x14;
8569 spec->autocfg.speaker_pins[1] = 0x15;
8570 spec->autocfg.speaker_pins[2] = 0x16;
8571 spec->autocfg.speaker_pins[3] = 0x17;
8574 static void alc888_lenovo_sky_setup(struct hda_codec *codec)
8576 struct alc_spec *spec = codec->spec;
8578 spec->autocfg.hp_pins[0] = 0x1b;
8579 spec->autocfg.speaker_pins[0] = 0x14;
8580 spec->autocfg.speaker_pins[1] = 0x15;
8581 spec->autocfg.speaker_pins[2] = 0x16;
8582 spec->autocfg.speaker_pins[3] = 0x17;
8583 spec->autocfg.speaker_pins[4] = 0x1a;
8586 static void alc883_vaiott_setup(struct hda_codec *codec)
8588 struct alc_spec *spec = codec->spec;
8590 spec->autocfg.hp_pins[0] = 0x15;
8591 spec->autocfg.speaker_pins[0] = 0x14;
8592 spec->autocfg.speaker_pins[1] = 0x17;
8595 static struct hda_verb alc888_asus_m90v_verbs[] = {
8596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8599 /* enable unsolicited event */
8600 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8601 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8602 { } /* end */
8605 static void alc883_mode2_setup(struct hda_codec *codec)
8607 struct alc_spec *spec = codec->spec;
8609 spec->autocfg.hp_pins[0] = 0x1b;
8610 spec->autocfg.speaker_pins[0] = 0x14;
8611 spec->autocfg.speaker_pins[1] = 0x15;
8612 spec->autocfg.speaker_pins[2] = 0x16;
8613 spec->ext_mic.pin = 0x18;
8614 spec->int_mic.pin = 0x19;
8615 spec->ext_mic.mux_idx = 0;
8616 spec->int_mic.mux_idx = 1;
8617 spec->auto_mic = 1;
8620 static struct hda_verb alc888_asus_eee1601_verbs[] = {
8621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8624 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8626 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8627 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8628 /* enable unsolicited event */
8629 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8630 { } /* end */
8633 static void alc883_eee1601_inithook(struct hda_codec *codec)
8635 struct alc_spec *spec = codec->spec;
8637 spec->autocfg.hp_pins[0] = 0x14;
8638 spec->autocfg.speaker_pins[0] = 0x1b;
8639 alc_automute_pin(codec);
8642 static struct hda_verb alc889A_mb31_verbs[] = {
8643 /* Init rear pin (used as headphone output) */
8644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8645 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8646 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8647 /* Init line pin (used as output in 4ch and 6ch mode) */
8648 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8649 /* Init line 2 pin (used as headphone out by default) */
8650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8651 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8652 { } /* end */
8655 /* Mute speakers according to the headphone jack state */
8656 static void alc889A_mb31_automute(struct hda_codec *codec)
8658 unsigned int present;
8660 /* Mute only in 2ch or 4ch mode */
8661 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8662 == 0x00) {
8663 present = snd_hda_codec_read(codec, 0x15, 0,
8664 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8665 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8666 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8667 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8668 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8672 static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8674 if ((res >> 26) == ALC880_HP_EVENT)
8675 alc889A_mb31_automute(codec);
8679 #ifdef CONFIG_SND_HDA_POWER_SAVE
8680 #define alc882_loopbacks alc880_loopbacks
8681 #endif
8683 /* pcm configuration: identical with ALC880 */
8684 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
8685 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
8686 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
8687 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
8689 static hda_nid_t alc883_slave_dig_outs[] = {
8690 ALC1200_DIGOUT_NID, 0,
8693 static hda_nid_t alc1200_slave_dig_outs[] = {
8694 ALC883_DIGOUT_NID, 0,
8698 * configuration and preset
8700 static const char *alc882_models[ALC882_MODEL_LAST] = {
8701 [ALC882_3ST_DIG] = "3stack-dig",
8702 [ALC882_6ST_DIG] = "6stack-dig",
8703 [ALC882_ARIMA] = "arima",
8704 [ALC882_W2JC] = "w2jc",
8705 [ALC882_TARGA] = "targa",
8706 [ALC882_ASUS_A7J] = "asus-a7j",
8707 [ALC882_ASUS_A7M] = "asus-a7m",
8708 [ALC885_MACPRO] = "macpro",
8709 [ALC885_MB5] = "mb5",
8710 [ALC885_MBP3] = "mbp3",
8711 [ALC885_IMAC24] = "imac24",
8712 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
8713 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8714 [ALC883_3ST_6ch] = "3stack-6ch",
8715 [ALC883_6ST_DIG] = "alc883-6stack-dig",
8716 [ALC883_TARGA_DIG] = "targa-dig",
8717 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
8718 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
8719 [ALC883_ACER] = "acer",
8720 [ALC883_ACER_ASPIRE] = "acer-aspire",
8721 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
8722 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
8723 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
8724 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
8725 [ALC883_MEDION] = "medion",
8726 [ALC883_MEDION_MD2] = "medion-md2",
8727 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
8728 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
8729 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8730 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
8731 [ALC888_LENOVO_SKY] = "lenovo-sky",
8732 [ALC883_HAIER_W66] = "haier-w66",
8733 [ALC888_3ST_HP] = "3stack-hp",
8734 [ALC888_6ST_DELL] = "6stack-dell",
8735 [ALC883_MITAC] = "mitac",
8736 [ALC883_CLEVO_M540R] = "clevo-m540r",
8737 [ALC883_CLEVO_M720] = "clevo-m720",
8738 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
8739 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
8740 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
8741 [ALC889A_INTEL] = "intel-alc889a",
8742 [ALC889_INTEL] = "intel-x58",
8743 [ALC1200_ASUS_P5Q] = "asus-p5q",
8744 [ALC889A_MB31] = "mb31",
8745 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
8746 [ALC882_AUTO] = "auto",
8749 static struct snd_pci_quirk alc882_cfg_tbl[] = {
8750 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8752 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8753 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
8754 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
8755 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8756 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
8757 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
8758 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8759 ALC888_ACER_ASPIRE_4930G),
8760 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8761 ALC888_ACER_ASPIRE_4930G),
8762 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8763 ALC888_ACER_ASPIRE_8930G),
8764 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8765 ALC888_ACER_ASPIRE_8930G),
8766 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8767 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
8768 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8769 ALC888_ACER_ASPIRE_6530G),
8770 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8771 ALC888_ACER_ASPIRE_6530G),
8772 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8773 ALC888_ACER_ASPIRE_7730G),
8774 /* default Acer -- disabled as it causes more problems.
8775 * model=auto should work fine now
8777 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
8779 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8781 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
8782 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8783 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
8784 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
8785 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
8786 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
8788 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8789 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8790 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
8791 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8792 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8793 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8794 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
8795 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8796 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
8797 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
8798 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8800 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
8801 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
8802 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
8803 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
8804 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8805 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
8806 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
8807 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
8808 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8810 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8811 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8812 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
8813 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
8814 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
8815 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
8816 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
8817 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
8818 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8819 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8820 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8821 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8822 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8823 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8824 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
8825 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8826 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8827 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
8828 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
8829 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8830 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
8831 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
8832 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
8833 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
8834 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
8835 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
8836 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
8837 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
8838 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
8840 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
8841 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8842 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
8843 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
8844 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
8845 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8846 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
8847 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
8848 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
8849 ALC883_FUJITSU_PI2515),
8850 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
8851 ALC888_FUJITSU_XA3530),
8852 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
8853 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8854 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8855 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8856 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
8857 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
8858 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
8859 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
8860 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
8862 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8863 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
8864 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
8865 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8866 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8867 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
8868 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
8873 /* codec SSID table for Intel Mac */
8874 static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8875 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8876 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8877 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8878 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8879 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8880 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8881 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8882 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8883 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8884 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8885 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8886 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8887 * no perfect solution yet
8889 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8890 {} /* terminator */
8893 static struct alc_config_preset alc882_presets[] = {
8894 [ALC882_3ST_DIG] = {
8895 .mixers = { alc882_base_mixer },
8896 .init_verbs = { alc882_base_init_verbs,
8897 alc882_adc1_init_verbs },
8898 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8899 .dac_nids = alc882_dac_nids,
8900 .dig_out_nid = ALC882_DIGOUT_NID,
8901 .dig_in_nid = ALC882_DIGIN_NID,
8902 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8903 .channel_mode = alc882_ch_modes,
8904 .need_dac_fix = 1,
8905 .input_mux = &alc882_capture_source,
8907 [ALC882_6ST_DIG] = {
8908 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8909 .init_verbs = { alc882_base_init_verbs,
8910 alc882_adc1_init_verbs },
8911 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8912 .dac_nids = alc882_dac_nids,
8913 .dig_out_nid = ALC882_DIGOUT_NID,
8914 .dig_in_nid = ALC882_DIGIN_NID,
8915 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8916 .channel_mode = alc882_sixstack_modes,
8917 .input_mux = &alc882_capture_source,
8919 [ALC882_ARIMA] = {
8920 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8921 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8922 alc882_eapd_verbs },
8923 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8924 .dac_nids = alc882_dac_nids,
8925 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8926 .channel_mode = alc882_sixstack_modes,
8927 .input_mux = &alc882_capture_source,
8929 [ALC882_W2JC] = {
8930 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
8931 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8932 alc882_eapd_verbs, alc880_gpio1_init_verbs },
8933 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8934 .dac_nids = alc882_dac_nids,
8935 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8936 .channel_mode = alc880_threestack_modes,
8937 .need_dac_fix = 1,
8938 .input_mux = &alc882_capture_source,
8939 .dig_out_nid = ALC882_DIGOUT_NID,
8941 [ALC885_MBP3] = {
8942 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8943 .init_verbs = { alc885_mbp3_init_verbs,
8944 alc880_gpio1_init_verbs },
8945 .num_dacs = 2,
8946 .dac_nids = alc882_dac_nids,
8947 .hp_nid = 0x04,
8948 .channel_mode = alc885_mbp_4ch_modes,
8949 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
8950 .input_mux = &alc882_capture_source,
8951 .dig_out_nid = ALC882_DIGOUT_NID,
8952 .dig_in_nid = ALC882_DIGIN_NID,
8953 .unsol_event = alc_automute_amp_unsol_event,
8954 .setup = alc885_mbp3_setup,
8955 .init_hook = alc_automute_amp,
8957 [ALC885_MB5] = {
8958 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8959 .init_verbs = { alc885_mb5_init_verbs,
8960 alc880_gpio1_init_verbs },
8961 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8962 .dac_nids = alc882_dac_nids,
8963 .channel_mode = alc885_mb5_6ch_modes,
8964 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8965 .input_mux = &mb5_capture_source,
8966 .dig_out_nid = ALC882_DIGOUT_NID,
8967 .dig_in_nid = ALC882_DIGIN_NID,
8969 [ALC885_MACPRO] = {
8970 .mixers = { alc882_macpro_mixer },
8971 .init_verbs = { alc882_macpro_init_verbs },
8972 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8973 .dac_nids = alc882_dac_nids,
8974 .dig_out_nid = ALC882_DIGOUT_NID,
8975 .dig_in_nid = ALC882_DIGIN_NID,
8976 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8977 .channel_mode = alc882_ch_modes,
8978 .input_mux = &alc882_capture_source,
8979 .init_hook = alc885_macpro_init_hook,
8981 [ALC885_IMAC24] = {
8982 .mixers = { alc885_imac24_mixer },
8983 .init_verbs = { alc885_imac24_init_verbs },
8984 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8985 .dac_nids = alc882_dac_nids,
8986 .dig_out_nid = ALC882_DIGOUT_NID,
8987 .dig_in_nid = ALC882_DIGIN_NID,
8988 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8989 .channel_mode = alc882_ch_modes,
8990 .input_mux = &alc882_capture_source,
8991 .unsol_event = alc_automute_amp_unsol_event,
8992 .setup = alc885_imac24_setup,
8993 .init_hook = alc885_imac24_init_hook,
8995 [ALC882_TARGA] = {
8996 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
8997 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8998 alc880_gpio3_init_verbs, alc882_targa_verbs},
8999 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9000 .dac_nids = alc882_dac_nids,
9001 .dig_out_nid = ALC882_DIGOUT_NID,
9002 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9003 .adc_nids = alc882_adc_nids,
9004 .capsrc_nids = alc882_capsrc_nids,
9005 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9006 .channel_mode = alc882_3ST_6ch_modes,
9007 .need_dac_fix = 1,
9008 .input_mux = &alc882_capture_source,
9009 .unsol_event = alc882_targa_unsol_event,
9010 .setup = alc882_targa_setup,
9011 .init_hook = alc882_targa_automute,
9013 [ALC882_ASUS_A7J] = {
9014 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
9015 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9016 alc882_asus_a7j_verbs},
9017 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9018 .dac_nids = alc882_dac_nids,
9019 .dig_out_nid = ALC882_DIGOUT_NID,
9020 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9021 .adc_nids = alc882_adc_nids,
9022 .capsrc_nids = alc882_capsrc_nids,
9023 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9024 .channel_mode = alc882_3ST_6ch_modes,
9025 .need_dac_fix = 1,
9026 .input_mux = &alc882_capture_source,
9028 [ALC882_ASUS_A7M] = {
9029 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
9030 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9031 alc882_eapd_verbs, alc880_gpio1_init_verbs,
9032 alc882_asus_a7m_verbs },
9033 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9034 .dac_nids = alc882_dac_nids,
9035 .dig_out_nid = ALC882_DIGOUT_NID,
9036 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9037 .channel_mode = alc880_threestack_modes,
9038 .need_dac_fix = 1,
9039 .input_mux = &alc882_capture_source,
9041 [ALC883_3ST_2ch_DIG] = {
9042 .mixers = { alc883_3ST_2ch_mixer },
9043 .init_verbs = { alc883_init_verbs },
9044 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9045 .dac_nids = alc883_dac_nids,
9046 .dig_out_nid = ALC883_DIGOUT_NID,
9047 .dig_in_nid = ALC883_DIGIN_NID,
9048 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9049 .channel_mode = alc883_3ST_2ch_modes,
9050 .input_mux = &alc883_capture_source,
9052 [ALC883_3ST_6ch_DIG] = {
9053 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9054 .init_verbs = { alc883_init_verbs },
9055 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9056 .dac_nids = alc883_dac_nids,
9057 .dig_out_nid = ALC883_DIGOUT_NID,
9058 .dig_in_nid = ALC883_DIGIN_NID,
9059 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9060 .channel_mode = alc883_3ST_6ch_modes,
9061 .need_dac_fix = 1,
9062 .input_mux = &alc883_capture_source,
9064 [ALC883_3ST_6ch] = {
9065 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9066 .init_verbs = { alc883_init_verbs },
9067 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9068 .dac_nids = alc883_dac_nids,
9069 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9070 .channel_mode = alc883_3ST_6ch_modes,
9071 .need_dac_fix = 1,
9072 .input_mux = &alc883_capture_source,
9074 [ALC883_3ST_6ch_INTEL] = {
9075 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9076 .init_verbs = { alc883_init_verbs },
9077 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9078 .dac_nids = alc883_dac_nids,
9079 .dig_out_nid = ALC883_DIGOUT_NID,
9080 .dig_in_nid = ALC883_DIGIN_NID,
9081 .slave_dig_outs = alc883_slave_dig_outs,
9082 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9083 .channel_mode = alc883_3ST_6ch_intel_modes,
9084 .need_dac_fix = 1,
9085 .input_mux = &alc883_3stack_6ch_intel,
9087 [ALC889A_INTEL] = {
9088 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9089 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9090 alc_hp15_unsol_verbs },
9091 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9092 .dac_nids = alc883_dac_nids,
9093 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9094 .adc_nids = alc889_adc_nids,
9095 .dig_out_nid = ALC883_DIGOUT_NID,
9096 .dig_in_nid = ALC883_DIGIN_NID,
9097 .slave_dig_outs = alc883_slave_dig_outs,
9098 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9099 .channel_mode = alc889_8ch_intel_modes,
9100 .capsrc_nids = alc889_capsrc_nids,
9101 .input_mux = &alc889_capture_source,
9102 .setup = alc889_automute_setup,
9103 .init_hook = alc_automute_amp,
9104 .unsol_event = alc_automute_amp_unsol_event,
9105 .need_dac_fix = 1,
9107 [ALC889_INTEL] = {
9108 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9109 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
9110 alc889_eapd_verbs, alc_hp15_unsol_verbs},
9111 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9112 .dac_nids = alc883_dac_nids,
9113 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9114 .adc_nids = alc889_adc_nids,
9115 .dig_out_nid = ALC883_DIGOUT_NID,
9116 .dig_in_nid = ALC883_DIGIN_NID,
9117 .slave_dig_outs = alc883_slave_dig_outs,
9118 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9119 .channel_mode = alc889_8ch_intel_modes,
9120 .capsrc_nids = alc889_capsrc_nids,
9121 .input_mux = &alc889_capture_source,
9122 .setup = alc889_automute_setup,
9123 .init_hook = alc889_intel_init_hook,
9124 .unsol_event = alc_automute_amp_unsol_event,
9125 .need_dac_fix = 1,
9127 [ALC883_6ST_DIG] = {
9128 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9129 .init_verbs = { alc883_init_verbs },
9130 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9131 .dac_nids = alc883_dac_nids,
9132 .dig_out_nid = ALC883_DIGOUT_NID,
9133 .dig_in_nid = ALC883_DIGIN_NID,
9134 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9135 .channel_mode = alc883_sixstack_modes,
9136 .input_mux = &alc883_capture_source,
9138 [ALC883_TARGA_DIG] = {
9139 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
9140 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9141 alc883_targa_verbs},
9142 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9143 .dac_nids = alc883_dac_nids,
9144 .dig_out_nid = ALC883_DIGOUT_NID,
9145 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9146 .channel_mode = alc883_3ST_6ch_modes,
9147 .need_dac_fix = 1,
9148 .input_mux = &alc883_capture_source,
9149 .unsol_event = alc883_targa_unsol_event,
9150 .setup = alc882_targa_setup,
9151 .init_hook = alc882_targa_automute,
9153 [ALC883_TARGA_2ch_DIG] = {
9154 .mixers = { alc883_targa_2ch_mixer},
9155 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9156 alc883_targa_verbs},
9157 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9158 .dac_nids = alc883_dac_nids,
9159 .adc_nids = alc883_adc_nids_alt,
9160 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
9161 .dig_out_nid = ALC883_DIGOUT_NID,
9162 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9163 .channel_mode = alc883_3ST_2ch_modes,
9164 .input_mux = &alc883_capture_source,
9165 .unsol_event = alc883_targa_unsol_event,
9166 .setup = alc882_targa_setup,
9167 .init_hook = alc882_targa_automute,
9169 [ALC883_TARGA_8ch_DIG] = {
9170 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9171 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9172 alc883_targa_verbs },
9173 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9174 .dac_nids = alc883_dac_nids,
9175 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9176 .adc_nids = alc883_adc_nids_rev,
9177 .capsrc_nids = alc883_capsrc_nids_rev,
9178 .dig_out_nid = ALC883_DIGOUT_NID,
9179 .dig_in_nid = ALC883_DIGIN_NID,
9180 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9181 .channel_mode = alc883_4ST_8ch_modes,
9182 .need_dac_fix = 1,
9183 .input_mux = &alc883_capture_source,
9184 .unsol_event = alc883_targa_unsol_event,
9185 .setup = alc882_targa_setup,
9186 .init_hook = alc882_targa_automute,
9188 [ALC883_ACER] = {
9189 .mixers = { alc883_base_mixer },
9190 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9191 * and the headphone jack. Turn this on and rely on the
9192 * standard mute methods whenever the user wants to turn
9193 * these outputs off.
9195 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9196 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9197 .dac_nids = alc883_dac_nids,
9198 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9199 .channel_mode = alc883_3ST_2ch_modes,
9200 .input_mux = &alc883_capture_source,
9202 [ALC883_ACER_ASPIRE] = {
9203 .mixers = { alc883_acer_aspire_mixer },
9204 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
9205 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9206 .dac_nids = alc883_dac_nids,
9207 .dig_out_nid = ALC883_DIGOUT_NID,
9208 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9209 .channel_mode = alc883_3ST_2ch_modes,
9210 .input_mux = &alc883_capture_source,
9211 .unsol_event = alc_automute_amp_unsol_event,
9212 .setup = alc883_acer_aspire_setup,
9213 .init_hook = alc_automute_amp,
9215 [ALC888_ACER_ASPIRE_4930G] = {
9216 .mixers = { alc888_base_mixer,
9217 alc883_chmode_mixer },
9218 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9219 alc888_acer_aspire_4930g_verbs },
9220 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9221 .dac_nids = alc883_dac_nids,
9222 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9223 .adc_nids = alc883_adc_nids_rev,
9224 .capsrc_nids = alc883_capsrc_nids_rev,
9225 .dig_out_nid = ALC883_DIGOUT_NID,
9226 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9227 .channel_mode = alc883_3ST_6ch_modes,
9228 .need_dac_fix = 1,
9229 .num_mux_defs =
9230 ARRAY_SIZE(alc888_2_capture_sources),
9231 .input_mux = alc888_2_capture_sources,
9232 .unsol_event = alc_automute_amp_unsol_event,
9233 .setup = alc888_acer_aspire_4930g_setup,
9234 .init_hook = alc_automute_amp,
9236 [ALC888_ACER_ASPIRE_6530G] = {
9237 .mixers = { alc888_acer_aspire_6530_mixer },
9238 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9239 alc888_acer_aspire_6530g_verbs },
9240 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9241 .dac_nids = alc883_dac_nids,
9242 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9243 .adc_nids = alc883_adc_nids_rev,
9244 .capsrc_nids = alc883_capsrc_nids_rev,
9245 .dig_out_nid = ALC883_DIGOUT_NID,
9246 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9247 .channel_mode = alc883_3ST_2ch_modes,
9248 .num_mux_defs =
9249 ARRAY_SIZE(alc888_2_capture_sources),
9250 .input_mux = alc888_acer_aspire_6530_sources,
9251 .unsol_event = alc_automute_amp_unsol_event,
9252 .setup = alc888_acer_aspire_6530g_setup,
9253 .init_hook = alc_automute_amp,
9255 [ALC888_ACER_ASPIRE_8930G] = {
9256 .mixers = { alc888_base_mixer,
9257 alc883_chmode_mixer },
9258 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9259 alc889_acer_aspire_8930g_verbs },
9260 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9261 .dac_nids = alc883_dac_nids,
9262 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9263 .adc_nids = alc889_adc_nids,
9264 .capsrc_nids = alc889_capsrc_nids,
9265 .dig_out_nid = ALC883_DIGOUT_NID,
9266 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9267 .channel_mode = alc883_3ST_6ch_modes,
9268 .need_dac_fix = 1,
9269 .const_channel_count = 6,
9270 .num_mux_defs =
9271 ARRAY_SIZE(alc889_capture_sources),
9272 .input_mux = alc889_capture_sources,
9273 .unsol_event = alc_automute_amp_unsol_event,
9274 .setup = alc889_acer_aspire_8930g_setup,
9275 .init_hook = alc_automute_amp,
9277 [ALC888_ACER_ASPIRE_7730G] = {
9278 .mixers = { alc883_3ST_6ch_mixer,
9279 alc883_chmode_mixer },
9280 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9281 alc888_acer_aspire_7730G_verbs },
9282 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9283 .dac_nids = alc883_dac_nids,
9284 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9285 .adc_nids = alc883_adc_nids_rev,
9286 .capsrc_nids = alc883_capsrc_nids_rev,
9287 .dig_out_nid = ALC883_DIGOUT_NID,
9288 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9289 .channel_mode = alc883_3ST_6ch_modes,
9290 .need_dac_fix = 1,
9291 .const_channel_count = 6,
9292 .input_mux = &alc883_capture_source,
9293 .unsol_event = alc_automute_amp_unsol_event,
9294 .setup = alc888_acer_aspire_6530g_setup,
9295 .init_hook = alc_automute_amp,
9297 [ALC883_MEDION] = {
9298 .mixers = { alc883_fivestack_mixer,
9299 alc883_chmode_mixer },
9300 .init_verbs = { alc883_init_verbs,
9301 alc883_medion_eapd_verbs },
9302 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9303 .dac_nids = alc883_dac_nids,
9304 .adc_nids = alc883_adc_nids_alt,
9305 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
9306 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9307 .channel_mode = alc883_sixstack_modes,
9308 .input_mux = &alc883_capture_source,
9310 [ALC883_MEDION_MD2] = {
9311 .mixers = { alc883_medion_md2_mixer},
9312 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9313 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9314 .dac_nids = alc883_dac_nids,
9315 .dig_out_nid = ALC883_DIGOUT_NID,
9316 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9317 .channel_mode = alc883_3ST_2ch_modes,
9318 .input_mux = &alc883_capture_source,
9319 .unsol_event = alc_automute_amp_unsol_event,
9320 .setup = alc883_medion_md2_setup,
9321 .init_hook = alc_automute_amp,
9323 [ALC883_LAPTOP_EAPD] = {
9324 .mixers = { alc883_base_mixer },
9325 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9326 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9327 .dac_nids = alc883_dac_nids,
9328 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9329 .channel_mode = alc883_3ST_2ch_modes,
9330 .input_mux = &alc883_capture_source,
9332 [ALC883_CLEVO_M540R] = {
9333 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9334 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9335 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9336 .dac_nids = alc883_dac_nids,
9337 .dig_out_nid = ALC883_DIGOUT_NID,
9338 .dig_in_nid = ALC883_DIGIN_NID,
9339 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9340 .channel_mode = alc883_3ST_6ch_clevo_modes,
9341 .need_dac_fix = 1,
9342 .input_mux = &alc883_capture_source,
9343 /* This machine has the hardware HP auto-muting, thus
9344 * we need no software mute via unsol event
9347 [ALC883_CLEVO_M720] = {
9348 .mixers = { alc883_clevo_m720_mixer },
9349 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
9350 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9351 .dac_nids = alc883_dac_nids,
9352 .dig_out_nid = ALC883_DIGOUT_NID,
9353 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9354 .channel_mode = alc883_3ST_2ch_modes,
9355 .input_mux = &alc883_capture_source,
9356 .unsol_event = alc883_clevo_m720_unsol_event,
9357 .setup = alc883_clevo_m720_setup,
9358 .init_hook = alc883_clevo_m720_init_hook,
9360 [ALC883_LENOVO_101E_2ch] = {
9361 .mixers = { alc883_lenovo_101e_2ch_mixer},
9362 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9363 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9364 .dac_nids = alc883_dac_nids,
9365 .adc_nids = alc883_adc_nids_alt,
9366 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
9367 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9368 .channel_mode = alc883_3ST_2ch_modes,
9369 .input_mux = &alc883_lenovo_101e_capture_source,
9370 .unsol_event = alc883_lenovo_101e_unsol_event,
9371 .init_hook = alc883_lenovo_101e_all_automute,
9373 [ALC883_LENOVO_NB0763] = {
9374 .mixers = { alc883_lenovo_nb0763_mixer },
9375 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9376 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9377 .dac_nids = alc883_dac_nids,
9378 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9379 .channel_mode = alc883_3ST_2ch_modes,
9380 .need_dac_fix = 1,
9381 .input_mux = &alc883_lenovo_nb0763_capture_source,
9382 .unsol_event = alc_automute_amp_unsol_event,
9383 .setup = alc883_medion_md2_setup,
9384 .init_hook = alc_automute_amp,
9386 [ALC888_LENOVO_MS7195_DIG] = {
9387 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9388 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9389 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9390 .dac_nids = alc883_dac_nids,
9391 .dig_out_nid = ALC883_DIGOUT_NID,
9392 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9393 .channel_mode = alc883_3ST_6ch_modes,
9394 .need_dac_fix = 1,
9395 .input_mux = &alc883_capture_source,
9396 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9397 .init_hook = alc888_lenovo_ms7195_front_automute,
9399 [ALC883_HAIER_W66] = {
9400 .mixers = { alc883_targa_2ch_mixer},
9401 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9402 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9403 .dac_nids = alc883_dac_nids,
9404 .dig_out_nid = ALC883_DIGOUT_NID,
9405 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9406 .channel_mode = alc883_3ST_2ch_modes,
9407 .input_mux = &alc883_capture_source,
9408 .unsol_event = alc_automute_amp_unsol_event,
9409 .setup = alc883_haier_w66_setup,
9410 .init_hook = alc_automute_amp,
9412 [ALC888_3ST_HP] = {
9413 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9414 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
9415 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9416 .dac_nids = alc883_dac_nids,
9417 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9418 .channel_mode = alc888_3st_hp_modes,
9419 .need_dac_fix = 1,
9420 .input_mux = &alc883_capture_source,
9421 .unsol_event = alc_automute_amp_unsol_event,
9422 .setup = alc888_3st_hp_setup,
9423 .init_hook = alc_automute_amp,
9425 [ALC888_6ST_DELL] = {
9426 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9427 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9428 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9429 .dac_nids = alc883_dac_nids,
9430 .dig_out_nid = ALC883_DIGOUT_NID,
9431 .dig_in_nid = ALC883_DIGIN_NID,
9432 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9433 .channel_mode = alc883_sixstack_modes,
9434 .input_mux = &alc883_capture_source,
9435 .unsol_event = alc_automute_amp_unsol_event,
9436 .setup = alc888_6st_dell_setup,
9437 .init_hook = alc_automute_amp,
9439 [ALC883_MITAC] = {
9440 .mixers = { alc883_mitac_mixer },
9441 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9442 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9443 .dac_nids = alc883_dac_nids,
9444 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9445 .channel_mode = alc883_3ST_2ch_modes,
9446 .input_mux = &alc883_capture_source,
9447 .unsol_event = alc_automute_amp_unsol_event,
9448 .setup = alc883_mitac_setup,
9449 .init_hook = alc_automute_amp,
9451 [ALC883_FUJITSU_PI2515] = {
9452 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9453 .init_verbs = { alc883_init_verbs,
9454 alc883_2ch_fujitsu_pi2515_verbs},
9455 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9456 .dac_nids = alc883_dac_nids,
9457 .dig_out_nid = ALC883_DIGOUT_NID,
9458 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9459 .channel_mode = alc883_3ST_2ch_modes,
9460 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9461 .unsol_event = alc_automute_amp_unsol_event,
9462 .setup = alc883_2ch_fujitsu_pi2515_setup,
9463 .init_hook = alc_automute_amp,
9465 [ALC888_FUJITSU_XA3530] = {
9466 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9467 .init_verbs = { alc883_init_verbs,
9468 alc888_fujitsu_xa3530_verbs },
9469 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9470 .dac_nids = alc883_dac_nids,
9471 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9472 .adc_nids = alc883_adc_nids_rev,
9473 .capsrc_nids = alc883_capsrc_nids_rev,
9474 .dig_out_nid = ALC883_DIGOUT_NID,
9475 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9476 .channel_mode = alc888_4ST_8ch_intel_modes,
9477 .num_mux_defs =
9478 ARRAY_SIZE(alc888_2_capture_sources),
9479 .input_mux = alc888_2_capture_sources,
9480 .unsol_event = alc_automute_amp_unsol_event,
9481 .setup = alc888_fujitsu_xa3530_setup,
9482 .init_hook = alc_automute_amp,
9484 [ALC888_LENOVO_SKY] = {
9485 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9486 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9487 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9488 .dac_nids = alc883_dac_nids,
9489 .dig_out_nid = ALC883_DIGOUT_NID,
9490 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9491 .channel_mode = alc883_sixstack_modes,
9492 .need_dac_fix = 1,
9493 .input_mux = &alc883_lenovo_sky_capture_source,
9494 .unsol_event = alc_automute_amp_unsol_event,
9495 .setup = alc888_lenovo_sky_setup,
9496 .init_hook = alc_automute_amp,
9498 [ALC888_ASUS_M90V] = {
9499 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9500 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9501 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9502 .dac_nids = alc883_dac_nids,
9503 .dig_out_nid = ALC883_DIGOUT_NID,
9504 .dig_in_nid = ALC883_DIGIN_NID,
9505 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9506 .channel_mode = alc883_3ST_6ch_modes,
9507 .need_dac_fix = 1,
9508 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9509 .unsol_event = alc_sku_unsol_event,
9510 .setup = alc883_mode2_setup,
9511 .init_hook = alc_inithook,
9513 [ALC888_ASUS_EEE1601] = {
9514 .mixers = { alc883_asus_eee1601_mixer },
9515 .cap_mixer = alc883_asus_eee1601_cap_mixer,
9516 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9517 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9518 .dac_nids = alc883_dac_nids,
9519 .dig_out_nid = ALC883_DIGOUT_NID,
9520 .dig_in_nid = ALC883_DIGIN_NID,
9521 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9522 .channel_mode = alc883_3ST_2ch_modes,
9523 .need_dac_fix = 1,
9524 .input_mux = &alc883_asus_eee1601_capture_source,
9525 .unsol_event = alc_sku_unsol_event,
9526 .init_hook = alc883_eee1601_inithook,
9528 [ALC1200_ASUS_P5Q] = {
9529 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9530 .init_verbs = { alc883_init_verbs },
9531 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9532 .dac_nids = alc883_dac_nids,
9533 .dig_out_nid = ALC1200_DIGOUT_NID,
9534 .dig_in_nid = ALC883_DIGIN_NID,
9535 .slave_dig_outs = alc1200_slave_dig_outs,
9536 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9537 .channel_mode = alc883_sixstack_modes,
9538 .input_mux = &alc883_capture_source,
9540 [ALC889A_MB31] = {
9541 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9542 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9543 alc880_gpio1_init_verbs },
9544 .adc_nids = alc883_adc_nids,
9545 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9546 .dac_nids = alc883_dac_nids,
9547 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9548 .channel_mode = alc889A_mb31_6ch_modes,
9549 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9550 .input_mux = &alc889A_mb31_capture_source,
9551 .dig_out_nid = ALC883_DIGOUT_NID,
9552 .unsol_event = alc889A_mb31_unsol_event,
9553 .init_hook = alc889A_mb31_automute,
9555 [ALC883_SONY_VAIO_TT] = {
9556 .mixers = { alc883_vaiott_mixer },
9557 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9558 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9559 .dac_nids = alc883_dac_nids,
9560 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9561 .channel_mode = alc883_3ST_2ch_modes,
9562 .input_mux = &alc883_capture_source,
9563 .unsol_event = alc_automute_amp_unsol_event,
9564 .setup = alc883_vaiott_setup,
9565 .init_hook = alc_automute_amp,
9571 * Pin config fixes
9573 enum {
9574 PINFIX_ABIT_AW9D_MAX
9577 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9578 { 0x15, 0x01080104 }, /* side */
9579 { 0x16, 0x01011012 }, /* rear */
9580 { 0x17, 0x01016011 }, /* clfe */
9584 static const struct alc_pincfg *alc882_pin_fixes[] = {
9585 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9588 static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9589 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9594 * BIOS auto configuration
9596 static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9597 const struct auto_pin_cfg *cfg)
9599 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9602 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
9603 hda_nid_t nid, int pin_type,
9604 int dac_idx)
9606 /* set as output */
9607 struct alc_spec *spec = codec->spec;
9608 int idx;
9610 alc_set_pin_output(codec, nid, pin_type);
9611 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9612 idx = 4;
9613 else
9614 idx = spec->multiout.dac_nids[dac_idx] - 2;
9615 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9619 static void alc882_auto_init_multi_out(struct hda_codec *codec)
9621 struct alc_spec *spec = codec->spec;
9622 int i;
9624 for (i = 0; i <= HDA_SIDE; i++) {
9625 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9626 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9627 if (nid)
9628 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
9633 static void alc882_auto_init_hp_out(struct hda_codec *codec)
9635 struct alc_spec *spec = codec->spec;
9636 hda_nid_t pin;
9638 pin = spec->autocfg.hp_pins[0];
9639 if (pin) /* connect to front */
9640 /* use dac 0 */
9641 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
9642 pin = spec->autocfg.speaker_pins[0];
9643 if (pin)
9644 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
9647 static void alc882_auto_init_analog_input(struct hda_codec *codec)
9649 struct alc_spec *spec = codec->spec;
9650 int i;
9652 for (i = 0; i < AUTO_PIN_LAST; i++) {
9653 hda_nid_t nid = spec->autocfg.input_pins[i];
9654 if (!nid)
9655 continue;
9656 alc_set_input_pin(codec, nid, i);
9657 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9658 snd_hda_codec_write(codec, nid, 0,
9659 AC_VERB_SET_AMP_GAIN_MUTE,
9660 AMP_OUT_MUTE);
9664 static void alc882_auto_init_input_src(struct hda_codec *codec)
9666 struct alc_spec *spec = codec->spec;
9667 int c;
9669 for (c = 0; c < spec->num_adc_nids; c++) {
9670 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9671 hda_nid_t nid = spec->capsrc_nids[c];
9672 unsigned int mux_idx;
9673 const struct hda_input_mux *imux;
9674 int conns, mute, idx, item;
9676 conns = snd_hda_get_connections(codec, nid, conn_list,
9677 ARRAY_SIZE(conn_list));
9678 if (conns < 0)
9679 continue;
9680 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9681 imux = &spec->input_mux[mux_idx];
9682 for (idx = 0; idx < conns; idx++) {
9683 /* if the current connection is the selected one,
9684 * unmute it as default - otherwise mute it
9686 mute = AMP_IN_MUTE(idx);
9687 for (item = 0; item < imux->num_items; item++) {
9688 if (imux->items[item].index == idx) {
9689 if (spec->cur_mux[c] == item)
9690 mute = AMP_IN_UNMUTE(idx);
9691 break;
9694 /* check if we have a selector or mixer
9695 * we could check for the widget type instead, but
9696 * just check for Amp-In presence (in case of mixer
9697 * without amp-in there is something wrong, this
9698 * function shouldn't be used or capsrc nid is wrong)
9700 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
9701 snd_hda_codec_write(codec, nid, 0,
9702 AC_VERB_SET_AMP_GAIN_MUTE,
9703 mute);
9704 else if (mute != AMP_IN_MUTE(idx))
9705 snd_hda_codec_write(codec, nid, 0,
9706 AC_VERB_SET_CONNECT_SEL,
9707 idx);
9712 /* add mic boosts if needed */
9713 static int alc_auto_add_mic_boost(struct hda_codec *codec)
9715 struct alc_spec *spec = codec->spec;
9716 int err;
9717 hda_nid_t nid;
9719 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9720 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9721 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9722 "Mic Boost",
9723 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9724 if (err < 0)
9725 return err;
9727 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9728 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9729 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9730 "Front Mic Boost",
9731 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9732 if (err < 0)
9733 return err;
9735 return 0;
9738 /* almost identical with ALC880 parser... */
9739 static int alc882_parse_auto_config(struct hda_codec *codec)
9741 struct alc_spec *spec = codec->spec;
9742 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9743 int i, err;
9745 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9746 alc882_ignore);
9747 if (err < 0)
9748 return err;
9749 if (!spec->autocfg.line_outs)
9750 return 0; /* can't find valid BIOS pin config */
9752 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9753 if (err < 0)
9754 return err;
9755 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9756 if (err < 0)
9757 return err;
9758 err = alc880_auto_create_extra_out(spec,
9759 spec->autocfg.speaker_pins[0],
9760 "Speaker");
9761 if (err < 0)
9762 return err;
9763 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9764 "Headphone");
9765 if (err < 0)
9766 return err;
9767 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9768 if (err < 0)
9769 return err;
9771 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9773 /* check multiple SPDIF-out (for recent codecs) */
9774 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9775 hda_nid_t dig_nid;
9776 err = snd_hda_get_connections(codec,
9777 spec->autocfg.dig_out_pins[i],
9778 &dig_nid, 1);
9779 if (err < 0)
9780 continue;
9781 if (!i)
9782 spec->multiout.dig_out_nid = dig_nid;
9783 else {
9784 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
9785 spec->slave_dig_outs[i - 1] = dig_nid;
9786 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
9787 break;
9790 if (spec->autocfg.dig_in_pin)
9791 spec->dig_in_nid = ALC880_DIGIN_NID;
9793 if (spec->kctls.list)
9794 add_mixer(spec, spec->kctls.list);
9796 add_verb(spec, alc883_auto_init_verbs);
9797 /* if ADC 0x07 is available, initialize it, too */
9798 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9799 add_verb(spec, alc882_adc1_init_verbs);
9801 spec->num_mux_defs = 1;
9802 spec->input_mux = &spec->private_imux[0];
9804 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
9806 err = alc_auto_add_mic_boost(codec);
9807 if (err < 0)
9808 return err;
9810 return 1; /* config found */
9813 /* additional initialization for auto-configuration model */
9814 static void alc882_auto_init(struct hda_codec *codec)
9816 struct alc_spec *spec = codec->spec;
9817 alc882_auto_init_multi_out(codec);
9818 alc882_auto_init_hp_out(codec);
9819 alc882_auto_init_analog_input(codec);
9820 alc882_auto_init_input_src(codec);
9821 if (spec->unsol_event)
9822 alc_inithook(codec);
9825 static int patch_alc882(struct hda_codec *codec)
9827 struct alc_spec *spec;
9828 int err, board_config;
9830 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9831 if (spec == NULL)
9832 return -ENOMEM;
9834 codec->spec = spec;
9836 switch (codec->vendor_id) {
9837 case 0x10ec0882:
9838 case 0x10ec0885:
9839 break;
9840 default:
9841 /* ALC883 and variants */
9842 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9843 break;
9846 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9847 alc882_models,
9848 alc882_cfg_tbl);
9850 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9851 board_config = snd_hda_check_board_codec_sid_config(codec,
9852 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9854 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
9855 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
9856 codec->chip_name);
9857 board_config = ALC882_AUTO;
9860 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9862 if (board_config == ALC882_AUTO) {
9863 /* automatic parse from the BIOS config */
9864 err = alc882_parse_auto_config(codec);
9865 if (err < 0) {
9866 alc_free(codec);
9867 return err;
9868 } else if (!err) {
9869 printk(KERN_INFO
9870 "hda_codec: Cannot set up configuration "
9871 "from BIOS. Using base mode...\n");
9872 board_config = ALC882_3ST_DIG;
9876 err = snd_hda_attach_beep_device(codec, 0x1);
9877 if (err < 0) {
9878 alc_free(codec);
9879 return err;
9882 if (board_config != ALC882_AUTO)
9883 setup_preset(codec, &alc882_presets[board_config]);
9885 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9886 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9887 /* FIXME: setup DAC5 */
9888 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9889 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9891 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9892 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9894 if (codec->vendor_id == 0x10ec0888)
9895 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
9897 if (!spec->adc_nids && spec->input_mux) {
9898 int i;
9899 spec->num_adc_nids = 0;
9900 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9901 hda_nid_t cap;
9902 hda_nid_t nid = alc882_adc_nids[i];
9903 unsigned int wcap = get_wcaps(codec, nid);
9904 /* get type */
9905 wcap = get_wcaps_type(wcap);
9906 if (wcap != AC_WID_AUD_IN)
9907 continue;
9908 spec->private_adc_nids[spec->num_adc_nids] = nid;
9909 err = snd_hda_get_connections(codec, nid, &cap, 1);
9910 if (err < 0)
9911 continue;
9912 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9913 spec->num_adc_nids++;
9915 spec->adc_nids = spec->private_adc_nids;
9916 spec->capsrc_nids = spec->private_capsrc_nids;
9919 set_capture_mixer(codec);
9920 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9922 spec->vmaster_nid = 0x0c;
9924 codec->patch_ops = alc_patch_ops;
9925 if (board_config == ALC882_AUTO)
9926 spec->init_hook = alc882_auto_init;
9927 #ifdef CONFIG_SND_HDA_POWER_SAVE
9928 if (!spec->loopback.amplist)
9929 spec->loopback.amplist = alc882_loopbacks;
9930 #endif
9931 codec->proc_widget_hook = print_realtek_coef;
9933 return 0;
9938 * ALC262 support
9941 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9942 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
9944 #define alc262_dac_nids alc260_dac_nids
9945 #define alc262_adc_nids alc882_adc_nids
9946 #define alc262_adc_nids_alt alc882_adc_nids_alt
9947 #define alc262_capsrc_nids alc882_capsrc_nids
9948 #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
9950 #define alc262_modes alc260_modes
9951 #define alc262_capture_source alc882_capture_source
9953 static hda_nid_t alc262_dmic_adc_nids[1] = {
9954 /* ADC0 */
9955 0x09
9958 static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9960 static struct snd_kcontrol_new alc262_base_mixer[] = {
9961 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9962 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9963 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9964 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9965 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9966 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9967 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9968 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9969 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9970 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9971 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9972 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9973 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9974 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9975 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9976 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
9977 { } /* end */
9980 /* update HP, line and mono-out pins according to the master switch */
9981 static void alc262_hp_master_update(struct hda_codec *codec)
9983 struct alc_spec *spec = codec->spec;
9984 int val = spec->master_sw;
9986 /* HP & line-out */
9987 snd_hda_codec_write_cache(codec, 0x1b, 0,
9988 AC_VERB_SET_PIN_WIDGET_CONTROL,
9989 val ? PIN_HP : 0);
9990 snd_hda_codec_write_cache(codec, 0x15, 0,
9991 AC_VERB_SET_PIN_WIDGET_CONTROL,
9992 val ? PIN_HP : 0);
9993 /* mono (speaker) depending on the HP jack sense */
9994 val = val && !spec->jack_present;
9995 snd_hda_codec_write_cache(codec, 0x16, 0,
9996 AC_VERB_SET_PIN_WIDGET_CONTROL,
9997 val ? PIN_OUT : 0);
10000 static void alc262_hp_bpc_automute(struct hda_codec *codec)
10002 struct alc_spec *spec = codec->spec;
10003 unsigned int presence;
10004 presence = snd_hda_codec_read(codec, 0x1b, 0,
10005 AC_VERB_GET_PIN_SENSE, 0);
10006 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10007 alc262_hp_master_update(codec);
10010 static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10012 if ((res >> 26) != ALC880_HP_EVENT)
10013 return;
10014 alc262_hp_bpc_automute(codec);
10017 static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10019 struct alc_spec *spec = codec->spec;
10020 unsigned int presence;
10021 presence = snd_hda_codec_read(codec, 0x15, 0,
10022 AC_VERB_GET_PIN_SENSE, 0);
10023 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10024 alc262_hp_master_update(codec);
10027 static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10028 unsigned int res)
10030 if ((res >> 26) != ALC880_HP_EVENT)
10031 return;
10032 alc262_hp_wildwest_automute(codec);
10035 #define alc262_hp_master_sw_get alc260_hp_master_sw_get
10037 static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10038 struct snd_ctl_elem_value *ucontrol)
10040 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10041 struct alc_spec *spec = codec->spec;
10042 int val = !!*ucontrol->value.integer.value;
10044 if (val == spec->master_sw)
10045 return 0;
10046 spec->master_sw = val;
10047 alc262_hp_master_update(codec);
10048 return 1;
10051 #define ALC262_HP_MASTER_SWITCH \
10053 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10054 .name = "Master Playback Switch", \
10055 .info = snd_ctl_boolean_mono_info, \
10056 .get = alc262_hp_master_sw_get, \
10057 .put = alc262_hp_master_sw_put, \
10060 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
10061 ALC262_HP_MASTER_SWITCH,
10062 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10063 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10064 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10065 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10066 HDA_OUTPUT),
10067 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10068 HDA_OUTPUT),
10069 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10070 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10071 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10072 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10073 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10074 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10075 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10076 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10077 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10078 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10079 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10080 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10081 { } /* end */
10084 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
10085 ALC262_HP_MASTER_SWITCH,
10086 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10087 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10088 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10090 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10091 HDA_OUTPUT),
10092 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10093 HDA_OUTPUT),
10094 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10095 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
10096 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
10097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10099 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10100 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10101 { } /* end */
10104 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10105 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10106 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10107 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
10108 { } /* end */
10111 /* mute/unmute internal speaker according to the hp jack and mute state */
10112 static void alc262_hp_t5735_setup(struct hda_codec *codec)
10114 struct alc_spec *spec = codec->spec;
10116 spec->autocfg.hp_pins[0] = 0x15;
10117 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10120 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
10121 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10122 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10123 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10124 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10125 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10127 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10128 { } /* end */
10131 static struct hda_verb alc262_hp_t5735_verbs[] = {
10132 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10133 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10135 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10139 static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
10140 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10142 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10143 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
10144 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10145 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10146 { } /* end */
10149 static struct hda_verb alc262_hp_rp5700_verbs[] = {
10150 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10151 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10152 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10153 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10154 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10155 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10158 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10159 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10163 static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10164 .num_items = 1,
10165 .items = {
10166 { "Line", 0x1 },
10170 /* bind hp and internal speaker mute (with plug check) as master switch */
10171 static void alc262_hippo_master_update(struct hda_codec *codec)
10173 struct alc_spec *spec = codec->spec;
10174 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10175 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10176 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10177 unsigned int mute;
10179 /* HP */
10180 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10181 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10182 HDA_AMP_MUTE, mute);
10183 /* mute internal speaker per jack sense */
10184 if (spec->jack_present)
10185 mute = HDA_AMP_MUTE;
10186 if (line_nid)
10187 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10188 HDA_AMP_MUTE, mute);
10189 if (speaker_nid && speaker_nid != line_nid)
10190 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10191 HDA_AMP_MUTE, mute);
10194 #define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10196 static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10197 struct snd_ctl_elem_value *ucontrol)
10199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10200 struct alc_spec *spec = codec->spec;
10201 int val = !!*ucontrol->value.integer.value;
10203 if (val == spec->master_sw)
10204 return 0;
10205 spec->master_sw = val;
10206 alc262_hippo_master_update(codec);
10207 return 1;
10210 #define ALC262_HIPPO_MASTER_SWITCH \
10212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10213 .name = "Master Playback Switch", \
10214 .info = snd_ctl_boolean_mono_info, \
10215 .get = alc262_hippo_master_sw_get, \
10216 .put = alc262_hippo_master_sw_put, \
10219 static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10220 ALC262_HIPPO_MASTER_SWITCH,
10221 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10222 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10223 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10224 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10225 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10226 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10227 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10228 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10229 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10230 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10231 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10232 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10233 { } /* end */
10236 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10237 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10238 ALC262_HIPPO_MASTER_SWITCH,
10239 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10240 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10241 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10242 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10245 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10246 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10247 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10248 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10249 { } /* end */
10252 /* mute/unmute internal speaker according to the hp jack and mute state */
10253 static void alc262_hippo_automute(struct hda_codec *codec)
10255 struct alc_spec *spec = codec->spec;
10256 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10257 unsigned int present;
10259 /* need to execute and sync at first */
10260 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10261 present = snd_hda_codec_read(codec, hp_nid, 0,
10262 AC_VERB_GET_PIN_SENSE, 0);
10263 spec->jack_present = (present & 0x80000000) != 0;
10264 alc262_hippo_master_update(codec);
10267 static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10269 if ((res >> 26) != ALC880_HP_EVENT)
10270 return;
10271 alc262_hippo_automute(codec);
10274 static void alc262_hippo_setup(struct hda_codec *codec)
10276 struct alc_spec *spec = codec->spec;
10278 spec->autocfg.hp_pins[0] = 0x15;
10279 spec->autocfg.speaker_pins[0] = 0x14;
10282 static void alc262_hippo1_setup(struct hda_codec *codec)
10284 struct alc_spec *spec = codec->spec;
10286 spec->autocfg.hp_pins[0] = 0x1b;
10287 spec->autocfg.speaker_pins[0] = 0x14;
10291 static struct snd_kcontrol_new alc262_sony_mixer[] = {
10292 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10293 ALC262_HIPPO_MASTER_SWITCH,
10294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10296 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10297 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10298 { } /* end */
10301 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
10302 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10303 ALC262_HIPPO_MASTER_SWITCH,
10304 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10306 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10307 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10308 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10309 { } /* end */
10312 static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10313 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10314 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10315 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10316 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10317 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10318 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10319 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10320 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10321 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10322 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10323 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10324 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10325 { } /* end */
10328 static struct hda_verb alc262_tyan_verbs[] = {
10329 /* Headphone automute */
10330 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10331 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10332 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10334 /* P11 AUX_IN, white 4-pin connector */
10335 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10336 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10337 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10338 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10343 /* unsolicited event for HP jack sensing */
10344 static void alc262_tyan_setup(struct hda_codec *codec)
10346 struct alc_spec *spec = codec->spec;
10348 spec->autocfg.hp_pins[0] = 0x1b;
10349 spec->autocfg.speaker_pins[0] = 0x15;
10353 #define alc262_capture_mixer alc882_capture_mixer
10354 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
10357 * generic initialization of ADC, input mixers and output mixers
10359 static struct hda_verb alc262_init_verbs[] = {
10361 * Unmute ADC0-2 and set the default input to mic-in
10363 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10364 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10365 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10366 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10367 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10368 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10370 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10371 * mixer widget
10372 * Note: PASD motherboards uses the Line In 2 as the input for
10373 * front panel mic (mic 2)
10375 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10376 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10379 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10383 * Set up output mixers (0x0c - 0x0e)
10385 /* set vol=0 to output mixers */
10386 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10387 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10388 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10389 /* set up input amps for analog loopback */
10390 /* Amp Indices: DAC = 0, mixer = 1 */
10391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10393 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10394 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10395 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10396 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10398 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10399 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10400 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10401 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10402 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10403 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10405 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10406 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10407 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10408 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10409 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10411 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10412 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10414 /* FIXME: use matrix-type input source selection */
10415 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10416 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10417 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10418 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10419 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10420 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10421 /* Input mixer2 */
10422 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10423 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10424 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10425 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10426 /* Input mixer3 */
10427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10428 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10429 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10430 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10435 static struct hda_verb alc262_eapd_verbs[] = {
10436 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10437 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10441 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10442 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10443 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10444 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10446 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10447 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10451 static struct hda_verb alc262_sony_unsol_verbs[] = {
10452 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10453 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10456 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10457 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10461 static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10462 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10463 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10464 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10466 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10467 { } /* end */
10470 static struct hda_verb alc262_toshiba_s06_verbs[] = {
10471 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10473 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10474 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10475 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10476 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10477 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10478 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10482 static void alc262_toshiba_s06_setup(struct hda_codec *codec)
10484 struct alc_spec *spec = codec->spec;
10486 spec->autocfg.hp_pins[0] = 0x15;
10487 spec->autocfg.speaker_pins[0] = 0x14;
10488 spec->ext_mic.pin = 0x18;
10489 spec->ext_mic.mux_idx = 0;
10490 spec->int_mic.pin = 0x12;
10491 spec->int_mic.mux_idx = 9;
10492 spec->auto_mic = 1;
10496 * nec model
10497 * 0x15 = headphone
10498 * 0x16 = internal speaker
10499 * 0x18 = external mic
10502 static struct snd_kcontrol_new alc262_nec_mixer[] = {
10503 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10504 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10508 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10510 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10511 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10512 { } /* end */
10515 static struct hda_verb alc262_nec_verbs[] = {
10516 /* Unmute Speaker */
10517 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10519 /* Headphone */
10520 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10523 /* External mic to headphone */
10524 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10525 /* External mic to speaker */
10526 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10531 * fujitsu model
10532 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10533 * 0x1b = port replicator headphone out
10536 #define ALC_HP_EVENT 0x37
10538 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10539 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10540 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10541 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10542 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10546 static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10547 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10548 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10552 static struct hda_input_mux alc262_fujitsu_capture_source = {
10553 .num_items = 3,
10554 .items = {
10555 { "Mic", 0x0 },
10556 { "Int Mic", 0x1 },
10557 { "CD", 0x4 },
10561 static struct hda_input_mux alc262_HP_capture_source = {
10562 .num_items = 5,
10563 .items = {
10564 { "Mic", 0x0 },
10565 { "Front Mic", 0x1 },
10566 { "Line", 0x2 },
10567 { "CD", 0x4 },
10568 { "AUX IN", 0x6 },
10572 static struct hda_input_mux alc262_HP_D7000_capture_source = {
10573 .num_items = 4,
10574 .items = {
10575 { "Mic", 0x0 },
10576 { "Front Mic", 0x2 },
10577 { "Line", 0x1 },
10578 { "CD", 0x4 },
10582 /* mute/unmute internal speaker according to the hp jacks and mute state */
10583 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10585 struct alc_spec *spec = codec->spec;
10586 unsigned int mute;
10588 if (force || !spec->sense_updated) {
10589 unsigned int present;
10590 /* need to execute and sync at first */
10591 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
10592 /* check laptop HP jack */
10593 present = snd_hda_codec_read(codec, 0x14, 0,
10594 AC_VERB_GET_PIN_SENSE, 0);
10595 /* need to execute and sync at first */
10596 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10597 /* check docking HP jack */
10598 present |= snd_hda_codec_read(codec, 0x1b, 0,
10599 AC_VERB_GET_PIN_SENSE, 0);
10600 if (present & AC_PINSENSE_PRESENCE)
10601 spec->jack_present = 1;
10602 else
10603 spec->jack_present = 0;
10604 spec->sense_updated = 1;
10606 /* unmute internal speaker only if both HPs are unplugged and
10607 * master switch is on
10609 if (spec->jack_present)
10610 mute = HDA_AMP_MUTE;
10611 else
10612 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10613 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10614 HDA_AMP_MUTE, mute);
10617 /* unsolicited event for HP jack sensing */
10618 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10619 unsigned int res)
10621 if ((res >> 26) != ALC_HP_EVENT)
10622 return;
10623 alc262_fujitsu_automute(codec, 1);
10626 static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10628 alc262_fujitsu_automute(codec, 1);
10631 /* bind volumes of both NID 0x0c and 0x0d */
10632 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10633 .ops = &snd_hda_bind_vol,
10634 .values = {
10635 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10636 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10641 /* mute/unmute internal speaker according to the hp jack and mute state */
10642 static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10644 struct alc_spec *spec = codec->spec;
10645 unsigned int mute;
10647 if (force || !spec->sense_updated) {
10648 unsigned int present_int_hp;
10649 /* need to execute and sync at first */
10650 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10651 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10652 AC_VERB_GET_PIN_SENSE, 0);
10653 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10654 spec->sense_updated = 1;
10656 if (spec->jack_present) {
10657 /* mute internal speaker */
10658 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10659 HDA_AMP_MUTE, HDA_AMP_MUTE);
10660 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10661 HDA_AMP_MUTE, HDA_AMP_MUTE);
10662 } else {
10663 /* unmute internal speaker if necessary */
10664 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10665 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10666 HDA_AMP_MUTE, mute);
10667 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10668 HDA_AMP_MUTE, mute);
10672 /* unsolicited event for HP jack sensing */
10673 static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10674 unsigned int res)
10676 if ((res >> 26) != ALC_HP_EVENT)
10677 return;
10678 alc262_lenovo_3000_automute(codec, 1);
10681 static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10682 int dir, int idx, long *valp)
10684 int i, change = 0;
10686 for (i = 0; i < 2; i++, valp++)
10687 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10688 HDA_AMP_MUTE,
10689 *valp ? 0 : HDA_AMP_MUTE);
10690 return change;
10693 /* bind hp and internal speaker mute (with plug check) */
10694 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10695 struct snd_ctl_elem_value *ucontrol)
10697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10698 long *valp = ucontrol->value.integer.value;
10699 int change;
10701 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10702 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
10703 if (change)
10704 alc262_fujitsu_automute(codec, 0);
10705 return change;
10708 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
10709 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10711 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10712 .name = "Master Playback Switch",
10713 .info = snd_hda_mixer_amp_switch_info,
10714 .get = snd_hda_mixer_amp_switch_get,
10715 .put = alc262_fujitsu_master_sw_put,
10716 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10718 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10719 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10721 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10722 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10723 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10724 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10725 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10726 { } /* end */
10729 /* bind hp and internal speaker mute (with plug check) */
10730 static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10731 struct snd_ctl_elem_value *ucontrol)
10733 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10734 long *valp = ucontrol->value.integer.value;
10735 int change;
10737 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
10738 if (change)
10739 alc262_lenovo_3000_automute(codec, 0);
10740 return change;
10743 static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10744 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10746 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10747 .name = "Master Playback Switch",
10748 .info = snd_hda_mixer_amp_switch_info,
10749 .get = snd_hda_mixer_amp_switch_get,
10750 .put = alc262_lenovo_3000_master_sw_put,
10751 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10753 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10754 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10755 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10757 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10758 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10759 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10760 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10761 { } /* end */
10764 static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10765 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10766 ALC262_HIPPO_MASTER_SWITCH,
10767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10768 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10769 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10770 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10771 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10772 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10773 { } /* end */
10776 /* additional init verbs for Benq laptops */
10777 static struct hda_verb alc262_EAPD_verbs[] = {
10778 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10779 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10783 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10785 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10787 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10788 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10792 /* Samsung Q1 Ultra Vista model setup */
10793 static struct snd_kcontrol_new alc262_ultra_mixer[] = {
10794 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10795 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10798 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
10799 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
10800 { } /* end */
10803 static struct hda_verb alc262_ultra_verbs[] = {
10804 /* output mixer */
10805 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10808 /* speaker */
10809 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10810 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10811 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10812 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10813 /* HP */
10814 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10815 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10817 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10818 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10819 /* internal mic */
10820 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10821 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10822 /* ADC, choose mic */
10823 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10824 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10825 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10826 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10827 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10828 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10829 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10830 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10831 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10832 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
10836 /* mute/unmute internal speaker according to the hp jack and mute state */
10837 static void alc262_ultra_automute(struct hda_codec *codec)
10839 struct alc_spec *spec = codec->spec;
10840 unsigned int mute;
10842 mute = 0;
10843 /* auto-mute only when HP is used as HP */
10844 if (!spec->cur_mux[0]) {
10845 unsigned int present;
10846 /* need to execute and sync at first */
10847 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10848 present = snd_hda_codec_read(codec, 0x15, 0,
10849 AC_VERB_GET_PIN_SENSE, 0);
10850 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10851 if (spec->jack_present)
10852 mute = HDA_AMP_MUTE;
10854 /* mute/unmute internal speaker */
10855 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10856 HDA_AMP_MUTE, mute);
10857 /* mute/unmute HP */
10858 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10859 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
10862 /* unsolicited event for HP jack sensing */
10863 static void alc262_ultra_unsol_event(struct hda_codec *codec,
10864 unsigned int res)
10866 if ((res >> 26) != ALC880_HP_EVENT)
10867 return;
10868 alc262_ultra_automute(codec);
10871 static struct hda_input_mux alc262_ultra_capture_source = {
10872 .num_items = 2,
10873 .items = {
10874 { "Mic", 0x1 },
10875 { "Headphone", 0x7 },
10879 static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10880 struct snd_ctl_elem_value *ucontrol)
10882 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10883 struct alc_spec *spec = codec->spec;
10884 int ret;
10886 ret = alc_mux_enum_put(kcontrol, ucontrol);
10887 if (!ret)
10888 return 0;
10889 /* reprogram the HP pin as mic or HP according to the input source */
10890 snd_hda_codec_write_cache(codec, 0x15, 0,
10891 AC_VERB_SET_PIN_WIDGET_CONTROL,
10892 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10893 alc262_ultra_automute(codec); /* mute/unmute HP */
10894 return ret;
10897 static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10898 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10899 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10901 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10902 .name = "Capture Source",
10903 .info = alc_mux_enum_info,
10904 .get = alc_mux_enum_get,
10905 .put = alc262_ultra_mux_enum_put,
10907 { } /* end */
10910 /* We use two mixers depending on the output pin; 0x16 is a mono output
10911 * and thus it's bound with a different mixer.
10912 * This function returns which mixer amp should be used.
10914 static int alc262_check_volbit(hda_nid_t nid)
10916 if (!nid)
10917 return 0;
10918 else if (nid == 0x16)
10919 return 2;
10920 else
10921 return 1;
10924 static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10925 const char *pfx, int *vbits)
10927 char name[32];
10928 unsigned long val;
10929 int vbit;
10931 vbit = alc262_check_volbit(nid);
10932 if (!vbit)
10933 return 0;
10934 if (*vbits & vbit) /* a volume control for this mixer already there */
10935 return 0;
10936 *vbits |= vbit;
10937 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
10938 if (vbit == 2)
10939 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10940 else
10941 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
10942 return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
10945 static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10946 const char *pfx)
10948 char name[32];
10949 unsigned long val;
10951 if (!nid)
10952 return 0;
10953 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
10954 if (nid == 0x16)
10955 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10956 else
10957 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
10958 return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
10961 /* add playback controls from the parsed DAC table */
10962 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10963 const struct auto_pin_cfg *cfg)
10965 const char *pfx;
10966 int vbits;
10967 int err;
10969 spec->multiout.num_dacs = 1; /* only use one dac */
10970 spec->multiout.dac_nids = spec->private_dac_nids;
10971 spec->multiout.dac_nids[0] = 2;
10973 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
10974 pfx = "Master";
10975 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10976 pfx = "Speaker";
10977 else
10978 pfx = "Front";
10979 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
10980 if (err < 0)
10981 return err;
10982 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
10983 if (err < 0)
10984 return err;
10985 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
10986 if (err < 0)
10987 return err;
10989 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
10990 alc262_check_volbit(cfg->speaker_pins[0]) |
10991 alc262_check_volbit(cfg->hp_pins[0]);
10992 if (vbits == 1 || vbits == 2)
10993 pfx = "Master"; /* only one mixer is used */
10994 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10995 pfx = "Speaker";
10996 else
10997 pfx = "Front";
10998 vbits = 0;
10999 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11000 if (err < 0)
11001 return err;
11002 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11003 &vbits);
11004 if (err < 0)
11005 return err;
11006 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11007 &vbits);
11008 if (err < 0)
11009 return err;
11010 return 0;
11013 #define alc262_auto_create_input_ctls \
11014 alc880_auto_create_input_ctls
11017 * generic initialization of ADC, input mixers and output mixers
11019 static struct hda_verb alc262_volume_init_verbs[] = {
11021 * Unmute ADC0-2 and set the default input to mic-in
11023 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11024 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11025 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11026 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11027 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11028 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11030 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11031 * mixer widget
11032 * Note: PASD motherboards uses the Line In 2 as the input for
11033 * front panel mic (mic 2)
11035 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11036 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11037 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11043 * Set up output mixers (0x0c - 0x0f)
11045 /* set vol=0 to output mixers */
11046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11047 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11048 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11050 /* set up input amps for analog loopback */
11051 /* Amp Indices: DAC = 0, mixer = 1 */
11052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11054 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11056 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11059 /* FIXME: use matrix-type input source selection */
11060 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11061 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11065 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11066 /* Input mixer2 */
11067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11069 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11071 /* Input mixer3 */
11072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11073 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11080 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11082 * Unmute ADC0-2 and set the default input to mic-in
11084 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11086 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11087 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11088 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11091 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11092 * mixer widget
11093 * Note: PASD motherboards uses the Line In 2 as the input for
11094 * front panel mic (mic 2)
11096 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11106 * Set up output mixers (0x0c - 0x0e)
11108 /* set vol=0 to output mixers */
11109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11110 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11113 /* set up input amps for analog loopback */
11114 /* Amp Indices: DAC = 0, mixer = 1 */
11115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11122 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11123 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11124 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11126 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11129 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11130 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11132 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11133 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11134 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11135 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11136 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11138 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11139 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11140 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11142 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11143 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11146 /* FIXME: use matrix-type input source selection */
11147 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11148 /* Input mixer1: only unmute Mic */
11149 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11150 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11151 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11152 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11153 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11154 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11155 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
11158 /* Input mixer2 */
11159 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11160 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11161 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11162 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11163 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11164 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11166 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11167 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
11168 /* Input mixer3 */
11169 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11170 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11171 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11174 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11175 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11176 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
11179 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11184 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11186 * Unmute ADC0-2 and set the default input to mic-in
11188 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11189 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11190 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11192 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11195 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11196 * mixer widget
11197 * Note: PASD motherboards uses the Line In 2 as the input for front
11198 * panel mic (mic 2)
11200 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11204 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11205 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11210 * Set up output mixers (0x0c - 0x0e)
11212 /* set vol=0 to output mixers */
11213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11214 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11215 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11217 /* set up input amps for analog loopback */
11218 /* Amp Indices: DAC = 0, mixer = 1 */
11219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11222 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11223 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11224 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11228 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11229 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11230 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11231 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11233 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11235 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11238 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11239 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11241 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11242 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11243 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11244 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11245 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11246 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11248 /* FIXME: use matrix-type input source selection */
11249 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11250 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11251 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11252 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11253 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11255 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11256 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11257 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11258 /* Input mixer2 */
11259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11260 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11261 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11262 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11263 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11264 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11265 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11266 /* Input mixer3 */
11267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11269 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11270 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11271 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11272 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11275 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11280 static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11282 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11283 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11284 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11286 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11287 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11288 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11289 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11291 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11292 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11293 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11298 #ifdef CONFIG_SND_HDA_POWER_SAVE
11299 #define alc262_loopbacks alc880_loopbacks
11300 #endif
11302 /* pcm configuration: identical with ALC880 */
11303 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
11304 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
11305 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
11306 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
11309 * BIOS auto configuration
11311 static int alc262_parse_auto_config(struct hda_codec *codec)
11313 struct alc_spec *spec = codec->spec;
11314 int err;
11315 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11317 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11318 alc262_ignore);
11319 if (err < 0)
11320 return err;
11321 if (!spec->autocfg.line_outs) {
11322 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11323 spec->multiout.max_channels = 2;
11324 spec->no_analog = 1;
11325 goto dig_only;
11327 return 0; /* can't find valid BIOS pin config */
11329 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11330 if (err < 0)
11331 return err;
11332 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
11333 if (err < 0)
11334 return err;
11336 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11338 dig_only:
11339 if (spec->autocfg.dig_outs) {
11340 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
11341 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11343 if (spec->autocfg.dig_in_pin)
11344 spec->dig_in_nid = ALC262_DIGIN_NID;
11346 if (spec->kctls.list)
11347 add_mixer(spec, spec->kctls.list);
11349 add_verb(spec, alc262_volume_init_verbs);
11350 spec->num_mux_defs = 1;
11351 spec->input_mux = &spec->private_imux[0];
11353 err = alc_auto_add_mic_boost(codec);
11354 if (err < 0)
11355 return err;
11357 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11359 return 1;
11362 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
11363 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
11364 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
11365 #define alc262_auto_init_input_src alc882_auto_init_input_src
11368 /* init callback for auto-configuration model -- overriding the default init */
11369 static void alc262_auto_init(struct hda_codec *codec)
11371 struct alc_spec *spec = codec->spec;
11372 alc262_auto_init_multi_out(codec);
11373 alc262_auto_init_hp_out(codec);
11374 alc262_auto_init_analog_input(codec);
11375 alc262_auto_init_input_src(codec);
11376 if (spec->unsol_event)
11377 alc_inithook(codec);
11381 * configuration and preset
11383 static const char *alc262_models[ALC262_MODEL_LAST] = {
11384 [ALC262_BASIC] = "basic",
11385 [ALC262_HIPPO] = "hippo",
11386 [ALC262_HIPPO_1] = "hippo_1",
11387 [ALC262_FUJITSU] = "fujitsu",
11388 [ALC262_HP_BPC] = "hp-bpc",
11389 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
11390 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
11391 [ALC262_HP_RP5700] = "hp-rp5700",
11392 [ALC262_BENQ_ED8] = "benq",
11393 [ALC262_BENQ_T31] = "benq-t31",
11394 [ALC262_SONY_ASSAMD] = "sony-assamd",
11395 [ALC262_TOSHIBA_S06] = "toshiba-s06",
11396 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
11397 [ALC262_ULTRA] = "ultra",
11398 [ALC262_LENOVO_3000] = "lenovo-3000",
11399 [ALC262_NEC] = "nec",
11400 [ALC262_TYAN] = "tyan",
11401 [ALC262_AUTO] = "auto",
11404 static struct snd_pci_quirk alc262_cfg_tbl[] = {
11405 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
11406 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
11407 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11408 ALC262_HP_BPC),
11409 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11410 ALC262_HP_BPC),
11411 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11412 ALC262_HP_BPC),
11413 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
11414 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
11415 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
11416 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
11417 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
11418 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
11419 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
11420 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
11421 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11422 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11423 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
11424 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11425 ALC262_HP_TC_T5735),
11426 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
11427 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
11428 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
11429 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
11430 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
11431 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
11432 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11433 ALC262_SONY_ASSAMD),
11434 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
11435 ALC262_TOSHIBA_RX1),
11436 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
11437 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
11438 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
11439 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
11440 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11441 ALC262_ULTRA),
11442 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
11443 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
11444 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
11445 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
11446 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
11450 static struct alc_config_preset alc262_presets[] = {
11451 [ALC262_BASIC] = {
11452 .mixers = { alc262_base_mixer },
11453 .init_verbs = { alc262_init_verbs },
11454 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11455 .dac_nids = alc262_dac_nids,
11456 .hp_nid = 0x03,
11457 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11458 .channel_mode = alc262_modes,
11459 .input_mux = &alc262_capture_source,
11461 [ALC262_HIPPO] = {
11462 .mixers = { alc262_hippo_mixer },
11463 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
11464 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11465 .dac_nids = alc262_dac_nids,
11466 .hp_nid = 0x03,
11467 .dig_out_nid = ALC262_DIGOUT_NID,
11468 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11469 .channel_mode = alc262_modes,
11470 .input_mux = &alc262_capture_source,
11471 .unsol_event = alc262_hippo_unsol_event,
11472 .setup = alc262_hippo_setup,
11473 .init_hook = alc262_hippo_automute,
11475 [ALC262_HIPPO_1] = {
11476 .mixers = { alc262_hippo1_mixer },
11477 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11478 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11479 .dac_nids = alc262_dac_nids,
11480 .hp_nid = 0x02,
11481 .dig_out_nid = ALC262_DIGOUT_NID,
11482 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11483 .channel_mode = alc262_modes,
11484 .input_mux = &alc262_capture_source,
11485 .unsol_event = alc262_hippo_unsol_event,
11486 .setup = alc262_hippo1_setup,
11487 .init_hook = alc262_hippo_automute,
11489 [ALC262_FUJITSU] = {
11490 .mixers = { alc262_fujitsu_mixer },
11491 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11492 alc262_fujitsu_unsol_verbs },
11493 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11494 .dac_nids = alc262_dac_nids,
11495 .hp_nid = 0x03,
11496 .dig_out_nid = ALC262_DIGOUT_NID,
11497 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11498 .channel_mode = alc262_modes,
11499 .input_mux = &alc262_fujitsu_capture_source,
11500 .unsol_event = alc262_fujitsu_unsol_event,
11501 .init_hook = alc262_fujitsu_init_hook,
11503 [ALC262_HP_BPC] = {
11504 .mixers = { alc262_HP_BPC_mixer },
11505 .init_verbs = { alc262_HP_BPC_init_verbs },
11506 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11507 .dac_nids = alc262_dac_nids,
11508 .hp_nid = 0x03,
11509 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11510 .channel_mode = alc262_modes,
11511 .input_mux = &alc262_HP_capture_source,
11512 .unsol_event = alc262_hp_bpc_unsol_event,
11513 .init_hook = alc262_hp_bpc_automute,
11515 [ALC262_HP_BPC_D7000_WF] = {
11516 .mixers = { alc262_HP_BPC_WildWest_mixer },
11517 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11518 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11519 .dac_nids = alc262_dac_nids,
11520 .hp_nid = 0x03,
11521 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11522 .channel_mode = alc262_modes,
11523 .input_mux = &alc262_HP_D7000_capture_source,
11524 .unsol_event = alc262_hp_wildwest_unsol_event,
11525 .init_hook = alc262_hp_wildwest_automute,
11527 [ALC262_HP_BPC_D7000_WL] = {
11528 .mixers = { alc262_HP_BPC_WildWest_mixer,
11529 alc262_HP_BPC_WildWest_option_mixer },
11530 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11531 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11532 .dac_nids = alc262_dac_nids,
11533 .hp_nid = 0x03,
11534 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11535 .channel_mode = alc262_modes,
11536 .input_mux = &alc262_HP_D7000_capture_source,
11537 .unsol_event = alc262_hp_wildwest_unsol_event,
11538 .init_hook = alc262_hp_wildwest_automute,
11540 [ALC262_HP_TC_T5735] = {
11541 .mixers = { alc262_hp_t5735_mixer },
11542 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11543 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11544 .dac_nids = alc262_dac_nids,
11545 .hp_nid = 0x03,
11546 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11547 .channel_mode = alc262_modes,
11548 .input_mux = &alc262_capture_source,
11549 .unsol_event = alc_automute_amp_unsol_event,
11550 .setup = alc262_hp_t5735_setup,
11551 .init_hook = alc_automute_amp,
11553 [ALC262_HP_RP5700] = {
11554 .mixers = { alc262_hp_rp5700_mixer },
11555 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11556 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11557 .dac_nids = alc262_dac_nids,
11558 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11559 .channel_mode = alc262_modes,
11560 .input_mux = &alc262_hp_rp5700_capture_source,
11562 [ALC262_BENQ_ED8] = {
11563 .mixers = { alc262_base_mixer },
11564 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11565 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11566 .dac_nids = alc262_dac_nids,
11567 .hp_nid = 0x03,
11568 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11569 .channel_mode = alc262_modes,
11570 .input_mux = &alc262_capture_source,
11572 [ALC262_SONY_ASSAMD] = {
11573 .mixers = { alc262_sony_mixer },
11574 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11575 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11576 .dac_nids = alc262_dac_nids,
11577 .hp_nid = 0x02,
11578 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11579 .channel_mode = alc262_modes,
11580 .input_mux = &alc262_capture_source,
11581 .unsol_event = alc262_hippo_unsol_event,
11582 .setup = alc262_hippo_setup,
11583 .init_hook = alc262_hippo_automute,
11585 [ALC262_BENQ_T31] = {
11586 .mixers = { alc262_benq_t31_mixer },
11587 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11588 alc_hp15_unsol_verbs },
11589 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11590 .dac_nids = alc262_dac_nids,
11591 .hp_nid = 0x03,
11592 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11593 .channel_mode = alc262_modes,
11594 .input_mux = &alc262_capture_source,
11595 .unsol_event = alc262_hippo_unsol_event,
11596 .setup = alc262_hippo_setup,
11597 .init_hook = alc262_hippo_automute,
11599 [ALC262_ULTRA] = {
11600 .mixers = { alc262_ultra_mixer },
11601 .cap_mixer = alc262_ultra_capture_mixer,
11602 .init_verbs = { alc262_ultra_verbs },
11603 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11604 .dac_nids = alc262_dac_nids,
11605 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11606 .channel_mode = alc262_modes,
11607 .input_mux = &alc262_ultra_capture_source,
11608 .adc_nids = alc262_adc_nids, /* ADC0 */
11609 .capsrc_nids = alc262_capsrc_nids,
11610 .num_adc_nids = 1, /* single ADC */
11611 .unsol_event = alc262_ultra_unsol_event,
11612 .init_hook = alc262_ultra_automute,
11614 [ALC262_LENOVO_3000] = {
11615 .mixers = { alc262_lenovo_3000_mixer },
11616 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11617 alc262_lenovo_3000_unsol_verbs },
11618 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11619 .dac_nids = alc262_dac_nids,
11620 .hp_nid = 0x03,
11621 .dig_out_nid = ALC262_DIGOUT_NID,
11622 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11623 .channel_mode = alc262_modes,
11624 .input_mux = &alc262_fujitsu_capture_source,
11625 .unsol_event = alc262_lenovo_3000_unsol_event,
11627 [ALC262_NEC] = {
11628 .mixers = { alc262_nec_mixer },
11629 .init_verbs = { alc262_nec_verbs },
11630 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11631 .dac_nids = alc262_dac_nids,
11632 .hp_nid = 0x03,
11633 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11634 .channel_mode = alc262_modes,
11635 .input_mux = &alc262_capture_source,
11637 [ALC262_TOSHIBA_S06] = {
11638 .mixers = { alc262_toshiba_s06_mixer },
11639 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11640 alc262_eapd_verbs },
11641 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11642 .capsrc_nids = alc262_dmic_capsrc_nids,
11643 .dac_nids = alc262_dac_nids,
11644 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11645 .num_adc_nids = 1, /* single ADC */
11646 .dig_out_nid = ALC262_DIGOUT_NID,
11647 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11648 .channel_mode = alc262_modes,
11649 .unsol_event = alc_sku_unsol_event,
11650 .setup = alc262_toshiba_s06_setup,
11651 .init_hook = alc_inithook,
11653 [ALC262_TOSHIBA_RX1] = {
11654 .mixers = { alc262_toshiba_rx1_mixer },
11655 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11656 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11657 .dac_nids = alc262_dac_nids,
11658 .hp_nid = 0x03,
11659 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11660 .channel_mode = alc262_modes,
11661 .input_mux = &alc262_capture_source,
11662 .unsol_event = alc262_hippo_unsol_event,
11663 .setup = alc262_hippo_setup,
11664 .init_hook = alc262_hippo_automute,
11666 [ALC262_TYAN] = {
11667 .mixers = { alc262_tyan_mixer },
11668 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11669 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11670 .dac_nids = alc262_dac_nids,
11671 .hp_nid = 0x02,
11672 .dig_out_nid = ALC262_DIGOUT_NID,
11673 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11674 .channel_mode = alc262_modes,
11675 .input_mux = &alc262_capture_source,
11676 .unsol_event = alc_automute_amp_unsol_event,
11677 .setup = alc262_tyan_setup,
11678 .init_hook = alc_automute_amp,
11682 static int patch_alc262(struct hda_codec *codec)
11684 struct alc_spec *spec;
11685 int board_config;
11686 int err;
11688 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11689 if (spec == NULL)
11690 return -ENOMEM;
11692 codec->spec = spec;
11693 #if 0
11694 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11695 * under-run
11698 int tmp;
11699 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11700 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11701 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11702 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11704 #endif
11706 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11708 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11709 alc262_models,
11710 alc262_cfg_tbl);
11712 if (board_config < 0) {
11713 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11714 codec->chip_name);
11715 board_config = ALC262_AUTO;
11718 if (board_config == ALC262_AUTO) {
11719 /* automatic parse from the BIOS config */
11720 err = alc262_parse_auto_config(codec);
11721 if (err < 0) {
11722 alc_free(codec);
11723 return err;
11724 } else if (!err) {
11725 printk(KERN_INFO
11726 "hda_codec: Cannot set up configuration "
11727 "from BIOS. Using base mode...\n");
11728 board_config = ALC262_BASIC;
11732 if (!spec->no_analog) {
11733 err = snd_hda_attach_beep_device(codec, 0x1);
11734 if (err < 0) {
11735 alc_free(codec);
11736 return err;
11740 if (board_config != ALC262_AUTO)
11741 setup_preset(codec, &alc262_presets[board_config]);
11743 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11744 spec->stream_analog_capture = &alc262_pcm_analog_capture;
11746 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11747 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11749 if (!spec->adc_nids && spec->input_mux) {
11750 int i;
11751 /* check whether the digital-mic has to be supported */
11752 for (i = 0; i < spec->input_mux->num_items; i++) {
11753 if (spec->input_mux->items[i].index >= 9)
11754 break;
11756 if (i < spec->input_mux->num_items) {
11757 /* use only ADC0 */
11758 spec->adc_nids = alc262_dmic_adc_nids;
11759 spec->num_adc_nids = 1;
11760 spec->capsrc_nids = alc262_dmic_capsrc_nids;
11761 } else {
11762 /* all analog inputs */
11763 /* check whether NID 0x07 is valid */
11764 unsigned int wcap = get_wcaps(codec, 0x07);
11766 /* get type */
11767 wcap = get_wcaps_type(wcap);
11768 if (wcap != AC_WID_AUD_IN) {
11769 spec->adc_nids = alc262_adc_nids_alt;
11770 spec->num_adc_nids =
11771 ARRAY_SIZE(alc262_adc_nids_alt);
11772 spec->capsrc_nids = alc262_capsrc_nids_alt;
11773 } else {
11774 spec->adc_nids = alc262_adc_nids;
11775 spec->num_adc_nids =
11776 ARRAY_SIZE(alc262_adc_nids);
11777 spec->capsrc_nids = alc262_capsrc_nids;
11781 if (!spec->cap_mixer && !spec->no_analog)
11782 set_capture_mixer(codec);
11783 if (!spec->no_analog)
11784 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
11786 spec->vmaster_nid = 0x0c;
11788 codec->patch_ops = alc_patch_ops;
11789 if (board_config == ALC262_AUTO)
11790 spec->init_hook = alc262_auto_init;
11791 #ifdef CONFIG_SND_HDA_POWER_SAVE
11792 if (!spec->loopback.amplist)
11793 spec->loopback.amplist = alc262_loopbacks;
11794 #endif
11795 codec->proc_widget_hook = print_realtek_coef;
11797 return 0;
11801 * ALC268 channel source setting (2 channel)
11803 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11804 #define alc268_modes alc260_modes
11806 static hda_nid_t alc268_dac_nids[2] = {
11807 /* front, hp */
11808 0x02, 0x03
11811 static hda_nid_t alc268_adc_nids[2] = {
11812 /* ADC0-1 */
11813 0x08, 0x07
11816 static hda_nid_t alc268_adc_nids_alt[1] = {
11817 /* ADC0 */
11818 0x08
11821 static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11823 static struct snd_kcontrol_new alc268_base_mixer[] = {
11824 /* output mixer control */
11825 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11826 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11827 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11828 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11829 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11830 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11831 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11835 static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11836 /* output mixer control */
11837 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11838 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11839 ALC262_HIPPO_MASTER_SWITCH,
11840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11841 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11842 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11846 /* bind Beep switches of both NID 0x0f and 0x10 */
11847 static struct hda_bind_ctls alc268_bind_beep_sw = {
11848 .ops = &snd_hda_bind_sw,
11849 .values = {
11850 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11851 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11856 static struct snd_kcontrol_new alc268_beep_mixer[] = {
11857 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11858 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11862 static struct hda_verb alc268_eapd_verbs[] = {
11863 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11864 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11868 /* Toshiba specific */
11869 static struct hda_verb alc268_toshiba_verbs[] = {
11870 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11871 { } /* end */
11874 /* Acer specific */
11875 /* bind volumes of both NID 0x02 and 0x03 */
11876 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11877 .ops = &snd_hda_bind_vol,
11878 .values = {
11879 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11880 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11885 /* mute/unmute internal speaker according to the hp jack and mute state */
11886 static void alc268_acer_automute(struct hda_codec *codec, int force)
11888 struct alc_spec *spec = codec->spec;
11889 unsigned int mute;
11891 if (force || !spec->sense_updated) {
11892 unsigned int present;
11893 present = snd_hda_codec_read(codec, 0x14, 0,
11894 AC_VERB_GET_PIN_SENSE, 0);
11895 spec->jack_present = (present & 0x80000000) != 0;
11896 spec->sense_updated = 1;
11898 if (spec->jack_present)
11899 mute = HDA_AMP_MUTE; /* mute internal speaker */
11900 else /* unmute internal speaker if necessary */
11901 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11902 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11903 HDA_AMP_MUTE, mute);
11907 /* bind hp and internal speaker mute (with plug check) */
11908 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11909 struct snd_ctl_elem_value *ucontrol)
11911 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11912 long *valp = ucontrol->value.integer.value;
11913 int change;
11915 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11916 if (change)
11917 alc268_acer_automute(codec, 0);
11918 return change;
11921 static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11922 /* output mixer control */
11923 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11925 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11926 .name = "Master Playback Switch",
11927 .info = snd_hda_mixer_amp_switch_info,
11928 .get = snd_hda_mixer_amp_switch_get,
11929 .put = alc268_acer_master_sw_put,
11930 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11932 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11936 static struct snd_kcontrol_new alc268_acer_mixer[] = {
11937 /* output mixer control */
11938 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11940 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11941 .name = "Master Playback Switch",
11942 .info = snd_hda_mixer_amp_switch_info,
11943 .get = snd_hda_mixer_amp_switch_get,
11944 .put = alc268_acer_master_sw_put,
11945 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11947 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11948 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11949 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11953 static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11954 /* output mixer control */
11955 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11958 .name = "Master Playback Switch",
11959 .info = snd_hda_mixer_amp_switch_info,
11960 .get = snd_hda_mixer_amp_switch_get,
11961 .put = alc268_acer_master_sw_put,
11962 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11964 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11965 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11969 static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11970 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11972 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11973 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11974 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11979 static struct hda_verb alc268_acer_verbs[] = {
11980 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11981 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11984 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11985 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11986 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11990 /* unsolicited event for HP jack sensing */
11991 #define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11992 #define alc268_toshiba_setup alc262_hippo_setup
11993 #define alc268_toshiba_automute alc262_hippo_automute
11995 static void alc268_acer_unsol_event(struct hda_codec *codec,
11996 unsigned int res)
11998 if ((res >> 26) != ALC880_HP_EVENT)
11999 return;
12000 alc268_acer_automute(codec, 1);
12003 static void alc268_acer_init_hook(struct hda_codec *codec)
12005 alc268_acer_automute(codec, 1);
12008 /* toggle speaker-output according to the hp-jack state */
12009 static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12011 unsigned int present;
12012 unsigned char bits;
12014 present = snd_hda_codec_read(codec, 0x15, 0,
12015 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12016 bits = present ? AMP_IN_MUTE(0) : 0;
12017 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12018 AMP_IN_MUTE(0), bits);
12019 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12020 AMP_IN_MUTE(0), bits);
12023 static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12024 unsigned int res)
12026 switch (res >> 26) {
12027 case ALC880_HP_EVENT:
12028 alc268_aspire_one_speaker_automute(codec);
12029 break;
12030 case ALC880_MIC_EVENT:
12031 alc_mic_automute(codec);
12032 break;
12036 static void alc268_acer_lc_setup(struct hda_codec *codec)
12038 struct alc_spec *spec = codec->spec;
12039 spec->ext_mic.pin = 0x18;
12040 spec->ext_mic.mux_idx = 0;
12041 spec->int_mic.pin = 0x12;
12042 spec->int_mic.mux_idx = 6;
12043 spec->auto_mic = 1;
12046 static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12048 alc268_aspire_one_speaker_automute(codec);
12049 alc_mic_automute(codec);
12052 static struct snd_kcontrol_new alc268_dell_mixer[] = {
12053 /* output mixer control */
12054 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12055 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12056 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12057 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12058 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12059 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12063 static struct hda_verb alc268_dell_verbs[] = {
12064 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12066 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12067 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12071 /* mute/unmute internal speaker according to the hp jack and mute state */
12072 static void alc268_dell_setup(struct hda_codec *codec)
12074 struct alc_spec *spec = codec->spec;
12076 spec->autocfg.hp_pins[0] = 0x15;
12077 spec->autocfg.speaker_pins[0] = 0x14;
12078 spec->ext_mic.pin = 0x18;
12079 spec->ext_mic.mux_idx = 0;
12080 spec->int_mic.pin = 0x19;
12081 spec->int_mic.mux_idx = 1;
12082 spec->auto_mic = 1;
12085 static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12086 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12087 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12088 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12090 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12091 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12092 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12093 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12097 static struct hda_verb alc267_quanta_il1_verbs[] = {
12098 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12099 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12103 static void alc267_quanta_il1_setup(struct hda_codec *codec)
12105 struct alc_spec *spec = codec->spec;
12106 spec->autocfg.hp_pins[0] = 0x15;
12107 spec->autocfg.speaker_pins[0] = 0x14;
12108 spec->ext_mic.pin = 0x18;
12109 spec->ext_mic.mux_idx = 0;
12110 spec->int_mic.pin = 0x19;
12111 spec->int_mic.mux_idx = 1;
12112 spec->auto_mic = 1;
12116 * generic initialization of ADC, input mixers and output mixers
12118 static struct hda_verb alc268_base_init_verbs[] = {
12119 /* Unmute DAC0-1 and set vol = 0 */
12120 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12121 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12124 * Set up output mixers (0x0c - 0x0e)
12126 /* set vol=0 to output mixers */
12127 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12128 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12130 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12131 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12135 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12136 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12137 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12138 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12139 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12140 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12142 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12144 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12146 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12148 /* set PCBEEP vol = 0, mute connections */
12149 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12150 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12151 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12153 /* Unmute Selector 23h,24h and set the default input to mic-in */
12155 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12157 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12158 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12164 * generic initialization of ADC, input mixers and output mixers
12166 static struct hda_verb alc268_volume_init_verbs[] = {
12167 /* set output DAC */
12168 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12169 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12171 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12172 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12173 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12174 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12175 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12177 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12178 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12179 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12184 /* set PCBEEP vol = 0, mute connections */
12185 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12186 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12187 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12192 static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12193 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12194 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12195 { } /* end */
12198 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12199 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12200 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12201 _DEFINE_CAPSRC(1),
12202 { } /* end */
12205 static struct snd_kcontrol_new alc268_capture_mixer[] = {
12206 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12207 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12208 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12209 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12210 _DEFINE_CAPSRC(2),
12211 { } /* end */
12214 static struct hda_input_mux alc268_capture_source = {
12215 .num_items = 4,
12216 .items = {
12217 { "Mic", 0x0 },
12218 { "Front Mic", 0x1 },
12219 { "Line", 0x2 },
12220 { "CD", 0x3 },
12224 static struct hda_input_mux alc268_acer_capture_source = {
12225 .num_items = 3,
12226 .items = {
12227 { "Mic", 0x0 },
12228 { "Internal Mic", 0x1 },
12229 { "Line", 0x2 },
12233 static struct hda_input_mux alc268_acer_dmic_capture_source = {
12234 .num_items = 3,
12235 .items = {
12236 { "Mic", 0x0 },
12237 { "Internal Mic", 0x6 },
12238 { "Line", 0x2 },
12242 #ifdef CONFIG_SND_DEBUG
12243 static struct snd_kcontrol_new alc268_test_mixer[] = {
12244 /* Volume widgets */
12245 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12246 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12247 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12248 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12249 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12250 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12251 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12252 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12253 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12254 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12255 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12256 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12257 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
12258 /* The below appears problematic on some hardwares */
12259 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
12260 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12261 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12262 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12263 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12265 /* Modes for retasking pin widgets */
12266 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12267 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12268 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12269 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12271 /* Controls for GPIO pins, assuming they are configured as outputs */
12272 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12273 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12274 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12275 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12277 /* Switches to allow the digital SPDIF output pin to be enabled.
12278 * The ALC268 does not have an SPDIF input.
12280 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12282 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12283 * this output to turn on an external amplifier.
12285 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12286 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12288 { } /* end */
12290 #endif
12292 /* create input playback/capture controls for the given pin */
12293 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12294 const char *ctlname, int idx)
12296 char name[32];
12297 hda_nid_t dac;
12298 int err;
12300 sprintf(name, "%s Playback Volume", ctlname);
12301 switch (nid) {
12302 case 0x14:
12303 case 0x16:
12304 dac = 0x02;
12305 break;
12306 case 0x15:
12307 dac = 0x03;
12308 break;
12309 default:
12310 return 0;
12312 if (spec->multiout.dac_nids[0] != dac &&
12313 spec->multiout.dac_nids[1] != dac) {
12314 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
12315 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
12316 HDA_OUTPUT));
12317 if (err < 0)
12318 return err;
12319 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12322 sprintf(name, "%s Playback Switch", ctlname);
12323 if (nid != 0x16)
12324 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12325 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12326 else /* mono */
12327 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12328 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
12329 if (err < 0)
12330 return err;
12331 return 0;
12334 /* add playback controls from the parsed DAC table */
12335 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12336 const struct auto_pin_cfg *cfg)
12338 hda_nid_t nid;
12339 int err;
12341 spec->multiout.dac_nids = spec->private_dac_nids;
12343 nid = cfg->line_out_pins[0];
12344 if (nid) {
12345 const char *name;
12346 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12347 name = "Speaker";
12348 else
12349 name = "Front";
12350 err = alc268_new_analog_output(spec, nid, name, 0);
12351 if (err < 0)
12352 return err;
12355 nid = cfg->speaker_pins[0];
12356 if (nid == 0x1d) {
12357 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12358 "Speaker Playback Volume",
12359 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12360 if (err < 0)
12361 return err;
12362 } else {
12363 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12364 if (err < 0)
12365 return err;
12367 nid = cfg->hp_pins[0];
12368 if (nid) {
12369 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12370 if (err < 0)
12371 return err;
12374 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12375 if (nid == 0x16) {
12376 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12377 "Mono Playback Switch",
12378 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
12379 if (err < 0)
12380 return err;
12382 return 0;
12385 /* create playback/capture controls for input pins */
12386 static int alc268_auto_create_input_ctls(struct hda_codec *codec,
12387 const struct auto_pin_cfg *cfg)
12389 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
12392 static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12393 hda_nid_t nid, int pin_type)
12395 int idx;
12397 alc_set_pin_output(codec, nid, pin_type);
12398 if (nid == 0x14 || nid == 0x16)
12399 idx = 0;
12400 else
12401 idx = 1;
12402 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12405 static void alc268_auto_init_multi_out(struct hda_codec *codec)
12407 struct alc_spec *spec = codec->spec;
12408 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12409 if (nid) {
12410 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12411 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12415 static void alc268_auto_init_hp_out(struct hda_codec *codec)
12417 struct alc_spec *spec = codec->spec;
12418 hda_nid_t pin;
12420 pin = spec->autocfg.hp_pins[0];
12421 if (pin)
12422 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12423 pin = spec->autocfg.speaker_pins[0];
12424 if (pin)
12425 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12428 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12430 struct alc_spec *spec = codec->spec;
12431 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12432 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12433 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12434 unsigned int dac_vol1, dac_vol2;
12436 if (line_nid == 0x1d || speaker_nid == 0x1d) {
12437 snd_hda_codec_write(codec, speaker_nid, 0,
12438 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12439 /* mute mixer inputs from 0x1d */
12440 snd_hda_codec_write(codec, 0x0f, 0,
12441 AC_VERB_SET_AMP_GAIN_MUTE,
12442 AMP_IN_UNMUTE(1));
12443 snd_hda_codec_write(codec, 0x10, 0,
12444 AC_VERB_SET_AMP_GAIN_MUTE,
12445 AMP_IN_UNMUTE(1));
12446 } else {
12447 /* unmute mixer inputs from 0x1d */
12448 snd_hda_codec_write(codec, 0x0f, 0,
12449 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12450 snd_hda_codec_write(codec, 0x10, 0,
12451 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12454 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
12455 if (line_nid == 0x14)
12456 dac_vol2 = AMP_OUT_ZERO;
12457 else if (line_nid == 0x15)
12458 dac_vol1 = AMP_OUT_ZERO;
12459 if (hp_nid == 0x14)
12460 dac_vol2 = AMP_OUT_ZERO;
12461 else if (hp_nid == 0x15)
12462 dac_vol1 = AMP_OUT_ZERO;
12463 if (line_nid != 0x16 || hp_nid != 0x16 ||
12464 spec->autocfg.line_out_pins[1] != 0x16 ||
12465 spec->autocfg.line_out_pins[2] != 0x16)
12466 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12468 snd_hda_codec_write(codec, 0x02, 0,
12469 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12470 snd_hda_codec_write(codec, 0x03, 0,
12471 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12474 /* pcm configuration: identical with ALC880 */
12475 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
12476 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
12477 #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
12478 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
12481 * BIOS auto configuration
12483 static int alc268_parse_auto_config(struct hda_codec *codec)
12485 struct alc_spec *spec = codec->spec;
12486 int err;
12487 static hda_nid_t alc268_ignore[] = { 0 };
12489 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12490 alc268_ignore);
12491 if (err < 0)
12492 return err;
12493 if (!spec->autocfg.line_outs) {
12494 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12495 spec->multiout.max_channels = 2;
12496 spec->no_analog = 1;
12497 goto dig_only;
12499 return 0; /* can't find valid BIOS pin config */
12501 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12502 if (err < 0)
12503 return err;
12504 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
12505 if (err < 0)
12506 return err;
12508 spec->multiout.max_channels = 2;
12510 dig_only:
12511 /* digital only support output */
12512 if (spec->autocfg.dig_outs) {
12513 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
12514 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12516 if (spec->kctls.list)
12517 add_mixer(spec, spec->kctls.list);
12519 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
12520 add_mixer(spec, alc268_beep_mixer);
12522 add_verb(spec, alc268_volume_init_verbs);
12523 spec->num_mux_defs = 2;
12524 spec->input_mux = &spec->private_imux[0];
12526 err = alc_auto_add_mic_boost(codec);
12527 if (err < 0)
12528 return err;
12530 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12532 return 1;
12535 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
12537 /* init callback for auto-configuration model -- overriding the default init */
12538 static void alc268_auto_init(struct hda_codec *codec)
12540 struct alc_spec *spec = codec->spec;
12541 alc268_auto_init_multi_out(codec);
12542 alc268_auto_init_hp_out(codec);
12543 alc268_auto_init_mono_speaker_out(codec);
12544 alc268_auto_init_analog_input(codec);
12545 if (spec->unsol_event)
12546 alc_inithook(codec);
12550 * configuration and preset
12552 static const char *alc268_models[ALC268_MODEL_LAST] = {
12553 [ALC267_QUANTA_IL1] = "quanta-il1",
12554 [ALC268_3ST] = "3stack",
12555 [ALC268_TOSHIBA] = "toshiba",
12556 [ALC268_ACER] = "acer",
12557 [ALC268_ACER_DMIC] = "acer-dmic",
12558 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
12559 [ALC268_DELL] = "dell",
12560 [ALC268_ZEPTO] = "zepto",
12561 #ifdef CONFIG_SND_DEBUG
12562 [ALC268_TEST] = "test",
12563 #endif
12564 [ALC268_AUTO] = "auto",
12567 static struct snd_pci_quirk alc268_cfg_tbl[] = {
12568 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
12569 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
12570 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
12571 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
12572 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
12573 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12574 ALC268_ACER_ASPIRE_ONE),
12575 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
12576 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
12577 /* almost compatible with toshiba but with optional digital outs;
12578 * auto-probing seems working fine
12580 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12581 ALC268_AUTO),
12582 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
12583 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12584 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
12585 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
12586 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
12587 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
12591 /* Toshiba laptops have no unique PCI SSID but only codec SSID */
12592 static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12593 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12594 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12595 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12596 ALC268_TOSHIBA),
12600 static struct alc_config_preset alc268_presets[] = {
12601 [ALC267_QUANTA_IL1] = {
12602 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12603 alc268_capture_nosrc_mixer },
12604 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12605 alc267_quanta_il1_verbs },
12606 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12607 .dac_nids = alc268_dac_nids,
12608 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12609 .adc_nids = alc268_adc_nids_alt,
12610 .hp_nid = 0x03,
12611 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12612 .channel_mode = alc268_modes,
12613 .unsol_event = alc_sku_unsol_event,
12614 .setup = alc267_quanta_il1_setup,
12615 .init_hook = alc_inithook,
12617 [ALC268_3ST] = {
12618 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12619 alc268_beep_mixer },
12620 .init_verbs = { alc268_base_init_verbs },
12621 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12622 .dac_nids = alc268_dac_nids,
12623 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12624 .adc_nids = alc268_adc_nids_alt,
12625 .capsrc_nids = alc268_capsrc_nids,
12626 .hp_nid = 0x03,
12627 .dig_out_nid = ALC268_DIGOUT_NID,
12628 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12629 .channel_mode = alc268_modes,
12630 .input_mux = &alc268_capture_source,
12632 [ALC268_TOSHIBA] = {
12633 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
12634 alc268_beep_mixer },
12635 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12636 alc268_toshiba_verbs },
12637 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12638 .dac_nids = alc268_dac_nids,
12639 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12640 .adc_nids = alc268_adc_nids_alt,
12641 .capsrc_nids = alc268_capsrc_nids,
12642 .hp_nid = 0x03,
12643 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12644 .channel_mode = alc268_modes,
12645 .input_mux = &alc268_capture_source,
12646 .unsol_event = alc268_toshiba_unsol_event,
12647 .setup = alc268_toshiba_setup,
12648 .init_hook = alc268_toshiba_automute,
12650 [ALC268_ACER] = {
12651 .mixers = { alc268_acer_mixer, alc268_capture_nosrc_mixer,
12652 alc268_beep_mixer },
12653 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12654 alc268_acer_verbs },
12655 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12656 .dac_nids = alc268_dac_nids,
12657 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12658 .adc_nids = alc268_adc_nids_alt,
12659 .capsrc_nids = alc268_capsrc_nids,
12660 .hp_nid = 0x02,
12661 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12662 .channel_mode = alc268_modes,
12663 .input_mux = &alc268_acer_capture_source,
12664 .unsol_event = alc268_acer_unsol_event,
12665 .init_hook = alc268_acer_init_hook,
12667 [ALC268_ACER_DMIC] = {
12668 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12669 alc268_beep_mixer },
12670 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12671 alc268_acer_verbs },
12672 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12673 .dac_nids = alc268_dac_nids,
12674 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12675 .adc_nids = alc268_adc_nids_alt,
12676 .capsrc_nids = alc268_capsrc_nids,
12677 .hp_nid = 0x02,
12678 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12679 .channel_mode = alc268_modes,
12680 .input_mux = &alc268_acer_dmic_capture_source,
12681 .unsol_event = alc268_acer_unsol_event,
12682 .init_hook = alc268_acer_init_hook,
12684 [ALC268_ACER_ASPIRE_ONE] = {
12685 .mixers = { alc268_acer_aspire_one_mixer,
12686 alc268_beep_mixer,
12687 alc268_capture_nosrc_mixer },
12688 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12689 alc268_acer_aspire_one_verbs },
12690 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12691 .dac_nids = alc268_dac_nids,
12692 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12693 .adc_nids = alc268_adc_nids_alt,
12694 .capsrc_nids = alc268_capsrc_nids,
12695 .hp_nid = 0x03,
12696 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12697 .channel_mode = alc268_modes,
12698 .unsol_event = alc268_acer_lc_unsol_event,
12699 .setup = alc268_acer_lc_setup,
12700 .init_hook = alc268_acer_lc_init_hook,
12702 [ALC268_DELL] = {
12703 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12704 alc268_capture_nosrc_mixer },
12705 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12706 alc268_dell_verbs },
12707 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12708 .dac_nids = alc268_dac_nids,
12709 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12710 .adc_nids = alc268_adc_nids_alt,
12711 .capsrc_nids = alc268_capsrc_nids,
12712 .hp_nid = 0x02,
12713 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12714 .channel_mode = alc268_modes,
12715 .unsol_event = alc_sku_unsol_event,
12716 .setup = alc268_dell_setup,
12717 .init_hook = alc_inithook,
12719 [ALC268_ZEPTO] = {
12720 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12721 alc268_beep_mixer },
12722 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12723 alc268_toshiba_verbs },
12724 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12725 .dac_nids = alc268_dac_nids,
12726 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12727 .adc_nids = alc268_adc_nids_alt,
12728 .capsrc_nids = alc268_capsrc_nids,
12729 .hp_nid = 0x03,
12730 .dig_out_nid = ALC268_DIGOUT_NID,
12731 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12732 .channel_mode = alc268_modes,
12733 .input_mux = &alc268_capture_source,
12734 .setup = alc268_toshiba_setup,
12735 .init_hook = alc268_toshiba_automute,
12737 #ifdef CONFIG_SND_DEBUG
12738 [ALC268_TEST] = {
12739 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12740 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12741 alc268_volume_init_verbs },
12742 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12743 .dac_nids = alc268_dac_nids,
12744 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12745 .adc_nids = alc268_adc_nids_alt,
12746 .capsrc_nids = alc268_capsrc_nids,
12747 .hp_nid = 0x03,
12748 .dig_out_nid = ALC268_DIGOUT_NID,
12749 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12750 .channel_mode = alc268_modes,
12751 .input_mux = &alc268_capture_source,
12753 #endif
12756 static int patch_alc268(struct hda_codec *codec)
12758 struct alc_spec *spec;
12759 int board_config;
12760 int i, has_beep, err;
12762 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12763 if (spec == NULL)
12764 return -ENOMEM;
12766 codec->spec = spec;
12768 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12769 alc268_models,
12770 alc268_cfg_tbl);
12772 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12773 board_config = snd_hda_check_board_codec_sid_config(codec,
12774 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12776 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12777 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12778 codec->chip_name);
12779 board_config = ALC268_AUTO;
12782 if (board_config == ALC268_AUTO) {
12783 /* automatic parse from the BIOS config */
12784 err = alc268_parse_auto_config(codec);
12785 if (err < 0) {
12786 alc_free(codec);
12787 return err;
12788 } else if (!err) {
12789 printk(KERN_INFO
12790 "hda_codec: Cannot set up configuration "
12791 "from BIOS. Using base mode...\n");
12792 board_config = ALC268_3ST;
12796 if (board_config != ALC268_AUTO)
12797 setup_preset(codec, &alc268_presets[board_config]);
12799 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12800 spec->stream_analog_capture = &alc268_pcm_analog_capture;
12801 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
12803 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12805 has_beep = 0;
12806 for (i = 0; i < spec->num_mixers; i++) {
12807 if (spec->mixers[i] == alc268_beep_mixer) {
12808 has_beep = 1;
12809 break;
12813 if (has_beep) {
12814 err = snd_hda_attach_beep_device(codec, 0x1);
12815 if (err < 0) {
12816 alc_free(codec);
12817 return err;
12819 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12820 /* override the amp caps for beep generator */
12821 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
12822 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12823 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12824 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12825 (0 << AC_AMPCAP_MUTE_SHIFT));
12828 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
12829 /* check whether NID 0x07 is valid */
12830 unsigned int wcap = get_wcaps(codec, 0x07);
12831 int i;
12833 /* get type */
12834 wcap = get_wcaps_type(wcap);
12835 if (spec->auto_mic ||
12836 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
12837 spec->adc_nids = alc268_adc_nids_alt;
12838 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
12839 if (spec->auto_mic || spec->input_mux->num_items == 1)
12840 add_mixer(spec, alc268_capture_nosrc_mixer);
12841 else
12842 add_mixer(spec, alc268_capture_alt_mixer);
12843 } else {
12844 spec->adc_nids = alc268_adc_nids;
12845 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
12846 add_mixer(spec, alc268_capture_mixer);
12848 spec->capsrc_nids = alc268_capsrc_nids;
12849 /* set default input source */
12850 for (i = 0; i < spec->num_adc_nids; i++)
12851 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12852 0, AC_VERB_SET_CONNECT_SEL,
12853 i < spec->num_mux_defs ?
12854 spec->input_mux[i].items[0].index :
12855 spec->input_mux->items[0].index);
12858 spec->vmaster_nid = 0x02;
12860 codec->patch_ops = alc_patch_ops;
12861 if (board_config == ALC268_AUTO)
12862 spec->init_hook = alc268_auto_init;
12864 codec->proc_widget_hook = print_realtek_coef;
12866 return 0;
12870 * ALC269 channel source setting (2 channel)
12872 #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12874 #define alc269_dac_nids alc260_dac_nids
12876 static hda_nid_t alc269_adc_nids[1] = {
12877 /* ADC1 */
12878 0x08,
12881 static hda_nid_t alc269_capsrc_nids[1] = {
12882 0x23,
12885 /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12886 * not a mux!
12889 #define alc269_modes alc260_modes
12890 #define alc269_capture_source alc880_lg_lw_capture_source
12892 static struct snd_kcontrol_new alc269_base_mixer[] = {
12893 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12894 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12896 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12899 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12900 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12901 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12902 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12903 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12904 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12905 { } /* end */
12908 static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12909 /* output mixer control */
12910 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12912 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12913 .name = "Master Playback Switch",
12914 .info = snd_hda_mixer_amp_switch_info,
12915 .get = snd_hda_mixer_amp_switch_get,
12916 .put = alc268_acer_master_sw_put,
12917 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12920 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12921 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12922 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12923 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12924 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12928 static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12929 /* output mixer control */
12930 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12932 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12933 .name = "Master Playback Switch",
12934 .info = snd_hda_mixer_amp_switch_info,
12935 .get = snd_hda_mixer_amp_switch_get,
12936 .put = alc268_acer_master_sw_put,
12937 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12939 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12940 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12941 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12942 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12943 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12944 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12945 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12946 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12947 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12951 static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12952 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12953 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12954 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12955 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12956 { } /* end */
12959 /* capture mixer elements */
12960 static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12961 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12962 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12963 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12964 { } /* end */
12967 /* FSC amilo */
12968 #define alc269_fujitsu_mixer alc269_eeepc_mixer
12970 static struct hda_verb alc269_quanta_fl1_verbs[] = {
12971 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12972 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12973 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12974 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12975 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12976 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12980 static struct hda_verb alc269_lifebook_verbs[] = {
12981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12982 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12983 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12985 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12986 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12987 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12988 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12989 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12990 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12994 /* toggle speaker-output according to the hp-jack state */
12995 static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12997 unsigned int present;
12998 unsigned char bits;
13000 present = snd_hda_codec_read(codec, 0x15, 0,
13001 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13002 bits = present ? AMP_IN_MUTE(0) : 0;
13003 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13004 AMP_IN_MUTE(0), bits);
13005 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13006 AMP_IN_MUTE(0), bits);
13008 snd_hda_codec_write(codec, 0x20, 0,
13009 AC_VERB_SET_COEF_INDEX, 0x0c);
13010 snd_hda_codec_write(codec, 0x20, 0,
13011 AC_VERB_SET_PROC_COEF, 0x680);
13013 snd_hda_codec_write(codec, 0x20, 0,
13014 AC_VERB_SET_COEF_INDEX, 0x0c);
13015 snd_hda_codec_write(codec, 0x20, 0,
13016 AC_VERB_SET_PROC_COEF, 0x480);
13019 /* toggle speaker-output according to the hp-jacks state */
13020 static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13022 unsigned int present;
13023 unsigned char bits;
13025 /* Check laptop headphone socket */
13026 present = snd_hda_codec_read(codec, 0x15, 0,
13027 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13029 /* Check port replicator headphone socket */
13030 present |= snd_hda_codec_read(codec, 0x1a, 0,
13031 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13033 bits = present ? AMP_IN_MUTE(0) : 0;
13034 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13035 AMP_IN_MUTE(0), bits);
13036 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13037 AMP_IN_MUTE(0), bits);
13039 snd_hda_codec_write(codec, 0x20, 0,
13040 AC_VERB_SET_COEF_INDEX, 0x0c);
13041 snd_hda_codec_write(codec, 0x20, 0,
13042 AC_VERB_SET_PROC_COEF, 0x680);
13044 snd_hda_codec_write(codec, 0x20, 0,
13045 AC_VERB_SET_COEF_INDEX, 0x0c);
13046 snd_hda_codec_write(codec, 0x20, 0,
13047 AC_VERB_SET_PROC_COEF, 0x480);
13050 static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13052 unsigned int present_laptop;
13053 unsigned int present_dock;
13055 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
13056 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13058 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
13059 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13061 /* Laptop mic port overrides dock mic port, design decision */
13062 if (present_dock)
13063 snd_hda_codec_write(codec, 0x23, 0,
13064 AC_VERB_SET_CONNECT_SEL, 0x3);
13065 if (present_laptop)
13066 snd_hda_codec_write(codec, 0x23, 0,
13067 AC_VERB_SET_CONNECT_SEL, 0x0);
13068 if (!present_dock && !present_laptop)
13069 snd_hda_codec_write(codec, 0x23, 0,
13070 AC_VERB_SET_CONNECT_SEL, 0x1);
13073 static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13074 unsigned int res)
13076 switch (res >> 26) {
13077 case ALC880_HP_EVENT:
13078 alc269_quanta_fl1_speaker_automute(codec);
13079 break;
13080 case ALC880_MIC_EVENT:
13081 alc_mic_automute(codec);
13082 break;
13086 static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13087 unsigned int res)
13089 if ((res >> 26) == ALC880_HP_EVENT)
13090 alc269_lifebook_speaker_automute(codec);
13091 if ((res >> 26) == ALC880_MIC_EVENT)
13092 alc269_lifebook_mic_autoswitch(codec);
13095 static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13097 struct alc_spec *spec = codec->spec;
13098 spec->ext_mic.pin = 0x18;
13099 spec->ext_mic.mux_idx = 0;
13100 spec->int_mic.pin = 0x19;
13101 spec->int_mic.mux_idx = 1;
13102 spec->auto_mic = 1;
13105 static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13107 alc269_quanta_fl1_speaker_automute(codec);
13108 alc_mic_automute(codec);
13111 static void alc269_lifebook_init_hook(struct hda_codec *codec)
13113 alc269_lifebook_speaker_automute(codec);
13114 alc269_lifebook_mic_autoswitch(codec);
13117 static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13118 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13119 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13120 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13122 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13123 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13124 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13128 static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13129 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13130 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13131 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13132 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13133 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13134 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13138 /* toggle speaker-output according to the hp-jack state */
13139 static void alc269_speaker_automute(struct hda_codec *codec)
13141 unsigned int present;
13142 unsigned char bits;
13144 present = snd_hda_codec_read(codec, 0x15, 0,
13145 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13146 bits = present ? AMP_IN_MUTE(0) : 0;
13147 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13148 AMP_IN_MUTE(0), bits);
13149 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13150 AMP_IN_MUTE(0), bits);
13153 /* unsolicited event for HP jack sensing */
13154 static void alc269_eeepc_unsol_event(struct hda_codec *codec,
13155 unsigned int res)
13157 switch (res >> 26) {
13158 case ALC880_HP_EVENT:
13159 alc269_speaker_automute(codec);
13160 break;
13161 case ALC880_MIC_EVENT:
13162 alc_mic_automute(codec);
13163 break;
13167 static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13169 struct alc_spec *spec = codec->spec;
13170 spec->ext_mic.pin = 0x18;
13171 spec->ext_mic.mux_idx = 0;
13172 spec->int_mic.pin = 0x12;
13173 spec->int_mic.mux_idx = 5;
13174 spec->auto_mic = 1;
13177 static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13179 struct alc_spec *spec = codec->spec;
13180 spec->ext_mic.pin = 0x18;
13181 spec->ext_mic.mux_idx = 0;
13182 spec->int_mic.pin = 0x19;
13183 spec->int_mic.mux_idx = 1;
13184 spec->auto_mic = 1;
13187 static void alc269_eeepc_inithook(struct hda_codec *codec)
13189 alc269_speaker_automute(codec);
13190 alc_mic_automute(codec);
13194 * generic initialization of ADC, input mixers and output mixers
13196 static struct hda_verb alc269_init_verbs[] = {
13198 * Unmute ADC0 and set the default input to mic-in
13200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13202 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13203 * analog-loopback mixer widget
13204 * Note: PASD motherboards uses the Line In 2 as the input for
13205 * front panel mic (mic 2)
13207 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13210 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13211 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13212 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13215 * Set up output mixers (0x0c - 0x0e)
13217 /* set vol=0 to output mixers */
13218 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13219 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13221 /* set up input amps for analog loopback */
13222 /* Amp Indices: DAC = 0, mixer = 1 */
13223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13225 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13232 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13233 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13234 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13235 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13236 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13240 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13241 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13242 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13243 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13244 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13246 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13249 /* FIXME: use matrix-type input source selection */
13250 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13251 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13252 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13253 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13255 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13257 /* set EAPD */
13258 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13259 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13263 #define alc269_auto_create_multi_out_ctls \
13264 alc268_auto_create_multi_out_ctls
13265 #define alc269_auto_create_input_ctls \
13266 alc268_auto_create_input_ctls
13268 #ifdef CONFIG_SND_HDA_POWER_SAVE
13269 #define alc269_loopbacks alc880_loopbacks
13270 #endif
13272 /* pcm configuration: identical with ALC880 */
13273 #define alc269_pcm_analog_playback alc880_pcm_analog_playback
13274 #define alc269_pcm_analog_capture alc880_pcm_analog_capture
13275 #define alc269_pcm_digital_playback alc880_pcm_digital_playback
13276 #define alc269_pcm_digital_capture alc880_pcm_digital_capture
13278 static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13279 .substreams = 1,
13280 .channels_min = 2,
13281 .channels_max = 8,
13282 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13283 /* NID is set in alc_build_pcms */
13284 .ops = {
13285 .open = alc880_playback_pcm_open,
13286 .prepare = alc880_playback_pcm_prepare,
13287 .cleanup = alc880_playback_pcm_cleanup
13291 static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13292 .substreams = 1,
13293 .channels_min = 2,
13294 .channels_max = 2,
13295 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13296 /* NID is set in alc_build_pcms */
13300 * BIOS auto configuration
13302 static int alc269_parse_auto_config(struct hda_codec *codec)
13304 struct alc_spec *spec = codec->spec;
13305 int err;
13306 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13308 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13309 alc269_ignore);
13310 if (err < 0)
13311 return err;
13313 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13314 if (err < 0)
13315 return err;
13316 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
13317 if (err < 0)
13318 return err;
13320 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13322 if (spec->autocfg.dig_outs)
13323 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13325 if (spec->kctls.list)
13326 add_mixer(spec, spec->kctls.list);
13328 add_verb(spec, alc269_init_verbs);
13329 spec->num_mux_defs = 1;
13330 spec->input_mux = &spec->private_imux[0];
13331 /* set default input source */
13332 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13333 0, AC_VERB_SET_CONNECT_SEL,
13334 spec->input_mux->items[0].index);
13336 err = alc_auto_add_mic_boost(codec);
13337 if (err < 0)
13338 return err;
13340 if (!spec->cap_mixer && !spec->no_analog)
13341 set_capture_mixer(codec);
13343 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13345 return 1;
13348 #define alc269_auto_init_multi_out alc268_auto_init_multi_out
13349 #define alc269_auto_init_hp_out alc268_auto_init_hp_out
13350 #define alc269_auto_init_analog_input alc882_auto_init_analog_input
13353 /* init callback for auto-configuration model -- overriding the default init */
13354 static void alc269_auto_init(struct hda_codec *codec)
13356 struct alc_spec *spec = codec->spec;
13357 alc269_auto_init_multi_out(codec);
13358 alc269_auto_init_hp_out(codec);
13359 alc269_auto_init_analog_input(codec);
13360 if (spec->unsol_event)
13361 alc_inithook(codec);
13365 * configuration and preset
13367 static const char *alc269_models[ALC269_MODEL_LAST] = {
13368 [ALC269_BASIC] = "basic",
13369 [ALC269_QUANTA_FL1] = "quanta",
13370 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
13371 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
13372 [ALC269_FUJITSU] = "fujitsu",
13373 [ALC269_LIFEBOOK] = "lifebook"
13376 static struct snd_pci_quirk alc269_cfg_tbl[] = {
13377 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
13378 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13379 ALC269_ASUS_EEEPC_P703),
13380 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13381 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13382 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13383 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13384 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13385 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
13386 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13387 ALC269_ASUS_EEEPC_P901),
13388 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13389 ALC269_ASUS_EEEPC_P901),
13390 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
13391 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
13392 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
13396 static struct alc_config_preset alc269_presets[] = {
13397 [ALC269_BASIC] = {
13398 .mixers = { alc269_base_mixer },
13399 .init_verbs = { alc269_init_verbs },
13400 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13401 .dac_nids = alc269_dac_nids,
13402 .hp_nid = 0x03,
13403 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13404 .channel_mode = alc269_modes,
13405 .input_mux = &alc269_capture_source,
13407 [ALC269_QUANTA_FL1] = {
13408 .mixers = { alc269_quanta_fl1_mixer },
13409 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13410 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13411 .dac_nids = alc269_dac_nids,
13412 .hp_nid = 0x03,
13413 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13414 .channel_mode = alc269_modes,
13415 .input_mux = &alc269_capture_source,
13416 .unsol_event = alc269_quanta_fl1_unsol_event,
13417 .setup = alc269_quanta_fl1_setup,
13418 .init_hook = alc269_quanta_fl1_init_hook,
13420 [ALC269_ASUS_EEEPC_P703] = {
13421 .mixers = { alc269_eeepc_mixer },
13422 .cap_mixer = alc269_epc_capture_mixer,
13423 .init_verbs = { alc269_init_verbs,
13424 alc269_eeepc_amic_init_verbs },
13425 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13426 .dac_nids = alc269_dac_nids,
13427 .hp_nid = 0x03,
13428 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13429 .channel_mode = alc269_modes,
13430 .unsol_event = alc269_eeepc_unsol_event,
13431 .setup = alc269_eeepc_amic_setup,
13432 .init_hook = alc269_eeepc_inithook,
13434 [ALC269_ASUS_EEEPC_P901] = {
13435 .mixers = { alc269_eeepc_mixer },
13436 .cap_mixer = alc269_epc_capture_mixer,
13437 .init_verbs = { alc269_init_verbs,
13438 alc269_eeepc_dmic_init_verbs },
13439 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13440 .dac_nids = alc269_dac_nids,
13441 .hp_nid = 0x03,
13442 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13443 .channel_mode = alc269_modes,
13444 .unsol_event = alc269_eeepc_unsol_event,
13445 .setup = alc269_eeepc_dmic_setup,
13446 .init_hook = alc269_eeepc_inithook,
13448 [ALC269_FUJITSU] = {
13449 .mixers = { alc269_fujitsu_mixer },
13450 .cap_mixer = alc269_epc_capture_mixer,
13451 .init_verbs = { alc269_init_verbs,
13452 alc269_eeepc_dmic_init_verbs },
13453 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13454 .dac_nids = alc269_dac_nids,
13455 .hp_nid = 0x03,
13456 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13457 .channel_mode = alc269_modes,
13458 .unsol_event = alc269_eeepc_unsol_event,
13459 .setup = alc269_eeepc_dmic_setup,
13460 .init_hook = alc269_eeepc_inithook,
13462 [ALC269_LIFEBOOK] = {
13463 .mixers = { alc269_lifebook_mixer },
13464 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13465 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13466 .dac_nids = alc269_dac_nids,
13467 .hp_nid = 0x03,
13468 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13469 .channel_mode = alc269_modes,
13470 .input_mux = &alc269_capture_source,
13471 .unsol_event = alc269_lifebook_unsol_event,
13472 .init_hook = alc269_lifebook_init_hook,
13476 static int patch_alc269(struct hda_codec *codec)
13478 struct alc_spec *spec;
13479 int board_config;
13480 int err;
13482 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13483 if (spec == NULL)
13484 return -ENOMEM;
13486 codec->spec = spec;
13488 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13490 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13491 alc269_models,
13492 alc269_cfg_tbl);
13494 if (board_config < 0) {
13495 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13496 codec->chip_name);
13497 board_config = ALC269_AUTO;
13500 if (board_config == ALC269_AUTO) {
13501 /* automatic parse from the BIOS config */
13502 err = alc269_parse_auto_config(codec);
13503 if (err < 0) {
13504 alc_free(codec);
13505 return err;
13506 } else if (!err) {
13507 printk(KERN_INFO
13508 "hda_codec: Cannot set up configuration "
13509 "from BIOS. Using base mode...\n");
13510 board_config = ALC269_BASIC;
13514 err = snd_hda_attach_beep_device(codec, 0x1);
13515 if (err < 0) {
13516 alc_free(codec);
13517 return err;
13520 if (board_config != ALC269_AUTO)
13521 setup_preset(codec, &alc269_presets[board_config]);
13523 if (codec->subsystem_id == 0x17aa3bf8) {
13524 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13525 * fix the sample rate of analog I/O to 44.1kHz
13527 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13528 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13529 } else {
13530 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13531 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13533 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13534 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13536 spec->adc_nids = alc269_adc_nids;
13537 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
13538 spec->capsrc_nids = alc269_capsrc_nids;
13539 if (!spec->cap_mixer)
13540 set_capture_mixer(codec);
13541 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
13543 spec->vmaster_nid = 0x02;
13545 codec->patch_ops = alc_patch_ops;
13546 if (board_config == ALC269_AUTO)
13547 spec->init_hook = alc269_auto_init;
13548 #ifdef CONFIG_SND_HDA_POWER_SAVE
13549 if (!spec->loopback.amplist)
13550 spec->loopback.amplist = alc269_loopbacks;
13551 #endif
13552 codec->proc_widget_hook = print_realtek_coef;
13554 return 0;
13558 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13562 * set the path ways for 2 channel output
13563 * need to set the codec line out and mic 1 pin widgets to inputs
13565 static struct hda_verb alc861_threestack_ch2_init[] = {
13566 /* set pin widget 1Ah (line in) for input */
13567 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13568 /* set pin widget 18h (mic1/2) for input, for mic also enable
13569 * the vref
13571 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13573 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13574 #if 0
13575 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13576 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13577 #endif
13578 { } /* end */
13581 * 6ch mode
13582 * need to set the codec line out and mic 1 pin widgets to outputs
13584 static struct hda_verb alc861_threestack_ch6_init[] = {
13585 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13586 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13587 /* set pin widget 18h (mic1) for output (CLFE)*/
13588 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13590 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13591 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13593 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13594 #if 0
13595 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13596 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13597 #endif
13598 { } /* end */
13601 static struct hda_channel_mode alc861_threestack_modes[2] = {
13602 { 2, alc861_threestack_ch2_init },
13603 { 6, alc861_threestack_ch6_init },
13605 /* Set mic1 as input and unmute the mixer */
13606 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13607 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13608 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13609 { } /* end */
13611 /* Set mic1 as output and mute mixer */
13612 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13613 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13614 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13615 { } /* end */
13618 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13619 { 2, alc861_uniwill_m31_ch2_init },
13620 { 4, alc861_uniwill_m31_ch4_init },
13623 /* Set mic1 and line-in as input and unmute the mixer */
13624 static struct hda_verb alc861_asus_ch2_init[] = {
13625 /* set pin widget 1Ah (line in) for input */
13626 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13627 /* set pin widget 18h (mic1/2) for input, for mic also enable
13628 * the vref
13630 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13632 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13633 #if 0
13634 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13635 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13636 #endif
13637 { } /* end */
13639 /* Set mic1 nad line-in as output and mute mixer */
13640 static struct hda_verb alc861_asus_ch6_init[] = {
13641 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13642 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13643 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13644 /* set pin widget 18h (mic1) for output (CLFE)*/
13645 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13646 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13647 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13648 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13650 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13651 #if 0
13652 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13653 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13654 #endif
13655 { } /* end */
13658 static struct hda_channel_mode alc861_asus_modes[2] = {
13659 { 2, alc861_asus_ch2_init },
13660 { 6, alc861_asus_ch6_init },
13663 /* patch-ALC861 */
13665 static struct snd_kcontrol_new alc861_base_mixer[] = {
13666 /* output mixer control */
13667 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13668 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13669 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13670 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13671 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13673 /*Input mixer control */
13674 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13675 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13676 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13677 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13678 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13679 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13681 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13682 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13683 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13685 { } /* end */
13688 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13689 /* output mixer control */
13690 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13691 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13692 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13693 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13694 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13696 /* Input mixer control */
13697 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13698 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13699 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13700 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13701 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13702 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13703 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13704 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13705 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13709 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13710 .name = "Channel Mode",
13711 .info = alc_ch_mode_info,
13712 .get = alc_ch_mode_get,
13713 .put = alc_ch_mode_put,
13714 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13716 { } /* end */
13719 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
13720 /* output mixer control */
13721 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13723 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13725 { } /* end */
13728 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13729 /* output mixer control */
13730 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13731 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13732 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13733 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13734 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13736 /* Input mixer control */
13737 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13738 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13739 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13740 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13741 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13742 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13744 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13745 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13746 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13749 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13750 .name = "Channel Mode",
13751 .info = alc_ch_mode_info,
13752 .get = alc_ch_mode_get,
13753 .put = alc_ch_mode_put,
13754 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13756 { } /* end */
13759 static struct snd_kcontrol_new alc861_asus_mixer[] = {
13760 /* output mixer control */
13761 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13762 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13763 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13764 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13765 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13767 /* Input mixer control */
13768 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13769 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13770 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13771 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13772 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13773 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13775 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13776 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13777 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13781 .name = "Channel Mode",
13782 .info = alc_ch_mode_info,
13783 .get = alc_ch_mode_get,
13784 .put = alc_ch_mode_put,
13785 .private_value = ARRAY_SIZE(alc861_asus_modes),
13790 /* additional mixer */
13791 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
13792 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13793 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13798 * generic initialization of ADC, input mixers and output mixers
13800 static struct hda_verb alc861_base_init_verbs[] = {
13802 * Unmute ADC0 and set the default input to mic-in
13804 /* port-A for surround (rear panel) */
13805 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13806 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13807 /* port-B for mic-in (rear panel) with vref */
13808 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13809 /* port-C for line-in (rear panel) */
13810 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13811 /* port-D for Front */
13812 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13813 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13814 /* port-E for HP out (front panel) */
13815 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13816 /* route front PCM to HP */
13817 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13818 /* port-F for mic-in (front panel) with vref */
13819 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13820 /* port-G for CLFE (rear panel) */
13821 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13822 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13823 /* port-H for side (rear panel) */
13824 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13825 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13826 /* CD-in */
13827 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13828 /* route front mic to ADC1*/
13829 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13830 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13832 /* Unmute DAC0~3 & spdif out*/
13833 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13834 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13835 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13836 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13837 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13839 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13840 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13841 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13842 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13843 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13845 /* Unmute Stereo Mixer 15 */
13846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13851 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13852 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13853 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13854 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13855 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13857 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13858 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13859 /* hp used DAC 3 (Front) */
13860 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13861 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13866 static struct hda_verb alc861_threestack_init_verbs[] = {
13868 * Unmute ADC0 and set the default input to mic-in
13870 /* port-A for surround (rear panel) */
13871 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13872 /* port-B for mic-in (rear panel) with vref */
13873 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13874 /* port-C for line-in (rear panel) */
13875 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13876 /* port-D for Front */
13877 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13878 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13879 /* port-E for HP out (front panel) */
13880 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13881 /* route front PCM to HP */
13882 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13883 /* port-F for mic-in (front panel) with vref */
13884 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13885 /* port-G for CLFE (rear panel) */
13886 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13887 /* port-H for side (rear panel) */
13888 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13889 /* CD-in */
13890 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13891 /* route front mic to ADC1*/
13892 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13893 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13894 /* Unmute DAC0~3 & spdif out*/
13895 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13896 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13897 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13898 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13899 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13901 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13902 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13903 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13904 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13905 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13907 /* Unmute Stereo Mixer 15 */
13908 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13909 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13910 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13913 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13916 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13917 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13918 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13919 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13920 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13921 /* hp used DAC 3 (Front) */
13922 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13923 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13927 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13929 * Unmute ADC0 and set the default input to mic-in
13931 /* port-A for surround (rear panel) */
13932 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13933 /* port-B for mic-in (rear panel) with vref */
13934 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13935 /* port-C for line-in (rear panel) */
13936 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13937 /* port-D for Front */
13938 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13939 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13940 /* port-E for HP out (front panel) */
13941 /* this has to be set to VREF80 */
13942 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13943 /* route front PCM to HP */
13944 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13945 /* port-F for mic-in (front panel) with vref */
13946 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13947 /* port-G for CLFE (rear panel) */
13948 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13949 /* port-H for side (rear panel) */
13950 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13951 /* CD-in */
13952 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13953 /* route front mic to ADC1*/
13954 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13956 /* Unmute DAC0~3 & spdif out*/
13957 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13958 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13959 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13960 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13961 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13963 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13964 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13965 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13966 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13967 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13969 /* Unmute Stereo Mixer 15 */
13970 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13971 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13972 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13975 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13976 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13977 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13978 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13979 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13980 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13981 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13982 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13983 /* hp used DAC 3 (Front) */
13984 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13985 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13989 static struct hda_verb alc861_asus_init_verbs[] = {
13991 * Unmute ADC0 and set the default input to mic-in
13993 /* port-A for surround (rear panel)
13994 * according to codec#0 this is the HP jack
13996 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13997 /* route front PCM to HP */
13998 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13999 /* port-B for mic-in (rear panel) with vref */
14000 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14001 /* port-C for line-in (rear panel) */
14002 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14003 /* port-D for Front */
14004 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14005 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14006 /* port-E for HP out (front panel) */
14007 /* this has to be set to VREF80 */
14008 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14009 /* route front PCM to HP */
14010 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14011 /* port-F for mic-in (front panel) with vref */
14012 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14013 /* port-G for CLFE (rear panel) */
14014 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14015 /* port-H for side (rear panel) */
14016 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14017 /* CD-in */
14018 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14019 /* route front mic to ADC1*/
14020 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14021 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14022 /* Unmute DAC0~3 & spdif out*/
14023 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14024 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14025 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14026 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14027 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14028 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14029 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14030 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14031 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14032 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14034 /* Unmute Stereo Mixer 15 */
14035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14036 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14037 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14038 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
14040 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14041 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14042 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14043 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14044 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14045 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14046 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14047 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14048 /* hp used DAC 3 (Front) */
14049 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
14050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14054 /* additional init verbs for ASUS laptops */
14055 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14056 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14057 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14062 * generic initialization of ADC, input mixers and output mixers
14064 static struct hda_verb alc861_auto_init_verbs[] = {
14066 * Unmute ADC0 and set the default input to mic-in
14068 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
14069 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14071 /* Unmute DAC0~3 & spdif out*/
14072 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14073 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14074 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14075 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14076 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14078 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14079 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14080 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14081 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14082 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14084 /* Unmute Stereo Mixer 15 */
14085 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14086 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14090 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14091 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14092 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14093 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14094 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14095 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14096 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14097 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14099 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14100 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14101 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14102 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14104 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14105 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14106 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
14113 static struct hda_verb alc861_toshiba_init_verbs[] = {
14114 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14119 /* toggle speaker-output according to the hp-jack state */
14120 static void alc861_toshiba_automute(struct hda_codec *codec)
14122 unsigned int present;
14124 present = snd_hda_codec_read(codec, 0x0f, 0,
14125 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14126 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14127 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14128 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14129 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
14132 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14133 unsigned int res)
14135 if ((res >> 26) == ALC880_HP_EVENT)
14136 alc861_toshiba_automute(codec);
14139 /* pcm configuration: identical with ALC880 */
14140 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
14141 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
14142 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
14143 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
14146 #define ALC861_DIGOUT_NID 0x07
14148 static struct hda_channel_mode alc861_8ch_modes[1] = {
14149 { 8, NULL }
14152 static hda_nid_t alc861_dac_nids[4] = {
14153 /* front, surround, clfe, side */
14154 0x03, 0x06, 0x05, 0x04
14157 static hda_nid_t alc660_dac_nids[3] = {
14158 /* front, clfe, surround */
14159 0x03, 0x05, 0x06
14162 static hda_nid_t alc861_adc_nids[1] = {
14163 /* ADC0-2 */
14164 0x08,
14167 static struct hda_input_mux alc861_capture_source = {
14168 .num_items = 5,
14169 .items = {
14170 { "Mic", 0x0 },
14171 { "Front Mic", 0x3 },
14172 { "Line", 0x1 },
14173 { "CD", 0x4 },
14174 { "Mixer", 0x5 },
14178 static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14180 struct alc_spec *spec = codec->spec;
14181 hda_nid_t mix, srcs[5];
14182 int i, j, num;
14184 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14185 return 0;
14186 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14187 if (num < 0)
14188 return 0;
14189 for (i = 0; i < num; i++) {
14190 unsigned int type;
14191 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
14192 if (type != AC_WID_AUD_OUT)
14193 continue;
14194 for (j = 0; j < spec->multiout.num_dacs; j++)
14195 if (spec->multiout.dac_nids[j] == srcs[i])
14196 break;
14197 if (j >= spec->multiout.num_dacs)
14198 return srcs[i];
14200 return 0;
14203 /* fill in the dac_nids table from the parsed pin configuration */
14204 static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
14205 const struct auto_pin_cfg *cfg)
14207 struct alc_spec *spec = codec->spec;
14208 int i;
14209 hda_nid_t nid, dac;
14211 spec->multiout.dac_nids = spec->private_dac_nids;
14212 for (i = 0; i < cfg->line_outs; i++) {
14213 nid = cfg->line_out_pins[i];
14214 dac = alc861_look_for_dac(codec, nid);
14215 if (!dac)
14216 continue;
14217 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
14219 return 0;
14222 static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14223 hda_nid_t nid, unsigned int chs)
14225 char name[32];
14226 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14227 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14228 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14231 /* add playback controls from the parsed DAC table */
14232 static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14233 const struct auto_pin_cfg *cfg)
14235 struct alc_spec *spec = codec->spec;
14236 static const char *chname[4] = {
14237 "Front", "Surround", NULL /*CLFE*/, "Side"
14239 hda_nid_t nid;
14240 int i, err;
14242 if (cfg->line_outs == 1) {
14243 const char *pfx = NULL;
14244 if (!cfg->hp_outs)
14245 pfx = "Master";
14246 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14247 pfx = "Speaker";
14248 if (pfx) {
14249 nid = spec->multiout.dac_nids[0];
14250 return alc861_create_out_sw(codec, pfx, nid, 3);
14254 for (i = 0; i < cfg->line_outs; i++) {
14255 nid = spec->multiout.dac_nids[i];
14256 if (!nid)
14257 continue;
14258 if (i == 2) {
14259 /* Center/LFE */
14260 err = alc861_create_out_sw(codec, "Center", nid, 1);
14261 if (err < 0)
14262 return err;
14263 err = alc861_create_out_sw(codec, "LFE", nid, 2);
14264 if (err < 0)
14265 return err;
14266 } else {
14267 err = alc861_create_out_sw(codec, chname[i], nid, 3);
14268 if (err < 0)
14269 return err;
14272 return 0;
14275 static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
14277 struct alc_spec *spec = codec->spec;
14278 int err;
14279 hda_nid_t nid;
14281 if (!pin)
14282 return 0;
14284 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14285 nid = alc861_look_for_dac(codec, pin);
14286 if (nid) {
14287 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14288 if (err < 0)
14289 return err;
14290 spec->multiout.hp_nid = nid;
14293 return 0;
14296 /* create playback/capture controls for input pins */
14297 static int alc861_auto_create_input_ctls(struct hda_codec *codec,
14298 const struct auto_pin_cfg *cfg)
14300 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
14303 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14304 hda_nid_t nid,
14305 int pin_type, hda_nid_t dac)
14307 hda_nid_t mix, srcs[5];
14308 int i, num;
14310 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14311 pin_type);
14312 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14313 AMP_OUT_UNMUTE);
14314 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14315 return;
14316 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14317 if (num < 0)
14318 return;
14319 for (i = 0; i < num; i++) {
14320 unsigned int mute;
14321 if (srcs[i] == dac || srcs[i] == 0x15)
14322 mute = AMP_IN_UNMUTE(i);
14323 else
14324 mute = AMP_IN_MUTE(i);
14325 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14326 mute);
14330 static void alc861_auto_init_multi_out(struct hda_codec *codec)
14332 struct alc_spec *spec = codec->spec;
14333 int i;
14335 for (i = 0; i < spec->autocfg.line_outs; i++) {
14336 hda_nid_t nid = spec->autocfg.line_out_pins[i];
14337 int pin_type = get_pin_type(spec->autocfg.line_out_type);
14338 if (nid)
14339 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
14340 spec->multiout.dac_nids[i]);
14344 static void alc861_auto_init_hp_out(struct hda_codec *codec)
14346 struct alc_spec *spec = codec->spec;
14347 hda_nid_t pin;
14349 pin = spec->autocfg.hp_pins[0];
14350 if (pin)
14351 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
14352 spec->multiout.hp_nid);
14353 pin = spec->autocfg.speaker_pins[0];
14354 if (pin)
14355 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14356 spec->multiout.dac_nids[0]);
14359 static void alc861_auto_init_analog_input(struct hda_codec *codec)
14361 struct alc_spec *spec = codec->spec;
14362 int i;
14364 for (i = 0; i < AUTO_PIN_LAST; i++) {
14365 hda_nid_t nid = spec->autocfg.input_pins[i];
14366 if (nid >= 0x0c && nid <= 0x11)
14367 alc_set_input_pin(codec, nid, i);
14371 /* parse the BIOS configuration and set up the alc_spec */
14372 /* return 1 if successful, 0 if the proper config is not found,
14373 * or a negative error code
14375 static int alc861_parse_auto_config(struct hda_codec *codec)
14377 struct alc_spec *spec = codec->spec;
14378 int err;
14379 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14381 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14382 alc861_ignore);
14383 if (err < 0)
14384 return err;
14385 if (!spec->autocfg.line_outs)
14386 return 0; /* can't find valid BIOS pin config */
14388 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
14389 if (err < 0)
14390 return err;
14391 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
14392 if (err < 0)
14393 return err;
14394 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
14395 if (err < 0)
14396 return err;
14397 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
14398 if (err < 0)
14399 return err;
14401 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14403 if (spec->autocfg.dig_outs)
14404 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14406 if (spec->kctls.list)
14407 add_mixer(spec, spec->kctls.list);
14409 add_verb(spec, alc861_auto_init_verbs);
14411 spec->num_mux_defs = 1;
14412 spec->input_mux = &spec->private_imux[0];
14414 spec->adc_nids = alc861_adc_nids;
14415 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
14416 set_capture_mixer(codec);
14418 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14420 return 1;
14423 /* additional initialization for auto-configuration model */
14424 static void alc861_auto_init(struct hda_codec *codec)
14426 struct alc_spec *spec = codec->spec;
14427 alc861_auto_init_multi_out(codec);
14428 alc861_auto_init_hp_out(codec);
14429 alc861_auto_init_analog_input(codec);
14430 if (spec->unsol_event)
14431 alc_inithook(codec);
14434 #ifdef CONFIG_SND_HDA_POWER_SAVE
14435 static struct hda_amp_list alc861_loopbacks[] = {
14436 { 0x15, HDA_INPUT, 0 },
14437 { 0x15, HDA_INPUT, 1 },
14438 { 0x15, HDA_INPUT, 2 },
14439 { 0x15, HDA_INPUT, 3 },
14440 { } /* end */
14442 #endif
14446 * configuration and preset
14448 static const char *alc861_models[ALC861_MODEL_LAST] = {
14449 [ALC861_3ST] = "3stack",
14450 [ALC660_3ST] = "3stack-660",
14451 [ALC861_3ST_DIG] = "3stack-dig",
14452 [ALC861_6ST_DIG] = "6stack-dig",
14453 [ALC861_UNIWILL_M31] = "uniwill-m31",
14454 [ALC861_TOSHIBA] = "toshiba",
14455 [ALC861_ASUS] = "asus",
14456 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14457 [ALC861_AUTO] = "auto",
14460 static struct snd_pci_quirk alc861_cfg_tbl[] = {
14461 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
14462 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14463 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14464 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
14465 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
14466 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
14467 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
14468 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14469 * Any other models that need this preset?
14471 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
14472 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14473 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
14474 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14475 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14476 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14477 /* FIXME: the below seems conflict */
14478 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14479 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14480 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
14484 static struct alc_config_preset alc861_presets[] = {
14485 [ALC861_3ST] = {
14486 .mixers = { alc861_3ST_mixer },
14487 .init_verbs = { alc861_threestack_init_verbs },
14488 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14489 .dac_nids = alc861_dac_nids,
14490 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14491 .channel_mode = alc861_threestack_modes,
14492 .need_dac_fix = 1,
14493 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14494 .adc_nids = alc861_adc_nids,
14495 .input_mux = &alc861_capture_source,
14497 [ALC861_3ST_DIG] = {
14498 .mixers = { alc861_base_mixer },
14499 .init_verbs = { alc861_threestack_init_verbs },
14500 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14501 .dac_nids = alc861_dac_nids,
14502 .dig_out_nid = ALC861_DIGOUT_NID,
14503 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14504 .channel_mode = alc861_threestack_modes,
14505 .need_dac_fix = 1,
14506 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14507 .adc_nids = alc861_adc_nids,
14508 .input_mux = &alc861_capture_source,
14510 [ALC861_6ST_DIG] = {
14511 .mixers = { alc861_base_mixer },
14512 .init_verbs = { alc861_base_init_verbs },
14513 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14514 .dac_nids = alc861_dac_nids,
14515 .dig_out_nid = ALC861_DIGOUT_NID,
14516 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14517 .channel_mode = alc861_8ch_modes,
14518 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14519 .adc_nids = alc861_adc_nids,
14520 .input_mux = &alc861_capture_source,
14522 [ALC660_3ST] = {
14523 .mixers = { alc861_3ST_mixer },
14524 .init_verbs = { alc861_threestack_init_verbs },
14525 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14526 .dac_nids = alc660_dac_nids,
14527 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14528 .channel_mode = alc861_threestack_modes,
14529 .need_dac_fix = 1,
14530 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14531 .adc_nids = alc861_adc_nids,
14532 .input_mux = &alc861_capture_source,
14534 [ALC861_UNIWILL_M31] = {
14535 .mixers = { alc861_uniwill_m31_mixer },
14536 .init_verbs = { alc861_uniwill_m31_init_verbs },
14537 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14538 .dac_nids = alc861_dac_nids,
14539 .dig_out_nid = ALC861_DIGOUT_NID,
14540 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14541 .channel_mode = alc861_uniwill_m31_modes,
14542 .need_dac_fix = 1,
14543 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14544 .adc_nids = alc861_adc_nids,
14545 .input_mux = &alc861_capture_source,
14547 [ALC861_TOSHIBA] = {
14548 .mixers = { alc861_toshiba_mixer },
14549 .init_verbs = { alc861_base_init_verbs,
14550 alc861_toshiba_init_verbs },
14551 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14552 .dac_nids = alc861_dac_nids,
14553 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14554 .channel_mode = alc883_3ST_2ch_modes,
14555 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14556 .adc_nids = alc861_adc_nids,
14557 .input_mux = &alc861_capture_source,
14558 .unsol_event = alc861_toshiba_unsol_event,
14559 .init_hook = alc861_toshiba_automute,
14561 [ALC861_ASUS] = {
14562 .mixers = { alc861_asus_mixer },
14563 .init_verbs = { alc861_asus_init_verbs },
14564 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14565 .dac_nids = alc861_dac_nids,
14566 .dig_out_nid = ALC861_DIGOUT_NID,
14567 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14568 .channel_mode = alc861_asus_modes,
14569 .need_dac_fix = 1,
14570 .hp_nid = 0x06,
14571 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14572 .adc_nids = alc861_adc_nids,
14573 .input_mux = &alc861_capture_source,
14575 [ALC861_ASUS_LAPTOP] = {
14576 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14577 .init_verbs = { alc861_asus_init_verbs,
14578 alc861_asus_laptop_init_verbs },
14579 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14580 .dac_nids = alc861_dac_nids,
14581 .dig_out_nid = ALC861_DIGOUT_NID,
14582 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14583 .channel_mode = alc883_3ST_2ch_modes,
14584 .need_dac_fix = 1,
14585 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14586 .adc_nids = alc861_adc_nids,
14587 .input_mux = &alc861_capture_source,
14592 static int patch_alc861(struct hda_codec *codec)
14594 struct alc_spec *spec;
14595 int board_config;
14596 int err;
14598 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14599 if (spec == NULL)
14600 return -ENOMEM;
14602 codec->spec = spec;
14604 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14605 alc861_models,
14606 alc861_cfg_tbl);
14608 if (board_config < 0) {
14609 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14610 codec->chip_name);
14611 board_config = ALC861_AUTO;
14614 if (board_config == ALC861_AUTO) {
14615 /* automatic parse from the BIOS config */
14616 err = alc861_parse_auto_config(codec);
14617 if (err < 0) {
14618 alc_free(codec);
14619 return err;
14620 } else if (!err) {
14621 printk(KERN_INFO
14622 "hda_codec: Cannot set up configuration "
14623 "from BIOS. Using base mode...\n");
14624 board_config = ALC861_3ST_DIG;
14628 err = snd_hda_attach_beep_device(codec, 0x23);
14629 if (err < 0) {
14630 alc_free(codec);
14631 return err;
14634 if (board_config != ALC861_AUTO)
14635 setup_preset(codec, &alc861_presets[board_config]);
14637 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14638 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14640 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14641 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14643 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14645 spec->vmaster_nid = 0x03;
14647 codec->patch_ops = alc_patch_ops;
14648 if (board_config == ALC861_AUTO)
14649 spec->init_hook = alc861_auto_init;
14650 #ifdef CONFIG_SND_HDA_POWER_SAVE
14651 if (!spec->loopback.amplist)
14652 spec->loopback.amplist = alc861_loopbacks;
14653 #endif
14654 codec->proc_widget_hook = print_realtek_coef;
14656 return 0;
14660 * ALC861-VD support
14662 * Based on ALC882
14664 * In addition, an independent DAC
14666 #define ALC861VD_DIGOUT_NID 0x06
14668 static hda_nid_t alc861vd_dac_nids[4] = {
14669 /* front, surr, clfe, side surr */
14670 0x02, 0x03, 0x04, 0x05
14673 /* dac_nids for ALC660vd are in a different order - according to
14674 * Realtek's driver.
14675 * This should probably result in a different mixer for 6stack models
14676 * of ALC660vd codecs, but for now there is only 3stack mixer
14677 * - and it is the same as in 861vd.
14678 * adc_nids in ALC660vd are (is) the same as in 861vd
14680 static hda_nid_t alc660vd_dac_nids[3] = {
14681 /* front, rear, clfe, rear_surr */
14682 0x02, 0x04, 0x03
14685 static hda_nid_t alc861vd_adc_nids[1] = {
14686 /* ADC0 */
14687 0x09,
14690 static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14692 /* input MUX */
14693 /* FIXME: should be a matrix-type input source selection */
14694 static struct hda_input_mux alc861vd_capture_source = {
14695 .num_items = 4,
14696 .items = {
14697 { "Mic", 0x0 },
14698 { "Front Mic", 0x1 },
14699 { "Line", 0x2 },
14700 { "CD", 0x4 },
14704 static struct hda_input_mux alc861vd_dallas_capture_source = {
14705 .num_items = 2,
14706 .items = {
14707 { "Ext Mic", 0x0 },
14708 { "Int Mic", 0x1 },
14712 static struct hda_input_mux alc861vd_hp_capture_source = {
14713 .num_items = 2,
14714 .items = {
14715 { "Front Mic", 0x0 },
14716 { "ATAPI Mic", 0x1 },
14721 * 2ch mode
14723 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14724 { 2, NULL }
14728 * 6ch mode
14730 static struct hda_verb alc861vd_6stack_ch6_init[] = {
14731 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14732 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14733 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14734 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14735 { } /* end */
14739 * 8ch mode
14741 static struct hda_verb alc861vd_6stack_ch8_init[] = {
14742 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14743 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14744 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14745 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14746 { } /* end */
14749 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14750 { 6, alc861vd_6stack_ch6_init },
14751 { 8, alc861vd_6stack_ch8_init },
14754 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14756 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14757 .name = "Channel Mode",
14758 .info = alc_ch_mode_info,
14759 .get = alc_ch_mode_get,
14760 .put = alc_ch_mode_put,
14762 { } /* end */
14765 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14766 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14768 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14769 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14770 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14772 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14773 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14775 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14776 HDA_OUTPUT),
14777 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14778 HDA_OUTPUT),
14779 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14780 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14782 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14783 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14785 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14787 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14788 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14789 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14791 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14792 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14793 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14796 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14798 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14799 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14801 { } /* end */
14804 static struct snd_kcontrol_new alc861vd_3st_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_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14810 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14811 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14814 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14815 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14821 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14822 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14824 { } /* end */
14827 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14828 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14829 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14830 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14832 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14834 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14838 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14839 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14840 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14842 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14843 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14845 { } /* end */
14848 /* Pin assignment: Speaker=0x14, HP = 0x15,
14849 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
14851 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
14852 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14853 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
14854 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14855 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14856 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14857 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14858 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14859 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14860 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14861 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14862 { } /* end */
14865 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
14866 * Front Mic=0x18, ATAPI Mic = 0x19,
14868 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14869 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14870 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14871 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14872 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14873 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14874 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14875 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14876 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14878 { } /* end */
14882 * generic initialization of ADC, input mixers and output mixers
14884 static struct hda_verb alc861vd_volume_init_verbs[] = {
14886 * Unmute ADC0 and set the default input to mic-in
14888 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14889 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14891 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14892 * the analog-loopback mixer widget
14894 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
14895 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14901 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
14902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14905 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
14908 * Set up output mixers (0x02 - 0x05)
14910 /* set vol=0 to output mixers */
14911 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14912 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14913 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14914 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14916 /* set up input amps for analog loopback */
14917 /* Amp Indices: DAC = 0, mixer = 1 */
14918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14919 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14920 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14921 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14923 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14924 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14925 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14931 * 3-stack pin configuration:
14932 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14934 static struct hda_verb alc861vd_3stack_init_verbs[] = {
14936 * Set pin mode and muting
14938 /* set front pin widgets 0x14 for output */
14939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14940 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14941 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14943 /* Mic (rear) pin: input vref at 80% */
14944 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14945 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14946 /* Front Mic pin: input vref at 80% */
14947 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14948 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14949 /* Line In pin: input */
14950 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14951 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14952 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14953 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14954 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14955 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14956 /* CD pin widget for input */
14957 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14963 * 6-stack pin configuration:
14965 static struct hda_verb alc861vd_6stack_init_verbs[] = {
14967 * Set pin mode and muting
14969 /* set front pin widgets 0x14 for output */
14970 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14971 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14972 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14974 /* Rear Pin: output 1 (0x0d) */
14975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14976 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14977 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14978 /* CLFE Pin: output 2 (0x0e) */
14979 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14980 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14981 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14982 /* Side Pin: output 3 (0x0f) */
14983 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14984 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14985 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14987 /* Mic (rear) pin: input vref at 80% */
14988 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14989 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14990 /* Front Mic pin: input vref at 80% */
14991 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14992 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14993 /* Line In pin: input */
14994 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14995 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14996 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14997 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14998 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14999 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15000 /* CD pin widget for input */
15001 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15006 static struct hda_verb alc861vd_eapd_verbs[] = {
15007 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15011 static struct hda_verb alc660vd_eapd_verbs[] = {
15012 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15013 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15017 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15019 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15021 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15022 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15026 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15028 unsigned int present;
15029 unsigned char bits;
15031 present = snd_hda_codec_read(codec, 0x18, 0,
15032 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15033 bits = present ? HDA_AMP_MUTE : 0;
15034 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15035 HDA_AMP_MUTE, bits);
15038 static void alc861vd_lenovo_setup(struct hda_codec *codec)
15040 struct alc_spec *spec = codec->spec;
15041 spec->autocfg.hp_pins[0] = 0x1b;
15042 spec->autocfg.speaker_pins[0] = 0x14;
15045 static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15047 alc_automute_amp(codec);
15048 alc861vd_lenovo_mic_automute(codec);
15051 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15052 unsigned int res)
15054 switch (res >> 26) {
15055 case ALC880_MIC_EVENT:
15056 alc861vd_lenovo_mic_automute(codec);
15057 break;
15058 default:
15059 alc_automute_amp_unsol_event(codec, res);
15060 break;
15064 static struct hda_verb alc861vd_dallas_verbs[] = {
15065 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15066 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15067 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15068 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15070 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15072 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15076 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15080 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15081 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15082 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15083 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15084 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15085 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15086 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15088 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15089 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15090 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15091 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15092 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15093 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15094 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15095 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15102 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15103 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15104 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15106 { } /* end */
15109 /* toggle speaker-output according to the hp-jack state */
15110 static void alc861vd_dallas_setup(struct hda_codec *codec)
15112 struct alc_spec *spec = codec->spec;
15114 spec->autocfg.hp_pins[0] = 0x15;
15115 spec->autocfg.speaker_pins[0] = 0x14;
15118 #ifdef CONFIG_SND_HDA_POWER_SAVE
15119 #define alc861vd_loopbacks alc880_loopbacks
15120 #endif
15122 /* pcm configuration: identical with ALC880 */
15123 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15124 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15125 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15126 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15129 * configuration and preset
15131 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15132 [ALC660VD_3ST] = "3stack-660",
15133 [ALC660VD_3ST_DIG] = "3stack-660-digout",
15134 [ALC660VD_ASUS_V1S] = "asus-v1s",
15135 [ALC861VD_3ST] = "3stack",
15136 [ALC861VD_3ST_DIG] = "3stack-digout",
15137 [ALC861VD_6ST_DIG] = "6stack-digout",
15138 [ALC861VD_LENOVO] = "lenovo",
15139 [ALC861VD_DALLAS] = "dallas",
15140 [ALC861VD_HP] = "hp",
15141 [ALC861VD_AUTO] = "auto",
15144 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
15145 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15146 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
15147 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
15148 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
15149 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
15150 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
15151 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
15152 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
15153 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
15154 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
15155 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
15156 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
15157 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
15158 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
15159 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
15163 static struct alc_config_preset alc861vd_presets[] = {
15164 [ALC660VD_3ST] = {
15165 .mixers = { alc861vd_3st_mixer },
15166 .init_verbs = { alc861vd_volume_init_verbs,
15167 alc861vd_3stack_init_verbs },
15168 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15169 .dac_nids = alc660vd_dac_nids,
15170 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15171 .channel_mode = alc861vd_3stack_2ch_modes,
15172 .input_mux = &alc861vd_capture_source,
15174 [ALC660VD_3ST_DIG] = {
15175 .mixers = { alc861vd_3st_mixer },
15176 .init_verbs = { alc861vd_volume_init_verbs,
15177 alc861vd_3stack_init_verbs },
15178 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15179 .dac_nids = alc660vd_dac_nids,
15180 .dig_out_nid = ALC861VD_DIGOUT_NID,
15181 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15182 .channel_mode = alc861vd_3stack_2ch_modes,
15183 .input_mux = &alc861vd_capture_source,
15185 [ALC861VD_3ST] = {
15186 .mixers = { alc861vd_3st_mixer },
15187 .init_verbs = { alc861vd_volume_init_verbs,
15188 alc861vd_3stack_init_verbs },
15189 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15190 .dac_nids = alc861vd_dac_nids,
15191 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15192 .channel_mode = alc861vd_3stack_2ch_modes,
15193 .input_mux = &alc861vd_capture_source,
15195 [ALC861VD_3ST_DIG] = {
15196 .mixers = { alc861vd_3st_mixer },
15197 .init_verbs = { alc861vd_volume_init_verbs,
15198 alc861vd_3stack_init_verbs },
15199 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15200 .dac_nids = alc861vd_dac_nids,
15201 .dig_out_nid = ALC861VD_DIGOUT_NID,
15202 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15203 .channel_mode = alc861vd_3stack_2ch_modes,
15204 .input_mux = &alc861vd_capture_source,
15206 [ALC861VD_6ST_DIG] = {
15207 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15208 .init_verbs = { alc861vd_volume_init_verbs,
15209 alc861vd_6stack_init_verbs },
15210 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15211 .dac_nids = alc861vd_dac_nids,
15212 .dig_out_nid = ALC861VD_DIGOUT_NID,
15213 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15214 .channel_mode = alc861vd_6stack_modes,
15215 .input_mux = &alc861vd_capture_source,
15217 [ALC861VD_LENOVO] = {
15218 .mixers = { alc861vd_lenovo_mixer },
15219 .init_verbs = { alc861vd_volume_init_verbs,
15220 alc861vd_3stack_init_verbs,
15221 alc861vd_eapd_verbs,
15222 alc861vd_lenovo_unsol_verbs },
15223 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15224 .dac_nids = alc660vd_dac_nids,
15225 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15226 .channel_mode = alc861vd_3stack_2ch_modes,
15227 .input_mux = &alc861vd_capture_source,
15228 .unsol_event = alc861vd_lenovo_unsol_event,
15229 .setup = alc861vd_lenovo_setup,
15230 .init_hook = alc861vd_lenovo_init_hook,
15232 [ALC861VD_DALLAS] = {
15233 .mixers = { alc861vd_dallas_mixer },
15234 .init_verbs = { alc861vd_dallas_verbs },
15235 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15236 .dac_nids = alc861vd_dac_nids,
15237 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15238 .channel_mode = alc861vd_3stack_2ch_modes,
15239 .input_mux = &alc861vd_dallas_capture_source,
15240 .unsol_event = alc_automute_amp_unsol_event,
15241 .setup = alc861vd_dallas_setup,
15242 .init_hook = alc_automute_amp,
15244 [ALC861VD_HP] = {
15245 .mixers = { alc861vd_hp_mixer },
15246 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15247 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15248 .dac_nids = alc861vd_dac_nids,
15249 .dig_out_nid = ALC861VD_DIGOUT_NID,
15250 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15251 .channel_mode = alc861vd_3stack_2ch_modes,
15252 .input_mux = &alc861vd_hp_capture_source,
15253 .unsol_event = alc_automute_amp_unsol_event,
15254 .setup = alc861vd_dallas_setup,
15255 .init_hook = alc_automute_amp,
15257 [ALC660VD_ASUS_V1S] = {
15258 .mixers = { alc861vd_lenovo_mixer },
15259 .init_verbs = { alc861vd_volume_init_verbs,
15260 alc861vd_3stack_init_verbs,
15261 alc861vd_eapd_verbs,
15262 alc861vd_lenovo_unsol_verbs },
15263 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15264 .dac_nids = alc660vd_dac_nids,
15265 .dig_out_nid = ALC861VD_DIGOUT_NID,
15266 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15267 .channel_mode = alc861vd_3stack_2ch_modes,
15268 .input_mux = &alc861vd_capture_source,
15269 .unsol_event = alc861vd_lenovo_unsol_event,
15270 .setup = alc861vd_lenovo_setup,
15271 .init_hook = alc861vd_lenovo_init_hook,
15276 * BIOS auto configuration
15278 static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15279 const struct auto_pin_cfg *cfg)
15281 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15285 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15286 hda_nid_t nid, int pin_type, int dac_idx)
15288 alc_set_pin_output(codec, nid, pin_type);
15291 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15293 struct alc_spec *spec = codec->spec;
15294 int i;
15296 for (i = 0; i <= HDA_SIDE; i++) {
15297 hda_nid_t nid = spec->autocfg.line_out_pins[i];
15298 int pin_type = get_pin_type(spec->autocfg.line_out_type);
15299 if (nid)
15300 alc861vd_auto_set_output_and_unmute(codec, nid,
15301 pin_type, i);
15306 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15308 struct alc_spec *spec = codec->spec;
15309 hda_nid_t pin;
15311 pin = spec->autocfg.hp_pins[0];
15312 if (pin) /* connect to front and use dac 0 */
15313 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
15314 pin = spec->autocfg.speaker_pins[0];
15315 if (pin)
15316 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
15319 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15321 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15323 struct alc_spec *spec = codec->spec;
15324 int i;
15326 for (i = 0; i < AUTO_PIN_LAST; i++) {
15327 hda_nid_t nid = spec->autocfg.input_pins[i];
15328 if (alc_is_input_pin(codec, nid)) {
15329 alc_set_input_pin(codec, nid, i);
15330 if (nid != ALC861VD_PIN_CD_NID &&
15331 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
15332 snd_hda_codec_write(codec, nid, 0,
15333 AC_VERB_SET_AMP_GAIN_MUTE,
15334 AMP_OUT_MUTE);
15339 #define alc861vd_auto_init_input_src alc882_auto_init_input_src
15341 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15342 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15344 /* add playback controls from the parsed DAC table */
15345 /* Based on ALC880 version. But ALC861VD has separate,
15346 * different NIDs for mute/unmute switch and volume control */
15347 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15348 const struct auto_pin_cfg *cfg)
15350 char name[32];
15351 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15352 hda_nid_t nid_v, nid_s;
15353 int i, err;
15355 for (i = 0; i < cfg->line_outs; i++) {
15356 if (!spec->multiout.dac_nids[i])
15357 continue;
15358 nid_v = alc861vd_idx_to_mixer_vol(
15359 alc880_dac_to_idx(
15360 spec->multiout.dac_nids[i]));
15361 nid_s = alc861vd_idx_to_mixer_switch(
15362 alc880_dac_to_idx(
15363 spec->multiout.dac_nids[i]));
15365 if (i == 2) {
15366 /* Center/LFE */
15367 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15368 "Center Playback Volume",
15369 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15370 HDA_OUTPUT));
15371 if (err < 0)
15372 return err;
15373 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15374 "LFE Playback Volume",
15375 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15376 HDA_OUTPUT));
15377 if (err < 0)
15378 return err;
15379 err = add_control(spec, ALC_CTL_BIND_MUTE,
15380 "Center Playback Switch",
15381 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15382 HDA_INPUT));
15383 if (err < 0)
15384 return err;
15385 err = add_control(spec, ALC_CTL_BIND_MUTE,
15386 "LFE Playback Switch",
15387 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15388 HDA_INPUT));
15389 if (err < 0)
15390 return err;
15391 } else {
15392 const char *pfx;
15393 if (cfg->line_outs == 1 &&
15394 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15395 if (!cfg->hp_pins)
15396 pfx = "Speaker";
15397 else
15398 pfx = "PCM";
15399 } else
15400 pfx = chname[i];
15401 sprintf(name, "%s Playback Volume", pfx);
15402 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15403 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15404 HDA_OUTPUT));
15405 if (err < 0)
15406 return err;
15407 if (cfg->line_outs == 1 &&
15408 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15409 pfx = "Speaker";
15410 sprintf(name, "%s Playback Switch", pfx);
15411 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15412 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
15413 HDA_INPUT));
15414 if (err < 0)
15415 return err;
15418 return 0;
15421 /* add playback controls for speaker and HP outputs */
15422 /* Based on ALC880 version. But ALC861VD has separate,
15423 * different NIDs for mute/unmute switch and volume control */
15424 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15425 hda_nid_t pin, const char *pfx)
15427 hda_nid_t nid_v, nid_s;
15428 int err;
15429 char name[32];
15431 if (!pin)
15432 return 0;
15434 if (alc880_is_fixed_pin(pin)) {
15435 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15436 /* specify the DAC as the extra output */
15437 if (!spec->multiout.hp_nid)
15438 spec->multiout.hp_nid = nid_v;
15439 else
15440 spec->multiout.extra_out_nid[0] = nid_v;
15441 /* control HP volume/switch on the output mixer amp */
15442 nid_v = alc861vd_idx_to_mixer_vol(
15443 alc880_fixed_pin_idx(pin));
15444 nid_s = alc861vd_idx_to_mixer_switch(
15445 alc880_fixed_pin_idx(pin));
15447 sprintf(name, "%s Playback Volume", pfx);
15448 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15449 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15450 if (err < 0)
15451 return err;
15452 sprintf(name, "%s Playback Switch", pfx);
15453 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15454 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15455 if (err < 0)
15456 return err;
15457 } else if (alc880_is_multi_pin(pin)) {
15458 /* set manual connection */
15459 /* we have only a switch on HP-out PIN */
15460 sprintf(name, "%s Playback Switch", pfx);
15461 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15462 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15463 if (err < 0)
15464 return err;
15466 return 0;
15469 /* parse the BIOS configuration and set up the alc_spec
15470 * return 1 if successful, 0 if the proper config is not found,
15471 * or a negative error code
15472 * Based on ALC880 version - had to change it to override
15473 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15474 static int alc861vd_parse_auto_config(struct hda_codec *codec)
15476 struct alc_spec *spec = codec->spec;
15477 int err;
15478 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15480 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15481 alc861vd_ignore);
15482 if (err < 0)
15483 return err;
15484 if (!spec->autocfg.line_outs)
15485 return 0; /* can't find valid BIOS pin config */
15487 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15488 if (err < 0)
15489 return err;
15490 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15491 if (err < 0)
15492 return err;
15493 err = alc861vd_auto_create_extra_out(spec,
15494 spec->autocfg.speaker_pins[0],
15495 "Speaker");
15496 if (err < 0)
15497 return err;
15498 err = alc861vd_auto_create_extra_out(spec,
15499 spec->autocfg.hp_pins[0],
15500 "Headphone");
15501 if (err < 0)
15502 return err;
15503 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
15504 if (err < 0)
15505 return err;
15507 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15509 if (spec->autocfg.dig_outs)
15510 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15512 if (spec->kctls.list)
15513 add_mixer(spec, spec->kctls.list);
15515 add_verb(spec, alc861vd_volume_init_verbs);
15517 spec->num_mux_defs = 1;
15518 spec->input_mux = &spec->private_imux[0];
15520 err = alc_auto_add_mic_boost(codec);
15521 if (err < 0)
15522 return err;
15524 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15526 return 1;
15529 /* additional initialization for auto-configuration model */
15530 static void alc861vd_auto_init(struct hda_codec *codec)
15532 struct alc_spec *spec = codec->spec;
15533 alc861vd_auto_init_multi_out(codec);
15534 alc861vd_auto_init_hp_out(codec);
15535 alc861vd_auto_init_analog_input(codec);
15536 alc861vd_auto_init_input_src(codec);
15537 if (spec->unsol_event)
15538 alc_inithook(codec);
15541 static int patch_alc861vd(struct hda_codec *codec)
15543 struct alc_spec *spec;
15544 int err, board_config;
15546 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15547 if (spec == NULL)
15548 return -ENOMEM;
15550 codec->spec = spec;
15552 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15553 alc861vd_models,
15554 alc861vd_cfg_tbl);
15556 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15557 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15558 codec->chip_name);
15559 board_config = ALC861VD_AUTO;
15562 if (board_config == ALC861VD_AUTO) {
15563 /* automatic parse from the BIOS config */
15564 err = alc861vd_parse_auto_config(codec);
15565 if (err < 0) {
15566 alc_free(codec);
15567 return err;
15568 } else if (!err) {
15569 printk(KERN_INFO
15570 "hda_codec: Cannot set up configuration "
15571 "from BIOS. Using base mode...\n");
15572 board_config = ALC861VD_3ST;
15576 err = snd_hda_attach_beep_device(codec, 0x23);
15577 if (err < 0) {
15578 alc_free(codec);
15579 return err;
15582 if (board_config != ALC861VD_AUTO)
15583 setup_preset(codec, &alc861vd_presets[board_config]);
15585 if (codec->vendor_id == 0x10ec0660) {
15586 /* always turn on EAPD */
15587 add_verb(spec, alc660vd_eapd_verbs);
15590 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15591 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15593 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15594 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15596 if (!spec->adc_nids) {
15597 spec->adc_nids = alc861vd_adc_nids;
15598 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15600 if (!spec->capsrc_nids)
15601 spec->capsrc_nids = alc861vd_capsrc_nids;
15603 set_capture_mixer(codec);
15604 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
15606 spec->vmaster_nid = 0x02;
15608 codec->patch_ops = alc_patch_ops;
15610 if (board_config == ALC861VD_AUTO)
15611 spec->init_hook = alc861vd_auto_init;
15612 #ifdef CONFIG_SND_HDA_POWER_SAVE
15613 if (!spec->loopback.amplist)
15614 spec->loopback.amplist = alc861vd_loopbacks;
15615 #endif
15616 codec->proc_widget_hook = print_realtek_coef;
15618 return 0;
15622 * ALC662 support
15624 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15625 * configuration. Each pin widget can choose any input DACs and a mixer.
15626 * Each ADC is connected from a mixer of all inputs. This makes possible
15627 * 6-channel independent captures.
15629 * In addition, an independent DAC for the multi-playback (not used in this
15630 * driver yet).
15632 #define ALC662_DIGOUT_NID 0x06
15633 #define ALC662_DIGIN_NID 0x0a
15635 static hda_nid_t alc662_dac_nids[4] = {
15636 /* front, rear, clfe, rear_surr */
15637 0x02, 0x03, 0x04
15640 static hda_nid_t alc272_dac_nids[2] = {
15641 0x02, 0x03
15644 static hda_nid_t alc662_adc_nids[2] = {
15645 /* ADC1-2 */
15646 0x09, 0x08
15649 static hda_nid_t alc272_adc_nids[1] = {
15650 /* ADC1-2 */
15651 0x08,
15654 static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
15655 static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15658 /* input MUX */
15659 /* FIXME: should be a matrix-type input source selection */
15660 static struct hda_input_mux alc662_capture_source = {
15661 .num_items = 4,
15662 .items = {
15663 { "Mic", 0x0 },
15664 { "Front Mic", 0x1 },
15665 { "Line", 0x2 },
15666 { "CD", 0x4 },
15670 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15671 .num_items = 2,
15672 .items = {
15673 { "Mic", 0x1 },
15674 { "Line", 0x2 },
15678 static struct hda_input_mux alc663_capture_source = {
15679 .num_items = 3,
15680 .items = {
15681 { "Mic", 0x0 },
15682 { "Front Mic", 0x1 },
15683 { "Line", 0x2 },
15687 #if 0 /* set to 1 for testing other input sources below */
15688 static struct hda_input_mux alc272_nc10_capture_source = {
15689 .num_items = 16,
15690 .items = {
15691 { "Autoselect Mic", 0x0 },
15692 { "Internal Mic", 0x1 },
15693 { "In-0x02", 0x2 },
15694 { "In-0x03", 0x3 },
15695 { "In-0x04", 0x4 },
15696 { "In-0x05", 0x5 },
15697 { "In-0x06", 0x6 },
15698 { "In-0x07", 0x7 },
15699 { "In-0x08", 0x8 },
15700 { "In-0x09", 0x9 },
15701 { "In-0x0a", 0x0a },
15702 { "In-0x0b", 0x0b },
15703 { "In-0x0c", 0x0c },
15704 { "In-0x0d", 0x0d },
15705 { "In-0x0e", 0x0e },
15706 { "In-0x0f", 0x0f },
15709 #endif
15712 * 2ch mode
15714 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15715 { 2, NULL }
15719 * 2ch mode
15721 static struct hda_verb alc662_3ST_ch2_init[] = {
15722 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15723 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15724 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15725 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15726 { } /* end */
15730 * 6ch mode
15732 static struct hda_verb alc662_3ST_ch6_init[] = {
15733 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15734 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15735 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15736 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15737 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15738 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15739 { } /* end */
15742 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15743 { 2, alc662_3ST_ch2_init },
15744 { 6, alc662_3ST_ch6_init },
15748 * 2ch mode
15750 static struct hda_verb alc662_sixstack_ch6_init[] = {
15751 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15752 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15753 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15754 { } /* end */
15758 * 6ch mode
15760 static struct hda_verb alc662_sixstack_ch8_init[] = {
15761 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15762 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15763 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15764 { } /* end */
15767 static struct hda_channel_mode alc662_5stack_modes[2] = {
15768 { 2, alc662_sixstack_ch6_init },
15769 { 6, alc662_sixstack_ch8_init },
15772 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15773 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15776 static struct snd_kcontrol_new alc662_base_mixer[] = {
15777 /* output mixer control */
15778 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
15779 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15780 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
15781 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
15782 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15783 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15784 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15785 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
15786 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15788 /*Input mixer control */
15789 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15790 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15791 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15792 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15793 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15794 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15795 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15796 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
15797 { } /* end */
15800 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15801 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15802 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15806 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15807 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15809 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15810 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15812 { } /* end */
15815 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15816 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15817 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15818 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15819 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
15820 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15821 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15822 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15823 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
15824 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15825 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15826 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15827 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15828 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15830 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15831 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15832 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15833 { } /* end */
15836 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15837 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15838 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
15839 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15840 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
15841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15842 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15843 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15844 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15845 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15846 { } /* end */
15849 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
15850 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15851 ALC262_HIPPO_MASTER_SWITCH,
15853 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15854 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15855 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15857 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15858 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15859 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15860 { } /* end */
15863 static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
15864 ALC262_HIPPO_MASTER_SWITCH,
15865 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15866 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15867 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15868 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15869 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15870 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15871 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15872 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15873 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15874 { } /* end */
15877 static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15878 .ops = &snd_hda_bind_vol,
15879 .values = {
15880 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15881 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15886 static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15887 .ops = &snd_hda_bind_sw,
15888 .values = {
15889 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15890 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15895 static struct snd_kcontrol_new alc663_m51va_mixer[] = {
15896 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15897 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15899 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15900 { } /* end */
15903 static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15904 .ops = &snd_hda_bind_sw,
15905 .values = {
15906 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15907 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15908 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15913 static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15914 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15915 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15917 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15918 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15919 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15921 { } /* end */
15924 static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15925 .ops = &snd_hda_bind_sw,
15926 .values = {
15927 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15928 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15929 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15934 static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15935 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15936 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15937 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15938 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15939 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15940 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15941 { } /* end */
15944 static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
15945 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15946 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15948 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15950 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15951 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15952 { } /* end */
15955 static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15956 .ops = &snd_hda_bind_vol,
15957 .values = {
15958 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15959 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15964 static struct hda_bind_ctls alc663_asus_two_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(0x16, 3, 0, HDA_OUTPUT),
15973 static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15974 HDA_BIND_VOL("Master Playback Volume",
15975 &alc663_asus_two_bind_master_vol),
15976 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15977 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15978 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15981 { } /* end */
15984 static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15985 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15986 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15987 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15989 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15990 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15991 { } /* end */
15994 static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15995 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15996 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15997 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15998 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15999 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16001 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16003 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16004 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16005 { } /* end */
16008 static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16009 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16010 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16011 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16015 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16016 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16017 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16018 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16019 { } /* end */
16022 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16024 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16025 .name = "Channel Mode",
16026 .info = alc_ch_mode_info,
16027 .get = alc_ch_mode_get,
16028 .put = alc_ch_mode_put,
16030 { } /* end */
16033 static struct hda_verb alc662_init_verbs[] = {
16034 /* ADC: mute amp left and right */
16035 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16036 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16037 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16045 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16047 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16048 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16049 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16050 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16052 /* Front Pin: output 0 (0x0c) */
16053 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16054 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16056 /* Rear Pin: output 1 (0x0d) */
16057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16060 /* CLFE Pin: output 2 (0x0e) */
16061 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16062 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16064 /* Mic (rear) pin: input vref at 80% */
16065 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16066 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16067 /* Front Mic pin: input vref at 80% */
16068 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16069 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16070 /* Line In pin: input */
16071 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16072 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16073 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16074 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16075 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16076 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16077 /* CD pin widget for input */
16078 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16080 /* FIXME: use matrix-type input source selection */
16081 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16082 /* Input mixer */
16083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16086 /* always trun on EAPD */
16087 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16088 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16093 static struct hda_verb alc662_sue_init_verbs[] = {
16094 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16095 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16099 static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16100 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16101 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16105 /* Set Unsolicited Event*/
16106 static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16107 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16108 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16113 * generic initialization of ADC, input mixers and output mixers
16115 static struct hda_verb alc662_auto_init_verbs[] = {
16117 * Unmute ADC and set the default input to mic-in
16119 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16120 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16122 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16123 * mixer widget
16124 * Note: PASD motherboards uses the Line In 2 as the input for front
16125 * panel mic (mic 2)
16127 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
16128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16130 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16131 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16132 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16135 * Set up output mixers (0x0c - 0x0f)
16137 /* set vol=0 to output mixers */
16138 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16139 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16140 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16142 /* set up input amps for analog loopback */
16143 /* Amp Indices: DAC = 0, mixer = 1 */
16144 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16146 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16147 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16149 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16152 /* FIXME: use matrix-type input source selection */
16153 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16154 /* Input mixer */
16155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16160 /* additional verbs for ALC663 */
16161 static struct hda_verb alc663_auto_init_verbs[] = {
16162 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16163 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16167 static struct hda_verb alc663_m51va_init_verbs[] = {
16168 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16169 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16170 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16171 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16172 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16174 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16175 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16176 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16180 static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16181 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16182 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16183 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16186 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16187 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16191 static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16192 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16195 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16198 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16199 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16203 static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16204 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16205 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16206 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16207 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16208 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16209 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16210 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16214 static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16216 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16217 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16218 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16221 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16224 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16225 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16226 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16230 static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16231 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16233 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16234 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16236 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16237 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16240 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16241 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16242 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16246 static struct hda_verb alc663_g71v_init_verbs[] = {
16247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16248 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16249 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16251 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16252 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16253 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16255 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16256 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16257 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16261 static struct hda_verb alc663_g50v_init_verbs[] = {
16262 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16263 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16264 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16266 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16267 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16271 static struct hda_verb alc662_ecs_init_verbs[] = {
16272 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16274 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16275 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16279 static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16280 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16281 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16283 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16284 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16285 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16286 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16289 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16290 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16294 static struct hda_verb alc272_dell_init_verbs[] = {
16295 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16296 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16297 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16298 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16299 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16300 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16301 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16302 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16304 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16305 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16309 static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16310 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16311 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16312 { } /* end */
16315 static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16316 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16317 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16318 { } /* end */
16321 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16323 unsigned int present;
16324 unsigned char bits;
16326 present = snd_hda_codec_read(codec, 0x14, 0,
16327 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16328 bits = present ? HDA_AMP_MUTE : 0;
16329 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16330 HDA_AMP_MUTE, bits);
16333 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16335 unsigned int present;
16336 unsigned char bits;
16338 present = snd_hda_codec_read(codec, 0x1b, 0,
16339 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16340 bits = present ? HDA_AMP_MUTE : 0;
16341 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16342 HDA_AMP_MUTE, bits);
16343 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16344 HDA_AMP_MUTE, bits);
16347 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16348 unsigned int res)
16350 if ((res >> 26) == ALC880_HP_EVENT)
16351 alc662_lenovo_101e_all_automute(codec);
16352 if ((res >> 26) == ALC880_FRONT_EVENT)
16353 alc662_lenovo_101e_ispeaker_automute(codec);
16356 /* unsolicited event for HP jack sensing */
16357 static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16358 unsigned int res)
16360 if ((res >> 26) == ALC880_MIC_EVENT)
16361 alc_mic_automute(codec);
16362 else
16363 alc262_hippo_unsol_event(codec, res);
16366 static void alc662_eeepc_setup(struct hda_codec *codec)
16368 struct alc_spec *spec = codec->spec;
16370 alc262_hippo1_setup(codec);
16371 spec->ext_mic.pin = 0x18;
16372 spec->ext_mic.mux_idx = 0;
16373 spec->int_mic.pin = 0x19;
16374 spec->int_mic.mux_idx = 1;
16375 spec->auto_mic = 1;
16378 static void alc662_eeepc_inithook(struct hda_codec *codec)
16380 alc262_hippo_automute(codec);
16381 alc_mic_automute(codec);
16384 static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
16386 struct alc_spec *spec = codec->spec;
16388 spec->autocfg.hp_pins[0] = 0x14;
16389 spec->autocfg.speaker_pins[0] = 0x1b;
16392 #define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16394 static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16396 unsigned int present;
16397 unsigned char bits;
16399 present = snd_hda_codec_read(codec, 0x21, 0,
16400 AC_VERB_GET_PIN_SENSE, 0)
16401 & AC_PINSENSE_PRESENCE;
16402 bits = present ? HDA_AMP_MUTE : 0;
16403 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16404 AMP_IN_MUTE(0), bits);
16405 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16406 AMP_IN_MUTE(0), bits);
16409 static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16411 unsigned int present;
16412 unsigned char bits;
16414 present = snd_hda_codec_read(codec, 0x21, 0,
16415 AC_VERB_GET_PIN_SENSE, 0)
16416 & AC_PINSENSE_PRESENCE;
16417 bits = present ? HDA_AMP_MUTE : 0;
16418 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16419 AMP_IN_MUTE(0), bits);
16420 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16421 AMP_IN_MUTE(0), bits);
16422 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16423 AMP_IN_MUTE(0), bits);
16424 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16425 AMP_IN_MUTE(0), bits);
16428 static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16430 unsigned int present;
16431 unsigned char bits;
16433 present = snd_hda_codec_read(codec, 0x15, 0,
16434 AC_VERB_GET_PIN_SENSE, 0)
16435 & AC_PINSENSE_PRESENCE;
16436 bits = present ? HDA_AMP_MUTE : 0;
16437 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16438 AMP_IN_MUTE(0), bits);
16439 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16440 AMP_IN_MUTE(0), bits);
16441 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16442 AMP_IN_MUTE(0), bits);
16443 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16444 AMP_IN_MUTE(0), bits);
16447 static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16449 unsigned int present;
16450 unsigned char bits;
16452 present = snd_hda_codec_read(codec, 0x1b, 0,
16453 AC_VERB_GET_PIN_SENSE, 0)
16454 & AC_PINSENSE_PRESENCE;
16455 bits = present ? 0 : PIN_OUT;
16456 snd_hda_codec_write(codec, 0x14, 0,
16457 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16460 static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16462 unsigned int present1, present2;
16464 present1 = snd_hda_codec_read(codec, 0x21, 0,
16465 AC_VERB_GET_PIN_SENSE, 0)
16466 & AC_PINSENSE_PRESENCE;
16467 present2 = snd_hda_codec_read(codec, 0x15, 0,
16468 AC_VERB_GET_PIN_SENSE, 0)
16469 & AC_PINSENSE_PRESENCE;
16471 if (present1 || present2) {
16472 snd_hda_codec_write_cache(codec, 0x14, 0,
16473 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16474 } else {
16475 snd_hda_codec_write_cache(codec, 0x14, 0,
16476 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16480 static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16482 unsigned int present1, present2;
16484 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16485 AC_VERB_GET_PIN_SENSE, 0)
16486 & AC_PINSENSE_PRESENCE;
16487 present2 = snd_hda_codec_read(codec, 0x15, 0,
16488 AC_VERB_GET_PIN_SENSE, 0)
16489 & AC_PINSENSE_PRESENCE;
16491 if (present1 || present2) {
16492 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16493 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16494 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16495 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16496 } else {
16497 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16498 AMP_IN_MUTE(0), 0);
16499 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16500 AMP_IN_MUTE(0), 0);
16504 static void alc663_m51va_unsol_event(struct hda_codec *codec,
16505 unsigned int res)
16507 switch (res >> 26) {
16508 case ALC880_HP_EVENT:
16509 alc663_m51va_speaker_automute(codec);
16510 break;
16511 case ALC880_MIC_EVENT:
16512 alc_mic_automute(codec);
16513 break;
16517 static void alc663_m51va_setup(struct hda_codec *codec)
16519 struct alc_spec *spec = codec->spec;
16520 spec->ext_mic.pin = 0x18;
16521 spec->ext_mic.mux_idx = 0;
16522 spec->int_mic.pin = 0x12;
16523 spec->int_mic.mux_idx = 1;
16524 spec->auto_mic = 1;
16527 static void alc663_m51va_inithook(struct hda_codec *codec)
16529 alc663_m51va_speaker_automute(codec);
16530 alc_mic_automute(codec);
16533 /* ***************** Mode1 ******************************/
16534 #define alc663_mode1_unsol_event alc663_m51va_unsol_event
16535 #define alc663_mode1_setup alc663_m51va_setup
16536 #define alc663_mode1_inithook alc663_m51va_inithook
16538 /* ***************** Mode2 ******************************/
16539 static void alc662_mode2_unsol_event(struct hda_codec *codec,
16540 unsigned int res)
16542 switch (res >> 26) {
16543 case ALC880_HP_EVENT:
16544 alc662_f5z_speaker_automute(codec);
16545 break;
16546 case ALC880_MIC_EVENT:
16547 alc_mic_automute(codec);
16548 break;
16552 #define alc662_mode2_setup alc663_m51va_setup
16554 static void alc662_mode2_inithook(struct hda_codec *codec)
16556 alc662_f5z_speaker_automute(codec);
16557 alc_mic_automute(codec);
16559 /* ***************** Mode3 ******************************/
16560 static void alc663_mode3_unsol_event(struct hda_codec *codec,
16561 unsigned int res)
16563 switch (res >> 26) {
16564 case ALC880_HP_EVENT:
16565 alc663_two_hp_m1_speaker_automute(codec);
16566 break;
16567 case ALC880_MIC_EVENT:
16568 alc_mic_automute(codec);
16569 break;
16573 #define alc663_mode3_setup alc663_m51va_setup
16575 static void alc663_mode3_inithook(struct hda_codec *codec)
16577 alc663_two_hp_m1_speaker_automute(codec);
16578 alc_mic_automute(codec);
16580 /* ***************** Mode4 ******************************/
16581 static void alc663_mode4_unsol_event(struct hda_codec *codec,
16582 unsigned int res)
16584 switch (res >> 26) {
16585 case ALC880_HP_EVENT:
16586 alc663_21jd_two_speaker_automute(codec);
16587 break;
16588 case ALC880_MIC_EVENT:
16589 alc_mic_automute(codec);
16590 break;
16594 #define alc663_mode4_setup alc663_m51va_setup
16596 static void alc663_mode4_inithook(struct hda_codec *codec)
16598 alc663_21jd_two_speaker_automute(codec);
16599 alc_mic_automute(codec);
16601 /* ***************** Mode5 ******************************/
16602 static void alc663_mode5_unsol_event(struct hda_codec *codec,
16603 unsigned int res)
16605 switch (res >> 26) {
16606 case ALC880_HP_EVENT:
16607 alc663_15jd_two_speaker_automute(codec);
16608 break;
16609 case ALC880_MIC_EVENT:
16610 alc_mic_automute(codec);
16611 break;
16615 #define alc663_mode5_setup alc663_m51va_setup
16617 static void alc663_mode5_inithook(struct hda_codec *codec)
16619 alc663_15jd_two_speaker_automute(codec);
16620 alc_mic_automute(codec);
16622 /* ***************** Mode6 ******************************/
16623 static void alc663_mode6_unsol_event(struct hda_codec *codec,
16624 unsigned int res)
16626 switch (res >> 26) {
16627 case ALC880_HP_EVENT:
16628 alc663_two_hp_m2_speaker_automute(codec);
16629 break;
16630 case ALC880_MIC_EVENT:
16631 alc_mic_automute(codec);
16632 break;
16636 #define alc663_mode6_setup alc663_m51va_setup
16638 static void alc663_mode6_inithook(struct hda_codec *codec)
16640 alc663_two_hp_m2_speaker_automute(codec);
16641 alc_mic_automute(codec);
16644 static void alc663_g71v_hp_automute(struct hda_codec *codec)
16646 unsigned int present;
16647 unsigned char bits;
16649 present = snd_hda_codec_read(codec, 0x21, 0,
16650 AC_VERB_GET_PIN_SENSE, 0)
16651 & AC_PINSENSE_PRESENCE;
16652 bits = present ? HDA_AMP_MUTE : 0;
16653 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16654 HDA_AMP_MUTE, bits);
16655 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16656 HDA_AMP_MUTE, bits);
16659 static void alc663_g71v_front_automute(struct hda_codec *codec)
16661 unsigned int present;
16662 unsigned char bits;
16664 present = snd_hda_codec_read(codec, 0x15, 0,
16665 AC_VERB_GET_PIN_SENSE, 0)
16666 & AC_PINSENSE_PRESENCE;
16667 bits = present ? HDA_AMP_MUTE : 0;
16668 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16669 HDA_AMP_MUTE, bits);
16672 static void alc663_g71v_unsol_event(struct hda_codec *codec,
16673 unsigned int res)
16675 switch (res >> 26) {
16676 case ALC880_HP_EVENT:
16677 alc663_g71v_hp_automute(codec);
16678 break;
16679 case ALC880_FRONT_EVENT:
16680 alc663_g71v_front_automute(codec);
16681 break;
16682 case ALC880_MIC_EVENT:
16683 alc_mic_automute(codec);
16684 break;
16688 #define alc663_g71v_setup alc663_m51va_setup
16690 static void alc663_g71v_inithook(struct hda_codec *codec)
16692 alc663_g71v_front_automute(codec);
16693 alc663_g71v_hp_automute(codec);
16694 alc_mic_automute(codec);
16697 static void alc663_g50v_unsol_event(struct hda_codec *codec,
16698 unsigned int res)
16700 switch (res >> 26) {
16701 case ALC880_HP_EVENT:
16702 alc663_m51va_speaker_automute(codec);
16703 break;
16704 case ALC880_MIC_EVENT:
16705 alc_mic_automute(codec);
16706 break;
16710 #define alc663_g50v_setup alc663_m51va_setup
16712 static void alc663_g50v_inithook(struct hda_codec *codec)
16714 alc663_m51va_speaker_automute(codec);
16715 alc_mic_automute(codec);
16718 static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16719 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16720 ALC262_HIPPO_MASTER_SWITCH,
16722 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16723 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16724 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16726 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16727 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16728 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16729 { } /* end */
16732 static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16733 /* Master Playback automatically created from Speaker and Headphone */
16734 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16735 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16736 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16737 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16739 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16740 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16741 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16743 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16744 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16745 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16746 { } /* end */
16749 #ifdef CONFIG_SND_HDA_POWER_SAVE
16750 #define alc662_loopbacks alc880_loopbacks
16751 #endif
16754 /* pcm configuration: identical with ALC880 */
16755 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
16756 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
16757 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
16758 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
16761 * configuration and preset
16763 static const char *alc662_models[ALC662_MODEL_LAST] = {
16764 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16765 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16766 [ALC662_3ST_6ch] = "3stack-6ch",
16767 [ALC662_5ST_DIG] = "6stack-dig",
16768 [ALC662_LENOVO_101E] = "lenovo-101e",
16769 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
16770 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
16771 [ALC662_ECS] = "ecs",
16772 [ALC663_ASUS_M51VA] = "m51va",
16773 [ALC663_ASUS_G71V] = "g71v",
16774 [ALC663_ASUS_H13] = "h13",
16775 [ALC663_ASUS_G50V] = "g50v",
16776 [ALC663_ASUS_MODE1] = "asus-mode1",
16777 [ALC662_ASUS_MODE2] = "asus-mode2",
16778 [ALC663_ASUS_MODE3] = "asus-mode3",
16779 [ALC663_ASUS_MODE4] = "asus-mode4",
16780 [ALC663_ASUS_MODE5] = "asus-mode5",
16781 [ALC663_ASUS_MODE6] = "asus-mode6",
16782 [ALC272_DELL] = "dell",
16783 [ALC272_DELL_ZM1] = "dell-zm1",
16784 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
16785 [ALC662_AUTO] = "auto",
16788 static struct snd_pci_quirk alc662_cfg_tbl[] = {
16789 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16790 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16791 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
16792 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16793 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16794 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16795 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16796 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16797 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16798 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16799 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16800 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16801 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16802 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16803 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16804 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16805 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16806 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
16807 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16808 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16809 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16810 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16811 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
16812 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16813 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16814 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
16815 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16816 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16817 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16818 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16819 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16820 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
16821 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16822 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16823 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16824 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
16825 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16826 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16827 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
16828 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
16829 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
16830 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16831 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16832 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16833 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
16834 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16835 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16836 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
16837 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
16838 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
16839 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
16840 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16841 ALC662_3ST_6ch_DIG),
16842 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
16843 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16844 ALC662_3ST_6ch_DIG),
16845 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
16846 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
16847 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
16848 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
16849 ALC662_3ST_6ch_DIG),
16850 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16851 ALC663_ASUS_H13),
16855 static struct alc_config_preset alc662_presets[] = {
16856 [ALC662_3ST_2ch_DIG] = {
16857 .mixers = { alc662_3ST_2ch_mixer },
16858 .init_verbs = { alc662_init_verbs },
16859 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16860 .dac_nids = alc662_dac_nids,
16861 .dig_out_nid = ALC662_DIGOUT_NID,
16862 .dig_in_nid = ALC662_DIGIN_NID,
16863 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16864 .channel_mode = alc662_3ST_2ch_modes,
16865 .input_mux = &alc662_capture_source,
16867 [ALC662_3ST_6ch_DIG] = {
16868 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
16869 .init_verbs = { alc662_init_verbs },
16870 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16871 .dac_nids = alc662_dac_nids,
16872 .dig_out_nid = ALC662_DIGOUT_NID,
16873 .dig_in_nid = ALC662_DIGIN_NID,
16874 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16875 .channel_mode = alc662_3ST_6ch_modes,
16876 .need_dac_fix = 1,
16877 .input_mux = &alc662_capture_source,
16879 [ALC662_3ST_6ch] = {
16880 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
16881 .init_verbs = { alc662_init_verbs },
16882 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16883 .dac_nids = alc662_dac_nids,
16884 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16885 .channel_mode = alc662_3ST_6ch_modes,
16886 .need_dac_fix = 1,
16887 .input_mux = &alc662_capture_source,
16889 [ALC662_5ST_DIG] = {
16890 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
16891 .init_verbs = { alc662_init_verbs },
16892 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16893 .dac_nids = alc662_dac_nids,
16894 .dig_out_nid = ALC662_DIGOUT_NID,
16895 .dig_in_nid = ALC662_DIGIN_NID,
16896 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16897 .channel_mode = alc662_5stack_modes,
16898 .input_mux = &alc662_capture_source,
16900 [ALC662_LENOVO_101E] = {
16901 .mixers = { alc662_lenovo_101e_mixer },
16902 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16903 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16904 .dac_nids = alc662_dac_nids,
16905 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16906 .channel_mode = alc662_3ST_2ch_modes,
16907 .input_mux = &alc662_lenovo_101e_capture_source,
16908 .unsol_event = alc662_lenovo_101e_unsol_event,
16909 .init_hook = alc662_lenovo_101e_all_automute,
16911 [ALC662_ASUS_EEEPC_P701] = {
16912 .mixers = { alc662_eeepc_p701_mixer },
16913 .init_verbs = { alc662_init_verbs,
16914 alc662_eeepc_sue_init_verbs },
16915 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16916 .dac_nids = alc662_dac_nids,
16917 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16918 .channel_mode = alc662_3ST_2ch_modes,
16919 .unsol_event = alc662_eeepc_unsol_event,
16920 .setup = alc662_eeepc_setup,
16921 .init_hook = alc662_eeepc_inithook,
16923 [ALC662_ASUS_EEEPC_EP20] = {
16924 .mixers = { alc662_eeepc_ep20_mixer,
16925 alc662_chmode_mixer },
16926 .init_verbs = { alc662_init_verbs,
16927 alc662_eeepc_ep20_sue_init_verbs },
16928 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16929 .dac_nids = alc662_dac_nids,
16930 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16931 .channel_mode = alc662_3ST_6ch_modes,
16932 .input_mux = &alc662_lenovo_101e_capture_source,
16933 .unsol_event = alc662_eeepc_unsol_event,
16934 .setup = alc662_eeepc_ep20_setup,
16935 .init_hook = alc662_eeepc_ep20_inithook,
16937 [ALC662_ECS] = {
16938 .mixers = { alc662_ecs_mixer },
16939 .init_verbs = { alc662_init_verbs,
16940 alc662_ecs_init_verbs },
16941 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16942 .dac_nids = alc662_dac_nids,
16943 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16944 .channel_mode = alc662_3ST_2ch_modes,
16945 .unsol_event = alc662_eeepc_unsol_event,
16946 .setup = alc662_eeepc_setup,
16947 .init_hook = alc662_eeepc_inithook,
16949 [ALC663_ASUS_M51VA] = {
16950 .mixers = { alc663_m51va_mixer },
16951 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16952 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16953 .dac_nids = alc662_dac_nids,
16954 .dig_out_nid = ALC662_DIGOUT_NID,
16955 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16956 .channel_mode = alc662_3ST_2ch_modes,
16957 .unsol_event = alc663_m51va_unsol_event,
16958 .setup = alc663_m51va_setup,
16959 .init_hook = alc663_m51va_inithook,
16961 [ALC663_ASUS_G71V] = {
16962 .mixers = { alc663_g71v_mixer },
16963 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16964 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16965 .dac_nids = alc662_dac_nids,
16966 .dig_out_nid = ALC662_DIGOUT_NID,
16967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16968 .channel_mode = alc662_3ST_2ch_modes,
16969 .unsol_event = alc663_g71v_unsol_event,
16970 .setup = alc663_g71v_setup,
16971 .init_hook = alc663_g71v_inithook,
16973 [ALC663_ASUS_H13] = {
16974 .mixers = { alc663_m51va_mixer },
16975 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16976 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16977 .dac_nids = alc662_dac_nids,
16978 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16979 .channel_mode = alc662_3ST_2ch_modes,
16980 .unsol_event = alc663_m51va_unsol_event,
16981 .init_hook = alc663_m51va_inithook,
16983 [ALC663_ASUS_G50V] = {
16984 .mixers = { alc663_g50v_mixer },
16985 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16986 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16987 .dac_nids = alc662_dac_nids,
16988 .dig_out_nid = ALC662_DIGOUT_NID,
16989 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16990 .channel_mode = alc662_3ST_6ch_modes,
16991 .input_mux = &alc663_capture_source,
16992 .unsol_event = alc663_g50v_unsol_event,
16993 .setup = alc663_g50v_setup,
16994 .init_hook = alc663_g50v_inithook,
16996 [ALC663_ASUS_MODE1] = {
16997 .mixers = { alc663_m51va_mixer },
16998 .cap_mixer = alc662_auto_capture_mixer,
16999 .init_verbs = { alc662_init_verbs,
17000 alc663_21jd_amic_init_verbs },
17001 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17002 .hp_nid = 0x03,
17003 .dac_nids = alc662_dac_nids,
17004 .dig_out_nid = ALC662_DIGOUT_NID,
17005 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17006 .channel_mode = alc662_3ST_2ch_modes,
17007 .unsol_event = alc663_mode1_unsol_event,
17008 .setup = alc663_mode1_setup,
17009 .init_hook = alc663_mode1_inithook,
17011 [ALC662_ASUS_MODE2] = {
17012 .mixers = { alc662_1bjd_mixer },
17013 .cap_mixer = alc662_auto_capture_mixer,
17014 .init_verbs = { alc662_init_verbs,
17015 alc662_1bjd_amic_init_verbs },
17016 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17017 .dac_nids = alc662_dac_nids,
17018 .dig_out_nid = ALC662_DIGOUT_NID,
17019 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17020 .channel_mode = alc662_3ST_2ch_modes,
17021 .unsol_event = alc662_mode2_unsol_event,
17022 .setup = alc662_mode2_setup,
17023 .init_hook = alc662_mode2_inithook,
17025 [ALC663_ASUS_MODE3] = {
17026 .mixers = { alc663_two_hp_m1_mixer },
17027 .cap_mixer = alc662_auto_capture_mixer,
17028 .init_verbs = { alc662_init_verbs,
17029 alc663_two_hp_amic_m1_init_verbs },
17030 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17031 .hp_nid = 0x03,
17032 .dac_nids = alc662_dac_nids,
17033 .dig_out_nid = ALC662_DIGOUT_NID,
17034 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17035 .channel_mode = alc662_3ST_2ch_modes,
17036 .unsol_event = alc663_mode3_unsol_event,
17037 .setup = alc663_mode3_setup,
17038 .init_hook = alc663_mode3_inithook,
17040 [ALC663_ASUS_MODE4] = {
17041 .mixers = { alc663_asus_21jd_clfe_mixer },
17042 .cap_mixer = alc662_auto_capture_mixer,
17043 .init_verbs = { alc662_init_verbs,
17044 alc663_21jd_amic_init_verbs},
17045 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17046 .hp_nid = 0x03,
17047 .dac_nids = alc662_dac_nids,
17048 .dig_out_nid = ALC662_DIGOUT_NID,
17049 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17050 .channel_mode = alc662_3ST_2ch_modes,
17051 .unsol_event = alc663_mode4_unsol_event,
17052 .setup = alc663_mode4_setup,
17053 .init_hook = alc663_mode4_inithook,
17055 [ALC663_ASUS_MODE5] = {
17056 .mixers = { alc663_asus_15jd_clfe_mixer },
17057 .cap_mixer = alc662_auto_capture_mixer,
17058 .init_verbs = { alc662_init_verbs,
17059 alc663_15jd_amic_init_verbs },
17060 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17061 .hp_nid = 0x03,
17062 .dac_nids = alc662_dac_nids,
17063 .dig_out_nid = ALC662_DIGOUT_NID,
17064 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17065 .channel_mode = alc662_3ST_2ch_modes,
17066 .unsol_event = alc663_mode5_unsol_event,
17067 .setup = alc663_mode5_setup,
17068 .init_hook = alc663_mode5_inithook,
17070 [ALC663_ASUS_MODE6] = {
17071 .mixers = { alc663_two_hp_m2_mixer },
17072 .cap_mixer = alc662_auto_capture_mixer,
17073 .init_verbs = { alc662_init_verbs,
17074 alc663_two_hp_amic_m2_init_verbs },
17075 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17076 .hp_nid = 0x03,
17077 .dac_nids = alc662_dac_nids,
17078 .dig_out_nid = ALC662_DIGOUT_NID,
17079 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17080 .channel_mode = alc662_3ST_2ch_modes,
17081 .unsol_event = alc663_mode6_unsol_event,
17082 .setup = alc663_mode6_setup,
17083 .init_hook = alc663_mode6_inithook,
17085 [ALC272_DELL] = {
17086 .mixers = { alc663_m51va_mixer },
17087 .cap_mixer = alc272_auto_capture_mixer,
17088 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17089 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17090 .dac_nids = alc662_dac_nids,
17091 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17092 .adc_nids = alc272_adc_nids,
17093 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17094 .capsrc_nids = alc272_capsrc_nids,
17095 .channel_mode = alc662_3ST_2ch_modes,
17096 .unsol_event = alc663_m51va_unsol_event,
17097 .setup = alc663_m51va_setup,
17098 .init_hook = alc663_m51va_inithook,
17100 [ALC272_DELL_ZM1] = {
17101 .mixers = { alc663_m51va_mixer },
17102 .cap_mixer = alc662_auto_capture_mixer,
17103 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17104 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17105 .dac_nids = alc662_dac_nids,
17106 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17107 .adc_nids = alc662_adc_nids,
17108 .num_adc_nids = 1,
17109 .capsrc_nids = alc662_capsrc_nids,
17110 .channel_mode = alc662_3ST_2ch_modes,
17111 .unsol_event = alc663_m51va_unsol_event,
17112 .setup = alc663_m51va_setup,
17113 .init_hook = alc663_m51va_inithook,
17115 [ALC272_SAMSUNG_NC10] = {
17116 .mixers = { alc272_nc10_mixer },
17117 .init_verbs = { alc662_init_verbs,
17118 alc663_21jd_amic_init_verbs },
17119 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17120 .dac_nids = alc272_dac_nids,
17121 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17122 .channel_mode = alc662_3ST_2ch_modes,
17123 /*.input_mux = &alc272_nc10_capture_source,*/
17124 .unsol_event = alc663_mode4_unsol_event,
17125 .setup = alc663_mode4_setup,
17126 .init_hook = alc663_mode4_inithook,
17132 * BIOS auto configuration
17135 /* add playback controls from the parsed DAC table */
17136 static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17137 const struct auto_pin_cfg *cfg)
17139 char name[32];
17140 static const char *chname[4] = {
17141 "Front", "Surround", NULL /*CLFE*/, "Side"
17143 hda_nid_t nid;
17144 int i, err;
17146 for (i = 0; i < cfg->line_outs; i++) {
17147 if (!spec->multiout.dac_nids[i])
17148 continue;
17149 nid = alc880_idx_to_dac(i);
17150 if (i == 2) {
17151 /* Center/LFE */
17152 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17153 "Center Playback Volume",
17154 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17155 HDA_OUTPUT));
17156 if (err < 0)
17157 return err;
17158 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17159 "LFE Playback Volume",
17160 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17161 HDA_OUTPUT));
17162 if (err < 0)
17163 return err;
17164 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
17165 "Center Playback Switch",
17166 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
17167 HDA_INPUT));
17168 if (err < 0)
17169 return err;
17170 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
17171 "LFE Playback Switch",
17172 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
17173 HDA_INPUT));
17174 if (err < 0)
17175 return err;
17176 } else {
17177 const char *pfx;
17178 if (cfg->line_outs == 1 &&
17179 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17180 if (!cfg->hp_pins)
17181 pfx = "Speaker";
17182 else
17183 pfx = "PCM";
17184 } else
17185 pfx = chname[i];
17186 sprintf(name, "%s Playback Volume", pfx);
17187 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17188 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17189 HDA_OUTPUT));
17190 if (err < 0)
17191 return err;
17192 if (cfg->line_outs == 1 &&
17193 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17194 pfx = "Speaker";
17195 sprintf(name, "%s Playback Switch", pfx);
17196 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17197 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17198 3, 0, HDA_INPUT));
17199 if (err < 0)
17200 return err;
17203 return 0;
17206 /* add playback controls for speaker and HP outputs */
17207 static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17208 const char *pfx)
17210 hda_nid_t nid;
17211 int err;
17212 char name[32];
17214 if (!pin)
17215 return 0;
17217 if (pin == 0x17) {
17218 /* ALC663 has a mono output pin on 0x17 */
17219 sprintf(name, "%s Playback Switch", pfx);
17220 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17221 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17222 return err;
17225 if (alc880_is_fixed_pin(pin)) {
17226 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17227 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
17228 /* specify the DAC as the extra output */
17229 if (!spec->multiout.hp_nid)
17230 spec->multiout.hp_nid = nid;
17231 else
17232 spec->multiout.extra_out_nid[0] = nid;
17233 /* control HP volume/switch on the output mixer amp */
17234 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17235 sprintf(name, "%s Playback Volume", pfx);
17236 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17237 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17238 if (err < 0)
17239 return err;
17240 sprintf(name, "%s Playback Switch", pfx);
17241 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17242 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17243 if (err < 0)
17244 return err;
17245 } else if (alc880_is_multi_pin(pin)) {
17246 /* set manual connection */
17247 /* we have only a switch on HP-out PIN */
17248 sprintf(name, "%s Playback Switch", pfx);
17249 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17250 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17251 if (err < 0)
17252 return err;
17254 return 0;
17257 /* create playback/capture controls for input pins */
17258 #define alc662_auto_create_input_ctls \
17259 alc880_auto_create_input_ctls
17261 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17262 hda_nid_t nid, int pin_type,
17263 int dac_idx)
17265 alc_set_pin_output(codec, nid, pin_type);
17266 /* need the manual connection? */
17267 if (alc880_is_multi_pin(nid)) {
17268 struct alc_spec *spec = codec->spec;
17269 int idx = alc880_multi_pin_idx(nid);
17270 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17271 AC_VERB_SET_CONNECT_SEL,
17272 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17276 static void alc662_auto_init_multi_out(struct hda_codec *codec)
17278 struct alc_spec *spec = codec->spec;
17279 int i;
17281 for (i = 0; i <= HDA_SIDE; i++) {
17282 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17283 int pin_type = get_pin_type(spec->autocfg.line_out_type);
17284 if (nid)
17285 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
17290 static void alc662_auto_init_hp_out(struct hda_codec *codec)
17292 struct alc_spec *spec = codec->spec;
17293 hda_nid_t pin;
17295 pin = spec->autocfg.hp_pins[0];
17296 if (pin) /* connect to front */
17297 /* use dac 0 */
17298 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
17299 pin = spec->autocfg.speaker_pins[0];
17300 if (pin)
17301 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
17304 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17306 static void alc662_auto_init_analog_input(struct hda_codec *codec)
17308 struct alc_spec *spec = codec->spec;
17309 int i;
17311 for (i = 0; i < AUTO_PIN_LAST; i++) {
17312 hda_nid_t nid = spec->autocfg.input_pins[i];
17313 if (alc_is_input_pin(codec, nid)) {
17314 alc_set_input_pin(codec, nid, i);
17315 if (nid != ALC662_PIN_CD_NID &&
17316 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
17317 snd_hda_codec_write(codec, nid, 0,
17318 AC_VERB_SET_AMP_GAIN_MUTE,
17319 AMP_OUT_MUTE);
17324 #define alc662_auto_init_input_src alc882_auto_init_input_src
17326 static int alc662_parse_auto_config(struct hda_codec *codec)
17328 struct alc_spec *spec = codec->spec;
17329 int err;
17330 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17332 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17333 alc662_ignore);
17334 if (err < 0)
17335 return err;
17336 if (!spec->autocfg.line_outs)
17337 return 0; /* can't find valid BIOS pin config */
17339 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17340 if (err < 0)
17341 return err;
17342 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17343 if (err < 0)
17344 return err;
17345 err = alc662_auto_create_extra_out(spec,
17346 spec->autocfg.speaker_pins[0],
17347 "Speaker");
17348 if (err < 0)
17349 return err;
17350 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17351 "Headphone");
17352 if (err < 0)
17353 return err;
17354 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
17355 if (err < 0)
17356 return err;
17358 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17360 if (spec->autocfg.dig_outs)
17361 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17363 if (spec->kctls.list)
17364 add_mixer(spec, spec->kctls.list);
17366 spec->num_mux_defs = 1;
17367 spec->input_mux = &spec->private_imux[0];
17369 add_verb(spec, alc662_auto_init_verbs);
17370 if (codec->vendor_id == 0x10ec0663)
17371 add_verb(spec, alc663_auto_init_verbs);
17373 err = alc_auto_add_mic_boost(codec);
17374 if (err < 0)
17375 return err;
17377 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17379 return 1;
17382 /* additional initialization for auto-configuration model */
17383 static void alc662_auto_init(struct hda_codec *codec)
17385 struct alc_spec *spec = codec->spec;
17386 alc662_auto_init_multi_out(codec);
17387 alc662_auto_init_hp_out(codec);
17388 alc662_auto_init_analog_input(codec);
17389 alc662_auto_init_input_src(codec);
17390 if (spec->unsol_event)
17391 alc_inithook(codec);
17394 static int patch_alc662(struct hda_codec *codec)
17396 struct alc_spec *spec;
17397 int err, board_config;
17399 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17400 if (!spec)
17401 return -ENOMEM;
17403 codec->spec = spec;
17405 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17407 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17408 alc662_models,
17409 alc662_cfg_tbl);
17410 if (board_config < 0) {
17411 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17412 codec->chip_name);
17413 board_config = ALC662_AUTO;
17416 if (board_config == ALC662_AUTO) {
17417 /* automatic parse from the BIOS config */
17418 err = alc662_parse_auto_config(codec);
17419 if (err < 0) {
17420 alc_free(codec);
17421 return err;
17422 } else if (!err) {
17423 printk(KERN_INFO
17424 "hda_codec: Cannot set up configuration "
17425 "from BIOS. Using base mode...\n");
17426 board_config = ALC662_3ST_2ch_DIG;
17430 err = snd_hda_attach_beep_device(codec, 0x1);
17431 if (err < 0) {
17432 alc_free(codec);
17433 return err;
17436 if (board_config != ALC662_AUTO)
17437 setup_preset(codec, &alc662_presets[board_config]);
17439 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17440 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17442 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17443 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17445 if (!spec->adc_nids) {
17446 spec->adc_nids = alc662_adc_nids;
17447 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17449 if (!spec->capsrc_nids)
17450 spec->capsrc_nids = alc662_capsrc_nids;
17452 if (!spec->cap_mixer)
17453 set_capture_mixer(codec);
17454 if (codec->vendor_id == 0x10ec0662)
17455 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17456 else
17457 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
17459 spec->vmaster_nid = 0x02;
17461 codec->patch_ops = alc_patch_ops;
17462 if (board_config == ALC662_AUTO)
17463 spec->init_hook = alc662_auto_init;
17464 #ifdef CONFIG_SND_HDA_POWER_SAVE
17465 if (!spec->loopback.amplist)
17466 spec->loopback.amplist = alc662_loopbacks;
17467 #endif
17468 codec->proc_widget_hook = print_realtek_coef;
17470 return 0;
17474 * patch entries
17476 static struct hda_codec_preset snd_hda_preset_realtek[] = {
17477 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
17478 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
17479 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
17480 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
17481 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
17482 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
17483 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
17484 .patch = patch_alc861 },
17485 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17486 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17487 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
17488 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17489 .patch = patch_alc882 },
17490 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17491 .patch = patch_alc662 },
17492 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
17493 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
17494 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
17495 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
17496 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17497 .patch = patch_alc882 },
17498 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
17499 .patch = patch_alc882 },
17500 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
17501 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
17502 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17503 .patch = patch_alc882 },
17504 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17505 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
17506 {} /* terminator */
17509 MODULE_ALIAS("snd-hda-codec-id:10ec*");
17511 MODULE_LICENSE("GPL");
17512 MODULE_DESCRIPTION("Realtek HD-audio codec");
17514 static struct hda_codec_preset_list realtek_list = {
17515 .preset = snd_hda_preset_realtek,
17516 .owner = THIS_MODULE,
17519 static int __init patch_realtek_init(void)
17521 return snd_hda_add_codec_preset(&realtek_list);
17524 static void __exit patch_realtek_exit(void)
17526 snd_hda_delete_codec_preset(&realtek_list);
17529 module_init(patch_realtek_init)
17530 module_exit(patch_realtek_exit)