On Tue, Nov 06, 2007 at 02:33:53AM -0800, akpm@linux-foundation.org wrote:
[mmotm.git] / sound / pci / hda / patch_realtek.c
blob4c8e5216506b4e5ece923b1bd743e38f346e5e66
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 hda_nid_t nid;
1336 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1337 if (tmp == 0)
1338 nid = porta;
1339 else if (tmp == 1)
1340 nid = porte;
1341 else if (tmp == 2)
1342 nid = portd;
1343 else
1344 return 1;
1345 for (i = 0; i < spec->autocfg.line_outs; i++)
1346 if (spec->autocfg.line_out_pins[i] == nid)
1347 return 1;
1348 spec->autocfg.hp_pins[0] = nid;
1351 alc_init_auto_hp(codec);
1352 alc_init_auto_mic(codec);
1353 return 1;
1356 static void alc_ssid_check(struct hda_codec *codec,
1357 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1359 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1360 struct alc_spec *spec = codec->spec;
1361 snd_printd("realtek: "
1362 "Enable default setup for auto mode as fallback\n");
1363 spec->init_amp = ALC_INIT_DEFAULT;
1364 alc_init_auto_hp(codec);
1365 alc_init_auto_mic(codec);
1370 * Fix-up pin default configurations and add default verbs
1373 struct alc_pincfg {
1374 hda_nid_t nid;
1375 u32 val;
1378 struct alc_fixup {
1379 const struct alc_pincfg *pins;
1380 const struct hda_verb *verbs;
1383 static void alc_pick_fixup(struct hda_codec *codec,
1384 const struct snd_pci_quirk *quirk,
1385 const struct alc_fixup *fix)
1387 const struct alc_pincfg *cfg;
1389 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1390 if (!quirk)
1391 return;
1393 fix += quirk->value;
1394 cfg = fix->pins;
1395 if (cfg) {
1396 for (; cfg->nid; cfg++)
1397 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1399 if (fix->verbs)
1400 add_verb(codec->spec, fix->verbs);
1404 * ALC888
1408 * 2ch mode
1410 static struct hda_verb alc888_4ST_ch2_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 Line in */
1415 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1416 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1417 /* Line-Out as Front */
1418 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1419 { } /* end */
1423 * 4ch mode
1425 static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1426 /* Mic-in jack as mic in */
1427 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1428 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
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 Front */
1433 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1434 { } /* end */
1438 * 6ch mode
1440 static struct hda_verb alc888_4ST_ch6_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 CLFE (workaround because Mic-in is not loud enough) */
1448 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1449 { } /* end */
1453 * 8ch mode
1455 static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1456 /* Mic-in jack as CLFE */
1457 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1458 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1459 /* Line-in jack as Surround */
1460 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1461 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1462 /* Line-Out as Side */
1463 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1464 { } /* end */
1467 static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1468 { 2, alc888_4ST_ch2_intel_init },
1469 { 4, alc888_4ST_ch4_intel_init },
1470 { 6, alc888_4ST_ch6_intel_init },
1471 { 8, alc888_4ST_ch8_intel_init },
1475 * ALC888 Fujitsu Siemens Amillo xa3530
1478 static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1479 /* Front Mic: set to PIN_IN (empty by default) */
1480 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1481 /* Connect Internal HP to Front */
1482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1484 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1485 /* Connect Bass HP to Front */
1486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1487 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1489 /* Connect Line-Out side jack (SPDIF) to Side */
1490 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1491 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1492 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1493 /* Connect Mic jack to CLFE */
1494 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1495 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1496 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1497 /* Connect Line-in jack to Surround */
1498 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1499 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1500 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1501 /* Connect HP out jack to Front */
1502 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1503 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1504 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1505 /* Enable unsolicited event for HP jack and Line-out jack */
1506 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1507 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1511 static void alc_automute_amp(struct hda_codec *codec)
1513 struct alc_spec *spec = codec->spec;
1514 unsigned int val, mute, pincap;
1515 hda_nid_t nid;
1516 int i;
1518 spec->jack_present = 0;
1519 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1520 nid = spec->autocfg.hp_pins[i];
1521 if (!nid)
1522 break;
1523 pincap = snd_hda_query_pin_caps(codec, nid);
1524 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1525 snd_hda_codec_read(codec, nid, 0,
1526 AC_VERB_SET_PIN_SENSE, 0);
1527 val = snd_hda_codec_read(codec, nid, 0,
1528 AC_VERB_GET_PIN_SENSE, 0);
1529 if (val & AC_PINSENSE_PRESENCE) {
1530 spec->jack_present = 1;
1531 break;
1535 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1536 /* Toggle internal speakers muting */
1537 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1538 nid = spec->autocfg.speaker_pins[i];
1539 if (!nid)
1540 break;
1541 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1542 HDA_AMP_MUTE, mute);
1546 static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1547 unsigned int res)
1549 if (codec->vendor_id == 0x10ec0880)
1550 res >>= 28;
1551 else
1552 res >>= 26;
1553 if (res == ALC880_HP_EVENT)
1554 alc_automute_amp(codec);
1557 static void alc889_automute_setup(struct hda_codec *codec)
1559 struct alc_spec *spec = codec->spec;
1561 spec->autocfg.hp_pins[0] = 0x15;
1562 spec->autocfg.speaker_pins[0] = 0x14;
1563 spec->autocfg.speaker_pins[1] = 0x16;
1564 spec->autocfg.speaker_pins[2] = 0x17;
1565 spec->autocfg.speaker_pins[3] = 0x19;
1566 spec->autocfg.speaker_pins[4] = 0x1a;
1569 static void alc889_intel_init_hook(struct hda_codec *codec)
1571 alc889_coef_init(codec);
1572 alc_automute_amp(codec);
1575 static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
1577 struct alc_spec *spec = codec->spec;
1579 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1580 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1581 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1582 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1586 * ALC888 Acer Aspire 4930G model
1589 static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1590 /* Front Mic: set to PIN_IN (empty by default) */
1591 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1592 /* Unselect Front Mic by default in input mixer 3 */
1593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1594 /* Enable unsolicited event for HP jack */
1595 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1596 /* Connect Internal HP to front */
1597 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1598 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1599 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1600 /* Connect HP out to front */
1601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1602 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1603 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1608 * ALC888 Acer Aspire 6530G model
1611 static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1612 /* Bias voltage on for external mic port */
1613 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
1614 /* Front Mic: set to PIN_IN (empty by default) */
1615 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1616 /* Unselect Front Mic by default in input mixer 3 */
1617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1618 /* Enable unsolicited event for HP jack */
1619 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1620 /* Enable speaker output */
1621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1622 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1623 /* Enable headphone output */
1624 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1625 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1626 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1631 * ALC889 Acer Aspire 8930G model
1634 static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
1635 /* Front Mic: set to PIN_IN (empty by default) */
1636 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1637 /* Unselect Front Mic by default in input mixer 3 */
1638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1639 /* Enable unsolicited event for HP jack */
1640 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1641 /* Connect Internal Front to Front */
1642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1644 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1645 /* Connect Internal Rear to Rear */
1646 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1647 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1648 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1649 /* Connect Internal CLFE to CLFE */
1650 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1651 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1652 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1653 /* Connect HP out to Front */
1654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1655 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1656 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1657 /* Enable all DACs */
1658 /* DAC DISABLE/MUTE 1? */
1659 /* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1660 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1661 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1662 /* DAC DISABLE/MUTE 2? */
1663 /* some bit here disables the other DACs. Init=0x4900 */
1664 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1665 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1666 /* Enable amplifiers */
1667 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1668 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1669 /* DMIC fix
1670 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1671 * which makes the stereo useless. However, either the mic or the ALC889
1672 * makes the signal become a difference/sum signal instead of standard
1673 * stereo, which is annoying. So instead we flip this bit which makes the
1674 * codec replicate the sum signal to both channels, turning it into a
1675 * normal mono mic.
1677 /* DMIC_CONTROL? Init value = 0x0001 */
1678 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1679 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
1683 static struct hda_input_mux alc888_2_capture_sources[2] = {
1684 /* Front mic only available on one ADC */
1686 .num_items = 4,
1687 .items = {
1688 { "Mic", 0x0 },
1689 { "Line", 0x2 },
1690 { "CD", 0x4 },
1691 { "Front Mic", 0xb },
1695 .num_items = 3,
1696 .items = {
1697 { "Mic", 0x0 },
1698 { "Line", 0x2 },
1699 { "CD", 0x4 },
1704 static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1705 /* Interal mic only available on one ADC */
1707 .num_items = 5,
1708 .items = {
1709 { "Ext Mic", 0x0 },
1710 { "Line In", 0x2 },
1711 { "CD", 0x4 },
1712 { "Input Mix", 0xa },
1713 { "Int Mic", 0xb },
1717 .num_items = 4,
1718 .items = {
1719 { "Ext Mic", 0x0 },
1720 { "Line In", 0x2 },
1721 { "CD", 0x4 },
1722 { "Input Mix", 0xa },
1727 static struct hda_input_mux alc889_capture_sources[3] = {
1728 /* Digital mic only available on first "ADC" */
1730 .num_items = 5,
1731 .items = {
1732 { "Mic", 0x0 },
1733 { "Line", 0x2 },
1734 { "CD", 0x4 },
1735 { "Front Mic", 0xb },
1736 { "Input Mix", 0xa },
1740 .num_items = 4,
1741 .items = {
1742 { "Mic", 0x0 },
1743 { "Line", 0x2 },
1744 { "CD", 0x4 },
1745 { "Input Mix", 0xa },
1749 .num_items = 4,
1750 .items = {
1751 { "Mic", 0x0 },
1752 { "Line", 0x2 },
1753 { "CD", 0x4 },
1754 { "Input Mix", 0xa },
1759 static struct snd_kcontrol_new alc888_base_mixer[] = {
1760 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1761 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1762 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1763 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1764 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1765 HDA_OUTPUT),
1766 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1767 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1768 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1769 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1770 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1771 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1772 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1776 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1778 { } /* end */
1781 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
1783 struct alc_spec *spec = codec->spec;
1785 spec->autocfg.hp_pins[0] = 0x15;
1786 spec->autocfg.speaker_pins[0] = 0x14;
1789 static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
1791 struct alc_spec *spec = codec->spec;
1793 spec->autocfg.hp_pins[0] = 0x15;
1794 spec->autocfg.speaker_pins[0] = 0x14;
1795 spec->autocfg.speaker_pins[1] = 0x16;
1796 spec->autocfg.speaker_pins[2] = 0x17;
1799 static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
1801 struct alc_spec *spec = codec->spec;
1803 spec->autocfg.hp_pins[0] = 0x15;
1804 spec->autocfg.speaker_pins[0] = 0x14;
1805 spec->autocfg.speaker_pins[1] = 0x16;
1806 spec->autocfg.speaker_pins[2] = 0x1b;
1810 * ALC880 3-stack model
1812 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
1813 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1814 * F-Mic = 0x1b, HP = 0x19
1817 static hda_nid_t alc880_dac_nids[4] = {
1818 /* front, rear, clfe, rear_surr */
1819 0x02, 0x05, 0x04, 0x03
1822 static hda_nid_t alc880_adc_nids[3] = {
1823 /* ADC0-2 */
1824 0x07, 0x08, 0x09,
1827 /* The datasheet says the node 0x07 is connected from inputs,
1828 * but it shows zero connection in the real implementation on some devices.
1829 * Note: this is a 915GAV bug, fixed on 915GLV
1831 static hda_nid_t alc880_adc_nids_alt[2] = {
1832 /* ADC1-2 */
1833 0x08, 0x09,
1836 #define ALC880_DIGOUT_NID 0x06
1837 #define ALC880_DIGIN_NID 0x0a
1839 static struct hda_input_mux alc880_capture_source = {
1840 .num_items = 4,
1841 .items = {
1842 { "Mic", 0x0 },
1843 { "Front Mic", 0x3 },
1844 { "Line", 0x2 },
1845 { "CD", 0x4 },
1849 /* channel source setting (2/6 channel selection for 3-stack) */
1850 /* 2ch mode */
1851 static struct hda_verb alc880_threestack_ch2_init[] = {
1852 /* set line-in to input, mute it */
1853 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1854 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1855 /* set mic-in to input vref 80%, mute it */
1856 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1857 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1858 { } /* end */
1861 /* 6ch mode */
1862 static struct hda_verb alc880_threestack_ch6_init[] = {
1863 /* set line-in to output, unmute it */
1864 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1865 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1866 /* set mic-in to output, unmute it */
1867 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1868 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1869 { } /* end */
1872 static struct hda_channel_mode alc880_threestack_modes[2] = {
1873 { 2, alc880_threestack_ch2_init },
1874 { 6, alc880_threestack_ch6_init },
1877 static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1878 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1879 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1880 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1881 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
1882 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1883 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1884 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1885 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1886 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1887 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1888 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1889 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1892 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1893 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1894 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1896 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1897 .name = "Channel Mode",
1898 .info = alc_ch_mode_info,
1899 .get = alc_ch_mode_get,
1900 .put = alc_ch_mode_put,
1902 { } /* end */
1905 /* capture mixer elements */
1906 static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1907 struct snd_ctl_elem_info *uinfo)
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_volume_info(kcontrol, uinfo);
1917 mutex_unlock(&codec->control_mutex);
1918 return err;
1921 static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1922 unsigned int size, unsigned int __user *tlv)
1924 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1925 struct alc_spec *spec = codec->spec;
1926 int err;
1928 mutex_lock(&codec->control_mutex);
1929 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1930 HDA_INPUT);
1931 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1932 mutex_unlock(&codec->control_mutex);
1933 return err;
1936 typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1937 struct snd_ctl_elem_value *ucontrol);
1939 static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1940 struct snd_ctl_elem_value *ucontrol,
1941 getput_call_t func)
1943 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1944 struct alc_spec *spec = codec->spec;
1945 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1946 int err;
1948 mutex_lock(&codec->control_mutex);
1949 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1950 3, 0, HDA_INPUT);
1951 err = func(kcontrol, ucontrol);
1952 mutex_unlock(&codec->control_mutex);
1953 return err;
1956 static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1957 struct snd_ctl_elem_value *ucontrol)
1959 return alc_cap_getput_caller(kcontrol, ucontrol,
1960 snd_hda_mixer_amp_volume_get);
1963 static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1964 struct snd_ctl_elem_value *ucontrol)
1966 return alc_cap_getput_caller(kcontrol, ucontrol,
1967 snd_hda_mixer_amp_volume_put);
1970 /* capture mixer elements */
1971 #define alc_cap_sw_info snd_ctl_boolean_stereo_info
1973 static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1974 struct snd_ctl_elem_value *ucontrol)
1976 return alc_cap_getput_caller(kcontrol, ucontrol,
1977 snd_hda_mixer_amp_switch_get);
1980 static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1981 struct snd_ctl_elem_value *ucontrol)
1983 return alc_cap_getput_caller(kcontrol, ucontrol,
1984 snd_hda_mixer_amp_switch_put);
1987 #define _DEFINE_CAPMIX(num) \
1989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1990 .name = "Capture Switch", \
1991 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1992 .count = num, \
1993 .info = alc_cap_sw_info, \
1994 .get = alc_cap_sw_get, \
1995 .put = alc_cap_sw_put, \
1996 }, \
1998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1999 .name = "Capture Volume", \
2000 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2001 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2002 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2003 .count = num, \
2004 .info = alc_cap_vol_info, \
2005 .get = alc_cap_vol_get, \
2006 .put = alc_cap_vol_put, \
2007 .tlv = { .c = alc_cap_vol_tlv }, \
2010 #define _DEFINE_CAPSRC(num) \
2012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2013 /* .name = "Capture Source", */ \
2014 .name = "Input Source", \
2015 .count = num, \
2016 .info = alc_mux_enum_info, \
2017 .get = alc_mux_enum_get, \
2018 .put = alc_mux_enum_put, \
2021 #define DEFINE_CAPMIX(num) \
2022 static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2023 _DEFINE_CAPMIX(num), \
2024 _DEFINE_CAPSRC(num), \
2025 { } /* end */ \
2028 #define DEFINE_CAPMIX_NOSRC(num) \
2029 static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2030 _DEFINE_CAPMIX(num), \
2031 { } /* end */ \
2034 /* up to three ADCs */
2035 DEFINE_CAPMIX(1);
2036 DEFINE_CAPMIX(2);
2037 DEFINE_CAPMIX(3);
2038 DEFINE_CAPMIX_NOSRC(1);
2039 DEFINE_CAPMIX_NOSRC(2);
2040 DEFINE_CAPMIX_NOSRC(3);
2043 * ALC880 5-stack model
2045 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2046 * Side = 0x02 (0xd)
2047 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2048 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2051 /* additional mixers to alc880_three_stack_mixer */
2052 static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
2053 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2054 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
2055 { } /* end */
2058 /* channel source setting (6/8 channel selection for 5-stack) */
2059 /* 6ch mode */
2060 static struct hda_verb alc880_fivestack_ch6_init[] = {
2061 /* set line-in to input, mute it */
2062 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2063 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2064 { } /* end */
2067 /* 8ch mode */
2068 static struct hda_verb alc880_fivestack_ch8_init[] = {
2069 /* set line-in to output, unmute it */
2070 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2071 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2072 { } /* end */
2075 static struct hda_channel_mode alc880_fivestack_modes[2] = {
2076 { 6, alc880_fivestack_ch6_init },
2077 { 8, alc880_fivestack_ch8_init },
2082 * ALC880 6-stack model
2084 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2085 * Side = 0x05 (0x0f)
2086 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2087 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2090 static hda_nid_t alc880_6st_dac_nids[4] = {
2091 /* front, rear, clfe, rear_surr */
2092 0x02, 0x03, 0x04, 0x05
2095 static struct hda_input_mux alc880_6stack_capture_source = {
2096 .num_items = 4,
2097 .items = {
2098 { "Mic", 0x0 },
2099 { "Front Mic", 0x1 },
2100 { "Line", 0x2 },
2101 { "CD", 0x4 },
2105 /* fixed 8-channels */
2106 static struct hda_channel_mode alc880_sixstack_modes[1] = {
2107 { 8, NULL },
2110 static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
2111 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2112 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2113 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2114 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2115 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2116 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2117 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2118 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2119 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2120 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2121 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2122 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2123 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2124 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2125 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2126 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2127 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2128 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2130 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2131 .name = "Channel Mode",
2132 .info = alc_ch_mode_info,
2133 .get = alc_ch_mode_get,
2134 .put = alc_ch_mode_put,
2136 { } /* end */
2141 * ALC880 W810 model
2143 * W810 has rear IO for:
2144 * Front (DAC 02)
2145 * Surround (DAC 03)
2146 * Center/LFE (DAC 04)
2147 * Digital out (06)
2149 * The system also has a pair of internal speakers, and a headphone jack.
2150 * These are both connected to Line2 on the codec, hence to DAC 02.
2152 * There is a variable resistor to control the speaker or headphone
2153 * volume. This is a hardware-only device without a software API.
2155 * Plugging headphones in will disable the internal speakers. This is
2156 * implemented in hardware, not via the driver using jack sense. In
2157 * a similar fashion, plugging into the rear socket marked "front" will
2158 * disable both the speakers and headphones.
2160 * For input, there's a microphone jack, and an "audio in" jack.
2161 * These may not do anything useful with this driver yet, because I
2162 * haven't setup any initialization verbs for these yet...
2165 static hda_nid_t alc880_w810_dac_nids[3] = {
2166 /* front, rear/surround, clfe */
2167 0x02, 0x03, 0x04
2170 /* fixed 6 channels */
2171 static struct hda_channel_mode alc880_w810_modes[1] = {
2172 { 6, NULL }
2175 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
2176 static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
2177 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2178 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2179 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2180 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2181 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2182 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2183 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2184 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2185 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2186 { } /* end */
2191 * Z710V model
2193 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
2194 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2195 * Line = 0x1a
2198 static hda_nid_t alc880_z71v_dac_nids[1] = {
2199 0x02
2201 #define ALC880_Z71V_HP_DAC 0x03
2203 /* fixed 2 channels */
2204 static struct hda_channel_mode alc880_2_jack_modes[1] = {
2205 { 2, NULL }
2208 static struct snd_kcontrol_new alc880_z71v_mixer[] = {
2209 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2210 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2211 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2212 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
2213 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2214 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2217 { } /* end */
2222 * ALC880 F1734 model
2224 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2225 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2228 static hda_nid_t alc880_f1734_dac_nids[1] = {
2229 0x03
2231 #define ALC880_F1734_HP_DAC 0x02
2233 static struct snd_kcontrol_new alc880_f1734_mixer[] = {
2234 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2235 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2236 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2237 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2238 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2239 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2241 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2242 { } /* end */
2245 static struct hda_input_mux alc880_f1734_capture_source = {
2246 .num_items = 2,
2247 .items = {
2248 { "Mic", 0x1 },
2249 { "CD", 0x4 },
2255 * ALC880 ASUS model
2257 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2258 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2259 * Mic = 0x18, Line = 0x1a
2262 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2263 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2265 static struct snd_kcontrol_new alc880_asus_mixer[] = {
2266 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2267 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2268 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2269 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2270 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2271 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2272 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2273 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2274 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2275 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2276 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2277 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2278 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2279 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2281 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2282 .name = "Channel Mode",
2283 .info = alc_ch_mode_info,
2284 .get = alc_ch_mode_get,
2285 .put = alc_ch_mode_put,
2287 { } /* end */
2291 * ALC880 ASUS W1V model
2293 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2294 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2295 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2298 /* additional mixers to alc880_asus_mixer */
2299 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
2300 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2301 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
2302 { } /* end */
2305 /* TCL S700 */
2306 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2307 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2308 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2309 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2310 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2311 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2312 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2313 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2315 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
2316 { } /* end */
2319 /* Uniwill */
2320 static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
2321 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2322 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2323 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2324 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2325 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2326 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2327 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2328 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2329 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2330 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2331 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2332 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2334 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2335 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2336 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2338 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2339 .name = "Channel Mode",
2340 .info = alc_ch_mode_info,
2341 .get = alc_ch_mode_get,
2342 .put = alc_ch_mode_put,
2344 { } /* end */
2347 static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2348 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2349 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2350 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2351 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2352 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2353 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2354 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2355 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2356 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2357 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2358 { } /* end */
2361 static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
2362 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2363 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2364 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2365 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2368 { } /* end */
2372 * virtual master controls
2376 * slave controls for virtual master
2378 static const char *alc_slave_vols[] = {
2379 "Front Playback Volume",
2380 "Surround Playback Volume",
2381 "Center Playback Volume",
2382 "LFE Playback Volume",
2383 "Side Playback Volume",
2384 "Headphone Playback Volume",
2385 "Speaker Playback Volume",
2386 "Mono Playback Volume",
2387 "Line-Out Playback Volume",
2388 "PCM Playback Volume",
2389 NULL,
2392 static const char *alc_slave_sws[] = {
2393 "Front Playback Switch",
2394 "Surround Playback Switch",
2395 "Center Playback Switch",
2396 "LFE Playback Switch",
2397 "Side Playback Switch",
2398 "Headphone Playback Switch",
2399 "Speaker Playback Switch",
2400 "Mono Playback Switch",
2401 "IEC958 Playback Switch",
2402 NULL,
2406 * build control elements
2409 static void alc_free_kctls(struct hda_codec *codec);
2411 /* additional beep mixers; the actual parameters are overwritten at build */
2412 static struct snd_kcontrol_new alc_beep_mixer[] = {
2413 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2414 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2415 { } /* end */
2418 static int alc_build_controls(struct hda_codec *codec)
2420 struct alc_spec *spec = codec->spec;
2421 int err;
2422 int i;
2424 for (i = 0; i < spec->num_mixers; i++) {
2425 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2426 if (err < 0)
2427 return err;
2429 if (spec->cap_mixer) {
2430 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2431 if (err < 0)
2432 return err;
2434 if (spec->multiout.dig_out_nid) {
2435 err = snd_hda_create_spdif_out_ctls(codec,
2436 spec->multiout.dig_out_nid);
2437 if (err < 0)
2438 return err;
2439 if (!spec->no_analog) {
2440 err = snd_hda_create_spdif_share_sw(codec,
2441 &spec->multiout);
2442 if (err < 0)
2443 return err;
2444 spec->multiout.share_spdif = 1;
2447 if (spec->dig_in_nid) {
2448 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2449 if (err < 0)
2450 return err;
2453 /* create beep controls if needed */
2454 if (spec->beep_amp) {
2455 struct snd_kcontrol_new *knew;
2456 for (knew = alc_beep_mixer; knew->name; knew++) {
2457 struct snd_kcontrol *kctl;
2458 kctl = snd_ctl_new1(knew, codec);
2459 if (!kctl)
2460 return -ENOMEM;
2461 kctl->private_value = spec->beep_amp;
2462 err = snd_hda_ctl_add(codec, kctl);
2463 if (err < 0)
2464 return err;
2468 /* if we have no master control, let's create it */
2469 if (!spec->no_analog &&
2470 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2471 unsigned int vmaster_tlv[4];
2472 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2473 HDA_OUTPUT, vmaster_tlv);
2474 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
2475 vmaster_tlv, alc_slave_vols);
2476 if (err < 0)
2477 return err;
2479 if (!spec->no_analog &&
2480 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2481 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2482 NULL, alc_slave_sws);
2483 if (err < 0)
2484 return err;
2487 alc_free_kctls(codec); /* no longer needed */
2488 return 0;
2493 * initialize the codec volumes, etc
2497 * generic initialization of ADC, input mixers and output mixers
2499 static struct hda_verb alc880_volume_init_verbs[] = {
2501 * Unmute ADC0-2 and set the default input to mic-in
2503 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
2504 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2505 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
2506 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2507 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
2508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2510 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2511 * mixer widget
2512 * Note: PASD motherboards uses the Line In 2 as the input for front
2513 * panel mic (mic 2)
2515 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
2516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2521 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2522 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
2525 * Set up output mixers (0x0c - 0x0f)
2527 /* set vol=0 to output mixers */
2528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2529 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2531 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2532 /* set up input amps for analog loopback */
2533 /* Amp Indices: DAC = 0, mixer = 1 */
2534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2536 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2538 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2541 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2547 * 3-stack pin configuration:
2548 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2550 static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2552 * preset connection lists of input pins
2553 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2555 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2556 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2557 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2560 * Set pin mode and muting
2562 /* set front pin widgets 0x14 for output */
2563 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2564 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2565 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2566 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2567 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2568 /* Mic2 (as headphone out) for HP output */
2569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2571 /* Line In pin widget for input */
2572 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2573 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2574 /* Line2 (as front mic) pin widget for input and vref at 80% */
2575 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2576 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2577 /* CD pin widget for input */
2578 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2584 * 5-stack pin configuration:
2585 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2586 * line-in/side = 0x1a, f-mic = 0x1b
2588 static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2590 * preset connection lists of input pins
2591 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2593 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2594 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2597 * Set pin mode and muting
2599 /* set pin widgets 0x14-0x17 for output */
2600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2601 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2602 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2603 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2604 /* unmute pins for output (no gain on this amp) */
2605 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2606 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2607 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2610 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2611 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2613 /* Mic2 (as headphone out) for HP output */
2614 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2615 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2616 /* Line In pin widget for input */
2617 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2618 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2619 /* Line2 (as front mic) pin widget for input and vref at 80% */
2620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2621 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2622 /* CD pin widget for input */
2623 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2629 * W810 pin configuration:
2630 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2632 static struct hda_verb alc880_pin_w810_init_verbs[] = {
2633 /* hphone/speaker input selector: front DAC */
2634 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2636 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2637 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2640 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2641 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2643 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2644 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2650 * Z71V pin configuration:
2651 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2653 static struct hda_verb alc880_pin_z71v_init_verbs[] = {
2654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2657 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2659 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2660 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2661 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2662 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2668 * 6-stack pin configuration:
2669 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2670 * f-mic = 0x19, line = 0x1a, HP = 0x1b
2672 static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2673 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2675 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2676 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2677 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2678 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2679 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2680 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2681 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2682 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2684 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2686 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2687 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2688 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2689 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2690 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2691 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2692 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2698 * Uniwill pin configuration:
2699 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2700 * line = 0x1a
2702 static struct hda_verb alc880_uniwill_init_verbs[] = {
2703 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2705 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2706 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2709 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2710 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2711 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2712 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2713 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2714 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2715 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2716 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2717 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2718 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2720 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2721 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2722 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2723 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2724 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2726 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2727 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2728 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2730 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2731 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2737 * Uniwill P53
2738 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
2740 static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2741 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2743 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2744 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2745 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2748 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2749 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2750 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2751 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2752 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2753 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2754 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2756 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2757 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2758 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2759 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2760 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2761 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2763 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2764 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2769 static struct hda_verb alc880_beep_init_verbs[] = {
2770 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2774 /* auto-toggle front mic */
2775 static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2777 unsigned int present;
2778 unsigned char bits;
2780 present = snd_hda_codec_read(codec, 0x18, 0,
2781 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2782 bits = present ? HDA_AMP_MUTE : 0;
2783 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
2786 static void alc880_uniwill_setup(struct hda_codec *codec)
2788 struct alc_spec *spec = codec->spec;
2790 spec->autocfg.hp_pins[0] = 0x14;
2791 spec->autocfg.speaker_pins[0] = 0x15;
2792 spec->autocfg.speaker_pins[0] = 0x16;
2795 static void alc880_uniwill_init_hook(struct hda_codec *codec)
2797 alc_automute_amp(codec);
2798 alc880_uniwill_mic_automute(codec);
2801 static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2802 unsigned int res)
2804 /* Looks like the unsol event is incompatible with the standard
2805 * definition. 4bit tag is placed at 28 bit!
2807 switch (res >> 28) {
2808 case ALC880_MIC_EVENT:
2809 alc880_uniwill_mic_automute(codec);
2810 break;
2811 default:
2812 alc_automute_amp_unsol_event(codec, res);
2813 break;
2817 static void alc880_uniwill_p53_setup(struct hda_codec *codec)
2819 struct alc_spec *spec = codec->spec;
2821 spec->autocfg.hp_pins[0] = 0x14;
2822 spec->autocfg.speaker_pins[0] = 0x15;
2825 static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2827 unsigned int present;
2829 present = snd_hda_codec_read(codec, 0x21, 0,
2830 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2831 present &= HDA_AMP_VOLMASK;
2832 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2833 HDA_AMP_VOLMASK, present);
2834 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2835 HDA_AMP_VOLMASK, present);
2838 static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2839 unsigned int res)
2841 /* Looks like the unsol event is incompatible with the standard
2842 * definition. 4bit tag is placed at 28 bit!
2844 if ((res >> 28) == ALC880_DCVOL_EVENT)
2845 alc880_uniwill_p53_dcvol_automute(codec);
2846 else
2847 alc_automute_amp_unsol_event(codec, res);
2851 * F1734 pin configuration:
2852 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2854 static struct hda_verb alc880_pin_f1734_init_verbs[] = {
2855 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
2856 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2857 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2858 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2859 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2861 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2863 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2866 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2867 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2868 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
2869 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2870 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2871 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2872 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2873 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2874 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2876 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2877 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2883 * ASUS pin configuration:
2884 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2886 static struct hda_verb alc880_pin_asus_init_verbs[] = {
2887 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2888 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2889 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2890 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2892 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2894 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2895 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2896 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2898 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2899 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2901 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2902 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2903 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2905 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2906 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2907 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2909 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2914 /* Enable GPIO mask and set output */
2915 #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2916 #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
2917 #define alc880_gpio3_init_verbs alc_gpio3_init_verbs
2919 /* Clevo m520g init */
2920 static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2921 /* headphone output */
2922 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2923 /* line-out */
2924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2926 /* Line-in */
2927 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2929 /* CD */
2930 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2931 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2932 /* Mic1 (rear panel) */
2933 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2934 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2935 /* Mic2 (front panel) */
2936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2938 /* headphone */
2939 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2940 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2941 /* change to EAPD mode */
2942 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2943 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2948 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
2949 /* change to EAPD mode */
2950 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2951 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2953 /* Headphone output */
2954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2955 /* Front output*/
2956 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2957 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2959 /* Line In pin widget for input */
2960 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2961 /* CD pin widget for input */
2962 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2963 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2964 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2966 /* change to EAPD mode */
2967 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2968 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2974 * LG m1 express dual
2976 * Pin assignment:
2977 * Rear Line-In/Out (blue): 0x14
2978 * Build-in Mic-In: 0x15
2979 * Speaker-out: 0x17
2980 * HP-Out (green): 0x1b
2981 * Mic-In/Out (red): 0x19
2982 * SPDIF-Out: 0x1e
2985 /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2986 static hda_nid_t alc880_lg_dac_nids[3] = {
2987 0x05, 0x02, 0x03
2990 /* seems analog CD is not working */
2991 static struct hda_input_mux alc880_lg_capture_source = {
2992 .num_items = 3,
2993 .items = {
2994 { "Mic", 0x1 },
2995 { "Line", 0x5 },
2996 { "Internal Mic", 0x6 },
3000 /* 2,4,6 channel modes */
3001 static struct hda_verb alc880_lg_ch2_init[] = {
3002 /* set line-in and mic-in to input */
3003 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3004 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3008 static struct hda_verb alc880_lg_ch4_init[] = {
3009 /* set line-in to out and mic-in to input */
3010 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3011 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3015 static struct hda_verb alc880_lg_ch6_init[] = {
3016 /* set line-in and mic-in to output */
3017 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3018 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3022 static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3023 { 2, alc880_lg_ch2_init },
3024 { 4, alc880_lg_ch4_init },
3025 { 6, alc880_lg_ch6_init },
3028 static struct snd_kcontrol_new alc880_lg_mixer[] = {
3029 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3030 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
3031 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3032 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3033 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3034 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3035 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3036 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3038 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3039 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3040 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3041 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3042 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3044 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3045 .name = "Channel Mode",
3046 .info = alc_ch_mode_info,
3047 .get = alc_ch_mode_get,
3048 .put = alc_ch_mode_put,
3050 { } /* end */
3053 static struct hda_verb alc880_lg_init_verbs[] = {
3054 /* set capture source to mic-in */
3055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3056 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3057 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3058 /* mute all amp mixer inputs */
3059 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
3060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3061 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3062 /* line-in to input */
3063 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3064 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3065 /* built-in mic */
3066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3068 /* speaker-out */
3069 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3070 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3071 /* mic-in to input */
3072 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3073 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3074 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3075 /* HP-out */
3076 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3077 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3078 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3079 /* jack sense */
3080 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3084 /* toggle speaker-output according to the hp-jack state */
3085 static void alc880_lg_setup(struct hda_codec *codec)
3087 struct alc_spec *spec = codec->spec;
3089 spec->autocfg.hp_pins[0] = 0x1b;
3090 spec->autocfg.speaker_pins[0] = 0x17;
3094 * LG LW20
3096 * Pin assignment:
3097 * Speaker-out: 0x14
3098 * Mic-In: 0x18
3099 * Built-in Mic-In: 0x19
3100 * Line-In: 0x1b
3101 * HP-Out: 0x1a
3102 * SPDIF-Out: 0x1e
3105 static struct hda_input_mux alc880_lg_lw_capture_source = {
3106 .num_items = 3,
3107 .items = {
3108 { "Mic", 0x0 },
3109 { "Internal Mic", 0x1 },
3110 { "Line In", 0x2 },
3114 #define alc880_lg_lw_modes alc880_threestack_modes
3116 static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
3117 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3118 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3119 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3120 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3121 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3122 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3123 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3124 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
3127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3129 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3130 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
3132 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3133 .name = "Channel Mode",
3134 .info = alc_ch_mode_info,
3135 .get = alc_ch_mode_get,
3136 .put = alc_ch_mode_put,
3138 { } /* end */
3141 static struct hda_verb alc880_lg_lw_init_verbs[] = {
3142 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3143 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3144 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3146 /* set capture source to mic-in */
3147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3148 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
3151 /* speaker-out */
3152 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3153 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3154 /* HP-out */
3155 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3156 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3157 /* mic-in to input */
3158 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3159 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3160 /* built-in mic */
3161 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3162 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3163 /* jack sense */
3164 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3168 /* toggle speaker-output according to the hp-jack state */
3169 static void alc880_lg_lw_setup(struct hda_codec *codec)
3171 struct alc_spec *spec = codec->spec;
3173 spec->autocfg.hp_pins[0] = 0x1b;
3174 spec->autocfg.speaker_pins[0] = 0x14;
3177 static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3178 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3179 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3180 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3181 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3182 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3183 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3184 { } /* end */
3187 static struct hda_input_mux alc880_medion_rim_capture_source = {
3188 .num_items = 2,
3189 .items = {
3190 { "Mic", 0x0 },
3191 { "Internal Mic", 0x1 },
3195 static struct hda_verb alc880_medion_rim_init_verbs[] = {
3196 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3198 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3199 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3201 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3202 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3203 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3204 /* Mic2 (as headphone out) for HP output */
3205 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3206 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3207 /* Internal Speaker */
3208 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3209 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3211 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3212 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3214 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3218 /* toggle speaker-output according to the hp-jack state */
3219 static void alc880_medion_rim_automute(struct hda_codec *codec)
3221 struct alc_spec *spec = codec->spec;
3222 alc_automute_amp(codec);
3223 /* toggle EAPD */
3224 if (spec->jack_present)
3225 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3226 else
3227 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3230 static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3231 unsigned int res)
3233 /* Looks like the unsol event is incompatible with the standard
3234 * definition. 4bit tag is placed at 28 bit!
3236 if ((res >> 28) == ALC880_HP_EVENT)
3237 alc880_medion_rim_automute(codec);
3240 static void alc880_medion_rim_setup(struct hda_codec *codec)
3242 struct alc_spec *spec = codec->spec;
3244 spec->autocfg.hp_pins[0] = 0x14;
3245 spec->autocfg.speaker_pins[0] = 0x1b;
3248 #ifdef CONFIG_SND_HDA_POWER_SAVE
3249 static struct hda_amp_list alc880_loopbacks[] = {
3250 { 0x0b, HDA_INPUT, 0 },
3251 { 0x0b, HDA_INPUT, 1 },
3252 { 0x0b, HDA_INPUT, 2 },
3253 { 0x0b, HDA_INPUT, 3 },
3254 { 0x0b, HDA_INPUT, 4 },
3255 { } /* end */
3258 static struct hda_amp_list alc880_lg_loopbacks[] = {
3259 { 0x0b, HDA_INPUT, 1 },
3260 { 0x0b, HDA_INPUT, 6 },
3261 { 0x0b, HDA_INPUT, 7 },
3262 { } /* end */
3264 #endif
3267 * Common callbacks
3270 static int alc_init(struct hda_codec *codec)
3272 struct alc_spec *spec = codec->spec;
3273 unsigned int i;
3275 alc_fix_pll(codec);
3276 alc_auto_init_amp(codec, spec->init_amp);
3278 for (i = 0; i < spec->num_init_verbs; i++)
3279 snd_hda_sequence_write(codec, spec->init_verbs[i]);
3281 if (spec->init_hook)
3282 spec->init_hook(codec);
3284 return 0;
3287 static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3289 struct alc_spec *spec = codec->spec;
3291 if (spec->unsol_event)
3292 spec->unsol_event(codec, res);
3295 #ifdef CONFIG_SND_HDA_POWER_SAVE
3296 static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3298 struct alc_spec *spec = codec->spec;
3299 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3301 #endif
3304 * Analog playback callbacks
3306 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3307 struct hda_codec *codec,
3308 struct snd_pcm_substream *substream)
3310 struct alc_spec *spec = codec->spec;
3311 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3312 hinfo);
3315 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3316 struct hda_codec *codec,
3317 unsigned int stream_tag,
3318 unsigned int format,
3319 struct snd_pcm_substream *substream)
3321 struct alc_spec *spec = codec->spec;
3322 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3323 stream_tag, format, substream);
3326 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3327 struct hda_codec *codec,
3328 struct snd_pcm_substream *substream)
3330 struct alc_spec *spec = codec->spec;
3331 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3335 * Digital out
3337 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3338 struct hda_codec *codec,
3339 struct snd_pcm_substream *substream)
3341 struct alc_spec *spec = codec->spec;
3342 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3345 static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3346 struct hda_codec *codec,
3347 unsigned int stream_tag,
3348 unsigned int format,
3349 struct snd_pcm_substream *substream)
3351 struct alc_spec *spec = codec->spec;
3352 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3353 stream_tag, format, substream);
3356 static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3357 struct hda_codec *codec,
3358 struct snd_pcm_substream *substream)
3360 struct alc_spec *spec = codec->spec;
3361 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3364 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3365 struct hda_codec *codec,
3366 struct snd_pcm_substream *substream)
3368 struct alc_spec *spec = codec->spec;
3369 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3373 * Analog capture
3375 static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3376 struct hda_codec *codec,
3377 unsigned int stream_tag,
3378 unsigned int format,
3379 struct snd_pcm_substream *substream)
3381 struct alc_spec *spec = codec->spec;
3383 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
3384 stream_tag, 0, format);
3385 return 0;
3388 static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3389 struct hda_codec *codec,
3390 struct snd_pcm_substream *substream)
3392 struct alc_spec *spec = codec->spec;
3394 snd_hda_codec_cleanup_stream(codec,
3395 spec->adc_nids[substream->number + 1]);
3396 return 0;
3402 static struct hda_pcm_stream alc880_pcm_analog_playback = {
3403 .substreams = 1,
3404 .channels_min = 2,
3405 .channels_max = 8,
3406 /* NID is set in alc_build_pcms */
3407 .ops = {
3408 .open = alc880_playback_pcm_open,
3409 .prepare = alc880_playback_pcm_prepare,
3410 .cleanup = alc880_playback_pcm_cleanup
3414 static struct hda_pcm_stream alc880_pcm_analog_capture = {
3415 .substreams = 1,
3416 .channels_min = 2,
3417 .channels_max = 2,
3418 /* NID is set in alc_build_pcms */
3421 static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3422 .substreams = 1,
3423 .channels_min = 2,
3424 .channels_max = 2,
3425 /* NID is set in alc_build_pcms */
3428 static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3429 .substreams = 2, /* can be overridden */
3430 .channels_min = 2,
3431 .channels_max = 2,
3432 /* NID is set in alc_build_pcms */
3433 .ops = {
3434 .prepare = alc880_alt_capture_pcm_prepare,
3435 .cleanup = alc880_alt_capture_pcm_cleanup
3439 static struct hda_pcm_stream alc880_pcm_digital_playback = {
3440 .substreams = 1,
3441 .channels_min = 2,
3442 .channels_max = 2,
3443 /* NID is set in alc_build_pcms */
3444 .ops = {
3445 .open = alc880_dig_playback_pcm_open,
3446 .close = alc880_dig_playback_pcm_close,
3447 .prepare = alc880_dig_playback_pcm_prepare,
3448 .cleanup = alc880_dig_playback_pcm_cleanup
3452 static struct hda_pcm_stream alc880_pcm_digital_capture = {
3453 .substreams = 1,
3454 .channels_min = 2,
3455 .channels_max = 2,
3456 /* NID is set in alc_build_pcms */
3459 /* Used by alc_build_pcms to flag that a PCM has no playback stream */
3460 static struct hda_pcm_stream alc_pcm_null_stream = {
3461 .substreams = 0,
3462 .channels_min = 0,
3463 .channels_max = 0,
3466 static int alc_build_pcms(struct hda_codec *codec)
3468 struct alc_spec *spec = codec->spec;
3469 struct hda_pcm *info = spec->pcm_rec;
3470 int i;
3472 codec->num_pcms = 1;
3473 codec->pcm_info = info;
3475 if (spec->no_analog)
3476 goto skip_analog;
3478 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3479 "%s Analog", codec->chip_name);
3480 info->name = spec->stream_name_analog;
3482 if (spec->stream_analog_playback) {
3483 if (snd_BUG_ON(!spec->multiout.dac_nids))
3484 return -EINVAL;
3485 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3486 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3488 if (spec->stream_analog_capture) {
3489 if (snd_BUG_ON(!spec->adc_nids))
3490 return -EINVAL;
3491 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3492 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3495 if (spec->channel_mode) {
3496 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3497 for (i = 0; i < spec->num_channel_mode; i++) {
3498 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3499 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3504 skip_analog:
3505 /* SPDIF for stream index #1 */
3506 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3507 snprintf(spec->stream_name_digital,
3508 sizeof(spec->stream_name_digital),
3509 "%s Digital", codec->chip_name);
3510 codec->num_pcms = 2;
3511 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
3512 info = spec->pcm_rec + 1;
3513 info->name = spec->stream_name_digital;
3514 if (spec->dig_out_type)
3515 info->pcm_type = spec->dig_out_type;
3516 else
3517 info->pcm_type = HDA_PCM_TYPE_SPDIF;
3518 if (spec->multiout.dig_out_nid &&
3519 spec->stream_digital_playback) {
3520 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3521 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3523 if (spec->dig_in_nid &&
3524 spec->stream_digital_capture) {
3525 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3526 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3528 /* FIXME: do we need this for all Realtek codec models? */
3529 codec->spdif_status_reset = 1;
3532 if (spec->no_analog)
3533 return 0;
3535 /* If the use of more than one ADC is requested for the current
3536 * model, configure a second analog capture-only PCM.
3538 /* Additional Analaog capture for index #2 */
3539 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3540 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
3541 codec->num_pcms = 3;
3542 info = spec->pcm_rec + 2;
3543 info->name = spec->stream_name_analog;
3544 if (spec->alt_dac_nid) {
3545 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3546 *spec->stream_analog_alt_playback;
3547 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3548 spec->alt_dac_nid;
3549 } else {
3550 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3551 alc_pcm_null_stream;
3552 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3554 if (spec->num_adc_nids > 1) {
3555 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3556 *spec->stream_analog_alt_capture;
3557 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3558 spec->adc_nids[1];
3559 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3560 spec->num_adc_nids - 1;
3561 } else {
3562 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3563 alc_pcm_null_stream;
3564 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
3568 return 0;
3571 static void alc_free_kctls(struct hda_codec *codec)
3573 struct alc_spec *spec = codec->spec;
3575 if (spec->kctls.list) {
3576 struct snd_kcontrol_new *kctl = spec->kctls.list;
3577 int i;
3578 for (i = 0; i < spec->kctls.used; i++)
3579 kfree(kctl[i].name);
3581 snd_array_free(&spec->kctls);
3584 static void alc_free(struct hda_codec *codec)
3586 struct alc_spec *spec = codec->spec;
3588 if (!spec)
3589 return;
3591 alc_free_kctls(codec);
3592 kfree(spec);
3593 snd_hda_detach_beep_device(codec);
3596 #ifdef SND_HDA_NEEDS_RESUME
3597 static int alc_resume(struct hda_codec *codec)
3599 codec->patch_ops.init(codec);
3600 snd_hda_codec_resume_amp(codec);
3601 snd_hda_codec_resume_cache(codec);
3602 return 0;
3604 #endif
3608 static struct hda_codec_ops alc_patch_ops = {
3609 .build_controls = alc_build_controls,
3610 .build_pcms = alc_build_pcms,
3611 .init = alc_init,
3612 .free = alc_free,
3613 .unsol_event = alc_unsol_event,
3614 #ifdef SND_HDA_NEEDS_RESUME
3615 .resume = alc_resume,
3616 #endif
3617 #ifdef CONFIG_SND_HDA_POWER_SAVE
3618 .check_power_status = alc_check_power_status,
3619 #endif
3624 * Test configuration for debugging
3626 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3627 * enum controls.
3629 #ifdef CONFIG_SND_DEBUG
3630 static hda_nid_t alc880_test_dac_nids[4] = {
3631 0x02, 0x03, 0x04, 0x05
3634 static struct hda_input_mux alc880_test_capture_source = {
3635 .num_items = 7,
3636 .items = {
3637 { "In-1", 0x0 },
3638 { "In-2", 0x1 },
3639 { "In-3", 0x2 },
3640 { "In-4", 0x3 },
3641 { "CD", 0x4 },
3642 { "Front", 0x5 },
3643 { "Surround", 0x6 },
3647 static struct hda_channel_mode alc880_test_modes[4] = {
3648 { 2, NULL },
3649 { 4, NULL },
3650 { 6, NULL },
3651 { 8, NULL },
3654 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3655 struct snd_ctl_elem_info *uinfo)
3657 static char *texts[] = {
3658 "N/A", "Line Out", "HP Out",
3659 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3661 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3662 uinfo->count = 1;
3663 uinfo->value.enumerated.items = 8;
3664 if (uinfo->value.enumerated.item >= 8)
3665 uinfo->value.enumerated.item = 7;
3666 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3667 return 0;
3670 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3671 struct snd_ctl_elem_value *ucontrol)
3673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3674 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3675 unsigned int pin_ctl, item = 0;
3677 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3678 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3679 if (pin_ctl & AC_PINCTL_OUT_EN) {
3680 if (pin_ctl & AC_PINCTL_HP_EN)
3681 item = 2;
3682 else
3683 item = 1;
3684 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3685 switch (pin_ctl & AC_PINCTL_VREFEN) {
3686 case AC_PINCTL_VREF_HIZ: item = 3; break;
3687 case AC_PINCTL_VREF_50: item = 4; break;
3688 case AC_PINCTL_VREF_GRD: item = 5; break;
3689 case AC_PINCTL_VREF_80: item = 6; break;
3690 case AC_PINCTL_VREF_100: item = 7; break;
3693 ucontrol->value.enumerated.item[0] = item;
3694 return 0;
3697 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3698 struct snd_ctl_elem_value *ucontrol)
3700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3701 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3702 static unsigned int ctls[] = {
3703 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3704 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3705 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3706 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3707 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3708 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3710 unsigned int old_ctl, new_ctl;
3712 old_ctl = snd_hda_codec_read(codec, nid, 0,
3713 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3714 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3715 if (old_ctl != new_ctl) {
3716 int val;
3717 snd_hda_codec_write_cache(codec, nid, 0,
3718 AC_VERB_SET_PIN_WIDGET_CONTROL,
3719 new_ctl);
3720 val = ucontrol->value.enumerated.item[0] >= 3 ?
3721 HDA_AMP_MUTE : 0;
3722 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3723 HDA_AMP_MUTE, val);
3724 return 1;
3726 return 0;
3729 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3730 struct snd_ctl_elem_info *uinfo)
3732 static char *texts[] = {
3733 "Front", "Surround", "CLFE", "Side"
3735 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3736 uinfo->count = 1;
3737 uinfo->value.enumerated.items = 4;
3738 if (uinfo->value.enumerated.item >= 4)
3739 uinfo->value.enumerated.item = 3;
3740 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3741 return 0;
3744 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3745 struct snd_ctl_elem_value *ucontrol)
3747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3748 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3749 unsigned int sel;
3751 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3752 ucontrol->value.enumerated.item[0] = sel & 3;
3753 return 0;
3756 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3757 struct snd_ctl_elem_value *ucontrol)
3759 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3760 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3761 unsigned int sel;
3763 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3764 if (ucontrol->value.enumerated.item[0] != sel) {
3765 sel = ucontrol->value.enumerated.item[0] & 3;
3766 snd_hda_codec_write_cache(codec, nid, 0,
3767 AC_VERB_SET_CONNECT_SEL, sel);
3768 return 1;
3770 return 0;
3773 #define PIN_CTL_TEST(xname,nid) { \
3774 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3775 .name = xname, \
3776 .info = alc_test_pin_ctl_info, \
3777 .get = alc_test_pin_ctl_get, \
3778 .put = alc_test_pin_ctl_put, \
3779 .private_value = nid \
3782 #define PIN_SRC_TEST(xname,nid) { \
3783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3784 .name = xname, \
3785 .info = alc_test_pin_src_info, \
3786 .get = alc_test_pin_src_get, \
3787 .put = alc_test_pin_src_put, \
3788 .private_value = nid \
3791 static struct snd_kcontrol_new alc880_test_mixer[] = {
3792 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3794 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3795 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3796 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3797 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3798 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3799 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
3800 PIN_CTL_TEST("Front Pin Mode", 0x14),
3801 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3802 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3803 PIN_CTL_TEST("Side Pin Mode", 0x17),
3804 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3805 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3806 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3807 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3808 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3809 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3810 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3811 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3812 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3813 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3814 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3815 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3816 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3817 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3818 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3819 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
3823 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3824 .name = "Channel Mode",
3825 .info = alc_ch_mode_info,
3826 .get = alc_ch_mode_get,
3827 .put = alc_ch_mode_put,
3829 { } /* end */
3832 static struct hda_verb alc880_test_init_verbs[] = {
3833 /* Unmute inputs of 0x0c - 0x0f */
3834 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3835 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3836 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3837 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3838 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3839 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3840 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3841 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3842 /* Vol output for 0x0c-0x0f */
3843 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3844 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3845 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3846 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3847 /* Set output pins 0x14-0x17 */
3848 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3850 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3851 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3852 /* Unmute output pins 0x14-0x17 */
3853 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3855 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3856 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3857 /* Set input pins 0x18-0x1c */
3858 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3859 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3860 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3861 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3862 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3863 /* Mute input pins 0x18-0x1b */
3864 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3865 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3866 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3867 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3868 /* ADC set up */
3869 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3870 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
3871 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3872 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
3873 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3874 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
3875 /* Analog input/passthru */
3876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3877 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3883 #endif
3888 static const char *alc880_models[ALC880_MODEL_LAST] = {
3889 [ALC880_3ST] = "3stack",
3890 [ALC880_TCL_S700] = "tcl",
3891 [ALC880_3ST_DIG] = "3stack-digout",
3892 [ALC880_CLEVO] = "clevo",
3893 [ALC880_5ST] = "5stack",
3894 [ALC880_5ST_DIG] = "5stack-digout",
3895 [ALC880_W810] = "w810",
3896 [ALC880_Z71V] = "z71v",
3897 [ALC880_6ST] = "6stack",
3898 [ALC880_6ST_DIG] = "6stack-digout",
3899 [ALC880_ASUS] = "asus",
3900 [ALC880_ASUS_W1V] = "asus-w1v",
3901 [ALC880_ASUS_DIG] = "asus-dig",
3902 [ALC880_ASUS_DIG2] = "asus-dig2",
3903 [ALC880_UNIWILL_DIG] = "uniwill",
3904 [ALC880_UNIWILL_P53] = "uniwill-p53",
3905 [ALC880_FUJITSU] = "fujitsu",
3906 [ALC880_F1734] = "F1734",
3907 [ALC880_LG] = "lg",
3908 [ALC880_LG_LW] = "lg-lw",
3909 [ALC880_MEDION_RIM] = "medion",
3910 #ifdef CONFIG_SND_DEBUG
3911 [ALC880_TEST] = "test",
3912 #endif
3913 [ALC880_AUTO] = "auto",
3916 static struct snd_pci_quirk alc880_cfg_tbl[] = {
3917 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
3918 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3919 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3920 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3921 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3922 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3923 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3924 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3925 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
3926 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3927 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
3928 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3929 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3930 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3931 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3932 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3933 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3934 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3935 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3936 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3937 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
3938 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
3939 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3940 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3941 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
3942 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
3943 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
3944 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3945 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
3946 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3947 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
3948 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3949 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3950 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3951 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
3952 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3953 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
3954 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
3955 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
3956 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
3957 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
3958 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3959 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
3960 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
3961 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
3962 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
3963 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
3964 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
3965 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
3966 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
3967 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
3968 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
3969 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3970 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
3971 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
3972 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3973 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3974 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3975 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
3976 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3977 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
3978 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
3979 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
3980 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3981 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
3982 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3983 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3984 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
3985 /* default Intel */
3986 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
3987 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3988 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
3993 * ALC880 codec presets
3995 static struct alc_config_preset alc880_presets[] = {
3996 [ALC880_3ST] = {
3997 .mixers = { alc880_three_stack_mixer },
3998 .init_verbs = { alc880_volume_init_verbs,
3999 alc880_pin_3stack_init_verbs },
4000 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4001 .dac_nids = alc880_dac_nids,
4002 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4003 .channel_mode = alc880_threestack_modes,
4004 .need_dac_fix = 1,
4005 .input_mux = &alc880_capture_source,
4007 [ALC880_3ST_DIG] = {
4008 .mixers = { alc880_three_stack_mixer },
4009 .init_verbs = { alc880_volume_init_verbs,
4010 alc880_pin_3stack_init_verbs },
4011 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4012 .dac_nids = alc880_dac_nids,
4013 .dig_out_nid = ALC880_DIGOUT_NID,
4014 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4015 .channel_mode = alc880_threestack_modes,
4016 .need_dac_fix = 1,
4017 .input_mux = &alc880_capture_source,
4019 [ALC880_TCL_S700] = {
4020 .mixers = { alc880_tcl_s700_mixer },
4021 .init_verbs = { alc880_volume_init_verbs,
4022 alc880_pin_tcl_S700_init_verbs,
4023 alc880_gpio2_init_verbs },
4024 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4025 .dac_nids = alc880_dac_nids,
4026 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4027 .num_adc_nids = 1, /* single ADC */
4028 .hp_nid = 0x03,
4029 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4030 .channel_mode = alc880_2_jack_modes,
4031 .input_mux = &alc880_capture_source,
4033 [ALC880_5ST] = {
4034 .mixers = { alc880_three_stack_mixer,
4035 alc880_five_stack_mixer},
4036 .init_verbs = { alc880_volume_init_verbs,
4037 alc880_pin_5stack_init_verbs },
4038 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4039 .dac_nids = alc880_dac_nids,
4040 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4041 .channel_mode = alc880_fivestack_modes,
4042 .input_mux = &alc880_capture_source,
4044 [ALC880_5ST_DIG] = {
4045 .mixers = { alc880_three_stack_mixer,
4046 alc880_five_stack_mixer },
4047 .init_verbs = { alc880_volume_init_verbs,
4048 alc880_pin_5stack_init_verbs },
4049 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4050 .dac_nids = alc880_dac_nids,
4051 .dig_out_nid = ALC880_DIGOUT_NID,
4052 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4053 .channel_mode = alc880_fivestack_modes,
4054 .input_mux = &alc880_capture_source,
4056 [ALC880_6ST] = {
4057 .mixers = { alc880_six_stack_mixer },
4058 .init_verbs = { alc880_volume_init_verbs,
4059 alc880_pin_6stack_init_verbs },
4060 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4061 .dac_nids = alc880_6st_dac_nids,
4062 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4063 .channel_mode = alc880_sixstack_modes,
4064 .input_mux = &alc880_6stack_capture_source,
4066 [ALC880_6ST_DIG] = {
4067 .mixers = { alc880_six_stack_mixer },
4068 .init_verbs = { alc880_volume_init_verbs,
4069 alc880_pin_6stack_init_verbs },
4070 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4071 .dac_nids = alc880_6st_dac_nids,
4072 .dig_out_nid = ALC880_DIGOUT_NID,
4073 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4074 .channel_mode = alc880_sixstack_modes,
4075 .input_mux = &alc880_6stack_capture_source,
4077 [ALC880_W810] = {
4078 .mixers = { alc880_w810_base_mixer },
4079 .init_verbs = { alc880_volume_init_verbs,
4080 alc880_pin_w810_init_verbs,
4081 alc880_gpio2_init_verbs },
4082 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4083 .dac_nids = alc880_w810_dac_nids,
4084 .dig_out_nid = ALC880_DIGOUT_NID,
4085 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4086 .channel_mode = alc880_w810_modes,
4087 .input_mux = &alc880_capture_source,
4089 [ALC880_Z71V] = {
4090 .mixers = { alc880_z71v_mixer },
4091 .init_verbs = { alc880_volume_init_verbs,
4092 alc880_pin_z71v_init_verbs },
4093 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4094 .dac_nids = alc880_z71v_dac_nids,
4095 .dig_out_nid = ALC880_DIGOUT_NID,
4096 .hp_nid = 0x03,
4097 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4098 .channel_mode = alc880_2_jack_modes,
4099 .input_mux = &alc880_capture_source,
4101 [ALC880_F1734] = {
4102 .mixers = { alc880_f1734_mixer },
4103 .init_verbs = { alc880_volume_init_verbs,
4104 alc880_pin_f1734_init_verbs },
4105 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4106 .dac_nids = alc880_f1734_dac_nids,
4107 .hp_nid = 0x02,
4108 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4109 .channel_mode = alc880_2_jack_modes,
4110 .input_mux = &alc880_f1734_capture_source,
4111 .unsol_event = alc880_uniwill_p53_unsol_event,
4112 .setup = alc880_uniwill_p53_setup,
4113 .init_hook = alc_automute_amp,
4115 [ALC880_ASUS] = {
4116 .mixers = { alc880_asus_mixer },
4117 .init_verbs = { alc880_volume_init_verbs,
4118 alc880_pin_asus_init_verbs,
4119 alc880_gpio1_init_verbs },
4120 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4121 .dac_nids = alc880_asus_dac_nids,
4122 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4123 .channel_mode = alc880_asus_modes,
4124 .need_dac_fix = 1,
4125 .input_mux = &alc880_capture_source,
4127 [ALC880_ASUS_DIG] = {
4128 .mixers = { alc880_asus_mixer },
4129 .init_verbs = { alc880_volume_init_verbs,
4130 alc880_pin_asus_init_verbs,
4131 alc880_gpio1_init_verbs },
4132 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4133 .dac_nids = alc880_asus_dac_nids,
4134 .dig_out_nid = ALC880_DIGOUT_NID,
4135 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4136 .channel_mode = alc880_asus_modes,
4137 .need_dac_fix = 1,
4138 .input_mux = &alc880_capture_source,
4140 [ALC880_ASUS_DIG2] = {
4141 .mixers = { alc880_asus_mixer },
4142 .init_verbs = { alc880_volume_init_verbs,
4143 alc880_pin_asus_init_verbs,
4144 alc880_gpio2_init_verbs }, /* use GPIO2 */
4145 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4146 .dac_nids = alc880_asus_dac_nids,
4147 .dig_out_nid = ALC880_DIGOUT_NID,
4148 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4149 .channel_mode = alc880_asus_modes,
4150 .need_dac_fix = 1,
4151 .input_mux = &alc880_capture_source,
4153 [ALC880_ASUS_W1V] = {
4154 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
4155 .init_verbs = { alc880_volume_init_verbs,
4156 alc880_pin_asus_init_verbs,
4157 alc880_gpio1_init_verbs },
4158 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4159 .dac_nids = alc880_asus_dac_nids,
4160 .dig_out_nid = ALC880_DIGOUT_NID,
4161 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4162 .channel_mode = alc880_asus_modes,
4163 .need_dac_fix = 1,
4164 .input_mux = &alc880_capture_source,
4166 [ALC880_UNIWILL_DIG] = {
4167 .mixers = { alc880_asus_mixer },
4168 .init_verbs = { alc880_volume_init_verbs,
4169 alc880_pin_asus_init_verbs },
4170 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4171 .dac_nids = alc880_asus_dac_nids,
4172 .dig_out_nid = ALC880_DIGOUT_NID,
4173 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4174 .channel_mode = alc880_asus_modes,
4175 .need_dac_fix = 1,
4176 .input_mux = &alc880_capture_source,
4178 [ALC880_UNIWILL] = {
4179 .mixers = { alc880_uniwill_mixer },
4180 .init_verbs = { alc880_volume_init_verbs,
4181 alc880_uniwill_init_verbs },
4182 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4183 .dac_nids = alc880_asus_dac_nids,
4184 .dig_out_nid = ALC880_DIGOUT_NID,
4185 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4186 .channel_mode = alc880_threestack_modes,
4187 .need_dac_fix = 1,
4188 .input_mux = &alc880_capture_source,
4189 .unsol_event = alc880_uniwill_unsol_event,
4190 .setup = alc880_uniwill_setup,
4191 .init_hook = alc880_uniwill_init_hook,
4193 [ALC880_UNIWILL_P53] = {
4194 .mixers = { alc880_uniwill_p53_mixer },
4195 .init_verbs = { alc880_volume_init_verbs,
4196 alc880_uniwill_p53_init_verbs },
4197 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4198 .dac_nids = alc880_asus_dac_nids,
4199 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4200 .channel_mode = alc880_threestack_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_FUJITSU] = {
4207 .mixers = { alc880_fujitsu_mixer },
4208 .init_verbs = { alc880_volume_init_verbs,
4209 alc880_uniwill_p53_init_verbs,
4210 alc880_beep_init_verbs },
4211 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4212 .dac_nids = alc880_dac_nids,
4213 .dig_out_nid = ALC880_DIGOUT_NID,
4214 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4215 .channel_mode = alc880_2_jack_modes,
4216 .input_mux = &alc880_capture_source,
4217 .unsol_event = alc880_uniwill_p53_unsol_event,
4218 .setup = alc880_uniwill_p53_setup,
4219 .init_hook = alc_automute_amp,
4221 [ALC880_CLEVO] = {
4222 .mixers = { alc880_three_stack_mixer },
4223 .init_verbs = { alc880_volume_init_verbs,
4224 alc880_pin_clevo_init_verbs },
4225 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4226 .dac_nids = alc880_dac_nids,
4227 .hp_nid = 0x03,
4228 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4229 .channel_mode = alc880_threestack_modes,
4230 .need_dac_fix = 1,
4231 .input_mux = &alc880_capture_source,
4233 [ALC880_LG] = {
4234 .mixers = { alc880_lg_mixer },
4235 .init_verbs = { alc880_volume_init_verbs,
4236 alc880_lg_init_verbs },
4237 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4238 .dac_nids = alc880_lg_dac_nids,
4239 .dig_out_nid = ALC880_DIGOUT_NID,
4240 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4241 .channel_mode = alc880_lg_ch_modes,
4242 .need_dac_fix = 1,
4243 .input_mux = &alc880_lg_capture_source,
4244 .unsol_event = alc_automute_amp_unsol_event,
4245 .setup = alc880_lg_setup,
4246 .init_hook = alc_automute_amp,
4247 #ifdef CONFIG_SND_HDA_POWER_SAVE
4248 .loopbacks = alc880_lg_loopbacks,
4249 #endif
4251 [ALC880_LG_LW] = {
4252 .mixers = { alc880_lg_lw_mixer },
4253 .init_verbs = { alc880_volume_init_verbs,
4254 alc880_lg_lw_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_lg_lw_modes),
4259 .channel_mode = alc880_lg_lw_modes,
4260 .input_mux = &alc880_lg_lw_capture_source,
4261 .unsol_event = alc_automute_amp_unsol_event,
4262 .setup = alc880_lg_lw_setup,
4263 .init_hook = alc_automute_amp,
4265 [ALC880_MEDION_RIM] = {
4266 .mixers = { alc880_medion_rim_mixer },
4267 .init_verbs = { alc880_volume_init_verbs,
4268 alc880_medion_rim_init_verbs,
4269 alc_gpio2_init_verbs },
4270 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4271 .dac_nids = alc880_dac_nids,
4272 .dig_out_nid = ALC880_DIGOUT_NID,
4273 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4274 .channel_mode = alc880_2_jack_modes,
4275 .input_mux = &alc880_medion_rim_capture_source,
4276 .unsol_event = alc880_medion_rim_unsol_event,
4277 .setup = alc880_medion_rim_setup,
4278 .init_hook = alc880_medion_rim_automute,
4280 #ifdef CONFIG_SND_DEBUG
4281 [ALC880_TEST] = {
4282 .mixers = { alc880_test_mixer },
4283 .init_verbs = { alc880_test_init_verbs },
4284 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4285 .dac_nids = alc880_test_dac_nids,
4286 .dig_out_nid = ALC880_DIGOUT_NID,
4287 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4288 .channel_mode = alc880_test_modes,
4289 .input_mux = &alc880_test_capture_source,
4291 #endif
4295 * Automatic parse of I/O pins from the BIOS configuration
4298 enum {
4299 ALC_CTL_WIDGET_VOL,
4300 ALC_CTL_WIDGET_MUTE,
4301 ALC_CTL_BIND_MUTE,
4303 static struct snd_kcontrol_new alc880_control_templates[] = {
4304 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4305 HDA_CODEC_MUTE(NULL, 0, 0, 0),
4306 HDA_BIND_MUTE(NULL, 0, 0, 0),
4309 /* add dynamic controls */
4310 static int add_control(struct alc_spec *spec, int type, const char *name,
4311 unsigned long val)
4313 struct snd_kcontrol_new *knew;
4315 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4316 knew = snd_array_new(&spec->kctls);
4317 if (!knew)
4318 return -ENOMEM;
4319 *knew = alc880_control_templates[type];
4320 knew->name = kstrdup(name, GFP_KERNEL);
4321 if (!knew->name)
4322 return -ENOMEM;
4323 knew->private_value = val;
4324 return 0;
4327 static int add_control_with_pfx(struct alc_spec *spec, int type,
4328 const char *pfx, const char *dir,
4329 const char *sfx, unsigned long val)
4331 char name[32];
4332 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4333 return add_control(spec, type, name, val);
4336 #define add_pb_vol_ctrl(spec, type, pfx, val) \
4337 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4338 #define add_pb_sw_ctrl(spec, type, pfx, val) \
4339 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4341 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4342 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4343 #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4344 #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4345 #define alc880_idx_to_dac(nid) ((nid) + 0x02)
4346 #define alc880_dac_to_idx(nid) ((nid) - 0x02)
4347 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4348 #define alc880_idx_to_selector(nid) ((nid) + 0x10)
4349 #define ALC880_PIN_CD_NID 0x1c
4351 /* fill in the dac_nids table from the parsed pin configuration */
4352 static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4353 const struct auto_pin_cfg *cfg)
4355 hda_nid_t nid;
4356 int assigned[4];
4357 int i, j;
4359 memset(assigned, 0, sizeof(assigned));
4360 spec->multiout.dac_nids = spec->private_dac_nids;
4362 /* check the pins hardwired to audio widget */
4363 for (i = 0; i < cfg->line_outs; i++) {
4364 nid = cfg->line_out_pins[i];
4365 if (alc880_is_fixed_pin(nid)) {
4366 int idx = alc880_fixed_pin_idx(nid);
4367 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
4368 assigned[idx] = 1;
4371 /* left pins can be connect to any audio widget */
4372 for (i = 0; i < cfg->line_outs; i++) {
4373 nid = cfg->line_out_pins[i];
4374 if (alc880_is_fixed_pin(nid))
4375 continue;
4376 /* search for an empty channel */
4377 for (j = 0; j < cfg->line_outs; j++) {
4378 if (!assigned[j]) {
4379 spec->multiout.dac_nids[i] =
4380 alc880_idx_to_dac(j);
4381 assigned[j] = 1;
4382 break;
4386 spec->multiout.num_dacs = cfg->line_outs;
4387 return 0;
4390 /* add playback controls from the parsed DAC table */
4391 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4392 const struct auto_pin_cfg *cfg)
4394 static const char *chname[4] = {
4395 "Front", "Surround", NULL /*CLFE*/, "Side"
4397 hda_nid_t nid;
4398 int i, err;
4400 for (i = 0; i < cfg->line_outs; i++) {
4401 if (!spec->multiout.dac_nids[i])
4402 continue;
4403 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4404 if (i == 2) {
4405 /* Center/LFE */
4406 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4407 "Center",
4408 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4409 HDA_OUTPUT));
4410 if (err < 0)
4411 return err;
4412 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4413 "LFE",
4414 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4415 HDA_OUTPUT));
4416 if (err < 0)
4417 return err;
4418 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4419 "Center",
4420 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4421 HDA_INPUT));
4422 if (err < 0)
4423 return err;
4424 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4425 "LFE",
4426 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4427 HDA_INPUT));
4428 if (err < 0)
4429 return err;
4430 } else {
4431 const char *pfx;
4432 if (cfg->line_outs == 1 &&
4433 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4434 pfx = "Speaker";
4435 else
4436 pfx = chname[i];
4437 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
4438 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4439 HDA_OUTPUT));
4440 if (err < 0)
4441 return err;
4442 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
4443 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4444 HDA_INPUT));
4445 if (err < 0)
4446 return err;
4449 return 0;
4452 /* add playback controls for speaker and HP outputs */
4453 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4454 const char *pfx)
4456 hda_nid_t nid;
4457 int err;
4459 if (!pin)
4460 return 0;
4462 if (alc880_is_fixed_pin(pin)) {
4463 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
4464 /* specify the DAC as the extra output */
4465 if (!spec->multiout.hp_nid)
4466 spec->multiout.hp_nid = nid;
4467 else
4468 spec->multiout.extra_out_nid[0] = nid;
4469 /* control HP volume/switch on the output mixer amp */
4470 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
4471 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
4472 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4473 if (err < 0)
4474 return err;
4475 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
4476 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4477 if (err < 0)
4478 return err;
4479 } else if (alc880_is_multi_pin(pin)) {
4480 /* set manual connection */
4481 /* we have only a switch on HP-out PIN */
4482 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
4483 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4484 if (err < 0)
4485 return err;
4487 return 0;
4490 /* create input playback/capture controls for the given pin */
4491 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4492 const char *ctlname,
4493 int idx, hda_nid_t mix_nid)
4495 int err;
4497 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
4498 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4499 if (err < 0)
4500 return err;
4501 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
4502 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4503 if (err < 0)
4504 return err;
4505 return 0;
4508 static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
4510 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4511 return (pincap & AC_PINCAP_IN) != 0;
4514 /* create playback/capture controls for input pins */
4515 static int alc_auto_create_input_ctls(struct hda_codec *codec,
4516 const struct auto_pin_cfg *cfg,
4517 hda_nid_t mixer,
4518 hda_nid_t cap1, hda_nid_t cap2)
4520 struct alc_spec *spec = codec->spec;
4521 struct hda_input_mux *imux = &spec->private_imux[0];
4522 int i, err, idx;
4524 for (i = 0; i < AUTO_PIN_LAST; i++) {
4525 hda_nid_t pin;
4527 pin = cfg->input_pins[i];
4528 if (!alc_is_input_pin(codec, pin))
4529 continue;
4531 if (mixer) {
4532 idx = get_connection_index(codec, mixer, pin);
4533 if (idx >= 0) {
4534 err = new_analog_input(spec, pin,
4535 auto_pin_cfg_labels[i],
4536 idx, mixer);
4537 if (err < 0)
4538 return err;
4542 if (!cap1)
4543 continue;
4544 idx = get_connection_index(codec, cap1, pin);
4545 if (idx < 0 && cap2)
4546 idx = get_connection_index(codec, cap2, pin);
4547 if (idx >= 0) {
4548 imux->items[imux->num_items].label =
4549 auto_pin_cfg_labels[i];
4550 imux->items[imux->num_items].index = idx;
4551 imux->num_items++;
4554 return 0;
4557 static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4558 const struct auto_pin_cfg *cfg)
4560 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4563 static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4564 unsigned int pin_type)
4566 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4567 pin_type);
4568 /* unmute pin */
4569 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4570 AMP_OUT_UNMUTE);
4573 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4574 hda_nid_t nid, int pin_type,
4575 int dac_idx)
4577 alc_set_pin_output(codec, nid, pin_type);
4578 /* need the manual connection? */
4579 if (alc880_is_multi_pin(nid)) {
4580 struct alc_spec *spec = codec->spec;
4581 int idx = alc880_multi_pin_idx(nid);
4582 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4583 AC_VERB_SET_CONNECT_SEL,
4584 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4588 static int get_pin_type(int line_out_type)
4590 if (line_out_type == AUTO_PIN_HP_OUT)
4591 return PIN_HP;
4592 else
4593 return PIN_OUT;
4596 static void alc880_auto_init_multi_out(struct hda_codec *codec)
4598 struct alc_spec *spec = codec->spec;
4599 int i;
4601 for (i = 0; i < spec->autocfg.line_outs; i++) {
4602 hda_nid_t nid = spec->autocfg.line_out_pins[i];
4603 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4604 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
4608 static void alc880_auto_init_extra_out(struct hda_codec *codec)
4610 struct alc_spec *spec = codec->spec;
4611 hda_nid_t pin;
4613 pin = spec->autocfg.speaker_pins[0];
4614 if (pin) /* connect to front */
4615 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
4616 pin = spec->autocfg.hp_pins[0];
4617 if (pin) /* connect to front */
4618 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4621 static void alc880_auto_init_analog_input(struct hda_codec *codec)
4623 struct alc_spec *spec = codec->spec;
4624 int i;
4626 for (i = 0; i < AUTO_PIN_LAST; i++) {
4627 hda_nid_t nid = spec->autocfg.input_pins[i];
4628 if (alc_is_input_pin(codec, nid)) {
4629 alc_set_input_pin(codec, nid, i);
4630 if (nid != ALC880_PIN_CD_NID &&
4631 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
4632 snd_hda_codec_write(codec, nid, 0,
4633 AC_VERB_SET_AMP_GAIN_MUTE,
4634 AMP_OUT_MUTE);
4639 /* parse the BIOS configuration and set up the alc_spec */
4640 /* return 1 if successful, 0 if the proper config is not found,
4641 * or a negative error code
4643 static int alc880_parse_auto_config(struct hda_codec *codec)
4645 struct alc_spec *spec = codec->spec;
4646 int i, err;
4647 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
4649 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4650 alc880_ignore);
4651 if (err < 0)
4652 return err;
4653 if (!spec->autocfg.line_outs)
4654 return 0; /* can't find valid BIOS pin config */
4656 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4657 if (err < 0)
4658 return err;
4659 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4660 if (err < 0)
4661 return err;
4662 err = alc880_auto_create_extra_out(spec,
4663 spec->autocfg.speaker_pins[0],
4664 "Speaker");
4665 if (err < 0)
4666 return err;
4667 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4668 "Headphone");
4669 if (err < 0)
4670 return err;
4671 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
4672 if (err < 0)
4673 return err;
4675 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4677 /* check multiple SPDIF-out (for recent codecs) */
4678 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4679 hda_nid_t dig_nid;
4680 err = snd_hda_get_connections(codec,
4681 spec->autocfg.dig_out_pins[i],
4682 &dig_nid, 1);
4683 if (err < 0)
4684 continue;
4685 if (!i)
4686 spec->multiout.dig_out_nid = dig_nid;
4687 else {
4688 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4689 spec->slave_dig_outs[i - 1] = dig_nid;
4690 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4691 break;
4694 if (spec->autocfg.dig_in_pin)
4695 spec->dig_in_nid = ALC880_DIGIN_NID;
4697 if (spec->kctls.list)
4698 add_mixer(spec, spec->kctls.list);
4700 add_verb(spec, alc880_volume_init_verbs);
4702 spec->num_mux_defs = 1;
4703 spec->input_mux = &spec->private_imux[0];
4705 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4707 return 1;
4710 /* additional initialization for auto-configuration model */
4711 static void alc880_auto_init(struct hda_codec *codec)
4713 struct alc_spec *spec = codec->spec;
4714 alc880_auto_init_multi_out(codec);
4715 alc880_auto_init_extra_out(codec);
4716 alc880_auto_init_analog_input(codec);
4717 if (spec->unsol_event)
4718 alc_inithook(codec);
4721 /* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4722 * one of two digital mic pins, e.g. on ALC272
4724 static void fixup_automic_adc(struct hda_codec *codec)
4726 struct alc_spec *spec = codec->spec;
4727 int i;
4729 for (i = 0; i < spec->num_adc_nids; i++) {
4730 hda_nid_t cap = spec->capsrc_nids ?
4731 spec->capsrc_nids[i] : spec->adc_nids[i];
4732 int iidx, eidx;
4734 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4735 if (iidx < 0)
4736 continue;
4737 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4738 if (eidx < 0)
4739 continue;
4740 spec->int_mic.mux_idx = iidx;
4741 spec->ext_mic.mux_idx = eidx;
4742 if (spec->capsrc_nids)
4743 spec->capsrc_nids += i;
4744 spec->adc_nids += i;
4745 spec->num_adc_nids = 1;
4746 return;
4748 snd_printd(KERN_INFO "hda_codec: %s: "
4749 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4750 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4751 spec->auto_mic = 0; /* disable auto-mic to be sure */
4754 static void set_capture_mixer(struct hda_codec *codec)
4756 struct alc_spec *spec = codec->spec;
4757 static struct snd_kcontrol_new *caps[2][3] = {
4758 { alc_capture_mixer_nosrc1,
4759 alc_capture_mixer_nosrc2,
4760 alc_capture_mixer_nosrc3 },
4761 { alc_capture_mixer1,
4762 alc_capture_mixer2,
4763 alc_capture_mixer3 },
4765 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4766 int mux;
4767 if (spec->auto_mic) {
4768 mux = 0;
4769 fixup_automic_adc(codec);
4770 } else if (spec->input_mux && spec->input_mux->num_items > 1)
4771 mux = 1;
4772 else
4773 mux = 0;
4774 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4778 #define set_beep_amp(spec, nid, idx, dir) \
4779 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4782 * OK, here we have finally the patch for ALC880
4785 static int patch_alc880(struct hda_codec *codec)
4787 struct alc_spec *spec;
4788 int board_config;
4789 int err;
4791 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4792 if (spec == NULL)
4793 return -ENOMEM;
4795 codec->spec = spec;
4797 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4798 alc880_models,
4799 alc880_cfg_tbl);
4800 if (board_config < 0) {
4801 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4802 codec->chip_name);
4803 board_config = ALC880_AUTO;
4806 if (board_config == ALC880_AUTO) {
4807 /* automatic parse from the BIOS config */
4808 err = alc880_parse_auto_config(codec);
4809 if (err < 0) {
4810 alc_free(codec);
4811 return err;
4812 } else if (!err) {
4813 printk(KERN_INFO
4814 "hda_codec: Cannot set up configuration "
4815 "from BIOS. Using 3-stack mode...\n");
4816 board_config = ALC880_3ST;
4820 err = snd_hda_attach_beep_device(codec, 0x1);
4821 if (err < 0) {
4822 alc_free(codec);
4823 return err;
4826 if (board_config != ALC880_AUTO)
4827 setup_preset(codec, &alc880_presets[board_config]);
4829 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4830 spec->stream_analog_capture = &alc880_pcm_analog_capture;
4831 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
4833 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4834 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4836 if (!spec->adc_nids && spec->input_mux) {
4837 /* check whether NID 0x07 is valid */
4838 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
4839 /* get type */
4840 wcap = get_wcaps_type(wcap);
4841 if (wcap != AC_WID_AUD_IN) {
4842 spec->adc_nids = alc880_adc_nids_alt;
4843 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
4844 } else {
4845 spec->adc_nids = alc880_adc_nids;
4846 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
4849 set_capture_mixer(codec);
4850 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4852 spec->vmaster_nid = 0x0c;
4854 codec->patch_ops = alc_patch_ops;
4855 if (board_config == ALC880_AUTO)
4856 spec->init_hook = alc880_auto_init;
4857 #ifdef CONFIG_SND_HDA_POWER_SAVE
4858 if (!spec->loopback.amplist)
4859 spec->loopback.amplist = alc880_loopbacks;
4860 #endif
4861 codec->proc_widget_hook = print_realtek_coef;
4863 return 0;
4868 * ALC260 support
4871 static hda_nid_t alc260_dac_nids[1] = {
4872 /* front */
4873 0x02,
4876 static hda_nid_t alc260_adc_nids[1] = {
4877 /* ADC0 */
4878 0x04,
4881 static hda_nid_t alc260_adc_nids_alt[1] = {
4882 /* ADC1 */
4883 0x05,
4886 /* NIDs used when simultaneous access to both ADCs makes sense. Note that
4887 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4889 static hda_nid_t alc260_dual_adc_nids[2] = {
4890 /* ADC0, ADC1 */
4891 0x04, 0x05
4894 #define ALC260_DIGOUT_NID 0x03
4895 #define ALC260_DIGIN_NID 0x06
4897 static struct hda_input_mux alc260_capture_source = {
4898 .num_items = 4,
4899 .items = {
4900 { "Mic", 0x0 },
4901 { "Front Mic", 0x1 },
4902 { "Line", 0x2 },
4903 { "CD", 0x4 },
4907 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
4908 * headphone jack and the internal CD lines since these are the only pins at
4909 * which audio can appear. For flexibility, also allow the option of
4910 * recording the mixer output on the second ADC (ADC0 doesn't have a
4911 * connection to the mixer output).
4913 static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4915 .num_items = 3,
4916 .items = {
4917 { "Mic/Line", 0x0 },
4918 { "CD", 0x4 },
4919 { "Headphone", 0x2 },
4923 .num_items = 4,
4924 .items = {
4925 { "Mic/Line", 0x0 },
4926 { "CD", 0x4 },
4927 { "Headphone", 0x2 },
4928 { "Mixer", 0x5 },
4934 /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4935 * the Fujitsu S702x, but jacks are marked differently.
4937 static struct hda_input_mux alc260_acer_capture_sources[2] = {
4939 .num_items = 4,
4940 .items = {
4941 { "Mic", 0x0 },
4942 { "Line", 0x2 },
4943 { "CD", 0x4 },
4944 { "Headphone", 0x5 },
4948 .num_items = 5,
4949 .items = {
4950 { "Mic", 0x0 },
4951 { "Line", 0x2 },
4952 { "CD", 0x4 },
4953 { "Headphone", 0x6 },
4954 { "Mixer", 0x5 },
4959 /* Maxdata Favorit 100XS */
4960 static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4962 .num_items = 2,
4963 .items = {
4964 { "Line/Mic", 0x0 },
4965 { "CD", 0x4 },
4969 .num_items = 3,
4970 .items = {
4971 { "Line/Mic", 0x0 },
4972 { "CD", 0x4 },
4973 { "Mixer", 0x5 },
4979 * This is just place-holder, so there's something for alc_build_pcms to look
4980 * at when it calculates the maximum number of channels. ALC260 has no mixer
4981 * element which allows changing the channel mode, so the verb list is
4982 * never used.
4984 static struct hda_channel_mode alc260_modes[1] = {
4985 { 2, NULL },
4989 /* Mixer combinations
4991 * basic: base_output + input + pc_beep + capture
4992 * HP: base_output + input + capture_alt
4993 * HP_3013: hp_3013 + input + capture
4994 * fujitsu: fujitsu + capture
4995 * acer: acer + capture
4998 static struct snd_kcontrol_new alc260_base_output_mixer[] = {
4999 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5000 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5001 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5002 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5003 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5004 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5005 { } /* end */
5008 static struct snd_kcontrol_new alc260_input_mixer[] = {
5009 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5010 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5011 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5012 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5014 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5015 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5016 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
5017 { } /* end */
5020 /* update HP, line and mono out pins according to the master switch */
5021 static void alc260_hp_master_update(struct hda_codec *codec,
5022 hda_nid_t hp, hda_nid_t line,
5023 hda_nid_t mono)
5025 struct alc_spec *spec = codec->spec;
5026 unsigned int val = spec->master_sw ? PIN_HP : 0;
5027 /* change HP and line-out pins */
5028 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5029 val);
5030 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5031 val);
5032 /* mono (speaker) depending on the HP jack sense */
5033 val = (val && !spec->jack_present) ? PIN_OUT : 0;
5034 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5035 val);
5038 static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5039 struct snd_ctl_elem_value *ucontrol)
5041 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5042 struct alc_spec *spec = codec->spec;
5043 *ucontrol->value.integer.value = spec->master_sw;
5044 return 0;
5047 static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5048 struct snd_ctl_elem_value *ucontrol)
5050 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5051 struct alc_spec *spec = codec->spec;
5052 int val = !!*ucontrol->value.integer.value;
5053 hda_nid_t hp, line, mono;
5055 if (val == spec->master_sw)
5056 return 0;
5057 spec->master_sw = val;
5058 hp = (kcontrol->private_value >> 16) & 0xff;
5059 line = (kcontrol->private_value >> 8) & 0xff;
5060 mono = kcontrol->private_value & 0xff;
5061 alc260_hp_master_update(codec, hp, line, mono);
5062 return 1;
5065 static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5068 .name = "Master Playback Switch",
5069 .info = snd_ctl_boolean_mono_info,
5070 .get = alc260_hp_master_sw_get,
5071 .put = alc260_hp_master_sw_put,
5072 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5074 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5075 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5076 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5077 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5078 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5079 HDA_OUTPUT),
5080 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5081 { } /* end */
5084 static struct hda_verb alc260_hp_unsol_verbs[] = {
5085 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5089 static void alc260_hp_automute(struct hda_codec *codec)
5091 struct alc_spec *spec = codec->spec;
5092 unsigned int present;
5094 present = snd_hda_codec_read(codec, 0x10, 0,
5095 AC_VERB_GET_PIN_SENSE, 0);
5096 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5097 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5100 static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5102 if ((res >> 26) == ALC880_HP_EVENT)
5103 alc260_hp_automute(codec);
5106 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
5108 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5109 .name = "Master Playback Switch",
5110 .info = snd_ctl_boolean_mono_info,
5111 .get = alc260_hp_master_sw_get,
5112 .put = alc260_hp_master_sw_put,
5113 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
5115 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5116 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5117 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5118 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5119 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5120 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5121 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5122 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
5123 { } /* end */
5126 static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5127 .ops = &snd_hda_bind_vol,
5128 .values = {
5129 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5130 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5131 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5136 static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5137 .ops = &snd_hda_bind_sw,
5138 .values = {
5139 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5140 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5145 static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5146 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5147 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5148 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5150 { } /* end */
5153 static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5154 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5158 static void alc260_hp_3013_automute(struct hda_codec *codec)
5160 struct alc_spec *spec = codec->spec;
5161 unsigned int present;
5163 present = snd_hda_codec_read(codec, 0x15, 0,
5164 AC_VERB_GET_PIN_SENSE, 0);
5165 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5166 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
5169 static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5170 unsigned int res)
5172 if ((res >> 26) == ALC880_HP_EVENT)
5173 alc260_hp_3013_automute(codec);
5176 static void alc260_hp_3012_automute(struct hda_codec *codec)
5178 unsigned int present, bits;
5180 present = snd_hda_codec_read(codec, 0x10, 0,
5181 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5183 bits = present ? 0 : PIN_OUT;
5184 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5185 bits);
5186 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5187 bits);
5188 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5189 bits);
5192 static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5193 unsigned int res)
5195 if ((res >> 26) == ALC880_HP_EVENT)
5196 alc260_hp_3012_automute(codec);
5199 /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
5200 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5202 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
5203 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5204 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
5205 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5206 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5207 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5208 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5209 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
5210 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
5211 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5212 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
5213 { } /* end */
5216 /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5217 * versions of the ALC260 don't act on requests to enable mic bias from NID
5218 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5219 * datasheet doesn't mention this restriction. At this stage it's not clear
5220 * whether this behaviour is intentional or is a hardware bug in chip
5221 * revisions available in early 2006. Therefore for now allow the
5222 * "Headphone Jack Mode" control to span all choices, but if it turns out
5223 * that the lack of mic bias for this NID is intentional we could change the
5224 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5226 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5227 * don't appear to make the mic bias available from the "line" jack, even
5228 * though the NID used for this jack (0x14) can supply it. The theory is
5229 * that perhaps Acer have included blocking capacitors between the ALC260
5230 * and the output jack. If this turns out to be the case for all such
5231 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5232 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
5234 * The C20x Tablet series have a mono internal speaker which is controlled
5235 * via the chip's Mono sum widget and pin complex, so include the necessary
5236 * controls for such models. On models without a "mono speaker" the control
5237 * won't do anything.
5239 static struct snd_kcontrol_new alc260_acer_mixer[] = {
5240 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5241 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5242 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5243 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5244 HDA_OUTPUT),
5245 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
5246 HDA_INPUT),
5247 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5248 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5249 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5250 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5251 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5252 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5253 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5254 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5255 { } /* end */
5258 /* Maxdata Favorit 100XS: one output and one input (0x12) jack
5260 static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5261 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5262 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5263 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5264 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5265 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5266 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5267 { } /* end */
5270 /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5271 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5273 static struct snd_kcontrol_new alc260_will_mixer[] = {
5274 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5275 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5276 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5277 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5278 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
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 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5283 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5284 { } /* end */
5287 /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5288 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5290 static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5291 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5292 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5294 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5295 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5296 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5297 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5298 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5299 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5300 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5301 { } /* end */
5305 * initialization verbs
5307 static struct hda_verb alc260_init_verbs[] = {
5308 /* Line In pin widget for input */
5309 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5310 /* CD pin widget for input */
5311 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5312 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5313 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5314 /* Mic2 (front panel) pin widget for input and vref at 80% */
5315 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5316 /* LINE-2 is used for line-out in rear */
5317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5318 /* select line-out */
5319 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
5320 /* LINE-OUT pin */
5321 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5322 /* enable HP */
5323 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5324 /* enable Mono */
5325 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5326 /* mute capture amp left and right */
5327 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5328 /* set connection select to line in (default select for this ADC) */
5329 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5330 /* mute capture amp left and right */
5331 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5332 /* set connection select to line in (default select for this ADC) */
5333 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
5334 /* set vol=0 Line-Out mixer amp left and right */
5335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5336 /* unmute pin widget amp left and right (no gain on this amp) */
5337 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5338 /* set vol=0 HP mixer amp left and right */
5339 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5340 /* unmute pin widget amp left and right (no gain on this amp) */
5341 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5342 /* set vol=0 Mono mixer amp left and right */
5343 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5344 /* unmute pin widget amp left and right (no gain on this amp) */
5345 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5346 /* unmute LINE-2 out pin */
5347 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5348 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5349 * Line In 2 = 0x03
5351 /* mute analog inputs */
5352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5353 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5354 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5355 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5357 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5358 /* mute Front out path */
5359 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5360 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5361 /* mute Headphone out path */
5362 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5363 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5364 /* mute Mono out path */
5365 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5366 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5370 #if 0 /* should be identical with alc260_init_verbs? */
5371 static struct hda_verb alc260_hp_init_verbs[] = {
5372 /* Headphone and output */
5373 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5374 /* mono output */
5375 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5376 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5377 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5378 /* Mic2 (front panel) pin widget for input and vref at 80% */
5379 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5380 /* Line In pin widget for input */
5381 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5382 /* Line-2 pin widget for output */
5383 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5384 /* CD pin widget for input */
5385 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5386 /* unmute amp left and right */
5387 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5388 /* set connection select to line in (default select for this ADC) */
5389 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5390 /* unmute Line-Out mixer amp left and right (volume = 0) */
5391 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5392 /* mute pin widget amp left and right (no gain on this amp) */
5393 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5394 /* unmute HP mixer amp left and right (volume = 0) */
5395 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5396 /* mute pin widget amp left and right (no gain on this amp) */
5397 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5398 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5399 * Line In 2 = 0x03
5401 /* mute analog inputs */
5402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5406 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5407 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5408 /* Unmute Front out path */
5409 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5410 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5411 /* Unmute Headphone out path */
5412 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5413 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5414 /* Unmute Mono out path */
5415 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5416 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5419 #endif
5421 static struct hda_verb alc260_hp_3013_init_verbs[] = {
5422 /* Line out and output */
5423 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5424 /* mono output */
5425 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5426 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5427 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5428 /* Mic2 (front panel) pin widget for input and vref at 80% */
5429 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5430 /* Line In pin widget for input */
5431 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5432 /* Headphone pin widget for output */
5433 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5434 /* CD pin widget for input */
5435 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5436 /* unmute amp left and right */
5437 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5438 /* set connection select to line in (default select for this ADC) */
5439 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5440 /* unmute Line-Out mixer amp left and right (volume = 0) */
5441 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5442 /* mute pin widget amp left and right (no gain on this amp) */
5443 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5444 /* unmute HP mixer amp left and right (volume = 0) */
5445 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5446 /* mute pin widget amp left and right (no gain on this amp) */
5447 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5448 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5449 * Line In 2 = 0x03
5451 /* mute analog inputs */
5452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5456 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5457 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5458 /* Unmute Front out path */
5459 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5460 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5461 /* Unmute Headphone out path */
5462 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5463 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5464 /* Unmute Mono out path */
5465 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5466 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5470 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
5471 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5472 * audio = 0x16, internal speaker = 0x10.
5474 static struct hda_verb alc260_fujitsu_init_verbs[] = {
5475 /* Disable all GPIOs */
5476 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5477 /* Internal speaker is connected to headphone pin */
5478 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5479 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5481 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5482 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5483 /* Ensure all other unused pins are disabled and muted. */
5484 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5485 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5486 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5487 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5488 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5489 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5490 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5491 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5493 /* Disable digital (SPDIF) pins */
5494 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5495 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5497 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
5498 * when acting as an output.
5500 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5502 /* Start with output sum widgets muted and their output gains at min */
5503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5505 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5507 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5509 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5510 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5511 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5513 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5514 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5515 /* Unmute Line1 pin widget output buffer since it starts as an output.
5516 * If the pin mode is changed by the user the pin mode control will
5517 * take care of enabling the pin's input/output buffers as needed.
5518 * Therefore there's no need to enable the input buffer at this
5519 * stage.
5521 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5522 /* Unmute input buffer of pin widget used for Line-in (no equiv
5523 * mixer ctrl)
5525 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5527 /* Mute capture amp left and right */
5528 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5529 /* Set ADC connection select to match default mixer setting - line
5530 * in (on mic1 pin)
5532 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5534 /* Do the same for the second ADC: mute capture input amp and
5535 * set ADC connection to line in (on mic1 pin)
5537 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5538 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5540 /* Mute all inputs to mixer widget (even unconnected ones) */
5541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5553 /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5554 * similar laptops (adapted from Fujitsu init verbs).
5556 static struct hda_verb alc260_acer_init_verbs[] = {
5557 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5558 * the headphone jack. Turn this on and rely on the standard mute
5559 * methods whenever the user wants to turn these outputs off.
5561 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5562 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5563 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5564 /* Internal speaker/Headphone jack is connected to Line-out pin */
5565 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5566 /* Internal microphone/Mic jack is connected to Mic1 pin */
5567 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5568 /* Line In jack is connected to Line1 pin */
5569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5570 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5571 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5572 /* Ensure all other unused pins are disabled and muted. */
5573 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5574 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5575 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5576 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5577 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5578 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5579 /* Disable digital (SPDIF) pins */
5580 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5581 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5583 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5584 * bus when acting as outputs.
5586 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5587 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5589 /* Start with output sum widgets muted and their output gains at min */
5590 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5591 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5592 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5593 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5594 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5595 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5596 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5597 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5598 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5600 /* Unmute Line-out pin widget amp left and right
5601 * (no equiv mixer ctrl)
5603 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5604 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5605 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5606 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5607 * inputs. If the pin mode is changed by the user the pin mode control
5608 * will take care of enabling the pin's input/output buffers as needed.
5609 * Therefore there's no need to enable the input buffer at this
5610 * stage.
5612 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5613 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5615 /* Mute capture amp left and right */
5616 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5617 /* Set ADC connection select to match default mixer setting - mic
5618 * (on mic1 pin)
5620 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5622 /* Do similar with the second ADC: mute capture input amp and
5623 * set ADC connection to mic to match ALSA's default state.
5625 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5626 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5628 /* Mute all inputs to mixer widget (even unconnected ones) */
5629 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5630 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5641 /* Initialisation sequence for Maxdata Favorit 100XS
5642 * (adapted from Acer init verbs).
5644 static struct hda_verb alc260_favorit100_init_verbs[] = {
5645 /* GPIO 0 enables the output jack.
5646 * Turn this on and rely on the standard mute
5647 * methods whenever the user wants to turn these outputs off.
5649 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5650 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5651 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5652 /* Line/Mic input jack is connected to Mic1 pin */
5653 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5654 /* Ensure all other unused pins are disabled and muted. */
5655 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5656 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5657 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5658 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5659 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5660 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5661 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5662 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5663 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5665 /* Disable digital (SPDIF) pins */
5666 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5667 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5669 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5670 * bus when acting as outputs.
5672 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5673 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5675 /* Start with output sum widgets muted and their output gains at min */
5676 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5677 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5678 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5679 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5680 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5681 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5682 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5683 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5684 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5686 /* Unmute Line-out pin widget amp left and right
5687 * (no equiv mixer ctrl)
5689 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5690 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5691 * inputs. If the pin mode is changed by the user the pin mode control
5692 * will take care of enabling the pin's input/output buffers as needed.
5693 * Therefore there's no need to enable the input buffer at this
5694 * stage.
5696 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5698 /* Mute capture amp left and right */
5699 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5700 /* Set ADC connection select to match default mixer setting - mic
5701 * (on mic1 pin)
5703 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5705 /* Do similar with the second ADC: mute capture input amp and
5706 * set ADC connection to mic to match ALSA's default state.
5708 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5709 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5711 /* Mute all inputs to mixer widget (even unconnected ones) */
5712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5717 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5718 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5719 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5724 static struct hda_verb alc260_will_verbs[] = {
5725 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5726 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5727 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5728 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5729 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5730 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5734 static struct hda_verb alc260_replacer_672v_verbs[] = {
5735 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5736 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5737 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5739 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5740 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5741 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5743 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5747 /* toggle speaker-output according to the hp-jack state */
5748 static void alc260_replacer_672v_automute(struct hda_codec *codec)
5750 unsigned int present;
5752 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5753 present = snd_hda_codec_read(codec, 0x0f, 0,
5754 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5755 if (present) {
5756 snd_hda_codec_write_cache(codec, 0x01, 0,
5757 AC_VERB_SET_GPIO_DATA, 1);
5758 snd_hda_codec_write_cache(codec, 0x0f, 0,
5759 AC_VERB_SET_PIN_WIDGET_CONTROL,
5760 PIN_HP);
5761 } else {
5762 snd_hda_codec_write_cache(codec, 0x01, 0,
5763 AC_VERB_SET_GPIO_DATA, 0);
5764 snd_hda_codec_write_cache(codec, 0x0f, 0,
5765 AC_VERB_SET_PIN_WIDGET_CONTROL,
5766 PIN_OUT);
5770 static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5771 unsigned int res)
5773 if ((res >> 26) == ALC880_HP_EVENT)
5774 alc260_replacer_672v_automute(codec);
5777 static struct hda_verb alc260_hp_dc7600_verbs[] = {
5778 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5780 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5781 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5782 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5783 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5784 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5785 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5786 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5787 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5791 /* Test configuration for debugging, modelled after the ALC880 test
5792 * configuration.
5794 #ifdef CONFIG_SND_DEBUG
5795 static hda_nid_t alc260_test_dac_nids[1] = {
5796 0x02,
5798 static hda_nid_t alc260_test_adc_nids[2] = {
5799 0x04, 0x05,
5801 /* For testing the ALC260, each input MUX needs its own definition since
5802 * the signal assignments are different. This assumes that the first ADC
5803 * is NID 0x04.
5805 static struct hda_input_mux alc260_test_capture_sources[2] = {
5807 .num_items = 7,
5808 .items = {
5809 { "MIC1 pin", 0x0 },
5810 { "MIC2 pin", 0x1 },
5811 { "LINE1 pin", 0x2 },
5812 { "LINE2 pin", 0x3 },
5813 { "CD pin", 0x4 },
5814 { "LINE-OUT pin", 0x5 },
5815 { "HP-OUT pin", 0x6 },
5819 .num_items = 8,
5820 .items = {
5821 { "MIC1 pin", 0x0 },
5822 { "MIC2 pin", 0x1 },
5823 { "LINE1 pin", 0x2 },
5824 { "LINE2 pin", 0x3 },
5825 { "CD pin", 0x4 },
5826 { "Mixer", 0x5 },
5827 { "LINE-OUT pin", 0x6 },
5828 { "HP-OUT pin", 0x7 },
5832 static struct snd_kcontrol_new alc260_test_mixer[] = {
5833 /* Output driver widgets */
5834 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5835 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5836 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5837 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5838 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5839 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5841 /* Modes for retasking pin widgets
5842 * Note: the ALC260 doesn't seem to act on requests to enable mic
5843 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5844 * mention this restriction. At this stage it's not clear whether
5845 * this behaviour is intentional or is a hardware bug in chip
5846 * revisions available at least up until early 2006. Therefore for
5847 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5848 * choices, but if it turns out that the lack of mic bias for these
5849 * NIDs is intentional we could change their modes from
5850 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5852 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5853 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5854 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5855 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5856 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5857 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5859 /* Loopback mixer controls */
5860 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5861 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5862 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5863 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5864 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5865 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5866 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5867 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5868 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5869 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5870 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5871 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5872 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5873 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
5875 /* Controls for GPIO pins, assuming they are configured as outputs */
5876 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5877 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5878 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5879 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5881 /* Switches to allow the digital IO pins to be enabled. The datasheet
5882 * is ambigious as to which NID is which; testing on laptops which
5883 * make this output available should provide clarification.
5885 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5886 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5888 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5889 * this output to turn on an external amplifier.
5891 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5892 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5894 { } /* end */
5896 static struct hda_verb alc260_test_init_verbs[] = {
5897 /* Enable all GPIOs as outputs with an initial value of 0 */
5898 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5899 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5900 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5902 /* Enable retasking pins as output, initially without power amp */
5903 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5904 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5905 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5906 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5907 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5908 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5910 /* Disable digital (SPDIF) pins initially, but users can enable
5911 * them via a mixer switch. In the case of SPDIF-out, this initverb
5912 * payload also sets the generation to 0, output to be in "consumer"
5913 * PCM format, copyright asserted, no pre-emphasis and no validity
5914 * control.
5916 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5917 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5919 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
5920 * OUT1 sum bus when acting as an output.
5922 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5923 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5924 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5925 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5927 /* Start with output sum widgets muted and their output gains at min */
5928 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5929 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5930 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5931 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5932 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5933 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5934 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5935 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5936 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5938 /* Unmute retasking pin widget output buffers since the default
5939 * state appears to be output. As the pin mode is changed by the
5940 * user the pin mode control will take care of enabling the pin's
5941 * input/output buffers as needed.
5943 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5944 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5945 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5946 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5947 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5948 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5949 /* Also unmute the mono-out pin widget */
5950 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5952 /* Mute capture amp left and right */
5953 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5954 /* Set ADC connection select to match default mixer setting (mic1
5955 * pin)
5957 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5959 /* Do the same for the second ADC: mute capture input amp and
5960 * set ADC connection to mic1 pin
5962 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5963 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5965 /* Mute all inputs to mixer widget (even unconnected ones) */
5966 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5977 #endif
5979 #define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5980 #define alc260_pcm_analog_capture alc880_pcm_analog_capture
5982 #define alc260_pcm_digital_playback alc880_pcm_digital_playback
5983 #define alc260_pcm_digital_capture alc880_pcm_digital_capture
5986 * for BIOS auto-configuration
5989 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
5990 const char *pfx, int *vol_bits)
5992 hda_nid_t nid_vol;
5993 unsigned long vol_val, sw_val;
5994 int err;
5996 if (nid >= 0x0f && nid < 0x11) {
5997 nid_vol = nid - 0x7;
5998 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5999 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6000 } else if (nid == 0x11) {
6001 nid_vol = nid - 0x7;
6002 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6003 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6004 } else if (nid >= 0x12 && nid <= 0x15) {
6005 nid_vol = 0x08;
6006 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6007 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6008 } else
6009 return 0; /* N/A */
6011 if (!(*vol_bits & (1 << nid_vol))) {
6012 /* first control for the volume widget */
6013 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
6014 if (err < 0)
6015 return err;
6016 *vol_bits |= (1 << nid_vol);
6018 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
6019 if (err < 0)
6020 return err;
6021 return 1;
6024 /* add playback controls from the parsed DAC table */
6025 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6026 const struct auto_pin_cfg *cfg)
6028 hda_nid_t nid;
6029 int err;
6030 int vols = 0;
6032 spec->multiout.num_dacs = 1;
6033 spec->multiout.dac_nids = spec->private_dac_nids;
6034 spec->multiout.dac_nids[0] = 0x02;
6036 nid = cfg->line_out_pins[0];
6037 if (nid) {
6038 const char *pfx;
6039 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6040 pfx = "Master";
6041 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6042 pfx = "Speaker";
6043 else
6044 pfx = "Front";
6045 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
6046 if (err < 0)
6047 return err;
6050 nid = cfg->speaker_pins[0];
6051 if (nid) {
6052 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
6053 if (err < 0)
6054 return err;
6057 nid = cfg->hp_pins[0];
6058 if (nid) {
6059 err = alc260_add_playback_controls(spec, nid, "Headphone",
6060 &vols);
6061 if (err < 0)
6062 return err;
6064 return 0;
6067 /* create playback/capture controls for input pins */
6068 static int alc260_auto_create_input_ctls(struct hda_codec *codec,
6069 const struct auto_pin_cfg *cfg)
6071 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
6074 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6075 hda_nid_t nid, int pin_type,
6076 int sel_idx)
6078 alc_set_pin_output(codec, nid, pin_type);
6079 /* need the manual connection? */
6080 if (nid >= 0x12) {
6081 int idx = nid - 0x12;
6082 snd_hda_codec_write(codec, idx + 0x0b, 0,
6083 AC_VERB_SET_CONNECT_SEL, sel_idx);
6087 static void alc260_auto_init_multi_out(struct hda_codec *codec)
6089 struct alc_spec *spec = codec->spec;
6090 hda_nid_t nid;
6092 nid = spec->autocfg.line_out_pins[0];
6093 if (nid) {
6094 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6095 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6098 nid = spec->autocfg.speaker_pins[0];
6099 if (nid)
6100 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6102 nid = spec->autocfg.hp_pins[0];
6103 if (nid)
6104 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
6107 #define ALC260_PIN_CD_NID 0x16
6108 static void alc260_auto_init_analog_input(struct hda_codec *codec)
6110 struct alc_spec *spec = codec->spec;
6111 int i;
6113 for (i = 0; i < AUTO_PIN_LAST; i++) {
6114 hda_nid_t nid = spec->autocfg.input_pins[i];
6115 if (nid >= 0x12) {
6116 alc_set_input_pin(codec, nid, i);
6117 if (nid != ALC260_PIN_CD_NID &&
6118 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
6119 snd_hda_codec_write(codec, nid, 0,
6120 AC_VERB_SET_AMP_GAIN_MUTE,
6121 AMP_OUT_MUTE);
6127 * generic initialization of ADC, input mixers and output mixers
6129 static struct hda_verb alc260_volume_init_verbs[] = {
6131 * Unmute ADC0-1 and set the default input to mic-in
6133 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6134 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6135 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6136 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6138 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6139 * mixer widget
6140 * Note: PASD motherboards uses the Line In 2 as the input for
6141 * front panel mic (mic 2)
6143 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
6144 /* mute analog inputs */
6145 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6152 * Set up output mixers (0x08 - 0x0a)
6154 /* set vol=0 to output mixers */
6155 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6156 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6157 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6158 /* set up input amps for analog loopback */
6159 /* Amp Indices: DAC = 0, mixer = 1 */
6160 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6161 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6162 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6163 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6164 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6165 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6170 static int alc260_parse_auto_config(struct hda_codec *codec)
6172 struct alc_spec *spec = codec->spec;
6173 int err;
6174 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6176 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6177 alc260_ignore);
6178 if (err < 0)
6179 return err;
6180 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6181 if (err < 0)
6182 return err;
6183 if (!spec->kctls.list)
6184 return 0; /* can't find valid BIOS pin config */
6185 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
6186 if (err < 0)
6187 return err;
6189 spec->multiout.max_channels = 2;
6191 if (spec->autocfg.dig_outs)
6192 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
6193 if (spec->kctls.list)
6194 add_mixer(spec, spec->kctls.list);
6196 add_verb(spec, alc260_volume_init_verbs);
6198 spec->num_mux_defs = 1;
6199 spec->input_mux = &spec->private_imux[0];
6201 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6203 return 1;
6206 /* additional initialization for auto-configuration model */
6207 static void alc260_auto_init(struct hda_codec *codec)
6209 struct alc_spec *spec = codec->spec;
6210 alc260_auto_init_multi_out(codec);
6211 alc260_auto_init_analog_input(codec);
6212 if (spec->unsol_event)
6213 alc_inithook(codec);
6216 #ifdef CONFIG_SND_HDA_POWER_SAVE
6217 static struct hda_amp_list alc260_loopbacks[] = {
6218 { 0x07, HDA_INPUT, 0 },
6219 { 0x07, HDA_INPUT, 1 },
6220 { 0x07, HDA_INPUT, 2 },
6221 { 0x07, HDA_INPUT, 3 },
6222 { 0x07, HDA_INPUT, 4 },
6223 { } /* end */
6225 #endif
6228 * ALC260 configurations
6230 static const char *alc260_models[ALC260_MODEL_LAST] = {
6231 [ALC260_BASIC] = "basic",
6232 [ALC260_HP] = "hp",
6233 [ALC260_HP_3013] = "hp-3013",
6234 [ALC260_HP_DC7600] = "hp-dc7600",
6235 [ALC260_FUJITSU_S702X] = "fujitsu",
6236 [ALC260_ACER] = "acer",
6237 [ALC260_WILL] = "will",
6238 [ALC260_REPLACER_672V] = "replacer",
6239 [ALC260_FAVORIT100] = "favorit100",
6240 #ifdef CONFIG_SND_DEBUG
6241 [ALC260_TEST] = "test",
6242 #endif
6243 [ALC260_AUTO] = "auto",
6246 static struct snd_pci_quirk alc260_cfg_tbl[] = {
6247 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
6248 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
6249 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
6250 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
6251 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
6252 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
6253 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
6254 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
6255 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6256 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6257 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6258 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6259 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6260 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6261 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6262 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6263 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
6264 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
6265 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
6269 static struct alc_config_preset alc260_presets[] = {
6270 [ALC260_BASIC] = {
6271 .mixers = { alc260_base_output_mixer,
6272 alc260_input_mixer },
6273 .init_verbs = { alc260_init_verbs },
6274 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6275 .dac_nids = alc260_dac_nids,
6276 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6277 .adc_nids = alc260_adc_nids,
6278 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6279 .channel_mode = alc260_modes,
6280 .input_mux = &alc260_capture_source,
6282 [ALC260_HP] = {
6283 .mixers = { alc260_hp_output_mixer,
6284 alc260_input_mixer },
6285 .init_verbs = { alc260_init_verbs,
6286 alc260_hp_unsol_verbs },
6287 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6288 .dac_nids = alc260_dac_nids,
6289 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6290 .adc_nids = alc260_adc_nids_alt,
6291 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6292 .channel_mode = alc260_modes,
6293 .input_mux = &alc260_capture_source,
6294 .unsol_event = alc260_hp_unsol_event,
6295 .init_hook = alc260_hp_automute,
6297 [ALC260_HP_DC7600] = {
6298 .mixers = { alc260_hp_dc7600_mixer,
6299 alc260_input_mixer },
6300 .init_verbs = { alc260_init_verbs,
6301 alc260_hp_dc7600_verbs },
6302 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6303 .dac_nids = alc260_dac_nids,
6304 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6305 .adc_nids = alc260_adc_nids_alt,
6306 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6307 .channel_mode = alc260_modes,
6308 .input_mux = &alc260_capture_source,
6309 .unsol_event = alc260_hp_3012_unsol_event,
6310 .init_hook = alc260_hp_3012_automute,
6312 [ALC260_HP_3013] = {
6313 .mixers = { alc260_hp_3013_mixer,
6314 alc260_input_mixer },
6315 .init_verbs = { alc260_hp_3013_init_verbs,
6316 alc260_hp_3013_unsol_verbs },
6317 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6318 .dac_nids = alc260_dac_nids,
6319 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6320 .adc_nids = alc260_adc_nids_alt,
6321 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6322 .channel_mode = alc260_modes,
6323 .input_mux = &alc260_capture_source,
6324 .unsol_event = alc260_hp_3013_unsol_event,
6325 .init_hook = alc260_hp_3013_automute,
6327 [ALC260_FUJITSU_S702X] = {
6328 .mixers = { alc260_fujitsu_mixer },
6329 .init_verbs = { alc260_fujitsu_init_verbs },
6330 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6331 .dac_nids = alc260_dac_nids,
6332 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6333 .adc_nids = alc260_dual_adc_nids,
6334 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6335 .channel_mode = alc260_modes,
6336 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6337 .input_mux = alc260_fujitsu_capture_sources,
6339 [ALC260_ACER] = {
6340 .mixers = { alc260_acer_mixer },
6341 .init_verbs = { alc260_acer_init_verbs },
6342 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6343 .dac_nids = alc260_dac_nids,
6344 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6345 .adc_nids = alc260_dual_adc_nids,
6346 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6347 .channel_mode = alc260_modes,
6348 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6349 .input_mux = alc260_acer_capture_sources,
6351 [ALC260_FAVORIT100] = {
6352 .mixers = { alc260_favorit100_mixer },
6353 .init_verbs = { alc260_favorit100_init_verbs },
6354 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6355 .dac_nids = alc260_dac_nids,
6356 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6357 .adc_nids = alc260_dual_adc_nids,
6358 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6359 .channel_mode = alc260_modes,
6360 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6361 .input_mux = alc260_favorit100_capture_sources,
6363 [ALC260_WILL] = {
6364 .mixers = { alc260_will_mixer },
6365 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6366 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6367 .dac_nids = alc260_dac_nids,
6368 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6369 .adc_nids = alc260_adc_nids,
6370 .dig_out_nid = ALC260_DIGOUT_NID,
6371 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6372 .channel_mode = alc260_modes,
6373 .input_mux = &alc260_capture_source,
6375 [ALC260_REPLACER_672V] = {
6376 .mixers = { alc260_replacer_672v_mixer },
6377 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6378 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6379 .dac_nids = alc260_dac_nids,
6380 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6381 .adc_nids = alc260_adc_nids,
6382 .dig_out_nid = ALC260_DIGOUT_NID,
6383 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6384 .channel_mode = alc260_modes,
6385 .input_mux = &alc260_capture_source,
6386 .unsol_event = alc260_replacer_672v_unsol_event,
6387 .init_hook = alc260_replacer_672v_automute,
6389 #ifdef CONFIG_SND_DEBUG
6390 [ALC260_TEST] = {
6391 .mixers = { alc260_test_mixer },
6392 .init_verbs = { alc260_test_init_verbs },
6393 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6394 .dac_nids = alc260_test_dac_nids,
6395 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6396 .adc_nids = alc260_test_adc_nids,
6397 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6398 .channel_mode = alc260_modes,
6399 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6400 .input_mux = alc260_test_capture_sources,
6402 #endif
6405 static int patch_alc260(struct hda_codec *codec)
6407 struct alc_spec *spec;
6408 int err, board_config;
6410 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6411 if (spec == NULL)
6412 return -ENOMEM;
6414 codec->spec = spec;
6416 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6417 alc260_models,
6418 alc260_cfg_tbl);
6419 if (board_config < 0) {
6420 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6421 codec->chip_name);
6422 board_config = ALC260_AUTO;
6425 if (board_config == ALC260_AUTO) {
6426 /* automatic parse from the BIOS config */
6427 err = alc260_parse_auto_config(codec);
6428 if (err < 0) {
6429 alc_free(codec);
6430 return err;
6431 } else if (!err) {
6432 printk(KERN_INFO
6433 "hda_codec: Cannot set up configuration "
6434 "from BIOS. Using base mode...\n");
6435 board_config = ALC260_BASIC;
6439 err = snd_hda_attach_beep_device(codec, 0x1);
6440 if (err < 0) {
6441 alc_free(codec);
6442 return err;
6445 if (board_config != ALC260_AUTO)
6446 setup_preset(codec, &alc260_presets[board_config]);
6448 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6449 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6451 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6452 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6454 if (!spec->adc_nids && spec->input_mux) {
6455 /* check whether NID 0x04 is valid */
6456 unsigned int wcap = get_wcaps(codec, 0x04);
6457 wcap = get_wcaps_type(wcap);
6458 /* get type */
6459 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6460 spec->adc_nids = alc260_adc_nids_alt;
6461 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6462 } else {
6463 spec->adc_nids = alc260_adc_nids;
6464 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6467 set_capture_mixer(codec);
6468 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
6470 spec->vmaster_nid = 0x08;
6472 codec->patch_ops = alc_patch_ops;
6473 if (board_config == ALC260_AUTO)
6474 spec->init_hook = alc260_auto_init;
6475 #ifdef CONFIG_SND_HDA_POWER_SAVE
6476 if (!spec->loopback.amplist)
6477 spec->loopback.amplist = alc260_loopbacks;
6478 #endif
6479 codec->proc_widget_hook = print_realtek_coef;
6481 return 0;
6486 * ALC882/883/885/888/889 support
6488 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6489 * configuration. Each pin widget can choose any input DACs and a mixer.
6490 * Each ADC is connected from a mixer of all inputs. This makes possible
6491 * 6-channel independent captures.
6493 * In addition, an independent DAC for the multi-playback (not used in this
6494 * driver yet).
6496 #define ALC882_DIGOUT_NID 0x06
6497 #define ALC882_DIGIN_NID 0x0a
6498 #define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6499 #define ALC883_DIGIN_NID ALC882_DIGIN_NID
6500 #define ALC1200_DIGOUT_NID 0x10
6503 static struct hda_channel_mode alc882_ch_modes[1] = {
6504 { 8, NULL }
6507 /* DACs */
6508 static hda_nid_t alc882_dac_nids[4] = {
6509 /* front, rear, clfe, rear_surr */
6510 0x02, 0x03, 0x04, 0x05
6512 #define alc883_dac_nids alc882_dac_nids
6514 /* ADCs */
6515 #define alc882_adc_nids alc880_adc_nids
6516 #define alc882_adc_nids_alt alc880_adc_nids_alt
6517 #define alc883_adc_nids alc882_adc_nids_alt
6518 static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6519 static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6520 #define alc889_adc_nids alc880_adc_nids
6522 static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6523 static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
6524 #define alc883_capsrc_nids alc882_capsrc_nids_alt
6525 static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6526 #define alc889_capsrc_nids alc882_capsrc_nids
6528 /* input MUX */
6529 /* FIXME: should be a matrix-type input source selection */
6531 static struct hda_input_mux alc882_capture_source = {
6532 .num_items = 4,
6533 .items = {
6534 { "Mic", 0x0 },
6535 { "Front Mic", 0x1 },
6536 { "Line", 0x2 },
6537 { "CD", 0x4 },
6541 #define alc883_capture_source alc882_capture_source
6543 static struct hda_input_mux alc889_capture_source = {
6544 .num_items = 3,
6545 .items = {
6546 { "Front Mic", 0x0 },
6547 { "Mic", 0x3 },
6548 { "Line", 0x2 },
6552 static struct hda_input_mux mb5_capture_source = {
6553 .num_items = 3,
6554 .items = {
6555 { "Mic", 0x1 },
6556 { "Line", 0x2 },
6557 { "CD", 0x4 },
6561 static struct hda_input_mux alc883_3stack_6ch_intel = {
6562 .num_items = 4,
6563 .items = {
6564 { "Mic", 0x1 },
6565 { "Front Mic", 0x0 },
6566 { "Line", 0x2 },
6567 { "CD", 0x4 },
6571 static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6572 .num_items = 2,
6573 .items = {
6574 { "Mic", 0x1 },
6575 { "Line", 0x2 },
6579 static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6580 .num_items = 4,
6581 .items = {
6582 { "Mic", 0x0 },
6583 { "iMic", 0x1 },
6584 { "Line", 0x2 },
6585 { "CD", 0x4 },
6589 static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6590 .num_items = 2,
6591 .items = {
6592 { "Mic", 0x0 },
6593 { "Int Mic", 0x1 },
6597 static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6598 .num_items = 3,
6599 .items = {
6600 { "Mic", 0x0 },
6601 { "Front Mic", 0x1 },
6602 { "Line", 0x4 },
6606 static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6607 .num_items = 2,
6608 .items = {
6609 { "Mic", 0x0 },
6610 { "Line", 0x2 },
6614 static struct hda_input_mux alc889A_mb31_capture_source = {
6615 .num_items = 2,
6616 .items = {
6617 { "Mic", 0x0 },
6618 /* Front Mic (0x01) unused */
6619 { "Line", 0x2 },
6620 /* Line 2 (0x03) unused */
6621 /* CD (0x04) unsused? */
6626 * 2ch mode
6628 static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6629 { 2, NULL }
6633 * 2ch mode
6635 static struct hda_verb alc882_3ST_ch2_init[] = {
6636 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6637 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6638 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6639 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6640 { } /* end */
6644 * 4ch mode
6646 static struct hda_verb alc882_3ST_ch4_init[] = {
6647 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6648 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6649 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6650 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6651 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6652 { } /* end */
6656 * 6ch mode
6658 static struct hda_verb alc882_3ST_ch6_init[] = {
6659 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6660 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6661 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6662 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6663 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6664 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6665 { } /* end */
6668 static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
6669 { 2, alc882_3ST_ch2_init },
6670 { 4, alc882_3ST_ch4_init },
6671 { 6, alc882_3ST_ch6_init },
6674 #define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6677 * 2ch mode
6679 static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6680 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6681 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6682 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6683 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6684 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6685 { } /* end */
6689 * 4ch mode
6691 static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6692 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6693 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6694 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6695 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6696 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6697 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6698 { } /* end */
6702 * 6ch mode
6704 static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6705 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6706 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6707 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6708 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6709 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6710 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6711 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6712 { } /* end */
6715 static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6716 { 2, alc883_3ST_ch2_clevo_init },
6717 { 4, alc883_3ST_ch4_clevo_init },
6718 { 6, alc883_3ST_ch6_clevo_init },
6723 * 6ch mode
6725 static struct hda_verb alc882_sixstack_ch6_init[] = {
6726 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6727 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6728 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6729 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6730 { } /* end */
6734 * 8ch mode
6736 static struct hda_verb alc882_sixstack_ch8_init[] = {
6737 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6738 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6739 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6740 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6741 { } /* end */
6744 static struct hda_channel_mode alc882_sixstack_modes[2] = {
6745 { 6, alc882_sixstack_ch6_init },
6746 { 8, alc882_sixstack_ch8_init },
6750 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
6754 * 2ch mode
6756 static struct hda_verb alc885_mbp_ch2_init[] = {
6757 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6758 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6759 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6760 { } /* end */
6764 * 4ch mode
6766 static struct hda_verb alc885_mbp_ch4_init[] = {
6767 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6768 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6769 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6770 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6771 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6772 { } /* end */
6775 static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
6776 { 2, alc885_mbp_ch2_init },
6777 { 4, alc885_mbp_ch4_init },
6781 * 2ch
6782 * Speakers/Woofer/HP = Front
6783 * LineIn = Input
6785 static struct hda_verb alc885_mb5_ch2_init[] = {
6786 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6787 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6788 { } /* end */
6792 * 6ch mode
6793 * Speakers/HP = Front
6794 * Woofer = LFE
6795 * LineIn = Surround
6797 static struct hda_verb alc885_mb5_ch6_init[] = {
6798 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6801 { } /* end */
6804 static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6805 { 2, alc885_mb5_ch2_init },
6806 { 6, alc885_mb5_ch6_init },
6811 * 2ch mode
6813 static struct hda_verb alc883_4ST_ch2_init[] = {
6814 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6815 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6816 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6817 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6818 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6819 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6820 { } /* end */
6824 * 4ch mode
6826 static struct hda_verb alc883_4ST_ch4_init[] = {
6827 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6828 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6829 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6830 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6831 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6832 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6833 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6834 { } /* end */
6838 * 6ch mode
6840 static struct hda_verb alc883_4ST_ch6_init[] = {
6841 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6842 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
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 */
6853 * 8ch mode
6855 static struct hda_verb alc883_4ST_ch8_init[] = {
6856 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6857 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6858 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6859 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6860 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6861 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6862 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6863 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6864 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6865 { } /* end */
6868 static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6869 { 2, alc883_4ST_ch2_init },
6870 { 4, alc883_4ST_ch4_init },
6871 { 6, alc883_4ST_ch6_init },
6872 { 8, alc883_4ST_ch8_init },
6877 * 2ch mode
6879 static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6880 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6881 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6882 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6883 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6884 { } /* end */
6888 * 4ch mode
6890 static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6891 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6892 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6893 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6894 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6895 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6896 { } /* end */
6900 * 6ch mode
6902 static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6903 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6904 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6905 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6906 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6907 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6908 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6909 { } /* end */
6912 static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6913 { 2, alc883_3ST_ch2_intel_init },
6914 { 4, alc883_3ST_ch4_intel_init },
6915 { 6, alc883_3ST_ch6_intel_init },
6919 * 2ch mode
6921 static struct hda_verb alc889_ch2_intel_init[] = {
6922 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6923 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6924 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6925 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6926 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6927 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6928 { } /* end */
6932 * 6ch mode
6934 static struct hda_verb alc889_ch6_intel_init[] = {
6935 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6936 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6937 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6938 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6939 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6940 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6941 { } /* end */
6945 * 8ch mode
6947 static struct hda_verb alc889_ch8_intel_init[] = {
6948 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6949 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6950 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6951 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6952 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
6953 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6954 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6955 { } /* end */
6958 static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6959 { 2, alc889_ch2_intel_init },
6960 { 6, alc889_ch6_intel_init },
6961 { 8, alc889_ch8_intel_init },
6965 * 6ch mode
6967 static struct hda_verb alc883_sixstack_ch6_init[] = {
6968 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6969 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6970 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6971 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6972 { } /* end */
6976 * 8ch mode
6978 static struct hda_verb alc883_sixstack_ch8_init[] = {
6979 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6980 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6981 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6982 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6983 { } /* end */
6986 static struct hda_channel_mode alc883_sixstack_modes[2] = {
6987 { 6, alc883_sixstack_ch6_init },
6988 { 8, alc883_sixstack_ch8_init },
6992 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6993 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6995 static struct snd_kcontrol_new alc882_base_mixer[] = {
6996 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6997 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6998 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6999 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7000 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7001 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7002 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7003 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7004 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7005 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7007 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7008 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7009 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7010 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7011 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7012 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7013 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7014 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7015 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7016 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7017 { } /* end */
7020 static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
7021 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7022 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7023 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7024 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7025 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7026 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7027 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7028 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7029 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7030 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
7031 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7032 { } /* end */
7035 static struct snd_kcontrol_new alc885_mb5_mixer[] = {
7036 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7037 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7038 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7039 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7040 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7041 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7042 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7043 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
7044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7045 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7047 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7048 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7049 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7050 { } /* end */
7053 static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7054 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7055 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7056 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7057 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7058 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7059 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7061 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7062 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7063 { } /* end */
7066 static struct snd_kcontrol_new alc882_targa_mixer[] = {
7067 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7068 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7069 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7072 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7073 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7074 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7075 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7076 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7077 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7078 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7079 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7080 { } /* end */
7083 /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7084 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7086 static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7087 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7088 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7089 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7090 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 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("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7096 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7097 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7098 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7099 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7100 { } /* end */
7103 static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7104 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7105 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7106 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7107 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7108 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7109 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7110 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7112 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7114 { } /* end */
7117 static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7120 .name = "Channel Mode",
7121 .info = alc_ch_mode_info,
7122 .get = alc_ch_mode_get,
7123 .put = alc_ch_mode_put,
7125 { } /* end */
7128 static struct hda_verb alc882_base_init_verbs[] = {
7129 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7133 /* Rear mixer */
7134 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7136 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7137 /* CLFE mixer */
7138 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7141 /* Side mixer */
7142 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7144 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7146 /* mute analog input loopbacks */
7147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7148 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7149 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7150 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7151 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7153 /* Front Pin: output 0 (0x0c) */
7154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7156 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7157 /* Rear Pin: output 1 (0x0d) */
7158 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7159 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7160 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7161 /* CLFE Pin: output 2 (0x0e) */
7162 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7163 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7164 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7165 /* Side Pin: output 3 (0x0f) */
7166 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7167 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7168 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7169 /* Mic (rear) pin: input vref at 80% */
7170 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7171 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7172 /* Front Mic pin: input vref at 80% */
7173 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7174 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7175 /* Line In pin: input */
7176 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7178 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7179 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7180 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7181 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7182 /* CD pin widget for input */
7183 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7185 /* FIXME: use matrix-type input source selection */
7186 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7187 /* Input mixer2 */
7188 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7192 /* Input mixer3 */
7193 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7197 /* ADC2: mute amp left and right */
7198 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7199 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7200 /* ADC3: mute amp left and right */
7201 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7202 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7207 static struct hda_verb alc882_adc1_init_verbs[] = {
7208 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7211 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7213 /* ADC1: mute amp left and right */
7214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7215 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7219 static struct hda_verb alc882_eapd_verbs[] = {
7220 /* change to EAPD mode */
7221 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7222 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
7226 static struct hda_verb alc889_eapd_verbs[] = {
7227 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7228 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7232 static struct hda_verb alc_hp15_unsol_verbs[] = {
7233 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7238 static struct hda_verb alc885_init_verbs[] = {
7239 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7243 /* Rear mixer */
7244 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7245 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7246 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7247 /* CLFE mixer */
7248 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7251 /* Side mixer */
7252 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7256 /* mute analog input loopbacks */
7257 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7258 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7261 /* Front HP Pin: output 0 (0x0c) */
7262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7263 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7264 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7265 /* Front Pin: output 0 (0x0c) */
7266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7267 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7268 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7269 /* Rear Pin: output 1 (0x0d) */
7270 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7272 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7273 /* CLFE Pin: output 2 (0x0e) */
7274 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7275 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7276 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7277 /* Side Pin: output 3 (0x0f) */
7278 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7279 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7280 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7281 /* Mic (rear) pin: input vref at 80% */
7282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7283 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7284 /* Front Mic pin: input vref at 80% */
7285 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7286 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7287 /* Line In pin: input */
7288 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7289 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7291 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7292 /* Input mixer1 */
7293 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7294 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7296 /* Input mixer2 */
7297 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7298 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7299 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7300 /* Input mixer3 */
7301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7303 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7304 /* ADC2: mute amp left and right */
7305 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7306 /* ADC3: mute amp left and right */
7307 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7312 static struct hda_verb alc885_init_input_verbs[] = {
7313 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7320 /* Unmute Selector 24h and set the default input to front mic */
7321 static struct hda_verb alc889_init_input_verbs[] = {
7322 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7328 #define alc883_init_verbs alc882_base_init_verbs
7330 /* Mac Pro test */
7331 static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7332 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7333 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7334 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7335 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7336 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
7337 /* FIXME: this looks suspicious...
7338 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7339 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
7341 { } /* end */
7344 static struct hda_verb alc882_macpro_init_verbs[] = {
7345 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7346 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7347 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7348 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7349 /* Front Pin: output 0 (0x0c) */
7350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7351 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7352 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7353 /* Front Mic pin: input vref at 80% */
7354 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7355 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7356 /* Speaker: output */
7357 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7358 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7359 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7360 /* Headphone output (output 0 - 0x0c) */
7361 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7362 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7363 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7365 /* FIXME: use matrix-type input source selection */
7366 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7367 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7371 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7372 /* Input mixer2 */
7373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7375 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7376 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7377 /* Input mixer3 */
7378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7380 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7381 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7382 /* ADC1: mute amp left and right */
7383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7384 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7385 /* ADC2: mute amp left and right */
7386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7387 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7388 /* ADC3: mute amp left and right */
7389 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7390 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7395 /* Macbook 5,1 */
7396 static struct hda_verb alc885_mb5_init_verbs[] = {
7397 /* DACs */
7398 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7399 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7400 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7401 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7402 /* Front mixer */
7403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7405 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7406 /* Surround mixer */
7407 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7410 /* LFE mixer */
7411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7412 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7414 /* HP mixer */
7415 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7417 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7418 /* Front Pin (0x0c) */
7419 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7420 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7421 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7422 /* LFE Pin (0x0e) */
7423 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7424 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7425 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7426 /* HP Pin (0x0f) */
7427 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7428 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7429 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7430 /* Front Mic pin: input vref at 80% */
7431 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7432 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7433 /* Line In pin */
7434 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7435 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7444 /* Macbook Pro rev3 */
7445 static struct hda_verb alc885_mbp3_init_verbs[] = {
7446 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7447 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7450 /* Rear mixer */
7451 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7452 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7453 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7454 /* HP mixer */
7455 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7456 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7457 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7458 /* Front Pin: output 0 (0x0c) */
7459 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7460 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7461 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7462 /* HP Pin: output 0 (0x0e) */
7463 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7464 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7465 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
7466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7467 /* Mic (rear) pin: input vref at 80% */
7468 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7469 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7470 /* Front Mic pin: input vref at 80% */
7471 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7472 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7473 /* Line In pin: use output 1 when in LineOut mode */
7474 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7475 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7476 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7478 /* FIXME: use matrix-type input source selection */
7479 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7480 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7481 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7482 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7483 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7484 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7485 /* Input mixer2 */
7486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7488 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7490 /* Input mixer3 */
7491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7495 /* ADC1: mute amp left and right */
7496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7497 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7498 /* ADC2: mute amp left and right */
7499 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7500 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7501 /* ADC3: mute amp left and right */
7502 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7503 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7508 /* iMac 24 mixer. */
7509 static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7510 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7511 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7512 { } /* end */
7515 /* iMac 24 init verbs. */
7516 static struct hda_verb alc885_imac24_init_verbs[] = {
7517 /* Internal speakers: output 0 (0x0c) */
7518 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7519 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7520 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7521 /* Internal speakers: output 0 (0x0c) */
7522 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7523 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7524 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7525 /* Headphone: output 0 (0x0c) */
7526 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7527 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7528 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7529 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7530 /* Front Mic: input vref at 80% */
7531 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7532 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7536 /* Toggle speaker-output according to the hp-jack state */
7537 static void alc885_imac24_setup(struct hda_codec *codec)
7539 struct alc_spec *spec = codec->spec;
7541 spec->autocfg.hp_pins[0] = 0x14;
7542 spec->autocfg.speaker_pins[0] = 0x18;
7543 spec->autocfg.speaker_pins[1] = 0x1a;
7546 static void alc885_mbp3_setup(struct hda_codec *codec)
7548 struct alc_spec *spec = codec->spec;
7550 spec->autocfg.hp_pins[0] = 0x15;
7551 spec->autocfg.speaker_pins[0] = 0x14;
7555 static struct hda_verb alc882_targa_verbs[] = {
7556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7560 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7562 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7563 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7564 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7566 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7567 { } /* end */
7570 /* toggle speaker-output according to the hp-jack state */
7571 static void alc882_targa_automute(struct hda_codec *codec)
7573 struct alc_spec *spec = codec->spec;
7574 alc_automute_amp(codec);
7575 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7576 spec->jack_present ? 1 : 3);
7579 static void alc882_targa_setup(struct hda_codec *codec)
7581 struct alc_spec *spec = codec->spec;
7583 spec->autocfg.hp_pins[0] = 0x14;
7584 spec->autocfg.speaker_pins[0] = 0x1b;
7587 static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7589 if ((res >> 26) == ALC880_HP_EVENT)
7590 alc882_targa_automute(codec);
7593 static struct hda_verb alc882_asus_a7j_verbs[] = {
7594 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7595 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7597 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7598 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7599 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7601 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7602 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7603 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7605 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7606 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7607 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7608 { } /* end */
7611 static struct hda_verb alc882_asus_a7m_verbs[] = {
7612 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7615 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7617 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7619 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7620 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7621 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7623 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7624 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7625 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7626 { } /* end */
7629 static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7631 unsigned int gpiostate, gpiomask, gpiodir;
7633 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7634 AC_VERB_GET_GPIO_DATA, 0);
7636 if (!muted)
7637 gpiostate |= (1 << pin);
7638 else
7639 gpiostate &= ~(1 << pin);
7641 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7642 AC_VERB_GET_GPIO_MASK, 0);
7643 gpiomask |= (1 << pin);
7645 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7646 AC_VERB_GET_GPIO_DIRECTION, 0);
7647 gpiodir |= (1 << pin);
7650 snd_hda_codec_write(codec, codec->afg, 0,
7651 AC_VERB_SET_GPIO_MASK, gpiomask);
7652 snd_hda_codec_write(codec, codec->afg, 0,
7653 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7655 msleep(1);
7657 snd_hda_codec_write(codec, codec->afg, 0,
7658 AC_VERB_SET_GPIO_DATA, gpiostate);
7661 /* set up GPIO at initialization */
7662 static void alc885_macpro_init_hook(struct hda_codec *codec)
7664 alc882_gpio_mute(codec, 0, 0);
7665 alc882_gpio_mute(codec, 1, 0);
7668 /* set up GPIO and update auto-muting at initialization */
7669 static void alc885_imac24_init_hook(struct hda_codec *codec)
7671 alc885_macpro_init_hook(codec);
7672 alc_automute_amp(codec);
7676 * generic initialization of ADC, input mixers and output mixers
7678 static struct hda_verb alc883_auto_init_verbs[] = {
7680 * Unmute ADC0-2 and set the default input to mic-in
7682 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7683 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7684 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7685 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7687 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7688 * mixer widget
7689 * Note: PASD motherboards uses the Line In 2 as the input for
7690 * front panel mic (mic 2)
7692 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
7693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7694 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7700 * Set up output mixers (0x0c - 0x0f)
7702 /* set vol=0 to output mixers */
7703 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7705 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7706 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7707 /* set up input amps for analog loopback */
7708 /* Amp Indices: DAC = 0, mixer = 1 */
7709 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7710 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7711 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7712 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7714 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7715 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7716 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7717 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7718 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7720 /* FIXME: use matrix-type input source selection */
7721 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7722 /* Input mixer2 */
7723 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7724 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7725 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7726 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7727 /* Input mixer3 */
7728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7729 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7730 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7731 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7736 /* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7737 static struct hda_verb alc889A_mb31_ch2_init[] = {
7738 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7739 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7740 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7741 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7742 { } /* end */
7745 /* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7746 static struct hda_verb alc889A_mb31_ch4_init[] = {
7747 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7748 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7749 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7750 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7751 { } /* end */
7754 /* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7755 static struct hda_verb alc889A_mb31_ch5_init[] = {
7756 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7757 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7758 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7759 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7760 { } /* end */
7763 /* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7764 static struct hda_verb alc889A_mb31_ch6_init[] = {
7765 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7766 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7767 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7768 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7769 { } /* end */
7772 static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7773 { 2, alc889A_mb31_ch2_init },
7774 { 4, alc889A_mb31_ch4_init },
7775 { 5, alc889A_mb31_ch5_init },
7776 { 6, alc889A_mb31_ch6_init },
7779 static struct hda_verb alc883_medion_eapd_verbs[] = {
7780 /* eanable EAPD on medion laptop */
7781 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7782 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7786 #define alc883_base_mixer alc882_base_mixer
7788 static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7789 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7790 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7791 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7792 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7793 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7794 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7796 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7797 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7799 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7800 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7801 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7802 { } /* end */
7805 static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
7806 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7807 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7808 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7809 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7813 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7814 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7815 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7816 { } /* end */
7819 static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7820 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7821 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7822 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7823 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7825 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7827 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7828 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7829 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7830 { } /* end */
7833 static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7834 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7835 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7837 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7838 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7839 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7840 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7842 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7843 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7844 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7845 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7846 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7847 { } /* end */
7850 static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7851 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7852 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7853 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7854 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7855 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7856 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7857 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7858 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7860 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7861 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7862 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7863 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7865 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7867 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7868 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7869 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7870 { } /* end */
7873 static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7874 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7875 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7876 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7877 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7878 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7879 HDA_OUTPUT),
7880 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7881 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7882 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7883 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7884 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7885 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7886 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7887 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7890 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7891 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7892 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7893 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7894 { } /* end */
7897 static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7898 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7899 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7900 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7901 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7902 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7903 HDA_OUTPUT),
7904 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7905 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7906 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7907 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7908 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7909 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7910 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7911 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7913 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7915 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7916 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7917 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7918 { } /* end */
7921 static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
7922 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7923 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7924 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7925 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7926 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7927 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7928 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7929 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7931 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7932 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7933 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7934 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7935 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7936 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7938 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7939 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7940 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7941 { } /* end */
7944 static struct snd_kcontrol_new alc883_targa_mixer[] = {
7945 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7946 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7948 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7949 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7950 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7951 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7952 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7953 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7954 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7955 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7956 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7957 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7958 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7960 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7962 { } /* end */
7965 static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
7966 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7967 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7969 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7970 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7971 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7973 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7974 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7975 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7976 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7977 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7978 { } /* end */
7981 static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
7982 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7983 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7984 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7986 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7987 { } /* end */
7990 static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7992 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7993 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7994 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7995 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7999 { } /* end */
8002 static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8003 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8004 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8005 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8006 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8007 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8010 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8011 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8012 { } /* end */
8015 static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8016 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8017 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8018 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8019 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8020 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8023 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8024 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8025 { } /* end */
8028 static struct snd_kcontrol_new alc883_acer_aspire_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_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8032 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8033 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8036 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8037 { } /* end */
8040 static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8041 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8043 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8044 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
8045 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8046 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8047 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8048 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8050 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8052 { } /* end */
8055 static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8056 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8057 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8058 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8059 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8060 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8061 0x0d, 1, 0x0, HDA_OUTPUT),
8062 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8063 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8064 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8065 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8066 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8067 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8068 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8069 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8070 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8072 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8074 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8075 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8076 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8077 { } /* end */
8080 static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8081 /* Output mixers */
8082 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8083 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8084 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8085 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8086 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8087 HDA_OUTPUT),
8088 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8089 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8090 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8091 /* Output switches */
8092 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8093 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8094 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8095 /* Boost mixers */
8096 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8097 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8098 /* Input mixers */
8099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8101 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8102 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8103 { } /* end */
8106 static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8107 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8108 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8109 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8111 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8113 { } /* end */
8116 static struct hda_bind_ctls alc883_bind_cap_vol = {
8117 .ops = &snd_hda_bind_vol,
8118 .values = {
8119 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8120 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8125 static struct hda_bind_ctls alc883_bind_cap_switch = {
8126 .ops = &snd_hda_bind_sw,
8127 .values = {
8128 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8129 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8134 static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8135 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8136 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8137 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8138 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8139 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8141 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8143 { } /* end */
8146 static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
8147 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8148 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8151 /* .name = "Capture Source", */
8152 .name = "Input Source",
8153 .count = 1,
8154 .info = alc_mux_enum_info,
8155 .get = alc_mux_enum_get,
8156 .put = alc_mux_enum_put,
8158 { } /* end */
8161 static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8163 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8164 .name = "Channel Mode",
8165 .info = alc_ch_mode_info,
8166 .get = alc_ch_mode_get,
8167 .put = alc_ch_mode_put,
8169 { } /* end */
8172 /* toggle speaker-output according to the hp-jack state */
8173 static void alc883_mitac_setup(struct hda_codec *codec)
8175 struct alc_spec *spec = codec->spec;
8177 spec->autocfg.hp_pins[0] = 0x15;
8178 spec->autocfg.speaker_pins[0] = 0x14;
8179 spec->autocfg.speaker_pins[1] = 0x17;
8182 /* auto-toggle front mic */
8184 static void alc883_mitac_mic_automute(struct hda_codec *codec)
8186 unsigned int present;
8187 unsigned char bits;
8189 present = snd_hda_codec_read(codec, 0x18, 0,
8190 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8191 bits = present ? HDA_AMP_MUTE : 0;
8192 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8196 static struct hda_verb alc883_mitac_verbs[] = {
8197 /* HP */
8198 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8199 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8200 /* Subwoofer */
8201 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8202 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8204 /* enable unsolicited event */
8205 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8206 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8208 { } /* end */
8211 static struct hda_verb alc883_clevo_m540r_verbs[] = {
8212 /* HP */
8213 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8214 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8215 /* Int speaker */
8216 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8218 /* enable unsolicited event */
8220 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8221 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8224 { } /* end */
8227 static struct hda_verb alc883_clevo_m720_verbs[] = {
8228 /* HP */
8229 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8231 /* Int speaker */
8232 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8233 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8235 /* enable unsolicited event */
8236 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8237 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8239 { } /* end */
8242 static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8243 /* HP */
8244 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8245 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8246 /* Subwoofer */
8247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8250 /* enable unsolicited event */
8251 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8253 { } /* end */
8256 static struct hda_verb alc883_targa_verbs[] = {
8257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8258 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8260 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8261 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8263 /* Connect Line-Out side jack (SPDIF) to Side */
8264 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8265 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8266 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8267 /* Connect Mic jack to CLFE */
8268 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8269 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8270 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8271 /* Connect Line-in jack to Surround */
8272 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8273 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8274 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8275 /* Connect HP out jack to Front */
8276 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8277 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8278 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8280 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8282 { } /* end */
8285 static struct hda_verb alc883_lenovo_101e_verbs[] = {
8286 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8287 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8288 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8289 { } /* end */
8292 static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8293 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8294 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8295 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8296 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8297 { } /* end */
8300 static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8301 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8302 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8303 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8304 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8305 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8306 { } /* end */
8309 static struct hda_verb alc883_haier_w66_verbs[] = {
8310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8315 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8316 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8317 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8318 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8319 { } /* end */
8322 static struct hda_verb alc888_lenovo_sky_verbs[] = {
8323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8325 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8326 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8327 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8328 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8329 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8330 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8331 { } /* end */
8334 static struct hda_verb alc888_6st_dell_verbs[] = {
8335 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8339 static struct hda_verb alc883_vaiott_verbs[] = {
8340 /* HP */
8341 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8342 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8344 /* enable unsolicited event */
8345 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8347 { } /* end */
8350 static void alc888_3st_hp_setup(struct hda_codec *codec)
8352 struct alc_spec *spec = codec->spec;
8354 spec->autocfg.hp_pins[0] = 0x1b;
8355 spec->autocfg.speaker_pins[0] = 0x14;
8356 spec->autocfg.speaker_pins[1] = 0x16;
8357 spec->autocfg.speaker_pins[2] = 0x18;
8360 static struct hda_verb alc888_3st_hp_verbs[] = {
8361 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
8362 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8363 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
8364 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8365 { } /* end */
8369 * 2ch mode
8371 static struct hda_verb alc888_3st_hp_2ch_init[] = {
8372 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8373 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8374 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8375 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8376 { } /* end */
8380 * 4ch mode
8382 static struct hda_verb alc888_3st_hp_4ch_init[] = {
8383 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8384 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8385 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8386 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8387 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8388 { } /* end */
8392 * 6ch mode
8394 static struct hda_verb alc888_3st_hp_6ch_init[] = {
8395 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8396 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8397 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
8398 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8399 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8400 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8401 { } /* end */
8404 static struct hda_channel_mode alc888_3st_hp_modes[3] = {
8405 { 2, alc888_3st_hp_2ch_init },
8406 { 4, alc888_3st_hp_4ch_init },
8407 { 6, alc888_3st_hp_6ch_init },
8410 /* toggle front-jack and RCA according to the hp-jack state */
8411 static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8413 unsigned int present;
8415 present = snd_hda_codec_read(codec, 0x1b, 0,
8416 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8417 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8418 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8419 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8420 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8423 /* toggle RCA according to the front-jack state */
8424 static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8426 unsigned int present;
8428 present = snd_hda_codec_read(codec, 0x14, 0,
8429 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8430 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8431 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8434 static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8435 unsigned int res)
8437 if ((res >> 26) == ALC880_HP_EVENT)
8438 alc888_lenovo_ms7195_front_automute(codec);
8439 if ((res >> 26) == ALC880_FRONT_EVENT)
8440 alc888_lenovo_ms7195_rca_automute(codec);
8443 static struct hda_verb alc883_medion_md2_verbs[] = {
8444 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8445 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8447 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8449 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8450 { } /* end */
8453 /* toggle speaker-output according to the hp-jack state */
8454 static void alc883_medion_md2_setup(struct hda_codec *codec)
8456 struct alc_spec *spec = codec->spec;
8458 spec->autocfg.hp_pins[0] = 0x14;
8459 spec->autocfg.speaker_pins[0] = 0x15;
8462 /* toggle speaker-output according to the hp-jack state */
8463 #define alc883_targa_init_hook alc882_targa_init_hook
8464 #define alc883_targa_unsol_event alc882_targa_unsol_event
8466 static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8468 unsigned int present;
8470 present = snd_hda_codec_read(codec, 0x18, 0,
8471 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8472 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8473 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8476 static void alc883_clevo_m720_setup(struct hda_codec *codec)
8478 struct alc_spec *spec = codec->spec;
8480 spec->autocfg.hp_pins[0] = 0x15;
8481 spec->autocfg.speaker_pins[0] = 0x14;
8484 static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8486 alc_automute_amp(codec);
8487 alc883_clevo_m720_mic_automute(codec);
8490 static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
8491 unsigned int res)
8493 switch (res >> 26) {
8494 case ALC880_MIC_EVENT:
8495 alc883_clevo_m720_mic_automute(codec);
8496 break;
8497 default:
8498 alc_automute_amp_unsol_event(codec, res);
8499 break;
8503 /* toggle speaker-output according to the hp-jack state */
8504 static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
8506 struct alc_spec *spec = codec->spec;
8508 spec->autocfg.hp_pins[0] = 0x14;
8509 spec->autocfg.speaker_pins[0] = 0x15;
8512 static void alc883_haier_w66_setup(struct hda_codec *codec)
8514 struct alc_spec *spec = codec->spec;
8516 spec->autocfg.hp_pins[0] = 0x1b;
8517 spec->autocfg.speaker_pins[0] = 0x14;
8520 static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8522 unsigned int present;
8523 unsigned char bits;
8525 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8526 & AC_PINSENSE_PRESENCE;
8527 bits = present ? HDA_AMP_MUTE : 0;
8528 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8529 HDA_AMP_MUTE, bits);
8532 static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8534 unsigned int present;
8535 unsigned char bits;
8537 present = snd_hda_codec_read(codec, 0x1b, 0,
8538 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8539 bits = present ? HDA_AMP_MUTE : 0;
8540 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8541 HDA_AMP_MUTE, bits);
8542 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8543 HDA_AMP_MUTE, bits);
8546 static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8547 unsigned int res)
8549 if ((res >> 26) == ALC880_HP_EVENT)
8550 alc883_lenovo_101e_all_automute(codec);
8551 if ((res >> 26) == ALC880_FRONT_EVENT)
8552 alc883_lenovo_101e_ispeaker_automute(codec);
8555 /* toggle speaker-output according to the hp-jack state */
8556 static void alc883_acer_aspire_setup(struct hda_codec *codec)
8558 struct alc_spec *spec = codec->spec;
8560 spec->autocfg.hp_pins[0] = 0x14;
8561 spec->autocfg.speaker_pins[0] = 0x15;
8562 spec->autocfg.speaker_pins[1] = 0x16;
8565 static struct hda_verb alc883_acer_eapd_verbs[] = {
8566 /* HP Pin: output 0 (0x0c) */
8567 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8568 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8569 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8570 /* Front Pin: output 0 (0x0c) */
8571 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8572 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8573 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8574 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8575 /* eanable EAPD on medion laptop */
8576 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8577 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
8578 /* enable unsolicited event */
8579 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8583 static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8584 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8585 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8586 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8587 { } /* end */
8590 static void alc888_6st_dell_setup(struct hda_codec *codec)
8592 struct alc_spec *spec = codec->spec;
8594 spec->autocfg.hp_pins[0] = 0x1b;
8595 spec->autocfg.speaker_pins[0] = 0x14;
8596 spec->autocfg.speaker_pins[1] = 0x15;
8597 spec->autocfg.speaker_pins[2] = 0x16;
8598 spec->autocfg.speaker_pins[3] = 0x17;
8601 static void alc888_lenovo_sky_setup(struct hda_codec *codec)
8603 struct alc_spec *spec = codec->spec;
8605 spec->autocfg.hp_pins[0] = 0x1b;
8606 spec->autocfg.speaker_pins[0] = 0x14;
8607 spec->autocfg.speaker_pins[1] = 0x15;
8608 spec->autocfg.speaker_pins[2] = 0x16;
8609 spec->autocfg.speaker_pins[3] = 0x17;
8610 spec->autocfg.speaker_pins[4] = 0x1a;
8613 static void alc883_vaiott_setup(struct hda_codec *codec)
8615 struct alc_spec *spec = codec->spec;
8617 spec->autocfg.hp_pins[0] = 0x15;
8618 spec->autocfg.speaker_pins[0] = 0x14;
8619 spec->autocfg.speaker_pins[1] = 0x17;
8622 static struct hda_verb alc888_asus_m90v_verbs[] = {
8623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8624 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8625 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8626 /* enable unsolicited event */
8627 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8628 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8629 { } /* end */
8632 static void alc883_mode2_setup(struct hda_codec *codec)
8634 struct alc_spec *spec = codec->spec;
8636 spec->autocfg.hp_pins[0] = 0x1b;
8637 spec->autocfg.speaker_pins[0] = 0x14;
8638 spec->autocfg.speaker_pins[1] = 0x15;
8639 spec->autocfg.speaker_pins[2] = 0x16;
8640 spec->ext_mic.pin = 0x18;
8641 spec->int_mic.pin = 0x19;
8642 spec->ext_mic.mux_idx = 0;
8643 spec->int_mic.mux_idx = 1;
8644 spec->auto_mic = 1;
8647 static struct hda_verb alc888_asus_eee1601_verbs[] = {
8648 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8649 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8650 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8651 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8652 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8653 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8654 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8655 /* enable unsolicited event */
8656 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8657 { } /* end */
8660 static void alc883_eee1601_inithook(struct hda_codec *codec)
8662 struct alc_spec *spec = codec->spec;
8664 spec->autocfg.hp_pins[0] = 0x14;
8665 spec->autocfg.speaker_pins[0] = 0x1b;
8666 alc_automute_pin(codec);
8669 static struct hda_verb alc889A_mb31_verbs[] = {
8670 /* Init rear pin (used as headphone output) */
8671 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8672 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8673 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8674 /* Init line pin (used as output in 4ch and 6ch mode) */
8675 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8676 /* Init line 2 pin (used as headphone out by default) */
8677 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8678 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8679 { } /* end */
8682 /* Mute speakers according to the headphone jack state */
8683 static void alc889A_mb31_automute(struct hda_codec *codec)
8685 unsigned int present;
8687 /* Mute only in 2ch or 4ch mode */
8688 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8689 == 0x00) {
8690 present = snd_hda_codec_read(codec, 0x15, 0,
8691 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8692 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8693 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8694 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8695 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8699 static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8701 if ((res >> 26) == ALC880_HP_EVENT)
8702 alc889A_mb31_automute(codec);
8706 #ifdef CONFIG_SND_HDA_POWER_SAVE
8707 #define alc882_loopbacks alc880_loopbacks
8708 #endif
8710 /* pcm configuration: identical with ALC880 */
8711 #define alc882_pcm_analog_playback alc880_pcm_analog_playback
8712 #define alc882_pcm_analog_capture alc880_pcm_analog_capture
8713 #define alc882_pcm_digital_playback alc880_pcm_digital_playback
8714 #define alc882_pcm_digital_capture alc880_pcm_digital_capture
8716 static hda_nid_t alc883_slave_dig_outs[] = {
8717 ALC1200_DIGOUT_NID, 0,
8720 static hda_nid_t alc1200_slave_dig_outs[] = {
8721 ALC883_DIGOUT_NID, 0,
8725 * configuration and preset
8727 static const char *alc882_models[ALC882_MODEL_LAST] = {
8728 [ALC882_3ST_DIG] = "3stack-dig",
8729 [ALC882_6ST_DIG] = "6stack-dig",
8730 [ALC882_ARIMA] = "arima",
8731 [ALC882_W2JC] = "w2jc",
8732 [ALC882_TARGA] = "targa",
8733 [ALC882_ASUS_A7J] = "asus-a7j",
8734 [ALC882_ASUS_A7M] = "asus-a7m",
8735 [ALC885_MACPRO] = "macpro",
8736 [ALC885_MB5] = "mb5",
8737 [ALC885_MBP3] = "mbp3",
8738 [ALC885_IMAC24] = "imac24",
8739 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
8740 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8741 [ALC883_3ST_6ch] = "3stack-6ch",
8742 [ALC883_6ST_DIG] = "alc883-6stack-dig",
8743 [ALC883_TARGA_DIG] = "targa-dig",
8744 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
8745 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
8746 [ALC883_ACER] = "acer",
8747 [ALC883_ACER_ASPIRE] = "acer-aspire",
8748 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
8749 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
8750 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
8751 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
8752 [ALC883_MEDION] = "medion",
8753 [ALC883_MEDION_MD2] = "medion-md2",
8754 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
8755 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
8756 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8757 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
8758 [ALC888_LENOVO_SKY] = "lenovo-sky",
8759 [ALC883_HAIER_W66] = "haier-w66",
8760 [ALC888_3ST_HP] = "3stack-hp",
8761 [ALC888_6ST_DELL] = "6stack-dell",
8762 [ALC883_MITAC] = "mitac",
8763 [ALC883_CLEVO_M540R] = "clevo-m540r",
8764 [ALC883_CLEVO_M720] = "clevo-m720",
8765 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
8766 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
8767 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
8768 [ALC889A_INTEL] = "intel-alc889a",
8769 [ALC889_INTEL] = "intel-x58",
8770 [ALC1200_ASUS_P5Q] = "asus-p5q",
8771 [ALC889A_MB31] = "mb31",
8772 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
8773 [ALC882_AUTO] = "auto",
8776 static struct snd_pci_quirk alc882_cfg_tbl[] = {
8777 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8779 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8780 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
8781 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
8782 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8783 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
8784 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
8785 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8786 ALC888_ACER_ASPIRE_4930G),
8787 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8788 ALC888_ACER_ASPIRE_4930G),
8789 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8790 ALC888_ACER_ASPIRE_8930G),
8791 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8792 ALC888_ACER_ASPIRE_8930G),
8793 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8794 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
8795 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8796 ALC888_ACER_ASPIRE_6530G),
8797 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8798 ALC888_ACER_ASPIRE_6530G),
8799 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
8800 ALC888_ACER_ASPIRE_7730G),
8801 /* default Acer -- disabled as it causes more problems.
8802 * model=auto should work fine now
8804 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
8806 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8808 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
8809 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8810 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
8811 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
8812 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
8813 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
8815 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8816 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8817 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
8818 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8819 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8820 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8821 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
8822 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8823 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
8824 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
8825 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
8827 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
8828 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
8829 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
8830 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
8831 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8832 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
8833 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
8834 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
8835 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8837 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8838 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8839 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
8840 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
8841 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
8842 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
8843 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
8844 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
8845 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8846 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8847 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8848 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8849 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8850 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8851 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
8852 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8853 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8854 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
8855 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
8856 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8857 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
8858 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
8859 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
8860 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
8861 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
8862 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
8863 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
8864 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
8865 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
8867 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
8868 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8869 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
8870 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
8871 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
8872 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8873 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
8874 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
8875 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
8876 ALC883_FUJITSU_PI2515),
8877 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
8878 ALC888_FUJITSU_XA3530),
8879 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
8880 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8881 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8882 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8883 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
8884 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
8885 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
8886 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
8887 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
8889 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8890 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
8891 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
8892 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8893 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8894 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
8895 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
8900 /* codec SSID table for Intel Mac */
8901 static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8902 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8903 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8904 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8905 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8906 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8907 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8908 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8909 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8910 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8911 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8912 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8913 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8914 * no perfect solution yet
8916 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8917 {} /* terminator */
8920 static struct alc_config_preset alc882_presets[] = {
8921 [ALC882_3ST_DIG] = {
8922 .mixers = { alc882_base_mixer },
8923 .init_verbs = { alc882_base_init_verbs,
8924 alc882_adc1_init_verbs },
8925 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8926 .dac_nids = alc882_dac_nids,
8927 .dig_out_nid = ALC882_DIGOUT_NID,
8928 .dig_in_nid = ALC882_DIGIN_NID,
8929 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8930 .channel_mode = alc882_ch_modes,
8931 .need_dac_fix = 1,
8932 .input_mux = &alc882_capture_source,
8934 [ALC882_6ST_DIG] = {
8935 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8936 .init_verbs = { alc882_base_init_verbs,
8937 alc882_adc1_init_verbs },
8938 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8939 .dac_nids = alc882_dac_nids,
8940 .dig_out_nid = ALC882_DIGOUT_NID,
8941 .dig_in_nid = ALC882_DIGIN_NID,
8942 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8943 .channel_mode = alc882_sixstack_modes,
8944 .input_mux = &alc882_capture_source,
8946 [ALC882_ARIMA] = {
8947 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
8948 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8949 alc882_eapd_verbs },
8950 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8951 .dac_nids = alc882_dac_nids,
8952 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8953 .channel_mode = alc882_sixstack_modes,
8954 .input_mux = &alc882_capture_source,
8956 [ALC882_W2JC] = {
8957 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
8958 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8959 alc882_eapd_verbs, alc880_gpio1_init_verbs },
8960 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8961 .dac_nids = alc882_dac_nids,
8962 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8963 .channel_mode = alc880_threestack_modes,
8964 .need_dac_fix = 1,
8965 .input_mux = &alc882_capture_source,
8966 .dig_out_nid = ALC882_DIGOUT_NID,
8968 [ALC885_MBP3] = {
8969 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8970 .init_verbs = { alc885_mbp3_init_verbs,
8971 alc880_gpio1_init_verbs },
8972 .num_dacs = 2,
8973 .dac_nids = alc882_dac_nids,
8974 .hp_nid = 0x04,
8975 .channel_mode = alc885_mbp_4ch_modes,
8976 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
8977 .input_mux = &alc882_capture_source,
8978 .dig_out_nid = ALC882_DIGOUT_NID,
8979 .dig_in_nid = ALC882_DIGIN_NID,
8980 .unsol_event = alc_automute_amp_unsol_event,
8981 .setup = alc885_mbp3_setup,
8982 .init_hook = alc_automute_amp,
8984 [ALC885_MB5] = {
8985 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8986 .init_verbs = { alc885_mb5_init_verbs,
8987 alc880_gpio1_init_verbs },
8988 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8989 .dac_nids = alc882_dac_nids,
8990 .channel_mode = alc885_mb5_6ch_modes,
8991 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8992 .input_mux = &mb5_capture_source,
8993 .dig_out_nid = ALC882_DIGOUT_NID,
8994 .dig_in_nid = ALC882_DIGIN_NID,
8996 [ALC885_MACPRO] = {
8997 .mixers = { alc882_macpro_mixer },
8998 .init_verbs = { alc882_macpro_init_verbs },
8999 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9000 .dac_nids = alc882_dac_nids,
9001 .dig_out_nid = ALC882_DIGOUT_NID,
9002 .dig_in_nid = ALC882_DIGIN_NID,
9003 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9004 .channel_mode = alc882_ch_modes,
9005 .input_mux = &alc882_capture_source,
9006 .init_hook = alc885_macpro_init_hook,
9008 [ALC885_IMAC24] = {
9009 .mixers = { alc885_imac24_mixer },
9010 .init_verbs = { alc885_imac24_init_verbs },
9011 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9012 .dac_nids = alc882_dac_nids,
9013 .dig_out_nid = ALC882_DIGOUT_NID,
9014 .dig_in_nid = ALC882_DIGIN_NID,
9015 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9016 .channel_mode = alc882_ch_modes,
9017 .input_mux = &alc882_capture_source,
9018 .unsol_event = alc_automute_amp_unsol_event,
9019 .setup = alc885_imac24_setup,
9020 .init_hook = alc885_imac24_init_hook,
9022 [ALC882_TARGA] = {
9023 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
9024 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9025 alc880_gpio3_init_verbs, alc882_targa_verbs},
9026 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9027 .dac_nids = alc882_dac_nids,
9028 .dig_out_nid = ALC882_DIGOUT_NID,
9029 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9030 .adc_nids = alc882_adc_nids,
9031 .capsrc_nids = alc882_capsrc_nids,
9032 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9033 .channel_mode = alc882_3ST_6ch_modes,
9034 .need_dac_fix = 1,
9035 .input_mux = &alc882_capture_source,
9036 .unsol_event = alc882_targa_unsol_event,
9037 .setup = alc882_targa_setup,
9038 .init_hook = alc882_targa_automute,
9040 [ALC882_ASUS_A7J] = {
9041 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
9042 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9043 alc882_asus_a7j_verbs},
9044 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9045 .dac_nids = alc882_dac_nids,
9046 .dig_out_nid = ALC882_DIGOUT_NID,
9047 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9048 .adc_nids = alc882_adc_nids,
9049 .capsrc_nids = alc882_capsrc_nids,
9050 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9051 .channel_mode = alc882_3ST_6ch_modes,
9052 .need_dac_fix = 1,
9053 .input_mux = &alc882_capture_source,
9055 [ALC882_ASUS_A7M] = {
9056 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
9057 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9058 alc882_eapd_verbs, alc880_gpio1_init_verbs,
9059 alc882_asus_a7m_verbs },
9060 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9061 .dac_nids = alc882_dac_nids,
9062 .dig_out_nid = ALC882_DIGOUT_NID,
9063 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9064 .channel_mode = alc880_threestack_modes,
9065 .need_dac_fix = 1,
9066 .input_mux = &alc882_capture_source,
9068 [ALC883_3ST_2ch_DIG] = {
9069 .mixers = { alc883_3ST_2ch_mixer },
9070 .init_verbs = { alc883_init_verbs },
9071 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9072 .dac_nids = alc883_dac_nids,
9073 .dig_out_nid = ALC883_DIGOUT_NID,
9074 .dig_in_nid = ALC883_DIGIN_NID,
9075 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9076 .channel_mode = alc883_3ST_2ch_modes,
9077 .input_mux = &alc883_capture_source,
9079 [ALC883_3ST_6ch_DIG] = {
9080 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9081 .init_verbs = { alc883_init_verbs },
9082 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9083 .dac_nids = alc883_dac_nids,
9084 .dig_out_nid = ALC883_DIGOUT_NID,
9085 .dig_in_nid = ALC883_DIGIN_NID,
9086 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9087 .channel_mode = alc883_3ST_6ch_modes,
9088 .need_dac_fix = 1,
9089 .input_mux = &alc883_capture_source,
9091 [ALC883_3ST_6ch] = {
9092 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9093 .init_verbs = { alc883_init_verbs },
9094 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9095 .dac_nids = alc883_dac_nids,
9096 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9097 .channel_mode = alc883_3ST_6ch_modes,
9098 .need_dac_fix = 1,
9099 .input_mux = &alc883_capture_source,
9101 [ALC883_3ST_6ch_INTEL] = {
9102 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9103 .init_verbs = { alc883_init_verbs },
9104 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9105 .dac_nids = alc883_dac_nids,
9106 .dig_out_nid = ALC883_DIGOUT_NID,
9107 .dig_in_nid = ALC883_DIGIN_NID,
9108 .slave_dig_outs = alc883_slave_dig_outs,
9109 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9110 .channel_mode = alc883_3ST_6ch_intel_modes,
9111 .need_dac_fix = 1,
9112 .input_mux = &alc883_3stack_6ch_intel,
9114 [ALC889A_INTEL] = {
9115 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9116 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9117 alc_hp15_unsol_verbs },
9118 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9119 .dac_nids = alc883_dac_nids,
9120 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9121 .adc_nids = alc889_adc_nids,
9122 .dig_out_nid = ALC883_DIGOUT_NID,
9123 .dig_in_nid = ALC883_DIGIN_NID,
9124 .slave_dig_outs = alc883_slave_dig_outs,
9125 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9126 .channel_mode = alc889_8ch_intel_modes,
9127 .capsrc_nids = alc889_capsrc_nids,
9128 .input_mux = &alc889_capture_source,
9129 .setup = alc889_automute_setup,
9130 .init_hook = alc_automute_amp,
9131 .unsol_event = alc_automute_amp_unsol_event,
9132 .need_dac_fix = 1,
9134 [ALC889_INTEL] = {
9135 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9136 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
9137 alc889_eapd_verbs, alc_hp15_unsol_verbs},
9138 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9139 .dac_nids = alc883_dac_nids,
9140 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9141 .adc_nids = alc889_adc_nids,
9142 .dig_out_nid = ALC883_DIGOUT_NID,
9143 .dig_in_nid = ALC883_DIGIN_NID,
9144 .slave_dig_outs = alc883_slave_dig_outs,
9145 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9146 .channel_mode = alc889_8ch_intel_modes,
9147 .capsrc_nids = alc889_capsrc_nids,
9148 .input_mux = &alc889_capture_source,
9149 .setup = alc889_automute_setup,
9150 .init_hook = alc889_intel_init_hook,
9151 .unsol_event = alc_automute_amp_unsol_event,
9152 .need_dac_fix = 1,
9154 [ALC883_6ST_DIG] = {
9155 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9156 .init_verbs = { alc883_init_verbs },
9157 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9158 .dac_nids = alc883_dac_nids,
9159 .dig_out_nid = ALC883_DIGOUT_NID,
9160 .dig_in_nid = ALC883_DIGIN_NID,
9161 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9162 .channel_mode = alc883_sixstack_modes,
9163 .input_mux = &alc883_capture_source,
9165 [ALC883_TARGA_DIG] = {
9166 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
9167 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9168 alc883_targa_verbs},
9169 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9170 .dac_nids = alc883_dac_nids,
9171 .dig_out_nid = ALC883_DIGOUT_NID,
9172 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9173 .channel_mode = alc883_3ST_6ch_modes,
9174 .need_dac_fix = 1,
9175 .input_mux = &alc883_capture_source,
9176 .unsol_event = alc883_targa_unsol_event,
9177 .setup = alc882_targa_setup,
9178 .init_hook = alc882_targa_automute,
9180 [ALC883_TARGA_2ch_DIG] = {
9181 .mixers = { alc883_targa_2ch_mixer},
9182 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9183 alc883_targa_verbs},
9184 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9185 .dac_nids = alc883_dac_nids,
9186 .adc_nids = alc883_adc_nids_alt,
9187 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
9188 .dig_out_nid = ALC883_DIGOUT_NID,
9189 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9190 .channel_mode = alc883_3ST_2ch_modes,
9191 .input_mux = &alc883_capture_source,
9192 .unsol_event = alc883_targa_unsol_event,
9193 .setup = alc882_targa_setup,
9194 .init_hook = alc882_targa_automute,
9196 [ALC883_TARGA_8ch_DIG] = {
9197 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9198 alc883_chmode_mixer },
9199 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9200 alc883_targa_verbs },
9201 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9202 .dac_nids = alc883_dac_nids,
9203 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9204 .adc_nids = alc883_adc_nids_rev,
9205 .capsrc_nids = alc883_capsrc_nids_rev,
9206 .dig_out_nid = ALC883_DIGOUT_NID,
9207 .dig_in_nid = ALC883_DIGIN_NID,
9208 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9209 .channel_mode = alc883_4ST_8ch_modes,
9210 .need_dac_fix = 1,
9211 .input_mux = &alc883_capture_source,
9212 .unsol_event = alc883_targa_unsol_event,
9213 .setup = alc882_targa_setup,
9214 .init_hook = alc882_targa_automute,
9216 [ALC883_ACER] = {
9217 .mixers = { alc883_base_mixer },
9218 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9219 * and the headphone jack. Turn this on and rely on the
9220 * standard mute methods whenever the user wants to turn
9221 * these outputs off.
9223 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9224 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9225 .dac_nids = alc883_dac_nids,
9226 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9227 .channel_mode = alc883_3ST_2ch_modes,
9228 .input_mux = &alc883_capture_source,
9230 [ALC883_ACER_ASPIRE] = {
9231 .mixers = { alc883_acer_aspire_mixer },
9232 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
9233 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9234 .dac_nids = alc883_dac_nids,
9235 .dig_out_nid = ALC883_DIGOUT_NID,
9236 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9237 .channel_mode = alc883_3ST_2ch_modes,
9238 .input_mux = &alc883_capture_source,
9239 .unsol_event = alc_automute_amp_unsol_event,
9240 .setup = alc883_acer_aspire_setup,
9241 .init_hook = alc_automute_amp,
9243 [ALC888_ACER_ASPIRE_4930G] = {
9244 .mixers = { alc888_base_mixer,
9245 alc883_chmode_mixer },
9246 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9247 alc888_acer_aspire_4930g_verbs },
9248 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9249 .dac_nids = alc883_dac_nids,
9250 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9251 .adc_nids = alc883_adc_nids_rev,
9252 .capsrc_nids = alc883_capsrc_nids_rev,
9253 .dig_out_nid = ALC883_DIGOUT_NID,
9254 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9255 .channel_mode = alc883_3ST_6ch_modes,
9256 .need_dac_fix = 1,
9257 .num_mux_defs =
9258 ARRAY_SIZE(alc888_2_capture_sources),
9259 .input_mux = alc888_2_capture_sources,
9260 .unsol_event = alc_automute_amp_unsol_event,
9261 .setup = alc888_acer_aspire_4930g_setup,
9262 .init_hook = alc_automute_amp,
9264 [ALC888_ACER_ASPIRE_6530G] = {
9265 .mixers = { alc888_acer_aspire_6530_mixer },
9266 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9267 alc888_acer_aspire_6530g_verbs },
9268 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9269 .dac_nids = alc883_dac_nids,
9270 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9271 .adc_nids = alc883_adc_nids_rev,
9272 .capsrc_nids = alc883_capsrc_nids_rev,
9273 .dig_out_nid = ALC883_DIGOUT_NID,
9274 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9275 .channel_mode = alc883_3ST_2ch_modes,
9276 .num_mux_defs =
9277 ARRAY_SIZE(alc888_2_capture_sources),
9278 .input_mux = alc888_acer_aspire_6530_sources,
9279 .unsol_event = alc_automute_amp_unsol_event,
9280 .setup = alc888_acer_aspire_6530g_setup,
9281 .init_hook = alc_automute_amp,
9283 [ALC888_ACER_ASPIRE_8930G] = {
9284 .mixers = { alc888_base_mixer,
9285 alc883_chmode_mixer },
9286 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9287 alc889_acer_aspire_8930g_verbs },
9288 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9289 .dac_nids = alc883_dac_nids,
9290 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9291 .adc_nids = alc889_adc_nids,
9292 .capsrc_nids = alc889_capsrc_nids,
9293 .dig_out_nid = ALC883_DIGOUT_NID,
9294 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9295 .channel_mode = alc883_3ST_6ch_modes,
9296 .need_dac_fix = 1,
9297 .const_channel_count = 6,
9298 .num_mux_defs =
9299 ARRAY_SIZE(alc889_capture_sources),
9300 .input_mux = alc889_capture_sources,
9301 .unsol_event = alc_automute_amp_unsol_event,
9302 .setup = alc889_acer_aspire_8930g_setup,
9303 .init_hook = alc_automute_amp,
9305 [ALC888_ACER_ASPIRE_7730G] = {
9306 .mixers = { alc883_3ST_6ch_mixer,
9307 alc883_chmode_mixer },
9308 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9309 alc888_acer_aspire_7730G_verbs },
9310 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9311 .dac_nids = alc883_dac_nids,
9312 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9313 .adc_nids = alc883_adc_nids_rev,
9314 .capsrc_nids = alc883_capsrc_nids_rev,
9315 .dig_out_nid = ALC883_DIGOUT_NID,
9316 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9317 .channel_mode = alc883_3ST_6ch_modes,
9318 .need_dac_fix = 1,
9319 .const_channel_count = 6,
9320 .input_mux = &alc883_capture_source,
9321 .unsol_event = alc_automute_amp_unsol_event,
9322 .setup = alc888_acer_aspire_6530g_setup,
9323 .init_hook = alc_automute_amp,
9325 [ALC883_MEDION] = {
9326 .mixers = { alc883_fivestack_mixer,
9327 alc883_chmode_mixer },
9328 .init_verbs = { alc883_init_verbs,
9329 alc883_medion_eapd_verbs },
9330 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9331 .dac_nids = alc883_dac_nids,
9332 .adc_nids = alc883_adc_nids_alt,
9333 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
9334 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9335 .channel_mode = alc883_sixstack_modes,
9336 .input_mux = &alc883_capture_source,
9338 [ALC883_MEDION_MD2] = {
9339 .mixers = { alc883_medion_md2_mixer},
9340 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9341 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9342 .dac_nids = alc883_dac_nids,
9343 .dig_out_nid = ALC883_DIGOUT_NID,
9344 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9345 .channel_mode = alc883_3ST_2ch_modes,
9346 .input_mux = &alc883_capture_source,
9347 .unsol_event = alc_automute_amp_unsol_event,
9348 .setup = alc883_medion_md2_setup,
9349 .init_hook = alc_automute_amp,
9351 [ALC883_LAPTOP_EAPD] = {
9352 .mixers = { alc883_base_mixer },
9353 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9354 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9355 .dac_nids = alc883_dac_nids,
9356 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9357 .channel_mode = alc883_3ST_2ch_modes,
9358 .input_mux = &alc883_capture_source,
9360 [ALC883_CLEVO_M540R] = {
9361 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9362 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9363 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9364 .dac_nids = alc883_dac_nids,
9365 .dig_out_nid = ALC883_DIGOUT_NID,
9366 .dig_in_nid = ALC883_DIGIN_NID,
9367 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9368 .channel_mode = alc883_3ST_6ch_clevo_modes,
9369 .need_dac_fix = 1,
9370 .input_mux = &alc883_capture_source,
9371 /* This machine has the hardware HP auto-muting, thus
9372 * we need no software mute via unsol event
9375 [ALC883_CLEVO_M720] = {
9376 .mixers = { alc883_clevo_m720_mixer },
9377 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
9378 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9379 .dac_nids = alc883_dac_nids,
9380 .dig_out_nid = ALC883_DIGOUT_NID,
9381 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9382 .channel_mode = alc883_3ST_2ch_modes,
9383 .input_mux = &alc883_capture_source,
9384 .unsol_event = alc883_clevo_m720_unsol_event,
9385 .setup = alc883_clevo_m720_setup,
9386 .init_hook = alc883_clevo_m720_init_hook,
9388 [ALC883_LENOVO_101E_2ch] = {
9389 .mixers = { alc883_lenovo_101e_2ch_mixer},
9390 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9391 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9392 .dac_nids = alc883_dac_nids,
9393 .adc_nids = alc883_adc_nids_alt,
9394 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
9395 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9396 .channel_mode = alc883_3ST_2ch_modes,
9397 .input_mux = &alc883_lenovo_101e_capture_source,
9398 .unsol_event = alc883_lenovo_101e_unsol_event,
9399 .init_hook = alc883_lenovo_101e_all_automute,
9401 [ALC883_LENOVO_NB0763] = {
9402 .mixers = { alc883_lenovo_nb0763_mixer },
9403 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9404 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9405 .dac_nids = alc883_dac_nids,
9406 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9407 .channel_mode = alc883_3ST_2ch_modes,
9408 .need_dac_fix = 1,
9409 .input_mux = &alc883_lenovo_nb0763_capture_source,
9410 .unsol_event = alc_automute_amp_unsol_event,
9411 .setup = alc883_medion_md2_setup,
9412 .init_hook = alc_automute_amp,
9414 [ALC888_LENOVO_MS7195_DIG] = {
9415 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9416 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9417 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9418 .dac_nids = alc883_dac_nids,
9419 .dig_out_nid = ALC883_DIGOUT_NID,
9420 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9421 .channel_mode = alc883_3ST_6ch_modes,
9422 .need_dac_fix = 1,
9423 .input_mux = &alc883_capture_source,
9424 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9425 .init_hook = alc888_lenovo_ms7195_front_automute,
9427 [ALC883_HAIER_W66] = {
9428 .mixers = { alc883_targa_2ch_mixer},
9429 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9430 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9431 .dac_nids = alc883_dac_nids,
9432 .dig_out_nid = ALC883_DIGOUT_NID,
9433 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9434 .channel_mode = alc883_3ST_2ch_modes,
9435 .input_mux = &alc883_capture_source,
9436 .unsol_event = alc_automute_amp_unsol_event,
9437 .setup = alc883_haier_w66_setup,
9438 .init_hook = alc_automute_amp,
9440 [ALC888_3ST_HP] = {
9441 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9442 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
9443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9444 .dac_nids = alc883_dac_nids,
9445 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9446 .channel_mode = alc888_3st_hp_modes,
9447 .need_dac_fix = 1,
9448 .input_mux = &alc883_capture_source,
9449 .unsol_event = alc_automute_amp_unsol_event,
9450 .setup = alc888_3st_hp_setup,
9451 .init_hook = alc_automute_amp,
9453 [ALC888_6ST_DELL] = {
9454 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9455 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9456 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9457 .dac_nids = alc883_dac_nids,
9458 .dig_out_nid = ALC883_DIGOUT_NID,
9459 .dig_in_nid = ALC883_DIGIN_NID,
9460 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9461 .channel_mode = alc883_sixstack_modes,
9462 .input_mux = &alc883_capture_source,
9463 .unsol_event = alc_automute_amp_unsol_event,
9464 .setup = alc888_6st_dell_setup,
9465 .init_hook = alc_automute_amp,
9467 [ALC883_MITAC] = {
9468 .mixers = { alc883_mitac_mixer },
9469 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9470 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9471 .dac_nids = alc883_dac_nids,
9472 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9473 .channel_mode = alc883_3ST_2ch_modes,
9474 .input_mux = &alc883_capture_source,
9475 .unsol_event = alc_automute_amp_unsol_event,
9476 .setup = alc883_mitac_setup,
9477 .init_hook = alc_automute_amp,
9479 [ALC883_FUJITSU_PI2515] = {
9480 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9481 .init_verbs = { alc883_init_verbs,
9482 alc883_2ch_fujitsu_pi2515_verbs},
9483 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9484 .dac_nids = alc883_dac_nids,
9485 .dig_out_nid = ALC883_DIGOUT_NID,
9486 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9487 .channel_mode = alc883_3ST_2ch_modes,
9488 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9489 .unsol_event = alc_automute_amp_unsol_event,
9490 .setup = alc883_2ch_fujitsu_pi2515_setup,
9491 .init_hook = alc_automute_amp,
9493 [ALC888_FUJITSU_XA3530] = {
9494 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9495 .init_verbs = { alc883_init_verbs,
9496 alc888_fujitsu_xa3530_verbs },
9497 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9498 .dac_nids = alc883_dac_nids,
9499 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9500 .adc_nids = alc883_adc_nids_rev,
9501 .capsrc_nids = alc883_capsrc_nids_rev,
9502 .dig_out_nid = ALC883_DIGOUT_NID,
9503 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9504 .channel_mode = alc888_4ST_8ch_intel_modes,
9505 .num_mux_defs =
9506 ARRAY_SIZE(alc888_2_capture_sources),
9507 .input_mux = alc888_2_capture_sources,
9508 .unsol_event = alc_automute_amp_unsol_event,
9509 .setup = alc888_fujitsu_xa3530_setup,
9510 .init_hook = alc_automute_amp,
9512 [ALC888_LENOVO_SKY] = {
9513 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9514 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9515 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9516 .dac_nids = alc883_dac_nids,
9517 .dig_out_nid = ALC883_DIGOUT_NID,
9518 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9519 .channel_mode = alc883_sixstack_modes,
9520 .need_dac_fix = 1,
9521 .input_mux = &alc883_lenovo_sky_capture_source,
9522 .unsol_event = alc_automute_amp_unsol_event,
9523 .setup = alc888_lenovo_sky_setup,
9524 .init_hook = alc_automute_amp,
9526 [ALC888_ASUS_M90V] = {
9527 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9528 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9529 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9530 .dac_nids = alc883_dac_nids,
9531 .dig_out_nid = ALC883_DIGOUT_NID,
9532 .dig_in_nid = ALC883_DIGIN_NID,
9533 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9534 .channel_mode = alc883_3ST_6ch_modes,
9535 .need_dac_fix = 1,
9536 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9537 .unsol_event = alc_sku_unsol_event,
9538 .setup = alc883_mode2_setup,
9539 .init_hook = alc_inithook,
9541 [ALC888_ASUS_EEE1601] = {
9542 .mixers = { alc883_asus_eee1601_mixer },
9543 .cap_mixer = alc883_asus_eee1601_cap_mixer,
9544 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9545 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9546 .dac_nids = alc883_dac_nids,
9547 .dig_out_nid = ALC883_DIGOUT_NID,
9548 .dig_in_nid = ALC883_DIGIN_NID,
9549 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9550 .channel_mode = alc883_3ST_2ch_modes,
9551 .need_dac_fix = 1,
9552 .input_mux = &alc883_asus_eee1601_capture_source,
9553 .unsol_event = alc_sku_unsol_event,
9554 .init_hook = alc883_eee1601_inithook,
9556 [ALC1200_ASUS_P5Q] = {
9557 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9558 .init_verbs = { alc883_init_verbs },
9559 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9560 .dac_nids = alc883_dac_nids,
9561 .dig_out_nid = ALC1200_DIGOUT_NID,
9562 .dig_in_nid = ALC883_DIGIN_NID,
9563 .slave_dig_outs = alc1200_slave_dig_outs,
9564 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9565 .channel_mode = alc883_sixstack_modes,
9566 .input_mux = &alc883_capture_source,
9568 [ALC889A_MB31] = {
9569 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9570 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9571 alc880_gpio1_init_verbs },
9572 .adc_nids = alc883_adc_nids,
9573 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9574 .dac_nids = alc883_dac_nids,
9575 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9576 .channel_mode = alc889A_mb31_6ch_modes,
9577 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9578 .input_mux = &alc889A_mb31_capture_source,
9579 .dig_out_nid = ALC883_DIGOUT_NID,
9580 .unsol_event = alc889A_mb31_unsol_event,
9581 .init_hook = alc889A_mb31_automute,
9583 [ALC883_SONY_VAIO_TT] = {
9584 .mixers = { alc883_vaiott_mixer },
9585 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9586 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9587 .dac_nids = alc883_dac_nids,
9588 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9589 .channel_mode = alc883_3ST_2ch_modes,
9590 .input_mux = &alc883_capture_source,
9591 .unsol_event = alc_automute_amp_unsol_event,
9592 .setup = alc883_vaiott_setup,
9593 .init_hook = alc_automute_amp,
9599 * Pin config fixes
9601 enum {
9602 PINFIX_ABIT_AW9D_MAX
9605 static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9606 { 0x15, 0x01080104 }, /* side */
9607 { 0x16, 0x01011012 }, /* rear */
9608 { 0x17, 0x01016011 }, /* clfe */
9612 static const struct alc_fixup alc882_fixups[] = {
9613 [PINFIX_ABIT_AW9D_MAX] = {
9614 .pins = alc882_abit_aw9d_pinfix
9618 static struct snd_pci_quirk alc882_fixup_tbl[] = {
9619 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9624 * BIOS auto configuration
9626 static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9627 const struct auto_pin_cfg *cfg)
9629 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9632 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
9633 hda_nid_t nid, int pin_type,
9634 int dac_idx)
9636 /* set as output */
9637 struct alc_spec *spec = codec->spec;
9638 int idx;
9640 alc_set_pin_output(codec, nid, pin_type);
9641 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9642 idx = 4;
9643 else
9644 idx = spec->multiout.dac_nids[dac_idx] - 2;
9645 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9649 static void alc882_auto_init_multi_out(struct hda_codec *codec)
9651 struct alc_spec *spec = codec->spec;
9652 int i;
9654 for (i = 0; i <= HDA_SIDE; i++) {
9655 hda_nid_t nid = spec->autocfg.line_out_pins[i];
9656 int pin_type = get_pin_type(spec->autocfg.line_out_type);
9657 if (nid)
9658 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
9663 static void alc882_auto_init_hp_out(struct hda_codec *codec)
9665 struct alc_spec *spec = codec->spec;
9666 hda_nid_t pin;
9668 pin = spec->autocfg.hp_pins[0];
9669 if (pin) /* connect to front */
9670 /* use dac 0 */
9671 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
9672 pin = spec->autocfg.speaker_pins[0];
9673 if (pin)
9674 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
9677 static void alc882_auto_init_analog_input(struct hda_codec *codec)
9679 struct alc_spec *spec = codec->spec;
9680 int i;
9682 for (i = 0; i < AUTO_PIN_LAST; i++) {
9683 hda_nid_t nid = spec->autocfg.input_pins[i];
9684 if (!nid)
9685 continue;
9686 alc_set_input_pin(codec, nid, i);
9687 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9688 snd_hda_codec_write(codec, nid, 0,
9689 AC_VERB_SET_AMP_GAIN_MUTE,
9690 AMP_OUT_MUTE);
9694 static void alc882_auto_init_input_src(struct hda_codec *codec)
9696 struct alc_spec *spec = codec->spec;
9697 int c;
9699 for (c = 0; c < spec->num_adc_nids; c++) {
9700 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9701 hda_nid_t nid = spec->capsrc_nids[c];
9702 unsigned int mux_idx;
9703 const struct hda_input_mux *imux;
9704 int conns, mute, idx, item;
9706 conns = snd_hda_get_connections(codec, nid, conn_list,
9707 ARRAY_SIZE(conn_list));
9708 if (conns < 0)
9709 continue;
9710 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9711 imux = &spec->input_mux[mux_idx];
9712 for (idx = 0; idx < conns; idx++) {
9713 /* if the current connection is the selected one,
9714 * unmute it as default - otherwise mute it
9716 mute = AMP_IN_MUTE(idx);
9717 for (item = 0; item < imux->num_items; item++) {
9718 if (imux->items[item].index == idx) {
9719 if (spec->cur_mux[c] == item)
9720 mute = AMP_IN_UNMUTE(idx);
9721 break;
9724 /* check if we have a selector or mixer
9725 * we could check for the widget type instead, but
9726 * just check for Amp-In presence (in case of mixer
9727 * without amp-in there is something wrong, this
9728 * function shouldn't be used or capsrc nid is wrong)
9730 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
9731 snd_hda_codec_write(codec, nid, 0,
9732 AC_VERB_SET_AMP_GAIN_MUTE,
9733 mute);
9734 else if (mute != AMP_IN_MUTE(idx))
9735 snd_hda_codec_write(codec, nid, 0,
9736 AC_VERB_SET_CONNECT_SEL,
9737 idx);
9742 /* add mic boosts if needed */
9743 static int alc_auto_add_mic_boost(struct hda_codec *codec)
9745 struct alc_spec *spec = codec->spec;
9746 int err;
9747 hda_nid_t nid;
9749 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9750 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9751 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9752 "Mic Boost",
9753 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9754 if (err < 0)
9755 return err;
9757 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9758 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9759 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9760 "Front Mic Boost",
9761 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9762 if (err < 0)
9763 return err;
9765 return 0;
9768 /* almost identical with ALC880 parser... */
9769 static int alc882_parse_auto_config(struct hda_codec *codec)
9771 struct alc_spec *spec = codec->spec;
9772 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9773 int i, err;
9775 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9776 alc882_ignore);
9777 if (err < 0)
9778 return err;
9779 if (!spec->autocfg.line_outs)
9780 return 0; /* can't find valid BIOS pin config */
9782 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9783 if (err < 0)
9784 return err;
9785 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9786 if (err < 0)
9787 return err;
9788 err = alc880_auto_create_extra_out(spec,
9789 spec->autocfg.speaker_pins[0],
9790 "Speaker");
9791 if (err < 0)
9792 return err;
9793 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9794 "Headphone");
9795 if (err < 0)
9796 return err;
9797 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9798 if (err < 0)
9799 return err;
9801 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9803 /* check multiple SPDIF-out (for recent codecs) */
9804 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9805 hda_nid_t dig_nid;
9806 err = snd_hda_get_connections(codec,
9807 spec->autocfg.dig_out_pins[i],
9808 &dig_nid, 1);
9809 if (err < 0)
9810 continue;
9811 if (!i)
9812 spec->multiout.dig_out_nid = dig_nid;
9813 else {
9814 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
9815 spec->slave_dig_outs[i - 1] = dig_nid;
9816 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
9817 break;
9820 if (spec->autocfg.dig_in_pin)
9821 spec->dig_in_nid = ALC880_DIGIN_NID;
9823 if (spec->kctls.list)
9824 add_mixer(spec, spec->kctls.list);
9826 add_verb(spec, alc883_auto_init_verbs);
9827 /* if ADC 0x07 is available, initialize it, too */
9828 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9829 add_verb(spec, alc882_adc1_init_verbs);
9831 spec->num_mux_defs = 1;
9832 spec->input_mux = &spec->private_imux[0];
9834 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
9836 err = alc_auto_add_mic_boost(codec);
9837 if (err < 0)
9838 return err;
9840 return 1; /* config found */
9843 /* additional initialization for auto-configuration model */
9844 static void alc882_auto_init(struct hda_codec *codec)
9846 struct alc_spec *spec = codec->spec;
9847 alc882_auto_init_multi_out(codec);
9848 alc882_auto_init_hp_out(codec);
9849 alc882_auto_init_analog_input(codec);
9850 alc882_auto_init_input_src(codec);
9851 if (spec->unsol_event)
9852 alc_inithook(codec);
9855 static int patch_alc882(struct hda_codec *codec)
9857 struct alc_spec *spec;
9858 int err, board_config;
9860 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9861 if (spec == NULL)
9862 return -ENOMEM;
9864 codec->spec = spec;
9866 switch (codec->vendor_id) {
9867 case 0x10ec0882:
9868 case 0x10ec0885:
9869 break;
9870 default:
9871 /* ALC883 and variants */
9872 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9873 break;
9876 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9877 alc882_models,
9878 alc882_cfg_tbl);
9880 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9881 board_config = snd_hda_check_board_codec_sid_config(codec,
9882 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9884 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
9885 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
9886 codec->chip_name);
9887 board_config = ALC882_AUTO;
9890 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
9892 if (board_config == ALC882_AUTO) {
9893 /* automatic parse from the BIOS config */
9894 err = alc882_parse_auto_config(codec);
9895 if (err < 0) {
9896 alc_free(codec);
9897 return err;
9898 } else if (!err) {
9899 printk(KERN_INFO
9900 "hda_codec: Cannot set up configuration "
9901 "from BIOS. Using base mode...\n");
9902 board_config = ALC882_3ST_DIG;
9906 err = snd_hda_attach_beep_device(codec, 0x1);
9907 if (err < 0) {
9908 alc_free(codec);
9909 return err;
9912 if (board_config != ALC882_AUTO)
9913 setup_preset(codec, &alc882_presets[board_config]);
9915 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9916 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9917 /* FIXME: setup DAC5 */
9918 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9919 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9921 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9922 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9924 if (codec->vendor_id == 0x10ec0888)
9925 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
9927 if (!spec->adc_nids && spec->input_mux) {
9928 int i;
9929 spec->num_adc_nids = 0;
9930 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9931 hda_nid_t cap;
9932 hda_nid_t nid = alc882_adc_nids[i];
9933 unsigned int wcap = get_wcaps(codec, nid);
9934 /* get type */
9935 wcap = get_wcaps_type(wcap);
9936 if (wcap != AC_WID_AUD_IN)
9937 continue;
9938 spec->private_adc_nids[spec->num_adc_nids] = nid;
9939 err = snd_hda_get_connections(codec, nid, &cap, 1);
9940 if (err < 0)
9941 continue;
9942 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9943 spec->num_adc_nids++;
9945 spec->adc_nids = spec->private_adc_nids;
9946 spec->capsrc_nids = spec->private_capsrc_nids;
9949 set_capture_mixer(codec);
9950 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9952 spec->vmaster_nid = 0x0c;
9954 codec->patch_ops = alc_patch_ops;
9955 if (board_config == ALC882_AUTO)
9956 spec->init_hook = alc882_auto_init;
9957 #ifdef CONFIG_SND_HDA_POWER_SAVE
9958 if (!spec->loopback.amplist)
9959 spec->loopback.amplist = alc882_loopbacks;
9960 #endif
9961 codec->proc_widget_hook = print_realtek_coef;
9963 return 0;
9968 * ALC262 support
9971 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9972 #define ALC262_DIGIN_NID ALC880_DIGIN_NID
9974 #define alc262_dac_nids alc260_dac_nids
9975 #define alc262_adc_nids alc882_adc_nids
9976 #define alc262_adc_nids_alt alc882_adc_nids_alt
9977 #define alc262_capsrc_nids alc882_capsrc_nids
9978 #define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
9980 #define alc262_modes alc260_modes
9981 #define alc262_capture_source alc882_capture_source
9983 static hda_nid_t alc262_dmic_adc_nids[1] = {
9984 /* ADC0 */
9985 0x09
9988 static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9990 static struct snd_kcontrol_new alc262_base_mixer[] = {
9991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9992 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9993 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9994 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9995 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9996 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9998 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9999 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10000 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10001 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10002 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10003 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10005 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10006 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
10007 { } /* end */
10010 /* update HP, line and mono-out pins according to the master switch */
10011 static void alc262_hp_master_update(struct hda_codec *codec)
10013 struct alc_spec *spec = codec->spec;
10014 int val = spec->master_sw;
10016 /* HP & line-out */
10017 snd_hda_codec_write_cache(codec, 0x1b, 0,
10018 AC_VERB_SET_PIN_WIDGET_CONTROL,
10019 val ? PIN_HP : 0);
10020 snd_hda_codec_write_cache(codec, 0x15, 0,
10021 AC_VERB_SET_PIN_WIDGET_CONTROL,
10022 val ? PIN_HP : 0);
10023 /* mono (speaker) depending on the HP jack sense */
10024 val = val && !spec->jack_present;
10025 snd_hda_codec_write_cache(codec, 0x16, 0,
10026 AC_VERB_SET_PIN_WIDGET_CONTROL,
10027 val ? PIN_OUT : 0);
10030 static void alc262_hp_bpc_automute(struct hda_codec *codec)
10032 struct alc_spec *spec = codec->spec;
10033 unsigned int presence;
10034 presence = snd_hda_codec_read(codec, 0x1b, 0,
10035 AC_VERB_GET_PIN_SENSE, 0);
10036 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10037 alc262_hp_master_update(codec);
10040 static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10042 if ((res >> 26) != ALC880_HP_EVENT)
10043 return;
10044 alc262_hp_bpc_automute(codec);
10047 static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10049 struct alc_spec *spec = codec->spec;
10050 unsigned int presence;
10051 presence = snd_hda_codec_read(codec, 0x15, 0,
10052 AC_VERB_GET_PIN_SENSE, 0);
10053 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
10054 alc262_hp_master_update(codec);
10057 static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10058 unsigned int res)
10060 if ((res >> 26) != ALC880_HP_EVENT)
10061 return;
10062 alc262_hp_wildwest_automute(codec);
10065 #define alc262_hp_master_sw_get alc260_hp_master_sw_get
10067 static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10068 struct snd_ctl_elem_value *ucontrol)
10070 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10071 struct alc_spec *spec = codec->spec;
10072 int val = !!*ucontrol->value.integer.value;
10074 if (val == spec->master_sw)
10075 return 0;
10076 spec->master_sw = val;
10077 alc262_hp_master_update(codec);
10078 return 1;
10081 #define ALC262_HP_MASTER_SWITCH \
10083 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10084 .name = "Master Playback Switch", \
10085 .info = snd_ctl_boolean_mono_info, \
10086 .get = alc262_hp_master_sw_get, \
10087 .put = alc262_hp_master_sw_put, \
10090 static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
10091 ALC262_HP_MASTER_SWITCH,
10092 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10093 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10095 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10096 HDA_OUTPUT),
10097 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10098 HDA_OUTPUT),
10099 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10100 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10101 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10102 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10103 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10104 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10105 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10106 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10107 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10108 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10109 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10110 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10111 { } /* end */
10114 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
10115 ALC262_HP_MASTER_SWITCH,
10116 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10117 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10118 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10119 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10120 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10121 HDA_OUTPUT),
10122 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10123 HDA_OUTPUT),
10124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
10126 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
10127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10129 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10130 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10131 { } /* end */
10134 static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10135 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10136 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10137 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
10138 { } /* end */
10141 /* mute/unmute internal speaker according to the hp jack and mute state */
10142 static void alc262_hp_t5735_setup(struct hda_codec *codec)
10144 struct alc_spec *spec = codec->spec;
10146 spec->autocfg.hp_pins[0] = 0x15;
10147 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
10150 static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
10151 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10152 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10153 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10154 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10157 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10158 { } /* end */
10161 static struct hda_verb alc262_hp_t5735_verbs[] = {
10162 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10163 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10165 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10169 static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
10170 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10171 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10172 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10173 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
10174 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10175 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10176 { } /* end */
10179 static struct hda_verb alc262_hp_rp5700_verbs[] = {
10180 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10181 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10182 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10183 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10184 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10185 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10186 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10187 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10188 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10193 static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10194 .num_items = 1,
10195 .items = {
10196 { "Line", 0x1 },
10200 /* bind hp and internal speaker mute (with plug check) as master switch */
10201 static void alc262_hippo_master_update(struct hda_codec *codec)
10203 struct alc_spec *spec = codec->spec;
10204 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10205 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10206 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10207 unsigned int mute;
10209 /* HP */
10210 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10211 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10212 HDA_AMP_MUTE, mute);
10213 /* mute internal speaker per jack sense */
10214 if (spec->jack_present)
10215 mute = HDA_AMP_MUTE;
10216 if (line_nid)
10217 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10218 HDA_AMP_MUTE, mute);
10219 if (speaker_nid && speaker_nid != line_nid)
10220 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10221 HDA_AMP_MUTE, mute);
10224 #define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10226 static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10227 struct snd_ctl_elem_value *ucontrol)
10229 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10230 struct alc_spec *spec = codec->spec;
10231 int val = !!*ucontrol->value.integer.value;
10233 if (val == spec->master_sw)
10234 return 0;
10235 spec->master_sw = val;
10236 alc262_hippo_master_update(codec);
10237 return 1;
10240 #define ALC262_HIPPO_MASTER_SWITCH \
10242 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10243 .name = "Master Playback Switch", \
10244 .info = snd_ctl_boolean_mono_info, \
10245 .get = alc262_hippo_master_sw_get, \
10246 .put = alc262_hippo_master_sw_put, \
10249 static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10250 ALC262_HIPPO_MASTER_SWITCH,
10251 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10252 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10253 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10254 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10255 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10256 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10257 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10258 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10259 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10260 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10261 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10262 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10263 { } /* end */
10266 static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10267 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10268 ALC262_HIPPO_MASTER_SWITCH,
10269 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10270 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10271 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10272 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10273 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10274 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10275 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10276 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10277 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10278 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10279 { } /* end */
10282 /* mute/unmute internal speaker according to the hp jack and mute state */
10283 static void alc262_hippo_automute(struct hda_codec *codec)
10285 struct alc_spec *spec = codec->spec;
10286 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10287 unsigned int present;
10289 /* need to execute and sync at first */
10290 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10291 present = snd_hda_codec_read(codec, hp_nid, 0,
10292 AC_VERB_GET_PIN_SENSE, 0);
10293 spec->jack_present = (present & 0x80000000) != 0;
10294 alc262_hippo_master_update(codec);
10297 static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10299 if ((res >> 26) != ALC880_HP_EVENT)
10300 return;
10301 alc262_hippo_automute(codec);
10304 static void alc262_hippo_setup(struct hda_codec *codec)
10306 struct alc_spec *spec = codec->spec;
10308 spec->autocfg.hp_pins[0] = 0x15;
10309 spec->autocfg.speaker_pins[0] = 0x14;
10312 static void alc262_hippo1_setup(struct hda_codec *codec)
10314 struct alc_spec *spec = codec->spec;
10316 spec->autocfg.hp_pins[0] = 0x1b;
10317 spec->autocfg.speaker_pins[0] = 0x14;
10321 static struct snd_kcontrol_new alc262_sony_mixer[] = {
10322 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10323 ALC262_HIPPO_MASTER_SWITCH,
10324 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10325 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10326 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10327 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10328 { } /* end */
10331 static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
10332 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10333 ALC262_HIPPO_MASTER_SWITCH,
10334 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10336 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10337 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10338 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10339 { } /* end */
10342 static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10343 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10344 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10345 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10346 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10347 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10348 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10349 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10350 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10351 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10352 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10353 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10354 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10355 { } /* end */
10358 static struct hda_verb alc262_tyan_verbs[] = {
10359 /* Headphone automute */
10360 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10361 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10362 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10364 /* P11 AUX_IN, white 4-pin connector */
10365 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10366 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10367 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10368 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10373 /* unsolicited event for HP jack sensing */
10374 static void alc262_tyan_setup(struct hda_codec *codec)
10376 struct alc_spec *spec = codec->spec;
10378 spec->autocfg.hp_pins[0] = 0x1b;
10379 spec->autocfg.speaker_pins[0] = 0x15;
10383 #define alc262_capture_mixer alc882_capture_mixer
10384 #define alc262_capture_alt_mixer alc882_capture_alt_mixer
10387 * generic initialization of ADC, input mixers and output mixers
10389 static struct hda_verb alc262_init_verbs[] = {
10391 * Unmute ADC0-2 and set the default input to mic-in
10393 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10395 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10396 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10397 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10398 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10400 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
10401 * mixer widget
10402 * Note: PASD motherboards uses the Line In 2 as the input for
10403 * front panel mic (mic 2)
10405 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
10406 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10407 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10408 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10409 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10413 * Set up output mixers (0x0c - 0x0e)
10415 /* set vol=0 to output mixers */
10416 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10417 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10418 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10419 /* set up input amps for analog loopback */
10420 /* Amp Indices: DAC = 0, mixer = 1 */
10421 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10422 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10423 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10424 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10425 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10426 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10428 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10429 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10430 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10431 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10432 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10433 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10435 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10437 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10438 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10439 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10441 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10442 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10444 /* FIXME: use matrix-type input source selection */
10445 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10446 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10447 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10451 /* Input mixer2 */
10452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10456 /* Input mixer3 */
10457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10465 static struct hda_verb alc262_eapd_verbs[] = {
10466 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10467 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10471 static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10472 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10473 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10474 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10476 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10477 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10481 static struct hda_verb alc262_sony_unsol_verbs[] = {
10482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10483 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10484 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10486 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10487 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10491 static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10492 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10493 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10494 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10495 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10496 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10497 { } /* end */
10500 static struct hda_verb alc262_toshiba_s06_verbs[] = {
10501 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10502 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10503 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10504 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10505 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10506 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10507 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10508 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10512 static void alc262_toshiba_s06_setup(struct hda_codec *codec)
10514 struct alc_spec *spec = codec->spec;
10516 spec->autocfg.hp_pins[0] = 0x15;
10517 spec->autocfg.speaker_pins[0] = 0x14;
10518 spec->ext_mic.pin = 0x18;
10519 spec->ext_mic.mux_idx = 0;
10520 spec->int_mic.pin = 0x12;
10521 spec->int_mic.mux_idx = 9;
10522 spec->auto_mic = 1;
10526 * nec model
10527 * 0x15 = headphone
10528 * 0x16 = internal speaker
10529 * 0x18 = external mic
10532 static struct snd_kcontrol_new alc262_nec_mixer[] = {
10533 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10534 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10536 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10537 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10538 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10540 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10541 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10542 { } /* end */
10545 static struct hda_verb alc262_nec_verbs[] = {
10546 /* Unmute Speaker */
10547 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10549 /* Headphone */
10550 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10553 /* External mic to headphone */
10554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10555 /* External mic to speaker */
10556 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10561 * fujitsu model
10562 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10563 * 0x1b = port replicator headphone out
10566 #define ALC_HP_EVENT 0x37
10568 static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10569 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10570 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10571 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10572 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10576 static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10577 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10578 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10582 static struct hda_input_mux alc262_fujitsu_capture_source = {
10583 .num_items = 3,
10584 .items = {
10585 { "Mic", 0x0 },
10586 { "Int Mic", 0x1 },
10587 { "CD", 0x4 },
10591 static struct hda_input_mux alc262_HP_capture_source = {
10592 .num_items = 5,
10593 .items = {
10594 { "Mic", 0x0 },
10595 { "Front Mic", 0x1 },
10596 { "Line", 0x2 },
10597 { "CD", 0x4 },
10598 { "AUX IN", 0x6 },
10602 static struct hda_input_mux alc262_HP_D7000_capture_source = {
10603 .num_items = 4,
10604 .items = {
10605 { "Mic", 0x0 },
10606 { "Front Mic", 0x2 },
10607 { "Line", 0x1 },
10608 { "CD", 0x4 },
10612 /* mute/unmute internal speaker according to the hp jacks and mute state */
10613 static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10615 struct alc_spec *spec = codec->spec;
10616 unsigned int mute;
10618 if (force || !spec->sense_updated) {
10619 unsigned int present;
10620 /* need to execute and sync at first */
10621 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
10622 /* check laptop HP jack */
10623 present = snd_hda_codec_read(codec, 0x14, 0,
10624 AC_VERB_GET_PIN_SENSE, 0);
10625 /* need to execute and sync at first */
10626 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10627 /* check docking HP jack */
10628 present |= snd_hda_codec_read(codec, 0x1b, 0,
10629 AC_VERB_GET_PIN_SENSE, 0);
10630 if (present & AC_PINSENSE_PRESENCE)
10631 spec->jack_present = 1;
10632 else
10633 spec->jack_present = 0;
10634 spec->sense_updated = 1;
10636 /* unmute internal speaker only if both HPs are unplugged and
10637 * master switch is on
10639 if (spec->jack_present)
10640 mute = HDA_AMP_MUTE;
10641 else
10642 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10643 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10644 HDA_AMP_MUTE, mute);
10647 /* unsolicited event for HP jack sensing */
10648 static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10649 unsigned int res)
10651 if ((res >> 26) != ALC_HP_EVENT)
10652 return;
10653 alc262_fujitsu_automute(codec, 1);
10656 static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10658 alc262_fujitsu_automute(codec, 1);
10661 /* bind volumes of both NID 0x0c and 0x0d */
10662 static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10663 .ops = &snd_hda_bind_vol,
10664 .values = {
10665 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10666 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10671 /* mute/unmute internal speaker according to the hp jack and mute state */
10672 static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10674 struct alc_spec *spec = codec->spec;
10675 unsigned int mute;
10677 if (force || !spec->sense_updated) {
10678 unsigned int present_int_hp;
10679 /* need to execute and sync at first */
10680 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10681 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10682 AC_VERB_GET_PIN_SENSE, 0);
10683 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10684 spec->sense_updated = 1;
10686 if (spec->jack_present) {
10687 /* mute internal speaker */
10688 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10689 HDA_AMP_MUTE, HDA_AMP_MUTE);
10690 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10691 HDA_AMP_MUTE, HDA_AMP_MUTE);
10692 } else {
10693 /* unmute internal speaker if necessary */
10694 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10695 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10696 HDA_AMP_MUTE, mute);
10697 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10698 HDA_AMP_MUTE, mute);
10702 /* unsolicited event for HP jack sensing */
10703 static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10704 unsigned int res)
10706 if ((res >> 26) != ALC_HP_EVENT)
10707 return;
10708 alc262_lenovo_3000_automute(codec, 1);
10711 static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10712 int dir, int idx, long *valp)
10714 int i, change = 0;
10716 for (i = 0; i < 2; i++, valp++)
10717 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10718 HDA_AMP_MUTE,
10719 *valp ? 0 : HDA_AMP_MUTE);
10720 return change;
10723 /* bind hp and internal speaker mute (with plug check) */
10724 static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10725 struct snd_ctl_elem_value *ucontrol)
10727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10728 long *valp = ucontrol->value.integer.value;
10729 int change;
10731 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10732 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
10733 if (change)
10734 alc262_fujitsu_automute(codec, 0);
10735 return change;
10738 static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
10739 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10742 .name = "Master Playback Switch",
10743 .info = snd_hda_mixer_amp_switch_info,
10744 .get = snd_hda_mixer_amp_switch_get,
10745 .put = alc262_fujitsu_master_sw_put,
10746 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10748 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10749 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10750 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10751 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10752 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10753 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10754 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10755 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10756 { } /* end */
10759 /* bind hp and internal speaker mute (with plug check) */
10760 static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10761 struct snd_ctl_elem_value *ucontrol)
10763 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10764 long *valp = ucontrol->value.integer.value;
10765 int change;
10767 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
10768 if (change)
10769 alc262_lenovo_3000_automute(codec, 0);
10770 return change;
10773 static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10774 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10777 .name = "Master Playback Switch",
10778 .info = snd_hda_mixer_amp_switch_info,
10779 .get = snd_hda_mixer_amp_switch_get,
10780 .put = alc262_lenovo_3000_master_sw_put,
10781 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10783 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10784 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10785 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10787 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10788 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10789 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10790 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10791 { } /* end */
10794 static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10795 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10796 ALC262_HIPPO_MASTER_SWITCH,
10797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10799 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10800 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10801 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10802 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10803 { } /* end */
10806 /* additional init verbs for Benq laptops */
10807 static struct hda_verb alc262_EAPD_verbs[] = {
10808 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10809 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10813 static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10814 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10815 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10817 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10818 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10822 /* Samsung Q1 Ultra Vista model setup */
10823 static struct snd_kcontrol_new alc262_ultra_mixer[] = {
10824 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10825 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10826 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10827 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10828 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
10829 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
10830 { } /* end */
10833 static struct hda_verb alc262_ultra_verbs[] = {
10834 /* output mixer */
10835 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10837 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10838 /* speaker */
10839 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10840 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10842 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10843 /* HP */
10844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10846 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10847 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10848 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10849 /* internal mic */
10850 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10851 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10852 /* ADC, choose mic */
10853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10854 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10855 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
10866 /* mute/unmute internal speaker according to the hp jack and mute state */
10867 static void alc262_ultra_automute(struct hda_codec *codec)
10869 struct alc_spec *spec = codec->spec;
10870 unsigned int mute;
10872 mute = 0;
10873 /* auto-mute only when HP is used as HP */
10874 if (!spec->cur_mux[0]) {
10875 unsigned int present;
10876 /* need to execute and sync at first */
10877 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10878 present = snd_hda_codec_read(codec, 0x15, 0,
10879 AC_VERB_GET_PIN_SENSE, 0);
10880 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10881 if (spec->jack_present)
10882 mute = HDA_AMP_MUTE;
10884 /* mute/unmute internal speaker */
10885 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10886 HDA_AMP_MUTE, mute);
10887 /* mute/unmute HP */
10888 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10889 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
10892 /* unsolicited event for HP jack sensing */
10893 static void alc262_ultra_unsol_event(struct hda_codec *codec,
10894 unsigned int res)
10896 if ((res >> 26) != ALC880_HP_EVENT)
10897 return;
10898 alc262_ultra_automute(codec);
10901 static struct hda_input_mux alc262_ultra_capture_source = {
10902 .num_items = 2,
10903 .items = {
10904 { "Mic", 0x1 },
10905 { "Headphone", 0x7 },
10909 static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10910 struct snd_ctl_elem_value *ucontrol)
10912 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10913 struct alc_spec *spec = codec->spec;
10914 int ret;
10916 ret = alc_mux_enum_put(kcontrol, ucontrol);
10917 if (!ret)
10918 return 0;
10919 /* reprogram the HP pin as mic or HP according to the input source */
10920 snd_hda_codec_write_cache(codec, 0x15, 0,
10921 AC_VERB_SET_PIN_WIDGET_CONTROL,
10922 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10923 alc262_ultra_automute(codec); /* mute/unmute HP */
10924 return ret;
10927 static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10928 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10929 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10932 .name = "Capture Source",
10933 .info = alc_mux_enum_info,
10934 .get = alc_mux_enum_get,
10935 .put = alc262_ultra_mux_enum_put,
10937 { } /* end */
10940 /* We use two mixers depending on the output pin; 0x16 is a mono output
10941 * and thus it's bound with a different mixer.
10942 * This function returns which mixer amp should be used.
10944 static int alc262_check_volbit(hda_nid_t nid)
10946 if (!nid)
10947 return 0;
10948 else if (nid == 0x16)
10949 return 2;
10950 else
10951 return 1;
10954 static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10955 const char *pfx, int *vbits)
10957 unsigned long val;
10958 int vbit;
10960 vbit = alc262_check_volbit(nid);
10961 if (!vbit)
10962 return 0;
10963 if (*vbits & vbit) /* a volume control for this mixer already there */
10964 return 0;
10965 *vbits |= vbit;
10966 if (vbit == 2)
10967 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10968 else
10969 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
10970 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
10973 static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10974 const char *pfx)
10976 unsigned long val;
10978 if (!nid)
10979 return 0;
10980 if (nid == 0x16)
10981 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10982 else
10983 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
10984 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
10987 /* add playback controls from the parsed DAC table */
10988 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10989 const struct auto_pin_cfg *cfg)
10991 const char *pfx;
10992 int vbits;
10993 int err;
10995 spec->multiout.num_dacs = 1; /* only use one dac */
10996 spec->multiout.dac_nids = spec->private_dac_nids;
10997 spec->multiout.dac_nids[0] = 2;
10999 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11000 pfx = "Master";
11001 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11002 pfx = "Speaker";
11003 else
11004 pfx = "Front";
11005 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11006 if (err < 0)
11007 return err;
11008 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11009 if (err < 0)
11010 return err;
11011 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11012 if (err < 0)
11013 return err;
11015 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11016 alc262_check_volbit(cfg->speaker_pins[0]) |
11017 alc262_check_volbit(cfg->hp_pins[0]);
11018 if (vbits == 1 || vbits == 2)
11019 pfx = "Master"; /* only one mixer is used */
11020 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11021 pfx = "Speaker";
11022 else
11023 pfx = "Front";
11024 vbits = 0;
11025 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11026 if (err < 0)
11027 return err;
11028 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11029 &vbits);
11030 if (err < 0)
11031 return err;
11032 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11033 &vbits);
11034 if (err < 0)
11035 return err;
11036 return 0;
11039 #define alc262_auto_create_input_ctls \
11040 alc880_auto_create_input_ctls
11043 * generic initialization of ADC, input mixers and output mixers
11045 static struct hda_verb alc262_volume_init_verbs[] = {
11047 * Unmute ADC0-2 and set the default input to mic-in
11049 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11051 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11052 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11053 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11054 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11056 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11057 * mixer widget
11058 * Note: PASD motherboards uses the Line In 2 as the input for
11059 * front panel mic (mic 2)
11061 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11062 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11063 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11064 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11065 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11066 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11069 * Set up output mixers (0x0c - 0x0f)
11071 /* set vol=0 to output mixers */
11072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11076 /* set up input amps for analog loopback */
11077 /* Amp Indices: DAC = 0, mixer = 1 */
11078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11081 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11083 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11085 /* FIXME: use matrix-type input source selection */
11086 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11087 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11088 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11089 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11090 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11091 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11092 /* Input mixer2 */
11093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11094 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11096 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11097 /* Input mixer3 */
11098 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11099 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11106 static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11108 * Unmute ADC0-2 and set the default input to mic-in
11110 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11112 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11113 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11114 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11115 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11117 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11118 * mixer widget
11119 * Note: PASD motherboards uses the Line In 2 as the input for
11120 * front panel mic (mic 2)
11122 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11123 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11124 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11125 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11126 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11127 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11128 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11129 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11132 * Set up output mixers (0x0c - 0x0e)
11134 /* set vol=0 to output mixers */
11135 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11136 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11137 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11139 /* set up input amps for analog loopback */
11140 /* Amp Indices: DAC = 0, mixer = 1 */
11141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11142 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11143 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11144 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11145 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11146 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11148 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11149 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11150 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11152 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11153 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11155 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11156 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11158 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11159 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11160 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11161 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11162 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11164 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11165 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11166 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11167 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11168 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11169 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11172 /* FIXME: use matrix-type input source selection */
11173 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11174 /* Input mixer1: only unmute Mic */
11175 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11176 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11177 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11178 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11179 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11180 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11181 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11182 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11183 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
11184 /* Input mixer2 */
11185 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11186 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11188 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11192 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11193 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
11194 /* Input mixer3 */
11195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11198 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11199 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11200 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11201 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11202 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
11205 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11210 static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11212 * Unmute ADC0-2 and set the default input to mic-in
11214 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11216 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11217 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11218 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11219 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11221 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
11222 * mixer widget
11223 * Note: PASD motherboards uses the Line In 2 as the input for front
11224 * panel mic (mic 2)
11226 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11229 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11230 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11231 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11236 * Set up output mixers (0x0c - 0x0e)
11238 /* set vol=0 to output mixers */
11239 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11240 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11241 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11243 /* set up input amps for analog loopback */
11244 /* Amp Indices: DAC = 0, mixer = 1 */
11245 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11246 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11247 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11248 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11253 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11254 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11255 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11256 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11257 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11258 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11259 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11262 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11264 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11265 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11267 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11269 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11271 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11272 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11274 /* FIXME: use matrix-type input source selection */
11275 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11276 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11280 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11282 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11283 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11284 /* Input mixer2 */
11285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11287 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11288 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11289 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11290 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11292 /* Input mixer3 */
11293 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11294 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11295 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11298 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11301 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11306 static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11309 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11310 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11312 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11313 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11314 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11315 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11318 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11319 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11324 #ifdef CONFIG_SND_HDA_POWER_SAVE
11325 #define alc262_loopbacks alc880_loopbacks
11326 #endif
11328 /* pcm configuration: identical with ALC880 */
11329 #define alc262_pcm_analog_playback alc880_pcm_analog_playback
11330 #define alc262_pcm_analog_capture alc880_pcm_analog_capture
11331 #define alc262_pcm_digital_playback alc880_pcm_digital_playback
11332 #define alc262_pcm_digital_capture alc880_pcm_digital_capture
11335 * BIOS auto configuration
11337 static int alc262_parse_auto_config(struct hda_codec *codec)
11339 struct alc_spec *spec = codec->spec;
11340 int err;
11341 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11343 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11344 alc262_ignore);
11345 if (err < 0)
11346 return err;
11347 if (!spec->autocfg.line_outs) {
11348 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11349 spec->multiout.max_channels = 2;
11350 spec->no_analog = 1;
11351 goto dig_only;
11353 return 0; /* can't find valid BIOS pin config */
11355 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11356 if (err < 0)
11357 return err;
11358 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
11359 if (err < 0)
11360 return err;
11362 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11364 dig_only:
11365 if (spec->autocfg.dig_outs) {
11366 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
11367 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11369 if (spec->autocfg.dig_in_pin)
11370 spec->dig_in_nid = ALC262_DIGIN_NID;
11372 if (spec->kctls.list)
11373 add_mixer(spec, spec->kctls.list);
11375 add_verb(spec, alc262_volume_init_verbs);
11376 spec->num_mux_defs = 1;
11377 spec->input_mux = &spec->private_imux[0];
11379 err = alc_auto_add_mic_boost(codec);
11380 if (err < 0)
11381 return err;
11383 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11385 return 1;
11388 #define alc262_auto_init_multi_out alc882_auto_init_multi_out
11389 #define alc262_auto_init_hp_out alc882_auto_init_hp_out
11390 #define alc262_auto_init_analog_input alc882_auto_init_analog_input
11391 #define alc262_auto_init_input_src alc882_auto_init_input_src
11394 /* init callback for auto-configuration model -- overriding the default init */
11395 static void alc262_auto_init(struct hda_codec *codec)
11397 struct alc_spec *spec = codec->spec;
11398 alc262_auto_init_multi_out(codec);
11399 alc262_auto_init_hp_out(codec);
11400 alc262_auto_init_analog_input(codec);
11401 alc262_auto_init_input_src(codec);
11402 if (spec->unsol_event)
11403 alc_inithook(codec);
11407 * configuration and preset
11409 static const char *alc262_models[ALC262_MODEL_LAST] = {
11410 [ALC262_BASIC] = "basic",
11411 [ALC262_HIPPO] = "hippo",
11412 [ALC262_HIPPO_1] = "hippo_1",
11413 [ALC262_FUJITSU] = "fujitsu",
11414 [ALC262_HP_BPC] = "hp-bpc",
11415 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
11416 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
11417 [ALC262_HP_RP5700] = "hp-rp5700",
11418 [ALC262_BENQ_ED8] = "benq",
11419 [ALC262_BENQ_T31] = "benq-t31",
11420 [ALC262_SONY_ASSAMD] = "sony-assamd",
11421 [ALC262_TOSHIBA_S06] = "toshiba-s06",
11422 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
11423 [ALC262_ULTRA] = "ultra",
11424 [ALC262_LENOVO_3000] = "lenovo-3000",
11425 [ALC262_NEC] = "nec",
11426 [ALC262_TYAN] = "tyan",
11427 [ALC262_AUTO] = "auto",
11430 static struct snd_pci_quirk alc262_cfg_tbl[] = {
11431 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
11432 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
11433 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11434 ALC262_HP_BPC),
11435 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11436 ALC262_HP_BPC),
11437 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11438 ALC262_HP_BPC),
11439 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
11440 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
11441 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
11442 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
11443 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
11444 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
11445 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
11446 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
11447 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11448 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11449 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
11450 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11451 ALC262_HP_TC_T5735),
11452 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
11453 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
11454 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
11455 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
11456 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
11457 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
11458 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11459 ALC262_SONY_ASSAMD),
11460 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
11461 ALC262_TOSHIBA_RX1),
11462 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
11463 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
11464 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
11465 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
11466 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11467 ALC262_ULTRA),
11468 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
11469 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
11470 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
11471 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
11472 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
11476 static struct alc_config_preset alc262_presets[] = {
11477 [ALC262_BASIC] = {
11478 .mixers = { alc262_base_mixer },
11479 .init_verbs = { alc262_init_verbs },
11480 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11481 .dac_nids = alc262_dac_nids,
11482 .hp_nid = 0x03,
11483 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11484 .channel_mode = alc262_modes,
11485 .input_mux = &alc262_capture_source,
11487 [ALC262_HIPPO] = {
11488 .mixers = { alc262_hippo_mixer },
11489 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
11490 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11491 .dac_nids = alc262_dac_nids,
11492 .hp_nid = 0x03,
11493 .dig_out_nid = ALC262_DIGOUT_NID,
11494 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11495 .channel_mode = alc262_modes,
11496 .input_mux = &alc262_capture_source,
11497 .unsol_event = alc262_hippo_unsol_event,
11498 .setup = alc262_hippo_setup,
11499 .init_hook = alc262_hippo_automute,
11501 [ALC262_HIPPO_1] = {
11502 .mixers = { alc262_hippo1_mixer },
11503 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11504 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11505 .dac_nids = alc262_dac_nids,
11506 .hp_nid = 0x02,
11507 .dig_out_nid = ALC262_DIGOUT_NID,
11508 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11509 .channel_mode = alc262_modes,
11510 .input_mux = &alc262_capture_source,
11511 .unsol_event = alc262_hippo_unsol_event,
11512 .setup = alc262_hippo1_setup,
11513 .init_hook = alc262_hippo_automute,
11515 [ALC262_FUJITSU] = {
11516 .mixers = { alc262_fujitsu_mixer },
11517 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11518 alc262_fujitsu_unsol_verbs },
11519 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11520 .dac_nids = alc262_dac_nids,
11521 .hp_nid = 0x03,
11522 .dig_out_nid = ALC262_DIGOUT_NID,
11523 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11524 .channel_mode = alc262_modes,
11525 .input_mux = &alc262_fujitsu_capture_source,
11526 .unsol_event = alc262_fujitsu_unsol_event,
11527 .init_hook = alc262_fujitsu_init_hook,
11529 [ALC262_HP_BPC] = {
11530 .mixers = { alc262_HP_BPC_mixer },
11531 .init_verbs = { alc262_HP_BPC_init_verbs },
11532 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11533 .dac_nids = alc262_dac_nids,
11534 .hp_nid = 0x03,
11535 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11536 .channel_mode = alc262_modes,
11537 .input_mux = &alc262_HP_capture_source,
11538 .unsol_event = alc262_hp_bpc_unsol_event,
11539 .init_hook = alc262_hp_bpc_automute,
11541 [ALC262_HP_BPC_D7000_WF] = {
11542 .mixers = { alc262_HP_BPC_WildWest_mixer },
11543 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11544 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11545 .dac_nids = alc262_dac_nids,
11546 .hp_nid = 0x03,
11547 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11548 .channel_mode = alc262_modes,
11549 .input_mux = &alc262_HP_D7000_capture_source,
11550 .unsol_event = alc262_hp_wildwest_unsol_event,
11551 .init_hook = alc262_hp_wildwest_automute,
11553 [ALC262_HP_BPC_D7000_WL] = {
11554 .mixers = { alc262_HP_BPC_WildWest_mixer,
11555 alc262_HP_BPC_WildWest_option_mixer },
11556 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11557 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11558 .dac_nids = alc262_dac_nids,
11559 .hp_nid = 0x03,
11560 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11561 .channel_mode = alc262_modes,
11562 .input_mux = &alc262_HP_D7000_capture_source,
11563 .unsol_event = alc262_hp_wildwest_unsol_event,
11564 .init_hook = alc262_hp_wildwest_automute,
11566 [ALC262_HP_TC_T5735] = {
11567 .mixers = { alc262_hp_t5735_mixer },
11568 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11569 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11570 .dac_nids = alc262_dac_nids,
11571 .hp_nid = 0x03,
11572 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11573 .channel_mode = alc262_modes,
11574 .input_mux = &alc262_capture_source,
11575 .unsol_event = alc_automute_amp_unsol_event,
11576 .setup = alc262_hp_t5735_setup,
11577 .init_hook = alc_automute_amp,
11579 [ALC262_HP_RP5700] = {
11580 .mixers = { alc262_hp_rp5700_mixer },
11581 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11582 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11583 .dac_nids = alc262_dac_nids,
11584 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11585 .channel_mode = alc262_modes,
11586 .input_mux = &alc262_hp_rp5700_capture_source,
11588 [ALC262_BENQ_ED8] = {
11589 .mixers = { alc262_base_mixer },
11590 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11591 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11592 .dac_nids = alc262_dac_nids,
11593 .hp_nid = 0x03,
11594 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11595 .channel_mode = alc262_modes,
11596 .input_mux = &alc262_capture_source,
11598 [ALC262_SONY_ASSAMD] = {
11599 .mixers = { alc262_sony_mixer },
11600 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11601 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11602 .dac_nids = alc262_dac_nids,
11603 .hp_nid = 0x02,
11604 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11605 .channel_mode = alc262_modes,
11606 .input_mux = &alc262_capture_source,
11607 .unsol_event = alc262_hippo_unsol_event,
11608 .setup = alc262_hippo_setup,
11609 .init_hook = alc262_hippo_automute,
11611 [ALC262_BENQ_T31] = {
11612 .mixers = { alc262_benq_t31_mixer },
11613 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11614 alc_hp15_unsol_verbs },
11615 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11616 .dac_nids = alc262_dac_nids,
11617 .hp_nid = 0x03,
11618 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11619 .channel_mode = alc262_modes,
11620 .input_mux = &alc262_capture_source,
11621 .unsol_event = alc262_hippo_unsol_event,
11622 .setup = alc262_hippo_setup,
11623 .init_hook = alc262_hippo_automute,
11625 [ALC262_ULTRA] = {
11626 .mixers = { alc262_ultra_mixer },
11627 .cap_mixer = alc262_ultra_capture_mixer,
11628 .init_verbs = { alc262_ultra_verbs },
11629 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11630 .dac_nids = alc262_dac_nids,
11631 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11632 .channel_mode = alc262_modes,
11633 .input_mux = &alc262_ultra_capture_source,
11634 .adc_nids = alc262_adc_nids, /* ADC0 */
11635 .capsrc_nids = alc262_capsrc_nids,
11636 .num_adc_nids = 1, /* single ADC */
11637 .unsol_event = alc262_ultra_unsol_event,
11638 .init_hook = alc262_ultra_automute,
11640 [ALC262_LENOVO_3000] = {
11641 .mixers = { alc262_lenovo_3000_mixer },
11642 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11643 alc262_lenovo_3000_unsol_verbs },
11644 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11645 .dac_nids = alc262_dac_nids,
11646 .hp_nid = 0x03,
11647 .dig_out_nid = ALC262_DIGOUT_NID,
11648 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11649 .channel_mode = alc262_modes,
11650 .input_mux = &alc262_fujitsu_capture_source,
11651 .unsol_event = alc262_lenovo_3000_unsol_event,
11653 [ALC262_NEC] = {
11654 .mixers = { alc262_nec_mixer },
11655 .init_verbs = { alc262_nec_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,
11663 [ALC262_TOSHIBA_S06] = {
11664 .mixers = { alc262_toshiba_s06_mixer },
11665 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11666 alc262_eapd_verbs },
11667 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11668 .capsrc_nids = alc262_dmic_capsrc_nids,
11669 .dac_nids = alc262_dac_nids,
11670 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
11671 .num_adc_nids = 1, /* single ADC */
11672 .dig_out_nid = ALC262_DIGOUT_NID,
11673 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11674 .channel_mode = alc262_modes,
11675 .unsol_event = alc_sku_unsol_event,
11676 .setup = alc262_toshiba_s06_setup,
11677 .init_hook = alc_inithook,
11679 [ALC262_TOSHIBA_RX1] = {
11680 .mixers = { alc262_toshiba_rx1_mixer },
11681 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11682 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11683 .dac_nids = alc262_dac_nids,
11684 .hp_nid = 0x03,
11685 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11686 .channel_mode = alc262_modes,
11687 .input_mux = &alc262_capture_source,
11688 .unsol_event = alc262_hippo_unsol_event,
11689 .setup = alc262_hippo_setup,
11690 .init_hook = alc262_hippo_automute,
11692 [ALC262_TYAN] = {
11693 .mixers = { alc262_tyan_mixer },
11694 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11695 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11696 .dac_nids = alc262_dac_nids,
11697 .hp_nid = 0x02,
11698 .dig_out_nid = ALC262_DIGOUT_NID,
11699 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11700 .channel_mode = alc262_modes,
11701 .input_mux = &alc262_capture_source,
11702 .unsol_event = alc_automute_amp_unsol_event,
11703 .setup = alc262_tyan_setup,
11704 .init_hook = alc_automute_amp,
11708 static int patch_alc262(struct hda_codec *codec)
11710 struct alc_spec *spec;
11711 int board_config;
11712 int err;
11714 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11715 if (spec == NULL)
11716 return -ENOMEM;
11718 codec->spec = spec;
11719 #if 0
11720 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11721 * under-run
11724 int tmp;
11725 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11726 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11727 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11728 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11730 #endif
11732 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11734 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11735 alc262_models,
11736 alc262_cfg_tbl);
11738 if (board_config < 0) {
11739 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11740 codec->chip_name);
11741 board_config = ALC262_AUTO;
11744 if (board_config == ALC262_AUTO) {
11745 /* automatic parse from the BIOS config */
11746 err = alc262_parse_auto_config(codec);
11747 if (err < 0) {
11748 alc_free(codec);
11749 return err;
11750 } else if (!err) {
11751 printk(KERN_INFO
11752 "hda_codec: Cannot set up configuration "
11753 "from BIOS. Using base mode...\n");
11754 board_config = ALC262_BASIC;
11758 if (!spec->no_analog) {
11759 err = snd_hda_attach_beep_device(codec, 0x1);
11760 if (err < 0) {
11761 alc_free(codec);
11762 return err;
11766 if (board_config != ALC262_AUTO)
11767 setup_preset(codec, &alc262_presets[board_config]);
11769 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11770 spec->stream_analog_capture = &alc262_pcm_analog_capture;
11772 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11773 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11775 if (!spec->adc_nids && spec->input_mux) {
11776 int i;
11777 /* check whether the digital-mic has to be supported */
11778 for (i = 0; i < spec->input_mux->num_items; i++) {
11779 if (spec->input_mux->items[i].index >= 9)
11780 break;
11782 if (i < spec->input_mux->num_items) {
11783 /* use only ADC0 */
11784 spec->adc_nids = alc262_dmic_adc_nids;
11785 spec->num_adc_nids = 1;
11786 spec->capsrc_nids = alc262_dmic_capsrc_nids;
11787 } else {
11788 /* all analog inputs */
11789 /* check whether NID 0x07 is valid */
11790 unsigned int wcap = get_wcaps(codec, 0x07);
11792 /* get type */
11793 wcap = get_wcaps_type(wcap);
11794 if (wcap != AC_WID_AUD_IN) {
11795 spec->adc_nids = alc262_adc_nids_alt;
11796 spec->num_adc_nids =
11797 ARRAY_SIZE(alc262_adc_nids_alt);
11798 spec->capsrc_nids = alc262_capsrc_nids_alt;
11799 } else {
11800 spec->adc_nids = alc262_adc_nids;
11801 spec->num_adc_nids =
11802 ARRAY_SIZE(alc262_adc_nids);
11803 spec->capsrc_nids = alc262_capsrc_nids;
11807 if (!spec->cap_mixer && !spec->no_analog)
11808 set_capture_mixer(codec);
11809 if (!spec->no_analog)
11810 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
11812 spec->vmaster_nid = 0x0c;
11814 codec->patch_ops = alc_patch_ops;
11815 if (board_config == ALC262_AUTO)
11816 spec->init_hook = alc262_auto_init;
11817 #ifdef CONFIG_SND_HDA_POWER_SAVE
11818 if (!spec->loopback.amplist)
11819 spec->loopback.amplist = alc262_loopbacks;
11820 #endif
11821 codec->proc_widget_hook = print_realtek_coef;
11823 return 0;
11827 * ALC268 channel source setting (2 channel)
11829 #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11830 #define alc268_modes alc260_modes
11832 static hda_nid_t alc268_dac_nids[2] = {
11833 /* front, hp */
11834 0x02, 0x03
11837 static hda_nid_t alc268_adc_nids[2] = {
11838 /* ADC0-1 */
11839 0x08, 0x07
11842 static hda_nid_t alc268_adc_nids_alt[1] = {
11843 /* ADC0 */
11844 0x08
11847 static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11849 static struct snd_kcontrol_new alc268_base_mixer[] = {
11850 /* output mixer control */
11851 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11852 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11853 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11854 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11855 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11856 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11857 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11861 static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11862 /* output mixer control */
11863 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11864 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11865 ALC262_HIPPO_MASTER_SWITCH,
11866 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11867 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11868 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11872 /* bind Beep switches of both NID 0x0f and 0x10 */
11873 static struct hda_bind_ctls alc268_bind_beep_sw = {
11874 .ops = &snd_hda_bind_sw,
11875 .values = {
11876 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11877 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11882 static struct snd_kcontrol_new alc268_beep_mixer[] = {
11883 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11884 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11888 static struct hda_verb alc268_eapd_verbs[] = {
11889 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11890 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11894 /* Toshiba specific */
11895 static struct hda_verb alc268_toshiba_verbs[] = {
11896 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11897 { } /* end */
11900 /* Acer specific */
11901 /* bind volumes of both NID 0x02 and 0x03 */
11902 static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11903 .ops = &snd_hda_bind_vol,
11904 .values = {
11905 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11906 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11911 /* mute/unmute internal speaker according to the hp jack and mute state */
11912 static void alc268_acer_automute(struct hda_codec *codec, int force)
11914 struct alc_spec *spec = codec->spec;
11915 unsigned int mute;
11917 if (force || !spec->sense_updated) {
11918 unsigned int present;
11919 present = snd_hda_codec_read(codec, 0x14, 0,
11920 AC_VERB_GET_PIN_SENSE, 0);
11921 spec->jack_present = (present & 0x80000000) != 0;
11922 spec->sense_updated = 1;
11924 if (spec->jack_present)
11925 mute = HDA_AMP_MUTE; /* mute internal speaker */
11926 else /* unmute internal speaker if necessary */
11927 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11928 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11929 HDA_AMP_MUTE, mute);
11933 /* bind hp and internal speaker mute (with plug check) */
11934 static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11935 struct snd_ctl_elem_value *ucontrol)
11937 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11938 long *valp = ucontrol->value.integer.value;
11939 int change;
11941 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11942 if (change)
11943 alc268_acer_automute(codec, 0);
11944 return change;
11947 static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11948 /* output mixer control */
11949 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11951 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11952 .name = "Master Playback Switch",
11953 .info = snd_hda_mixer_amp_switch_info,
11954 .get = snd_hda_mixer_amp_switch_get,
11955 .put = alc268_acer_master_sw_put,
11956 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11958 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11962 static struct snd_kcontrol_new alc268_acer_mixer[] = {
11963 /* output mixer control */
11964 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11966 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11967 .name = "Master Playback Switch",
11968 .info = snd_hda_mixer_amp_switch_info,
11969 .get = snd_hda_mixer_amp_switch_get,
11970 .put = alc268_acer_master_sw_put,
11971 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11973 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11974 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11975 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11979 static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11980 /* output mixer control */
11981 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11983 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11984 .name = "Master Playback Switch",
11985 .info = snd_hda_mixer_amp_switch_info,
11986 .get = snd_hda_mixer_amp_switch_get,
11987 .put = alc268_acer_master_sw_put,
11988 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11990 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11991 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11995 static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11996 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11997 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11998 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11999 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12000 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12001 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12005 static struct hda_verb alc268_acer_verbs[] = {
12006 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12007 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12008 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12010 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12011 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12012 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12016 /* unsolicited event for HP jack sensing */
12017 #define alc268_toshiba_unsol_event alc262_hippo_unsol_event
12018 #define alc268_toshiba_setup alc262_hippo_setup
12019 #define alc268_toshiba_automute alc262_hippo_automute
12021 static void alc268_acer_unsol_event(struct hda_codec *codec,
12022 unsigned int res)
12024 if ((res >> 26) != ALC880_HP_EVENT)
12025 return;
12026 alc268_acer_automute(codec, 1);
12029 static void alc268_acer_init_hook(struct hda_codec *codec)
12031 alc268_acer_automute(codec, 1);
12034 /* toggle speaker-output according to the hp-jack state */
12035 static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12037 unsigned int present;
12038 unsigned char bits;
12040 present = snd_hda_codec_read(codec, 0x15, 0,
12041 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12042 bits = present ? AMP_IN_MUTE(0) : 0;
12043 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12044 AMP_IN_MUTE(0), bits);
12045 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12046 AMP_IN_MUTE(0), bits);
12049 static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12050 unsigned int res)
12052 switch (res >> 26) {
12053 case ALC880_HP_EVENT:
12054 alc268_aspire_one_speaker_automute(codec);
12055 break;
12056 case ALC880_MIC_EVENT:
12057 alc_mic_automute(codec);
12058 break;
12062 static void alc268_acer_lc_setup(struct hda_codec *codec)
12064 struct alc_spec *spec = codec->spec;
12065 spec->ext_mic.pin = 0x18;
12066 spec->ext_mic.mux_idx = 0;
12067 spec->int_mic.pin = 0x12;
12068 spec->int_mic.mux_idx = 6;
12069 spec->auto_mic = 1;
12072 static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12074 alc268_aspire_one_speaker_automute(codec);
12075 alc_mic_automute(codec);
12078 static struct snd_kcontrol_new alc268_dell_mixer[] = {
12079 /* output mixer control */
12080 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12081 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12082 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12083 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12084 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12085 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12089 static struct hda_verb alc268_dell_verbs[] = {
12090 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12091 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12092 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12093 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12097 /* mute/unmute internal speaker according to the hp jack and mute state */
12098 static void alc268_dell_setup(struct hda_codec *codec)
12100 struct alc_spec *spec = codec->spec;
12102 spec->autocfg.hp_pins[0] = 0x15;
12103 spec->autocfg.speaker_pins[0] = 0x14;
12104 spec->ext_mic.pin = 0x18;
12105 spec->ext_mic.mux_idx = 0;
12106 spec->int_mic.pin = 0x19;
12107 spec->int_mic.mux_idx = 1;
12108 spec->auto_mic = 1;
12111 static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12112 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12113 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12114 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12116 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12117 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12118 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12119 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12123 static struct hda_verb alc267_quanta_il1_verbs[] = {
12124 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12125 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12129 static void alc267_quanta_il1_setup(struct hda_codec *codec)
12131 struct alc_spec *spec = codec->spec;
12132 spec->autocfg.hp_pins[0] = 0x15;
12133 spec->autocfg.speaker_pins[0] = 0x14;
12134 spec->ext_mic.pin = 0x18;
12135 spec->ext_mic.mux_idx = 0;
12136 spec->int_mic.pin = 0x19;
12137 spec->int_mic.mux_idx = 1;
12138 spec->auto_mic = 1;
12142 * generic initialization of ADC, input mixers and output mixers
12144 static struct hda_verb alc268_base_init_verbs[] = {
12145 /* Unmute DAC0-1 and set vol = 0 */
12146 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12147 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12150 * Set up output mixers (0x0c - 0x0e)
12152 /* set vol=0 to output mixers */
12153 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12154 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12156 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12157 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12159 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12160 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12161 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12162 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12164 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12165 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12166 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12168 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12169 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12170 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12171 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12172 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12174 /* set PCBEEP vol = 0, mute connections */
12175 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12177 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12179 /* Unmute Selector 23h,24h and set the default input to mic-in */
12181 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12182 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12183 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12184 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12190 * generic initialization of ADC, input mixers and output mixers
12192 static struct hda_verb alc268_volume_init_verbs[] = {
12193 /* set output DAC */
12194 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12195 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12197 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12198 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12199 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12200 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12201 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12203 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12204 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12205 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12207 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12208 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12210 /* set PCBEEP vol = 0, mute connections */
12211 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12212 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12213 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12218 static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12219 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12220 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12221 { } /* end */
12224 static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12225 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12226 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12227 _DEFINE_CAPSRC(1),
12228 { } /* end */
12231 static struct snd_kcontrol_new alc268_capture_mixer[] = {
12232 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12233 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12234 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12235 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12236 _DEFINE_CAPSRC(2),
12237 { } /* end */
12240 static struct hda_input_mux alc268_capture_source = {
12241 .num_items = 4,
12242 .items = {
12243 { "Mic", 0x0 },
12244 { "Front Mic", 0x1 },
12245 { "Line", 0x2 },
12246 { "CD", 0x3 },
12250 static struct hda_input_mux alc268_acer_capture_source = {
12251 .num_items = 3,
12252 .items = {
12253 { "Mic", 0x0 },
12254 { "Internal Mic", 0x1 },
12255 { "Line", 0x2 },
12259 static struct hda_input_mux alc268_acer_dmic_capture_source = {
12260 .num_items = 3,
12261 .items = {
12262 { "Mic", 0x0 },
12263 { "Internal Mic", 0x6 },
12264 { "Line", 0x2 },
12268 #ifdef CONFIG_SND_DEBUG
12269 static struct snd_kcontrol_new alc268_test_mixer[] = {
12270 /* Volume widgets */
12271 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12272 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12273 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12274 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12275 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12276 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12277 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12278 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12279 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12280 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12281 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12282 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12283 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
12284 /* The below appears problematic on some hardwares */
12285 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
12286 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12287 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12288 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12289 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12291 /* Modes for retasking pin widgets */
12292 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12293 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12294 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12295 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12297 /* Controls for GPIO pins, assuming they are configured as outputs */
12298 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12299 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12300 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12301 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12303 /* Switches to allow the digital SPDIF output pin to be enabled.
12304 * The ALC268 does not have an SPDIF input.
12306 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12308 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12309 * this output to turn on an external amplifier.
12311 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12312 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12314 { } /* end */
12316 #endif
12318 /* create input playback/capture controls for the given pin */
12319 static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12320 const char *ctlname, int idx)
12322 hda_nid_t dac;
12323 int err;
12325 switch (nid) {
12326 case 0x14:
12327 case 0x16:
12328 dac = 0x02;
12329 break;
12330 case 0x15:
12331 dac = 0x03;
12332 break;
12333 default:
12334 return 0;
12336 if (spec->multiout.dac_nids[0] != dac &&
12337 spec->multiout.dac_nids[1] != dac) {
12338 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
12339 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
12340 HDA_OUTPUT));
12341 if (err < 0)
12342 return err;
12343 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12346 if (nid != 0x16)
12347 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
12348 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
12349 else /* mono */
12350 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
12351 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
12352 if (err < 0)
12353 return err;
12354 return 0;
12357 /* add playback controls from the parsed DAC table */
12358 static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12359 const struct auto_pin_cfg *cfg)
12361 hda_nid_t nid;
12362 int err;
12364 spec->multiout.dac_nids = spec->private_dac_nids;
12366 nid = cfg->line_out_pins[0];
12367 if (nid) {
12368 const char *name;
12369 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12370 name = "Speaker";
12371 else
12372 name = "Front";
12373 err = alc268_new_analog_output(spec, nid, name, 0);
12374 if (err < 0)
12375 return err;
12378 nid = cfg->speaker_pins[0];
12379 if (nid == 0x1d) {
12380 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
12381 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12382 if (err < 0)
12383 return err;
12384 } else {
12385 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12386 if (err < 0)
12387 return err;
12389 nid = cfg->hp_pins[0];
12390 if (nid) {
12391 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12392 if (err < 0)
12393 return err;
12396 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12397 if (nid == 0x16) {
12398 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
12399 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
12400 if (err < 0)
12401 return err;
12403 return 0;
12406 /* create playback/capture controls for input pins */
12407 static int alc268_auto_create_input_ctls(struct hda_codec *codec,
12408 const struct auto_pin_cfg *cfg)
12410 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
12413 static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12414 hda_nid_t nid, int pin_type)
12416 int idx;
12418 alc_set_pin_output(codec, nid, pin_type);
12419 if (nid == 0x14 || nid == 0x16)
12420 idx = 0;
12421 else
12422 idx = 1;
12423 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12426 static void alc268_auto_init_multi_out(struct hda_codec *codec)
12428 struct alc_spec *spec = codec->spec;
12429 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12430 if (nid) {
12431 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12432 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12436 static void alc268_auto_init_hp_out(struct hda_codec *codec)
12438 struct alc_spec *spec = codec->spec;
12439 hda_nid_t pin;
12441 pin = spec->autocfg.hp_pins[0];
12442 if (pin)
12443 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12444 pin = spec->autocfg.speaker_pins[0];
12445 if (pin)
12446 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12449 static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12451 struct alc_spec *spec = codec->spec;
12452 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12453 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12454 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12455 unsigned int dac_vol1, dac_vol2;
12457 if (line_nid == 0x1d || speaker_nid == 0x1d) {
12458 snd_hda_codec_write(codec, speaker_nid, 0,
12459 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12460 /* mute mixer inputs from 0x1d */
12461 snd_hda_codec_write(codec, 0x0f, 0,
12462 AC_VERB_SET_AMP_GAIN_MUTE,
12463 AMP_IN_UNMUTE(1));
12464 snd_hda_codec_write(codec, 0x10, 0,
12465 AC_VERB_SET_AMP_GAIN_MUTE,
12466 AMP_IN_UNMUTE(1));
12467 } else {
12468 /* unmute mixer inputs from 0x1d */
12469 snd_hda_codec_write(codec, 0x0f, 0,
12470 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12471 snd_hda_codec_write(codec, 0x10, 0,
12472 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12475 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
12476 if (line_nid == 0x14)
12477 dac_vol2 = AMP_OUT_ZERO;
12478 else if (line_nid == 0x15)
12479 dac_vol1 = AMP_OUT_ZERO;
12480 if (hp_nid == 0x14)
12481 dac_vol2 = AMP_OUT_ZERO;
12482 else if (hp_nid == 0x15)
12483 dac_vol1 = AMP_OUT_ZERO;
12484 if (line_nid != 0x16 || hp_nid != 0x16 ||
12485 spec->autocfg.line_out_pins[1] != 0x16 ||
12486 spec->autocfg.line_out_pins[2] != 0x16)
12487 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12489 snd_hda_codec_write(codec, 0x02, 0,
12490 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12491 snd_hda_codec_write(codec, 0x03, 0,
12492 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12495 /* pcm configuration: identical with ALC880 */
12496 #define alc268_pcm_analog_playback alc880_pcm_analog_playback
12497 #define alc268_pcm_analog_capture alc880_pcm_analog_capture
12498 #define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
12499 #define alc268_pcm_digital_playback alc880_pcm_digital_playback
12502 * BIOS auto configuration
12504 static int alc268_parse_auto_config(struct hda_codec *codec)
12506 struct alc_spec *spec = codec->spec;
12507 int err;
12508 static hda_nid_t alc268_ignore[] = { 0 };
12510 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12511 alc268_ignore);
12512 if (err < 0)
12513 return err;
12514 if (!spec->autocfg.line_outs) {
12515 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12516 spec->multiout.max_channels = 2;
12517 spec->no_analog = 1;
12518 goto dig_only;
12520 return 0; /* can't find valid BIOS pin config */
12522 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12523 if (err < 0)
12524 return err;
12525 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
12526 if (err < 0)
12527 return err;
12529 spec->multiout.max_channels = 2;
12531 dig_only:
12532 /* digital only support output */
12533 if (spec->autocfg.dig_outs) {
12534 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
12535 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12537 if (spec->kctls.list)
12538 add_mixer(spec, spec->kctls.list);
12540 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
12541 add_mixer(spec, alc268_beep_mixer);
12543 add_verb(spec, alc268_volume_init_verbs);
12544 spec->num_mux_defs = 2;
12545 spec->input_mux = &spec->private_imux[0];
12547 err = alc_auto_add_mic_boost(codec);
12548 if (err < 0)
12549 return err;
12551 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12553 return 1;
12556 #define alc268_auto_init_analog_input alc882_auto_init_analog_input
12558 /* init callback for auto-configuration model -- overriding the default init */
12559 static void alc268_auto_init(struct hda_codec *codec)
12561 struct alc_spec *spec = codec->spec;
12562 alc268_auto_init_multi_out(codec);
12563 alc268_auto_init_hp_out(codec);
12564 alc268_auto_init_mono_speaker_out(codec);
12565 alc268_auto_init_analog_input(codec);
12566 if (spec->unsol_event)
12567 alc_inithook(codec);
12571 * configuration and preset
12573 static const char *alc268_models[ALC268_MODEL_LAST] = {
12574 [ALC267_QUANTA_IL1] = "quanta-il1",
12575 [ALC268_3ST] = "3stack",
12576 [ALC268_TOSHIBA] = "toshiba",
12577 [ALC268_ACER] = "acer",
12578 [ALC268_ACER_DMIC] = "acer-dmic",
12579 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
12580 [ALC268_DELL] = "dell",
12581 [ALC268_ZEPTO] = "zepto",
12582 #ifdef CONFIG_SND_DEBUG
12583 [ALC268_TEST] = "test",
12584 #endif
12585 [ALC268_AUTO] = "auto",
12588 static struct snd_pci_quirk alc268_cfg_tbl[] = {
12589 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
12590 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
12591 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
12592 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
12593 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
12594 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12595 ALC268_ACER_ASPIRE_ONE),
12596 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
12597 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
12598 /* almost compatible with toshiba but with optional digital outs;
12599 * auto-probing seems working fine
12601 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12602 ALC268_AUTO),
12603 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
12604 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12605 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
12606 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
12607 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
12608 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
12612 /* Toshiba laptops have no unique PCI SSID but only codec SSID */
12613 static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12614 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12615 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12616 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12617 ALC268_TOSHIBA),
12621 static struct alc_config_preset alc268_presets[] = {
12622 [ALC267_QUANTA_IL1] = {
12623 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12624 alc268_capture_nosrc_mixer },
12625 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12626 alc267_quanta_il1_verbs },
12627 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12628 .dac_nids = alc268_dac_nids,
12629 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12630 .adc_nids = alc268_adc_nids_alt,
12631 .hp_nid = 0x03,
12632 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12633 .channel_mode = alc268_modes,
12634 .unsol_event = alc_sku_unsol_event,
12635 .setup = alc267_quanta_il1_setup,
12636 .init_hook = alc_inithook,
12638 [ALC268_3ST] = {
12639 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12640 alc268_beep_mixer },
12641 .init_verbs = { alc268_base_init_verbs },
12642 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12643 .dac_nids = alc268_dac_nids,
12644 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12645 .adc_nids = alc268_adc_nids_alt,
12646 .capsrc_nids = alc268_capsrc_nids,
12647 .hp_nid = 0x03,
12648 .dig_out_nid = ALC268_DIGOUT_NID,
12649 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12650 .channel_mode = alc268_modes,
12651 .input_mux = &alc268_capture_source,
12653 [ALC268_TOSHIBA] = {
12654 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
12655 alc268_beep_mixer },
12656 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12657 alc268_toshiba_verbs },
12658 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12659 .dac_nids = alc268_dac_nids,
12660 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12661 .adc_nids = alc268_adc_nids_alt,
12662 .capsrc_nids = alc268_capsrc_nids,
12663 .hp_nid = 0x03,
12664 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12665 .channel_mode = alc268_modes,
12666 .input_mux = &alc268_capture_source,
12667 .unsol_event = alc268_toshiba_unsol_event,
12668 .setup = alc268_toshiba_setup,
12669 .init_hook = alc268_toshiba_automute,
12671 [ALC268_ACER] = {
12672 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12673 alc268_beep_mixer },
12674 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12675 alc268_acer_verbs },
12676 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12677 .dac_nids = alc268_dac_nids,
12678 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12679 .adc_nids = alc268_adc_nids_alt,
12680 .capsrc_nids = alc268_capsrc_nids,
12681 .hp_nid = 0x02,
12682 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12683 .channel_mode = alc268_modes,
12684 .input_mux = &alc268_acer_capture_source,
12685 .unsol_event = alc268_acer_unsol_event,
12686 .init_hook = alc268_acer_init_hook,
12688 [ALC268_ACER_DMIC] = {
12689 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12690 alc268_beep_mixer },
12691 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12692 alc268_acer_verbs },
12693 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12694 .dac_nids = alc268_dac_nids,
12695 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12696 .adc_nids = alc268_adc_nids_alt,
12697 .capsrc_nids = alc268_capsrc_nids,
12698 .hp_nid = 0x02,
12699 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12700 .channel_mode = alc268_modes,
12701 .input_mux = &alc268_acer_dmic_capture_source,
12702 .unsol_event = alc268_acer_unsol_event,
12703 .init_hook = alc268_acer_init_hook,
12705 [ALC268_ACER_ASPIRE_ONE] = {
12706 .mixers = { alc268_acer_aspire_one_mixer,
12707 alc268_beep_mixer,
12708 alc268_capture_nosrc_mixer },
12709 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12710 alc268_acer_aspire_one_verbs },
12711 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12712 .dac_nids = alc268_dac_nids,
12713 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12714 .adc_nids = alc268_adc_nids_alt,
12715 .capsrc_nids = alc268_capsrc_nids,
12716 .hp_nid = 0x03,
12717 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12718 .channel_mode = alc268_modes,
12719 .unsol_event = alc268_acer_lc_unsol_event,
12720 .setup = alc268_acer_lc_setup,
12721 .init_hook = alc268_acer_lc_init_hook,
12723 [ALC268_DELL] = {
12724 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12725 alc268_capture_nosrc_mixer },
12726 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12727 alc268_dell_verbs },
12728 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12729 .dac_nids = alc268_dac_nids,
12730 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12731 .adc_nids = alc268_adc_nids_alt,
12732 .capsrc_nids = alc268_capsrc_nids,
12733 .hp_nid = 0x02,
12734 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12735 .channel_mode = alc268_modes,
12736 .unsol_event = alc_sku_unsol_event,
12737 .setup = alc268_dell_setup,
12738 .init_hook = alc_inithook,
12740 [ALC268_ZEPTO] = {
12741 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12742 alc268_beep_mixer },
12743 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12744 alc268_toshiba_verbs },
12745 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12746 .dac_nids = alc268_dac_nids,
12747 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12748 .adc_nids = alc268_adc_nids_alt,
12749 .capsrc_nids = alc268_capsrc_nids,
12750 .hp_nid = 0x03,
12751 .dig_out_nid = ALC268_DIGOUT_NID,
12752 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12753 .channel_mode = alc268_modes,
12754 .input_mux = &alc268_capture_source,
12755 .setup = alc268_toshiba_setup,
12756 .init_hook = alc268_toshiba_automute,
12758 #ifdef CONFIG_SND_DEBUG
12759 [ALC268_TEST] = {
12760 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12761 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12762 alc268_volume_init_verbs },
12763 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12764 .dac_nids = alc268_dac_nids,
12765 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12766 .adc_nids = alc268_adc_nids_alt,
12767 .capsrc_nids = alc268_capsrc_nids,
12768 .hp_nid = 0x03,
12769 .dig_out_nid = ALC268_DIGOUT_NID,
12770 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12771 .channel_mode = alc268_modes,
12772 .input_mux = &alc268_capture_source,
12774 #endif
12777 static int patch_alc268(struct hda_codec *codec)
12779 struct alc_spec *spec;
12780 int board_config;
12781 int i, has_beep, err;
12783 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12784 if (spec == NULL)
12785 return -ENOMEM;
12787 codec->spec = spec;
12789 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12790 alc268_models,
12791 alc268_cfg_tbl);
12793 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12794 board_config = snd_hda_check_board_codec_sid_config(codec,
12795 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12797 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12798 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12799 codec->chip_name);
12800 board_config = ALC268_AUTO;
12803 if (board_config == ALC268_AUTO) {
12804 /* automatic parse from the BIOS config */
12805 err = alc268_parse_auto_config(codec);
12806 if (err < 0) {
12807 alc_free(codec);
12808 return err;
12809 } else if (!err) {
12810 printk(KERN_INFO
12811 "hda_codec: Cannot set up configuration "
12812 "from BIOS. Using base mode...\n");
12813 board_config = ALC268_3ST;
12817 if (board_config != ALC268_AUTO)
12818 setup_preset(codec, &alc268_presets[board_config]);
12820 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12821 spec->stream_analog_capture = &alc268_pcm_analog_capture;
12822 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
12824 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12826 has_beep = 0;
12827 for (i = 0; i < spec->num_mixers; i++) {
12828 if (spec->mixers[i] == alc268_beep_mixer) {
12829 has_beep = 1;
12830 break;
12834 if (has_beep) {
12835 err = snd_hda_attach_beep_device(codec, 0x1);
12836 if (err < 0) {
12837 alc_free(codec);
12838 return err;
12840 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12841 /* override the amp caps for beep generator */
12842 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
12843 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12844 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12845 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12846 (0 << AC_AMPCAP_MUTE_SHIFT));
12849 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
12850 /* check whether NID 0x07 is valid */
12851 unsigned int wcap = get_wcaps(codec, 0x07);
12852 int i;
12854 spec->capsrc_nids = alc268_capsrc_nids;
12855 /* get type */
12856 wcap = get_wcaps_type(wcap);
12857 if (spec->auto_mic ||
12858 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
12859 spec->adc_nids = alc268_adc_nids_alt;
12860 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
12861 if (spec->auto_mic)
12862 fixup_automic_adc(codec);
12863 if (spec->auto_mic || spec->input_mux->num_items == 1)
12864 add_mixer(spec, alc268_capture_nosrc_mixer);
12865 else
12866 add_mixer(spec, alc268_capture_alt_mixer);
12867 } else {
12868 spec->adc_nids = alc268_adc_nids;
12869 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
12870 add_mixer(spec, alc268_capture_mixer);
12872 /* set default input source */
12873 for (i = 0; i < spec->num_adc_nids; i++)
12874 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12875 0, AC_VERB_SET_CONNECT_SEL,
12876 i < spec->num_mux_defs ?
12877 spec->input_mux[i].items[0].index :
12878 spec->input_mux->items[0].index);
12881 spec->vmaster_nid = 0x02;
12883 codec->patch_ops = alc_patch_ops;
12884 if (board_config == ALC268_AUTO)
12885 spec->init_hook = alc268_auto_init;
12887 codec->proc_widget_hook = print_realtek_coef;
12889 return 0;
12893 * ALC269 channel source setting (2 channel)
12895 #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12897 #define alc269_dac_nids alc260_dac_nids
12899 static hda_nid_t alc269_adc_nids[1] = {
12900 /* ADC1 */
12901 0x08,
12904 static hda_nid_t alc269_capsrc_nids[1] = {
12905 0x23,
12908 /* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12909 * not a mux!
12912 #define alc269_modes alc260_modes
12913 #define alc269_capture_source alc880_lg_lw_capture_source
12915 static struct snd_kcontrol_new alc269_base_mixer[] = {
12916 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12917 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12918 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12919 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12922 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12923 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12924 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12925 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12926 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12927 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12928 { } /* end */
12931 static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12932 /* output mixer control */
12933 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12936 .name = "Master Playback Switch",
12937 .info = snd_hda_mixer_amp_switch_info,
12938 .get = snd_hda_mixer_amp_switch_get,
12939 .put = alc268_acer_master_sw_put,
12940 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12944 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12945 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12946 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12947 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12951 static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12952 /* output mixer control */
12953 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12956 .name = "Master Playback Switch",
12957 .info = snd_hda_mixer_amp_switch_info,
12958 .get = snd_hda_mixer_amp_switch_get,
12959 .put = alc268_acer_master_sw_put,
12960 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12962 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12963 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12964 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12965 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12966 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12967 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12968 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12969 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12970 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12974 static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12975 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12976 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12978 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12979 { } /* end */
12982 /* capture mixer elements */
12983 static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12984 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12985 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12986 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12987 { } /* end */
12990 /* FSC amilo */
12991 #define alc269_fujitsu_mixer alc269_eeepc_mixer
12993 static struct hda_verb alc269_quanta_fl1_verbs[] = {
12994 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12995 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12996 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12997 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12998 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12999 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13003 static struct hda_verb alc269_lifebook_verbs[] = {
13004 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13005 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13006 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13008 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13009 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13010 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13011 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13012 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13013 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13017 /* toggle speaker-output according to the hp-jack state */
13018 static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13020 unsigned int present;
13021 unsigned char bits;
13023 present = snd_hda_codec_read(codec, 0x15, 0,
13024 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13025 bits = present ? AMP_IN_MUTE(0) : 0;
13026 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13027 AMP_IN_MUTE(0), bits);
13028 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13029 AMP_IN_MUTE(0), bits);
13031 snd_hda_codec_write(codec, 0x20, 0,
13032 AC_VERB_SET_COEF_INDEX, 0x0c);
13033 snd_hda_codec_write(codec, 0x20, 0,
13034 AC_VERB_SET_PROC_COEF, 0x680);
13036 snd_hda_codec_write(codec, 0x20, 0,
13037 AC_VERB_SET_COEF_INDEX, 0x0c);
13038 snd_hda_codec_write(codec, 0x20, 0,
13039 AC_VERB_SET_PROC_COEF, 0x480);
13042 /* toggle speaker-output according to the hp-jacks state */
13043 static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13045 unsigned int present;
13046 unsigned char bits;
13048 /* Check laptop headphone socket */
13049 present = snd_hda_codec_read(codec, 0x15, 0,
13050 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13052 /* Check port replicator headphone socket */
13053 present |= snd_hda_codec_read(codec, 0x1a, 0,
13054 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13056 bits = present ? AMP_IN_MUTE(0) : 0;
13057 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13058 AMP_IN_MUTE(0), bits);
13059 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13060 AMP_IN_MUTE(0), bits);
13062 snd_hda_codec_write(codec, 0x20, 0,
13063 AC_VERB_SET_COEF_INDEX, 0x0c);
13064 snd_hda_codec_write(codec, 0x20, 0,
13065 AC_VERB_SET_PROC_COEF, 0x680);
13067 snd_hda_codec_write(codec, 0x20, 0,
13068 AC_VERB_SET_COEF_INDEX, 0x0c);
13069 snd_hda_codec_write(codec, 0x20, 0,
13070 AC_VERB_SET_PROC_COEF, 0x480);
13073 static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13075 unsigned int present_laptop;
13076 unsigned int present_dock;
13078 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
13079 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13081 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
13082 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13084 /* Laptop mic port overrides dock mic port, design decision */
13085 if (present_dock)
13086 snd_hda_codec_write(codec, 0x23, 0,
13087 AC_VERB_SET_CONNECT_SEL, 0x3);
13088 if (present_laptop)
13089 snd_hda_codec_write(codec, 0x23, 0,
13090 AC_VERB_SET_CONNECT_SEL, 0x0);
13091 if (!present_dock && !present_laptop)
13092 snd_hda_codec_write(codec, 0x23, 0,
13093 AC_VERB_SET_CONNECT_SEL, 0x1);
13096 static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13097 unsigned int res)
13099 switch (res >> 26) {
13100 case ALC880_HP_EVENT:
13101 alc269_quanta_fl1_speaker_automute(codec);
13102 break;
13103 case ALC880_MIC_EVENT:
13104 alc_mic_automute(codec);
13105 break;
13109 static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13110 unsigned int res)
13112 if ((res >> 26) == ALC880_HP_EVENT)
13113 alc269_lifebook_speaker_automute(codec);
13114 if ((res >> 26) == ALC880_MIC_EVENT)
13115 alc269_lifebook_mic_autoswitch(codec);
13118 static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13120 struct alc_spec *spec = codec->spec;
13121 spec->ext_mic.pin = 0x18;
13122 spec->ext_mic.mux_idx = 0;
13123 spec->int_mic.pin = 0x19;
13124 spec->int_mic.mux_idx = 1;
13125 spec->auto_mic = 1;
13128 static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13130 alc269_quanta_fl1_speaker_automute(codec);
13131 alc_mic_automute(codec);
13134 static void alc269_lifebook_init_hook(struct hda_codec *codec)
13136 alc269_lifebook_speaker_automute(codec);
13137 alc269_lifebook_mic_autoswitch(codec);
13140 static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
13141 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13142 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13143 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13145 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13146 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13147 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13151 static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13152 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13153 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13154 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13155 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13156 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13157 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13161 /* toggle speaker-output according to the hp-jack state */
13162 static void alc269_speaker_automute(struct hda_codec *codec)
13164 unsigned int present;
13165 unsigned char bits;
13167 present = snd_hda_codec_read(codec, 0x15, 0,
13168 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13169 bits = present ? AMP_IN_MUTE(0) : 0;
13170 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13171 AMP_IN_MUTE(0), bits);
13172 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13173 AMP_IN_MUTE(0), bits);
13176 /* unsolicited event for HP jack sensing */
13177 static void alc269_eeepc_unsol_event(struct hda_codec *codec,
13178 unsigned int res)
13180 switch (res >> 26) {
13181 case ALC880_HP_EVENT:
13182 alc269_speaker_automute(codec);
13183 break;
13184 case ALC880_MIC_EVENT:
13185 alc_mic_automute(codec);
13186 break;
13190 static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13192 struct alc_spec *spec = codec->spec;
13193 spec->ext_mic.pin = 0x18;
13194 spec->ext_mic.mux_idx = 0;
13195 spec->int_mic.pin = 0x12;
13196 spec->int_mic.mux_idx = 5;
13197 spec->auto_mic = 1;
13200 static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13202 struct alc_spec *spec = codec->spec;
13203 spec->ext_mic.pin = 0x18;
13204 spec->ext_mic.mux_idx = 0;
13205 spec->int_mic.pin = 0x19;
13206 spec->int_mic.mux_idx = 1;
13207 spec->auto_mic = 1;
13210 static void alc269_eeepc_inithook(struct hda_codec *codec)
13212 alc269_speaker_automute(codec);
13213 alc_mic_automute(codec);
13217 * generic initialization of ADC, input mixers and output mixers
13219 static struct hda_verb alc269_init_verbs[] = {
13221 * Unmute ADC0 and set the default input to mic-in
13223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13225 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13226 * analog-loopback mixer widget
13227 * Note: PASD motherboards uses the Line In 2 as the input for
13228 * front panel mic (mic 2)
13230 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13231 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13232 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13233 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13234 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13235 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13238 * Set up output mixers (0x0c - 0x0e)
13240 /* set vol=0 to output mixers */
13241 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13242 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13244 /* set up input amps for analog loopback */
13245 /* Amp Indices: DAC = 0, mixer = 1 */
13246 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13247 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13248 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13249 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13251 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13253 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13255 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13256 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13257 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13258 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13259 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13261 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13262 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13263 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13264 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13265 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13266 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13269 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13270 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13272 /* FIXME: use matrix-type input source selection */
13273 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13274 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13280 /* set EAPD */
13281 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13282 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13286 #define alc269_auto_create_multi_out_ctls \
13287 alc268_auto_create_multi_out_ctls
13288 #define alc269_auto_create_input_ctls \
13289 alc268_auto_create_input_ctls
13291 #ifdef CONFIG_SND_HDA_POWER_SAVE
13292 #define alc269_loopbacks alc880_loopbacks
13293 #endif
13295 /* pcm configuration: identical with ALC880 */
13296 #define alc269_pcm_analog_playback alc880_pcm_analog_playback
13297 #define alc269_pcm_analog_capture alc880_pcm_analog_capture
13298 #define alc269_pcm_digital_playback alc880_pcm_digital_playback
13299 #define alc269_pcm_digital_capture alc880_pcm_digital_capture
13301 static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13302 .substreams = 1,
13303 .channels_min = 2,
13304 .channels_max = 8,
13305 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13306 /* NID is set in alc_build_pcms */
13307 .ops = {
13308 .open = alc880_playback_pcm_open,
13309 .prepare = alc880_playback_pcm_prepare,
13310 .cleanup = alc880_playback_pcm_cleanup
13314 static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13315 .substreams = 1,
13316 .channels_min = 2,
13317 .channels_max = 2,
13318 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13319 /* NID is set in alc_build_pcms */
13323 * BIOS auto configuration
13325 static int alc269_parse_auto_config(struct hda_codec *codec)
13327 struct alc_spec *spec = codec->spec;
13328 int err;
13329 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13331 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13332 alc269_ignore);
13333 if (err < 0)
13334 return err;
13336 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13337 if (err < 0)
13338 return err;
13339 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
13340 if (err < 0)
13341 return err;
13343 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13345 if (spec->autocfg.dig_outs)
13346 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13348 if (spec->kctls.list)
13349 add_mixer(spec, spec->kctls.list);
13351 add_verb(spec, alc269_init_verbs);
13352 spec->num_mux_defs = 1;
13353 spec->input_mux = &spec->private_imux[0];
13354 /* set default input source */
13355 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13356 0, AC_VERB_SET_CONNECT_SEL,
13357 spec->input_mux->items[0].index);
13359 err = alc_auto_add_mic_boost(codec);
13360 if (err < 0)
13361 return err;
13363 if (!spec->cap_mixer && !spec->no_analog)
13364 set_capture_mixer(codec);
13366 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13368 return 1;
13371 #define alc269_auto_init_multi_out alc268_auto_init_multi_out
13372 #define alc269_auto_init_hp_out alc268_auto_init_hp_out
13373 #define alc269_auto_init_analog_input alc882_auto_init_analog_input
13376 /* init callback for auto-configuration model -- overriding the default init */
13377 static void alc269_auto_init(struct hda_codec *codec)
13379 struct alc_spec *spec = codec->spec;
13380 alc269_auto_init_multi_out(codec);
13381 alc269_auto_init_hp_out(codec);
13382 alc269_auto_init_analog_input(codec);
13383 if (spec->unsol_event)
13384 alc_inithook(codec);
13388 * configuration and preset
13390 static const char *alc269_models[ALC269_MODEL_LAST] = {
13391 [ALC269_BASIC] = "basic",
13392 [ALC269_QUANTA_FL1] = "quanta",
13393 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
13394 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
13395 [ALC269_FUJITSU] = "fujitsu",
13396 [ALC269_LIFEBOOK] = "lifebook",
13397 [ALC269_AUTO] = "auto",
13400 static struct snd_pci_quirk alc269_cfg_tbl[] = {
13401 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
13402 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13403 ALC269_ASUS_EEEPC_P703),
13404 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13405 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13406 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13407 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13408 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13409 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
13410 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13411 ALC269_ASUS_EEEPC_P901),
13412 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13413 ALC269_ASUS_EEEPC_P901),
13414 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
13415 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
13416 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
13420 static struct alc_config_preset alc269_presets[] = {
13421 [ALC269_BASIC] = {
13422 .mixers = { alc269_base_mixer },
13423 .init_verbs = { alc269_init_verbs },
13424 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13425 .dac_nids = alc269_dac_nids,
13426 .hp_nid = 0x03,
13427 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13428 .channel_mode = alc269_modes,
13429 .input_mux = &alc269_capture_source,
13431 [ALC269_QUANTA_FL1] = {
13432 .mixers = { alc269_quanta_fl1_mixer },
13433 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13434 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13435 .dac_nids = alc269_dac_nids,
13436 .hp_nid = 0x03,
13437 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13438 .channel_mode = alc269_modes,
13439 .input_mux = &alc269_capture_source,
13440 .unsol_event = alc269_quanta_fl1_unsol_event,
13441 .setup = alc269_quanta_fl1_setup,
13442 .init_hook = alc269_quanta_fl1_init_hook,
13444 [ALC269_ASUS_EEEPC_P703] = {
13445 .mixers = { alc269_eeepc_mixer },
13446 .cap_mixer = alc269_epc_capture_mixer,
13447 .init_verbs = { alc269_init_verbs,
13448 alc269_eeepc_amic_init_verbs },
13449 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13450 .dac_nids = alc269_dac_nids,
13451 .hp_nid = 0x03,
13452 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13453 .channel_mode = alc269_modes,
13454 .unsol_event = alc269_eeepc_unsol_event,
13455 .setup = alc269_eeepc_amic_setup,
13456 .init_hook = alc269_eeepc_inithook,
13458 [ALC269_ASUS_EEEPC_P901] = {
13459 .mixers = { alc269_eeepc_mixer },
13460 .cap_mixer = alc269_epc_capture_mixer,
13461 .init_verbs = { alc269_init_verbs,
13462 alc269_eeepc_dmic_init_verbs },
13463 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13464 .dac_nids = alc269_dac_nids,
13465 .hp_nid = 0x03,
13466 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13467 .channel_mode = alc269_modes,
13468 .unsol_event = alc269_eeepc_unsol_event,
13469 .setup = alc269_eeepc_dmic_setup,
13470 .init_hook = alc269_eeepc_inithook,
13472 [ALC269_FUJITSU] = {
13473 .mixers = { alc269_fujitsu_mixer },
13474 .cap_mixer = alc269_epc_capture_mixer,
13475 .init_verbs = { alc269_init_verbs,
13476 alc269_eeepc_dmic_init_verbs },
13477 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13478 .dac_nids = alc269_dac_nids,
13479 .hp_nid = 0x03,
13480 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13481 .channel_mode = alc269_modes,
13482 .unsol_event = alc269_eeepc_unsol_event,
13483 .setup = alc269_eeepc_dmic_setup,
13484 .init_hook = alc269_eeepc_inithook,
13486 [ALC269_LIFEBOOK] = {
13487 .mixers = { alc269_lifebook_mixer },
13488 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13489 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13490 .dac_nids = alc269_dac_nids,
13491 .hp_nid = 0x03,
13492 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13493 .channel_mode = alc269_modes,
13494 .input_mux = &alc269_capture_source,
13495 .unsol_event = alc269_lifebook_unsol_event,
13496 .init_hook = alc269_lifebook_init_hook,
13500 static int patch_alc269(struct hda_codec *codec)
13502 struct alc_spec *spec;
13503 int board_config;
13504 int err;
13506 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13507 if (spec == NULL)
13508 return -ENOMEM;
13510 codec->spec = spec;
13512 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13514 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13515 alc269_models,
13516 alc269_cfg_tbl);
13518 if (board_config < 0) {
13519 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13520 codec->chip_name);
13521 board_config = ALC269_AUTO;
13524 if (board_config == ALC269_AUTO) {
13525 /* automatic parse from the BIOS config */
13526 err = alc269_parse_auto_config(codec);
13527 if (err < 0) {
13528 alc_free(codec);
13529 return err;
13530 } else if (!err) {
13531 printk(KERN_INFO
13532 "hda_codec: Cannot set up configuration "
13533 "from BIOS. Using base mode...\n");
13534 board_config = ALC269_BASIC;
13538 err = snd_hda_attach_beep_device(codec, 0x1);
13539 if (err < 0) {
13540 alc_free(codec);
13541 return err;
13544 if (board_config != ALC269_AUTO)
13545 setup_preset(codec, &alc269_presets[board_config]);
13547 if (codec->subsystem_id == 0x17aa3bf8) {
13548 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13549 * fix the sample rate of analog I/O to 44.1kHz
13551 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13552 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13553 } else {
13554 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13555 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13557 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13558 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13560 spec->adc_nids = alc269_adc_nids;
13561 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
13562 spec->capsrc_nids = alc269_capsrc_nids;
13563 if (!spec->cap_mixer)
13564 set_capture_mixer(codec);
13565 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
13567 spec->vmaster_nid = 0x02;
13569 codec->patch_ops = alc_patch_ops;
13570 if (board_config == ALC269_AUTO)
13571 spec->init_hook = alc269_auto_init;
13572 #ifdef CONFIG_SND_HDA_POWER_SAVE
13573 if (!spec->loopback.amplist)
13574 spec->loopback.amplist = alc269_loopbacks;
13575 #endif
13576 codec->proc_widget_hook = print_realtek_coef;
13578 return 0;
13582 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13586 * set the path ways for 2 channel output
13587 * need to set the codec line out and mic 1 pin widgets to inputs
13589 static struct hda_verb alc861_threestack_ch2_init[] = {
13590 /* set pin widget 1Ah (line in) for input */
13591 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13592 /* set pin widget 18h (mic1/2) for input, for mic also enable
13593 * the vref
13595 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13597 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13598 #if 0
13599 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13600 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13601 #endif
13602 { } /* end */
13605 * 6ch mode
13606 * need to set the codec line out and mic 1 pin widgets to outputs
13608 static struct hda_verb alc861_threestack_ch6_init[] = {
13609 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13610 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13611 /* set pin widget 18h (mic1) for output (CLFE)*/
13612 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13614 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13615 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13617 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13618 #if 0
13619 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13620 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13621 #endif
13622 { } /* end */
13625 static struct hda_channel_mode alc861_threestack_modes[2] = {
13626 { 2, alc861_threestack_ch2_init },
13627 { 6, alc861_threestack_ch6_init },
13629 /* Set mic1 as input and unmute the mixer */
13630 static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13631 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13632 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13633 { } /* end */
13635 /* Set mic1 as output and mute mixer */
13636 static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13637 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13638 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13639 { } /* end */
13642 static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13643 { 2, alc861_uniwill_m31_ch2_init },
13644 { 4, alc861_uniwill_m31_ch4_init },
13647 /* Set mic1 and line-in as input and unmute the mixer */
13648 static struct hda_verb alc861_asus_ch2_init[] = {
13649 /* set pin widget 1Ah (line in) for input */
13650 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13651 /* set pin widget 18h (mic1/2) for input, for mic also enable
13652 * the vref
13654 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13656 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13657 #if 0
13658 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13659 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13660 #endif
13661 { } /* end */
13663 /* Set mic1 nad line-in as output and mute mixer */
13664 static struct hda_verb alc861_asus_ch6_init[] = {
13665 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13666 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13667 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13668 /* set pin widget 18h (mic1) for output (CLFE)*/
13669 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13670 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13671 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13672 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13674 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13675 #if 0
13676 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13677 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13678 #endif
13679 { } /* end */
13682 static struct hda_channel_mode alc861_asus_modes[2] = {
13683 { 2, alc861_asus_ch2_init },
13684 { 6, alc861_asus_ch6_init },
13687 /* patch-ALC861 */
13689 static struct snd_kcontrol_new alc861_base_mixer[] = {
13690 /* output mixer control */
13691 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13692 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13693 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13694 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13695 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13697 /*Input mixer control */
13698 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13699 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13700 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13701 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13702 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13703 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13704 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13705 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13706 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13707 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13709 { } /* end */
13712 static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13713 /* output mixer control */
13714 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13715 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13716 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13717 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13718 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13720 /* Input mixer control */
13721 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13722 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13723 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13724 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13725 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13726 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13727 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13728 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13729 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13730 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13733 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13734 .name = "Channel Mode",
13735 .info = alc_ch_mode_info,
13736 .get = alc_ch_mode_get,
13737 .put = alc_ch_mode_put,
13738 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13740 { } /* end */
13743 static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
13744 /* output mixer control */
13745 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13746 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13747 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13749 { } /* end */
13752 static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13753 /* output mixer control */
13754 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13755 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13756 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13757 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13758 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13760 /* Input mixer control */
13761 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13762 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13763 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13764 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13765 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13766 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13768 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13769 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
13773 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13774 .name = "Channel Mode",
13775 .info = alc_ch_mode_info,
13776 .get = alc_ch_mode_get,
13777 .put = alc_ch_mode_put,
13778 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13780 { } /* end */
13783 static struct snd_kcontrol_new alc861_asus_mixer[] = {
13784 /* output mixer control */
13785 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13786 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13787 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13788 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13789 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13791 /* Input mixer control */
13792 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13793 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13794 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13795 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13796 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13797 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13799 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13801 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13804 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13805 .name = "Channel Mode",
13806 .info = alc_ch_mode_info,
13807 .get = alc_ch_mode_get,
13808 .put = alc_ch_mode_put,
13809 .private_value = ARRAY_SIZE(alc861_asus_modes),
13814 /* additional mixer */
13815 static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
13816 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13817 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13822 * generic initialization of ADC, input mixers and output mixers
13824 static struct hda_verb alc861_base_init_verbs[] = {
13826 * Unmute ADC0 and set the default input to mic-in
13828 /* port-A for surround (rear panel) */
13829 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13830 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13831 /* port-B for mic-in (rear panel) with vref */
13832 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13833 /* port-C for line-in (rear panel) */
13834 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13835 /* port-D for Front */
13836 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13837 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13838 /* port-E for HP out (front panel) */
13839 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13840 /* route front PCM to HP */
13841 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13842 /* port-F for mic-in (front panel) with vref */
13843 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13844 /* port-G for CLFE (rear panel) */
13845 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13846 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13847 /* port-H for side (rear panel) */
13848 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13849 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13850 /* CD-in */
13851 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13852 /* route front mic to ADC1*/
13853 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13856 /* Unmute DAC0~3 & spdif out*/
13857 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13858 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13859 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13860 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13861 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13863 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13864 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13865 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13866 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13867 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13869 /* Unmute Stereo Mixer 15 */
13870 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13872 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13873 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13875 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13876 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13877 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13878 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13879 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13880 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13881 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13882 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13883 /* hp used DAC 3 (Front) */
13884 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13885 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13890 static struct hda_verb alc861_threestack_init_verbs[] = {
13892 * Unmute ADC0 and set the default input to mic-in
13894 /* port-A for surround (rear panel) */
13895 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13896 /* port-B for mic-in (rear panel) with vref */
13897 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13898 /* port-C for line-in (rear panel) */
13899 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13900 /* port-D for Front */
13901 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13902 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13903 /* port-E for HP out (front panel) */
13904 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13905 /* route front PCM to HP */
13906 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13907 /* port-F for mic-in (front panel) with vref */
13908 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13909 /* port-G for CLFE (rear panel) */
13910 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13911 /* port-H for side (rear panel) */
13912 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13913 /* CD-in */
13914 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13915 /* route front mic to ADC1*/
13916 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13917 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13918 /* Unmute DAC0~3 & spdif out*/
13919 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13920 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13921 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13922 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13923 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13925 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13926 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13927 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13928 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13929 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13931 /* Unmute Stereo Mixer 15 */
13932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13933 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13934 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13937 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13938 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13939 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13940 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13941 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13942 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13943 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13944 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13945 /* hp used DAC 3 (Front) */
13946 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
13947 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13951 static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13953 * Unmute ADC0 and set the default input to mic-in
13955 /* port-A for surround (rear panel) */
13956 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13957 /* port-B for mic-in (rear panel) with vref */
13958 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13959 /* port-C for line-in (rear panel) */
13960 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13961 /* port-D for Front */
13962 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13963 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13964 /* port-E for HP out (front panel) */
13965 /* this has to be set to VREF80 */
13966 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13967 /* route front PCM to HP */
13968 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13969 /* port-F for mic-in (front panel) with vref */
13970 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13971 /* port-G for CLFE (rear panel) */
13972 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13973 /* port-H for side (rear panel) */
13974 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13975 /* CD-in */
13976 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13977 /* route front mic to ADC1*/
13978 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13979 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13980 /* Unmute DAC0~3 & spdif out*/
13981 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13982 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13983 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13984 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13985 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13987 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13988 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13989 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13990 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13991 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13993 /* Unmute Stereo Mixer 15 */
13994 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13995 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13996 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13997 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
13999 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14000 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14001 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14002 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14003 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14004 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14005 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14006 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14007 /* hp used DAC 3 (Front) */
14008 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
14009 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14013 static struct hda_verb alc861_asus_init_verbs[] = {
14015 * Unmute ADC0 and set the default input to mic-in
14017 /* port-A for surround (rear panel)
14018 * according to codec#0 this is the HP jack
14020 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14021 /* route front PCM to HP */
14022 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14023 /* port-B for mic-in (rear panel) with vref */
14024 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14025 /* port-C for line-in (rear panel) */
14026 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14027 /* port-D for Front */
14028 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14029 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14030 /* port-E for HP out (front panel) */
14031 /* this has to be set to VREF80 */
14032 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14033 /* route front PCM to HP */
14034 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14035 /* port-F for mic-in (front panel) with vref */
14036 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14037 /* port-G for CLFE (rear panel) */
14038 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14039 /* port-H for side (rear panel) */
14040 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14041 /* CD-in */
14042 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14043 /* route front mic to ADC1*/
14044 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14045 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14046 /* Unmute DAC0~3 & spdif out*/
14047 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14048 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14049 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14050 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14051 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14052 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14053 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14054 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14055 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14056 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14058 /* Unmute Stereo Mixer 15 */
14059 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14060 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14061 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
14064 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14065 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14066 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14067 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14068 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14070 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14072 /* hp used DAC 3 (Front) */
14073 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
14074 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14078 /* additional init verbs for ASUS laptops */
14079 static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14080 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14081 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14086 * generic initialization of ADC, input mixers and output mixers
14088 static struct hda_verb alc861_auto_init_verbs[] = {
14090 * Unmute ADC0 and set the default input to mic-in
14092 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
14093 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14095 /* Unmute DAC0~3 & spdif out*/
14096 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14097 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14098 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14099 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14100 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14102 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14103 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14104 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14105 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14106 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14108 /* Unmute Stereo Mixer 15 */
14109 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14112 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14114 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14115 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14116 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14117 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14118 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14119 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14120 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14121 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14123 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14124 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14125 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14126 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14127 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14128 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14129 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14130 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14132 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
14137 static struct hda_verb alc861_toshiba_init_verbs[] = {
14138 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14143 /* toggle speaker-output according to the hp-jack state */
14144 static void alc861_toshiba_automute(struct hda_codec *codec)
14146 unsigned int present;
14148 present = snd_hda_codec_read(codec, 0x0f, 0,
14149 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14150 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14151 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14152 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14153 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
14156 static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14157 unsigned int res)
14159 if ((res >> 26) == ALC880_HP_EVENT)
14160 alc861_toshiba_automute(codec);
14163 /* pcm configuration: identical with ALC880 */
14164 #define alc861_pcm_analog_playback alc880_pcm_analog_playback
14165 #define alc861_pcm_analog_capture alc880_pcm_analog_capture
14166 #define alc861_pcm_digital_playback alc880_pcm_digital_playback
14167 #define alc861_pcm_digital_capture alc880_pcm_digital_capture
14170 #define ALC861_DIGOUT_NID 0x07
14172 static struct hda_channel_mode alc861_8ch_modes[1] = {
14173 { 8, NULL }
14176 static hda_nid_t alc861_dac_nids[4] = {
14177 /* front, surround, clfe, side */
14178 0x03, 0x06, 0x05, 0x04
14181 static hda_nid_t alc660_dac_nids[3] = {
14182 /* front, clfe, surround */
14183 0x03, 0x05, 0x06
14186 static hda_nid_t alc861_adc_nids[1] = {
14187 /* ADC0-2 */
14188 0x08,
14191 static struct hda_input_mux alc861_capture_source = {
14192 .num_items = 5,
14193 .items = {
14194 { "Mic", 0x0 },
14195 { "Front Mic", 0x3 },
14196 { "Line", 0x1 },
14197 { "CD", 0x4 },
14198 { "Mixer", 0x5 },
14202 static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14204 struct alc_spec *spec = codec->spec;
14205 hda_nid_t mix, srcs[5];
14206 int i, j, num;
14208 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14209 return 0;
14210 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14211 if (num < 0)
14212 return 0;
14213 for (i = 0; i < num; i++) {
14214 unsigned int type;
14215 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
14216 if (type != AC_WID_AUD_OUT)
14217 continue;
14218 for (j = 0; j < spec->multiout.num_dacs; j++)
14219 if (spec->multiout.dac_nids[j] == srcs[i])
14220 break;
14221 if (j >= spec->multiout.num_dacs)
14222 return srcs[i];
14224 return 0;
14227 /* fill in the dac_nids table from the parsed pin configuration */
14228 static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
14229 const struct auto_pin_cfg *cfg)
14231 struct alc_spec *spec = codec->spec;
14232 int i;
14233 hda_nid_t nid, dac;
14235 spec->multiout.dac_nids = spec->private_dac_nids;
14236 for (i = 0; i < cfg->line_outs; i++) {
14237 nid = cfg->line_out_pins[i];
14238 dac = alc861_look_for_dac(codec, nid);
14239 if (!dac)
14240 continue;
14241 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
14243 return 0;
14246 static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14247 hda_nid_t nid, unsigned int chs)
14249 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
14250 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14253 /* add playback controls from the parsed DAC table */
14254 static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14255 const struct auto_pin_cfg *cfg)
14257 struct alc_spec *spec = codec->spec;
14258 static const char *chname[4] = {
14259 "Front", "Surround", NULL /*CLFE*/, "Side"
14261 hda_nid_t nid;
14262 int i, err;
14264 if (cfg->line_outs == 1) {
14265 const char *pfx = NULL;
14266 if (!cfg->hp_outs)
14267 pfx = "Master";
14268 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14269 pfx = "Speaker";
14270 if (pfx) {
14271 nid = spec->multiout.dac_nids[0];
14272 return alc861_create_out_sw(codec, pfx, nid, 3);
14276 for (i = 0; i < cfg->line_outs; i++) {
14277 nid = spec->multiout.dac_nids[i];
14278 if (!nid)
14279 continue;
14280 if (i == 2) {
14281 /* Center/LFE */
14282 err = alc861_create_out_sw(codec, "Center", nid, 1);
14283 if (err < 0)
14284 return err;
14285 err = alc861_create_out_sw(codec, "LFE", nid, 2);
14286 if (err < 0)
14287 return err;
14288 } else {
14289 err = alc861_create_out_sw(codec, chname[i], nid, 3);
14290 if (err < 0)
14291 return err;
14294 return 0;
14297 static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
14299 struct alc_spec *spec = codec->spec;
14300 int err;
14301 hda_nid_t nid;
14303 if (!pin)
14304 return 0;
14306 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
14307 nid = alc861_look_for_dac(codec, pin);
14308 if (nid) {
14309 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14310 if (err < 0)
14311 return err;
14312 spec->multiout.hp_nid = nid;
14315 return 0;
14318 /* create playback/capture controls for input pins */
14319 static int alc861_auto_create_input_ctls(struct hda_codec *codec,
14320 const struct auto_pin_cfg *cfg)
14322 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
14325 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14326 hda_nid_t nid,
14327 int pin_type, hda_nid_t dac)
14329 hda_nid_t mix, srcs[5];
14330 int i, num;
14332 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14333 pin_type);
14334 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14335 AMP_OUT_UNMUTE);
14336 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14337 return;
14338 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14339 if (num < 0)
14340 return;
14341 for (i = 0; i < num; i++) {
14342 unsigned int mute;
14343 if (srcs[i] == dac || srcs[i] == 0x15)
14344 mute = AMP_IN_UNMUTE(i);
14345 else
14346 mute = AMP_IN_MUTE(i);
14347 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14348 mute);
14352 static void alc861_auto_init_multi_out(struct hda_codec *codec)
14354 struct alc_spec *spec = codec->spec;
14355 int i;
14357 for (i = 0; i < spec->autocfg.line_outs; i++) {
14358 hda_nid_t nid = spec->autocfg.line_out_pins[i];
14359 int pin_type = get_pin_type(spec->autocfg.line_out_type);
14360 if (nid)
14361 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
14362 spec->multiout.dac_nids[i]);
14366 static void alc861_auto_init_hp_out(struct hda_codec *codec)
14368 struct alc_spec *spec = codec->spec;
14370 if (spec->autocfg.hp_outs)
14371 alc861_auto_set_output_and_unmute(codec,
14372 spec->autocfg.hp_pins[0],
14373 PIN_HP,
14374 spec->multiout.hp_nid);
14375 if (spec->autocfg.speaker_outs)
14376 alc861_auto_set_output_and_unmute(codec,
14377 spec->autocfg.speaker_pins[0],
14378 PIN_OUT,
14379 spec->multiout.dac_nids[0]);
14382 static void alc861_auto_init_analog_input(struct hda_codec *codec)
14384 struct alc_spec *spec = codec->spec;
14385 int i;
14387 for (i = 0; i < AUTO_PIN_LAST; i++) {
14388 hda_nid_t nid = spec->autocfg.input_pins[i];
14389 if (nid >= 0x0c && nid <= 0x11)
14390 alc_set_input_pin(codec, nid, i);
14394 /* parse the BIOS configuration and set up the alc_spec */
14395 /* return 1 if successful, 0 if the proper config is not found,
14396 * or a negative error code
14398 static int alc861_parse_auto_config(struct hda_codec *codec)
14400 struct alc_spec *spec = codec->spec;
14401 int err;
14402 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14404 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14405 alc861_ignore);
14406 if (err < 0)
14407 return err;
14408 if (!spec->autocfg.line_outs)
14409 return 0; /* can't find valid BIOS pin config */
14411 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
14412 if (err < 0)
14413 return err;
14414 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
14415 if (err < 0)
14416 return err;
14417 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
14418 if (err < 0)
14419 return err;
14420 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
14421 if (err < 0)
14422 return err;
14424 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14426 if (spec->autocfg.dig_outs)
14427 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14429 if (spec->kctls.list)
14430 add_mixer(spec, spec->kctls.list);
14432 add_verb(spec, alc861_auto_init_verbs);
14434 spec->num_mux_defs = 1;
14435 spec->input_mux = &spec->private_imux[0];
14437 spec->adc_nids = alc861_adc_nids;
14438 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
14439 set_capture_mixer(codec);
14441 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14443 return 1;
14446 /* additional initialization for auto-configuration model */
14447 static void alc861_auto_init(struct hda_codec *codec)
14449 struct alc_spec *spec = codec->spec;
14450 alc861_auto_init_multi_out(codec);
14451 alc861_auto_init_hp_out(codec);
14452 alc861_auto_init_analog_input(codec);
14453 if (spec->unsol_event)
14454 alc_inithook(codec);
14457 #ifdef CONFIG_SND_HDA_POWER_SAVE
14458 static struct hda_amp_list alc861_loopbacks[] = {
14459 { 0x15, HDA_INPUT, 0 },
14460 { 0x15, HDA_INPUT, 1 },
14461 { 0x15, HDA_INPUT, 2 },
14462 { 0x15, HDA_INPUT, 3 },
14463 { } /* end */
14465 #endif
14469 * configuration and preset
14471 static const char *alc861_models[ALC861_MODEL_LAST] = {
14472 [ALC861_3ST] = "3stack",
14473 [ALC660_3ST] = "3stack-660",
14474 [ALC861_3ST_DIG] = "3stack-dig",
14475 [ALC861_6ST_DIG] = "6stack-dig",
14476 [ALC861_UNIWILL_M31] = "uniwill-m31",
14477 [ALC861_TOSHIBA] = "toshiba",
14478 [ALC861_ASUS] = "asus",
14479 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14480 [ALC861_AUTO] = "auto",
14483 static struct snd_pci_quirk alc861_cfg_tbl[] = {
14484 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
14485 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14486 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14487 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
14488 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
14489 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
14490 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
14491 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14492 * Any other models that need this preset?
14494 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
14495 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14496 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
14497 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14498 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14499 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14500 /* FIXME: the below seems conflict */
14501 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14502 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14503 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
14507 static struct alc_config_preset alc861_presets[] = {
14508 [ALC861_3ST] = {
14509 .mixers = { alc861_3ST_mixer },
14510 .init_verbs = { alc861_threestack_init_verbs },
14511 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14512 .dac_nids = alc861_dac_nids,
14513 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14514 .channel_mode = alc861_threestack_modes,
14515 .need_dac_fix = 1,
14516 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14517 .adc_nids = alc861_adc_nids,
14518 .input_mux = &alc861_capture_source,
14520 [ALC861_3ST_DIG] = {
14521 .mixers = { alc861_base_mixer },
14522 .init_verbs = { alc861_threestack_init_verbs },
14523 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14524 .dac_nids = alc861_dac_nids,
14525 .dig_out_nid = ALC861_DIGOUT_NID,
14526 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14527 .channel_mode = alc861_threestack_modes,
14528 .need_dac_fix = 1,
14529 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14530 .adc_nids = alc861_adc_nids,
14531 .input_mux = &alc861_capture_source,
14533 [ALC861_6ST_DIG] = {
14534 .mixers = { alc861_base_mixer },
14535 .init_verbs = { alc861_base_init_verbs },
14536 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14537 .dac_nids = alc861_dac_nids,
14538 .dig_out_nid = ALC861_DIGOUT_NID,
14539 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14540 .channel_mode = alc861_8ch_modes,
14541 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14542 .adc_nids = alc861_adc_nids,
14543 .input_mux = &alc861_capture_source,
14545 [ALC660_3ST] = {
14546 .mixers = { alc861_3ST_mixer },
14547 .init_verbs = { alc861_threestack_init_verbs },
14548 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14549 .dac_nids = alc660_dac_nids,
14550 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14551 .channel_mode = alc861_threestack_modes,
14552 .need_dac_fix = 1,
14553 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14554 .adc_nids = alc861_adc_nids,
14555 .input_mux = &alc861_capture_source,
14557 [ALC861_UNIWILL_M31] = {
14558 .mixers = { alc861_uniwill_m31_mixer },
14559 .init_verbs = { alc861_uniwill_m31_init_verbs },
14560 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14561 .dac_nids = alc861_dac_nids,
14562 .dig_out_nid = ALC861_DIGOUT_NID,
14563 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14564 .channel_mode = alc861_uniwill_m31_modes,
14565 .need_dac_fix = 1,
14566 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14567 .adc_nids = alc861_adc_nids,
14568 .input_mux = &alc861_capture_source,
14570 [ALC861_TOSHIBA] = {
14571 .mixers = { alc861_toshiba_mixer },
14572 .init_verbs = { alc861_base_init_verbs,
14573 alc861_toshiba_init_verbs },
14574 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14575 .dac_nids = alc861_dac_nids,
14576 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14577 .channel_mode = alc883_3ST_2ch_modes,
14578 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14579 .adc_nids = alc861_adc_nids,
14580 .input_mux = &alc861_capture_source,
14581 .unsol_event = alc861_toshiba_unsol_event,
14582 .init_hook = alc861_toshiba_automute,
14584 [ALC861_ASUS] = {
14585 .mixers = { alc861_asus_mixer },
14586 .init_verbs = { alc861_asus_init_verbs },
14587 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14588 .dac_nids = alc861_dac_nids,
14589 .dig_out_nid = ALC861_DIGOUT_NID,
14590 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14591 .channel_mode = alc861_asus_modes,
14592 .need_dac_fix = 1,
14593 .hp_nid = 0x06,
14594 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14595 .adc_nids = alc861_adc_nids,
14596 .input_mux = &alc861_capture_source,
14598 [ALC861_ASUS_LAPTOP] = {
14599 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14600 .init_verbs = { alc861_asus_init_verbs,
14601 alc861_asus_laptop_init_verbs },
14602 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14603 .dac_nids = alc861_dac_nids,
14604 .dig_out_nid = ALC861_DIGOUT_NID,
14605 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14606 .channel_mode = alc883_3ST_2ch_modes,
14607 .need_dac_fix = 1,
14608 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14609 .adc_nids = alc861_adc_nids,
14610 .input_mux = &alc861_capture_source,
14615 static int patch_alc861(struct hda_codec *codec)
14617 struct alc_spec *spec;
14618 int board_config;
14619 int err;
14621 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14622 if (spec == NULL)
14623 return -ENOMEM;
14625 codec->spec = spec;
14627 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14628 alc861_models,
14629 alc861_cfg_tbl);
14631 if (board_config < 0) {
14632 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14633 codec->chip_name);
14634 board_config = ALC861_AUTO;
14637 if (board_config == ALC861_AUTO) {
14638 /* automatic parse from the BIOS config */
14639 err = alc861_parse_auto_config(codec);
14640 if (err < 0) {
14641 alc_free(codec);
14642 return err;
14643 } else if (!err) {
14644 printk(KERN_INFO
14645 "hda_codec: Cannot set up configuration "
14646 "from BIOS. Using base mode...\n");
14647 board_config = ALC861_3ST_DIG;
14651 err = snd_hda_attach_beep_device(codec, 0x23);
14652 if (err < 0) {
14653 alc_free(codec);
14654 return err;
14657 if (board_config != ALC861_AUTO)
14658 setup_preset(codec, &alc861_presets[board_config]);
14660 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14661 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14663 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14664 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14666 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14668 spec->vmaster_nid = 0x03;
14670 codec->patch_ops = alc_patch_ops;
14671 if (board_config == ALC861_AUTO)
14672 spec->init_hook = alc861_auto_init;
14673 #ifdef CONFIG_SND_HDA_POWER_SAVE
14674 if (!spec->loopback.amplist)
14675 spec->loopback.amplist = alc861_loopbacks;
14676 #endif
14677 codec->proc_widget_hook = print_realtek_coef;
14679 return 0;
14683 * ALC861-VD support
14685 * Based on ALC882
14687 * In addition, an independent DAC
14689 #define ALC861VD_DIGOUT_NID 0x06
14691 static hda_nid_t alc861vd_dac_nids[4] = {
14692 /* front, surr, clfe, side surr */
14693 0x02, 0x03, 0x04, 0x05
14696 /* dac_nids for ALC660vd are in a different order - according to
14697 * Realtek's driver.
14698 * This should probably result in a different mixer for 6stack models
14699 * of ALC660vd codecs, but for now there is only 3stack mixer
14700 * - and it is the same as in 861vd.
14701 * adc_nids in ALC660vd are (is) the same as in 861vd
14703 static hda_nid_t alc660vd_dac_nids[3] = {
14704 /* front, rear, clfe, rear_surr */
14705 0x02, 0x04, 0x03
14708 static hda_nid_t alc861vd_adc_nids[1] = {
14709 /* ADC0 */
14710 0x09,
14713 static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14715 /* input MUX */
14716 /* FIXME: should be a matrix-type input source selection */
14717 static struct hda_input_mux alc861vd_capture_source = {
14718 .num_items = 4,
14719 .items = {
14720 { "Mic", 0x0 },
14721 { "Front Mic", 0x1 },
14722 { "Line", 0x2 },
14723 { "CD", 0x4 },
14727 static struct hda_input_mux alc861vd_dallas_capture_source = {
14728 .num_items = 2,
14729 .items = {
14730 { "Ext Mic", 0x0 },
14731 { "Int Mic", 0x1 },
14735 static struct hda_input_mux alc861vd_hp_capture_source = {
14736 .num_items = 2,
14737 .items = {
14738 { "Front Mic", 0x0 },
14739 { "ATAPI Mic", 0x1 },
14744 * 2ch mode
14746 static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14747 { 2, NULL }
14751 * 6ch mode
14753 static struct hda_verb alc861vd_6stack_ch6_init[] = {
14754 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14755 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14756 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14757 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14758 { } /* end */
14762 * 8ch mode
14764 static struct hda_verb alc861vd_6stack_ch8_init[] = {
14765 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14766 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14767 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14768 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14769 { } /* end */
14772 static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14773 { 6, alc861vd_6stack_ch6_init },
14774 { 8, alc861vd_6stack_ch8_init },
14777 static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14780 .name = "Channel Mode",
14781 .info = alc_ch_mode_info,
14782 .get = alc_ch_mode_get,
14783 .put = alc_ch_mode_put,
14785 { } /* end */
14788 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14789 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14791 static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14792 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14793 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14795 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14796 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14798 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14799 HDA_OUTPUT),
14800 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14801 HDA_OUTPUT),
14802 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14803 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14805 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14806 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 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_3st_mixer[] = {
14828 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14829 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14831 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14833 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14834 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14837 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14838 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14839 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14841 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14842 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14844 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14845 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14847 { } /* end */
14850 static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14851 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14852 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14853 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14855 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14857 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14858 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14859 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14861 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14862 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14863 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14865 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14866 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14868 { } /* end */
14871 /* Pin assignment: Speaker=0x14, HP = 0x15,
14872 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
14874 static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
14875 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14876 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
14877 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14878 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14879 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14880 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14881 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14882 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14883 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14884 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14885 { } /* end */
14888 /* Pin assignment: Speaker=0x14, Line-out = 0x15,
14889 * Front Mic=0x18, ATAPI Mic = 0x19,
14891 static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14892 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14893 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14894 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14895 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14896 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14897 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14898 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14899 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14901 { } /* end */
14905 * generic initialization of ADC, input mixers and output mixers
14907 static struct hda_verb alc861vd_volume_init_verbs[] = {
14909 * Unmute ADC0 and set the default input to mic-in
14911 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14912 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14914 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14915 * the analog-loopback mixer widget
14917 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
14918 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14921 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14922 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14924 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
14925 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14928 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
14931 * Set up output mixers (0x02 - 0x05)
14933 /* set vol=0 to output mixers */
14934 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14935 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14936 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14937 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14939 /* set up input amps for analog loopback */
14940 /* Amp Indices: DAC = 0, mixer = 1 */
14941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14942 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14944 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14946 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14947 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14948 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14954 * 3-stack pin configuration:
14955 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14957 static struct hda_verb alc861vd_3stack_init_verbs[] = {
14959 * Set pin mode and muting
14961 /* set front pin widgets 0x14 for output */
14962 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14963 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14964 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14966 /* Mic (rear) pin: input vref at 80% */
14967 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14968 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14969 /* Front Mic pin: input vref at 80% */
14970 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14971 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14972 /* Line In pin: input */
14973 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14974 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14975 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14976 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14977 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14978 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14979 /* CD pin widget for input */
14980 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14986 * 6-stack pin configuration:
14988 static struct hda_verb alc861vd_6stack_init_verbs[] = {
14990 * Set pin mode and muting
14992 /* set front pin widgets 0x14 for output */
14993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14994 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14995 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14997 /* Rear Pin: output 1 (0x0d) */
14998 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15000 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15001 /* CLFE Pin: output 2 (0x0e) */
15002 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15003 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15004 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15005 /* Side Pin: output 3 (0x0f) */
15006 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15007 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15008 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15010 /* Mic (rear) pin: input vref at 80% */
15011 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15012 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15013 /* Front Mic pin: input vref at 80% */
15014 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15015 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15016 /* Line In pin: input */
15017 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15018 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15019 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15020 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15021 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15022 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15023 /* CD pin widget for input */
15024 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15029 static struct hda_verb alc861vd_eapd_verbs[] = {
15030 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15034 static struct hda_verb alc660vd_eapd_verbs[] = {
15035 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15036 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15040 static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15041 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15042 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15044 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15045 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15049 static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15051 unsigned int present;
15052 unsigned char bits;
15054 present = snd_hda_codec_read(codec, 0x18, 0,
15055 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15056 bits = present ? HDA_AMP_MUTE : 0;
15057 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15058 HDA_AMP_MUTE, bits);
15061 static void alc861vd_lenovo_setup(struct hda_codec *codec)
15063 struct alc_spec *spec = codec->spec;
15064 spec->autocfg.hp_pins[0] = 0x1b;
15065 spec->autocfg.speaker_pins[0] = 0x14;
15068 static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15070 alc_automute_amp(codec);
15071 alc861vd_lenovo_mic_automute(codec);
15074 static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15075 unsigned int res)
15077 switch (res >> 26) {
15078 case ALC880_MIC_EVENT:
15079 alc861vd_lenovo_mic_automute(codec);
15080 break;
15081 default:
15082 alc_automute_amp_unsol_event(codec, res);
15083 break;
15087 static struct hda_verb alc861vd_dallas_verbs[] = {
15088 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15089 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15090 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15091 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15093 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15094 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15095 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15096 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15097 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15098 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15099 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15100 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15102 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15103 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15104 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15105 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15106 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15107 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15108 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15109 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15111 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15112 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15113 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15114 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15115 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15116 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15117 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15118 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15120 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15122 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15123 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15126 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15127 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15129 { } /* end */
15132 /* toggle speaker-output according to the hp-jack state */
15133 static void alc861vd_dallas_setup(struct hda_codec *codec)
15135 struct alc_spec *spec = codec->spec;
15137 spec->autocfg.hp_pins[0] = 0x15;
15138 spec->autocfg.speaker_pins[0] = 0x14;
15141 #ifdef CONFIG_SND_HDA_POWER_SAVE
15142 #define alc861vd_loopbacks alc880_loopbacks
15143 #endif
15145 /* pcm configuration: identical with ALC880 */
15146 #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15147 #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15148 #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15149 #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15152 * configuration and preset
15154 static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15155 [ALC660VD_3ST] = "3stack-660",
15156 [ALC660VD_3ST_DIG] = "3stack-660-digout",
15157 [ALC660VD_ASUS_V1S] = "asus-v1s",
15158 [ALC861VD_3ST] = "3stack",
15159 [ALC861VD_3ST_DIG] = "3stack-digout",
15160 [ALC861VD_6ST_DIG] = "6stack-digout",
15161 [ALC861VD_LENOVO] = "lenovo",
15162 [ALC861VD_DALLAS] = "dallas",
15163 [ALC861VD_HP] = "hp",
15164 [ALC861VD_AUTO] = "auto",
15167 static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
15168 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15169 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
15170 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
15171 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
15172 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
15173 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
15174 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
15175 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
15176 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
15177 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
15178 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
15179 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
15180 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
15181 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
15182 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
15186 static struct alc_config_preset alc861vd_presets[] = {
15187 [ALC660VD_3ST] = {
15188 .mixers = { alc861vd_3st_mixer },
15189 .init_verbs = { alc861vd_volume_init_verbs,
15190 alc861vd_3stack_init_verbs },
15191 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15192 .dac_nids = alc660vd_dac_nids,
15193 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15194 .channel_mode = alc861vd_3stack_2ch_modes,
15195 .input_mux = &alc861vd_capture_source,
15197 [ALC660VD_3ST_DIG] = {
15198 .mixers = { alc861vd_3st_mixer },
15199 .init_verbs = { alc861vd_volume_init_verbs,
15200 alc861vd_3stack_init_verbs },
15201 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15202 .dac_nids = alc660vd_dac_nids,
15203 .dig_out_nid = ALC861VD_DIGOUT_NID,
15204 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15205 .channel_mode = alc861vd_3stack_2ch_modes,
15206 .input_mux = &alc861vd_capture_source,
15208 [ALC861VD_3ST] = {
15209 .mixers = { alc861vd_3st_mixer },
15210 .init_verbs = { alc861vd_volume_init_verbs,
15211 alc861vd_3stack_init_verbs },
15212 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15213 .dac_nids = alc861vd_dac_nids,
15214 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15215 .channel_mode = alc861vd_3stack_2ch_modes,
15216 .input_mux = &alc861vd_capture_source,
15218 [ALC861VD_3ST_DIG] = {
15219 .mixers = { alc861vd_3st_mixer },
15220 .init_verbs = { alc861vd_volume_init_verbs,
15221 alc861vd_3stack_init_verbs },
15222 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15223 .dac_nids = alc861vd_dac_nids,
15224 .dig_out_nid = ALC861VD_DIGOUT_NID,
15225 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15226 .channel_mode = alc861vd_3stack_2ch_modes,
15227 .input_mux = &alc861vd_capture_source,
15229 [ALC861VD_6ST_DIG] = {
15230 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15231 .init_verbs = { alc861vd_volume_init_verbs,
15232 alc861vd_6stack_init_verbs },
15233 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15234 .dac_nids = alc861vd_dac_nids,
15235 .dig_out_nid = ALC861VD_DIGOUT_NID,
15236 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15237 .channel_mode = alc861vd_6stack_modes,
15238 .input_mux = &alc861vd_capture_source,
15240 [ALC861VD_LENOVO] = {
15241 .mixers = { alc861vd_lenovo_mixer },
15242 .init_verbs = { alc861vd_volume_init_verbs,
15243 alc861vd_3stack_init_verbs,
15244 alc861vd_eapd_verbs,
15245 alc861vd_lenovo_unsol_verbs },
15246 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15247 .dac_nids = alc660vd_dac_nids,
15248 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15249 .channel_mode = alc861vd_3stack_2ch_modes,
15250 .input_mux = &alc861vd_capture_source,
15251 .unsol_event = alc861vd_lenovo_unsol_event,
15252 .setup = alc861vd_lenovo_setup,
15253 .init_hook = alc861vd_lenovo_init_hook,
15255 [ALC861VD_DALLAS] = {
15256 .mixers = { alc861vd_dallas_mixer },
15257 .init_verbs = { alc861vd_dallas_verbs },
15258 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15259 .dac_nids = alc861vd_dac_nids,
15260 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15261 .channel_mode = alc861vd_3stack_2ch_modes,
15262 .input_mux = &alc861vd_dallas_capture_source,
15263 .unsol_event = alc_automute_amp_unsol_event,
15264 .setup = alc861vd_dallas_setup,
15265 .init_hook = alc_automute_amp,
15267 [ALC861VD_HP] = {
15268 .mixers = { alc861vd_hp_mixer },
15269 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15270 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15271 .dac_nids = alc861vd_dac_nids,
15272 .dig_out_nid = ALC861VD_DIGOUT_NID,
15273 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15274 .channel_mode = alc861vd_3stack_2ch_modes,
15275 .input_mux = &alc861vd_hp_capture_source,
15276 .unsol_event = alc_automute_amp_unsol_event,
15277 .setup = alc861vd_dallas_setup,
15278 .init_hook = alc_automute_amp,
15280 [ALC660VD_ASUS_V1S] = {
15281 .mixers = { alc861vd_lenovo_mixer },
15282 .init_verbs = { alc861vd_volume_init_verbs,
15283 alc861vd_3stack_init_verbs,
15284 alc861vd_eapd_verbs,
15285 alc861vd_lenovo_unsol_verbs },
15286 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15287 .dac_nids = alc660vd_dac_nids,
15288 .dig_out_nid = ALC861VD_DIGOUT_NID,
15289 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15290 .channel_mode = alc861vd_3stack_2ch_modes,
15291 .input_mux = &alc861vd_capture_source,
15292 .unsol_event = alc861vd_lenovo_unsol_event,
15293 .setup = alc861vd_lenovo_setup,
15294 .init_hook = alc861vd_lenovo_init_hook,
15299 * BIOS auto configuration
15301 static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15302 const struct auto_pin_cfg *cfg)
15304 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15308 static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15309 hda_nid_t nid, int pin_type, int dac_idx)
15311 alc_set_pin_output(codec, nid, pin_type);
15314 static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15316 struct alc_spec *spec = codec->spec;
15317 int i;
15319 for (i = 0; i <= HDA_SIDE; i++) {
15320 hda_nid_t nid = spec->autocfg.line_out_pins[i];
15321 int pin_type = get_pin_type(spec->autocfg.line_out_type);
15322 if (nid)
15323 alc861vd_auto_set_output_and_unmute(codec, nid,
15324 pin_type, i);
15329 static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15331 struct alc_spec *spec = codec->spec;
15332 hda_nid_t pin;
15334 pin = spec->autocfg.hp_pins[0];
15335 if (pin) /* connect to front and use dac 0 */
15336 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
15337 pin = spec->autocfg.speaker_pins[0];
15338 if (pin)
15339 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
15342 #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15344 static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15346 struct alc_spec *spec = codec->spec;
15347 int i;
15349 for (i = 0; i < AUTO_PIN_LAST; i++) {
15350 hda_nid_t nid = spec->autocfg.input_pins[i];
15351 if (alc_is_input_pin(codec, nid)) {
15352 alc_set_input_pin(codec, nid, i);
15353 if (nid != ALC861VD_PIN_CD_NID &&
15354 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
15355 snd_hda_codec_write(codec, nid, 0,
15356 AC_VERB_SET_AMP_GAIN_MUTE,
15357 AMP_OUT_MUTE);
15362 #define alc861vd_auto_init_input_src alc882_auto_init_input_src
15364 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15365 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15367 /* add playback controls from the parsed DAC table */
15368 /* Based on ALC880 version. But ALC861VD has separate,
15369 * different NIDs for mute/unmute switch and volume control */
15370 static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15371 const struct auto_pin_cfg *cfg)
15373 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15374 hda_nid_t nid_v, nid_s;
15375 int i, err;
15377 for (i = 0; i < cfg->line_outs; i++) {
15378 if (!spec->multiout.dac_nids[i])
15379 continue;
15380 nid_v = alc861vd_idx_to_mixer_vol(
15381 alc880_dac_to_idx(
15382 spec->multiout.dac_nids[i]));
15383 nid_s = alc861vd_idx_to_mixer_switch(
15384 alc880_dac_to_idx(
15385 spec->multiout.dac_nids[i]));
15387 if (i == 2) {
15388 /* Center/LFE */
15389 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15390 "Center",
15391 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15392 HDA_OUTPUT));
15393 if (err < 0)
15394 return err;
15395 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
15396 "LFE",
15397 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15398 HDA_OUTPUT));
15399 if (err < 0)
15400 return err;
15401 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15402 "Center",
15403 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15404 HDA_INPUT));
15405 if (err < 0)
15406 return err;
15407 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
15408 "LFE",
15409 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15410 HDA_INPUT));
15411 if (err < 0)
15412 return err;
15413 } else {
15414 const char *pfx;
15415 if (cfg->line_outs == 1 &&
15416 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15417 if (!cfg->hp_pins)
15418 pfx = "Speaker";
15419 else
15420 pfx = "PCM";
15421 } else
15422 pfx = chname[i];
15423 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
15424 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15425 HDA_OUTPUT));
15426 if (err < 0)
15427 return err;
15428 if (cfg->line_outs == 1 &&
15429 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15430 pfx = "Speaker";
15431 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
15432 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
15433 HDA_INPUT));
15434 if (err < 0)
15435 return err;
15438 return 0;
15441 /* add playback controls for speaker and HP outputs */
15442 /* Based on ALC880 version. But ALC861VD has separate,
15443 * different NIDs for mute/unmute switch and volume control */
15444 static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15445 hda_nid_t pin, const char *pfx)
15447 hda_nid_t nid_v, nid_s;
15448 int err;
15450 if (!pin)
15451 return 0;
15453 if (alc880_is_fixed_pin(pin)) {
15454 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15455 /* specify the DAC as the extra output */
15456 if (!spec->multiout.hp_nid)
15457 spec->multiout.hp_nid = nid_v;
15458 else
15459 spec->multiout.extra_out_nid[0] = nid_v;
15460 /* control HP volume/switch on the output mixer amp */
15461 nid_v = alc861vd_idx_to_mixer_vol(
15462 alc880_fixed_pin_idx(pin));
15463 nid_s = alc861vd_idx_to_mixer_switch(
15464 alc880_fixed_pin_idx(pin));
15466 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
15467 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15468 if (err < 0)
15469 return err;
15470 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
15471 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15472 if (err < 0)
15473 return err;
15474 } else if (alc880_is_multi_pin(pin)) {
15475 /* set manual connection */
15476 /* we have only a switch on HP-out PIN */
15477 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
15478 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15479 if (err < 0)
15480 return err;
15482 return 0;
15485 /* parse the BIOS configuration and set up the alc_spec
15486 * return 1 if successful, 0 if the proper config is not found,
15487 * or a negative error code
15488 * Based on ALC880 version - had to change it to override
15489 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15490 static int alc861vd_parse_auto_config(struct hda_codec *codec)
15492 struct alc_spec *spec = codec->spec;
15493 int err;
15494 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15496 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15497 alc861vd_ignore);
15498 if (err < 0)
15499 return err;
15500 if (!spec->autocfg.line_outs)
15501 return 0; /* can't find valid BIOS pin config */
15503 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15504 if (err < 0)
15505 return err;
15506 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15507 if (err < 0)
15508 return err;
15509 err = alc861vd_auto_create_extra_out(spec,
15510 spec->autocfg.speaker_pins[0],
15511 "Speaker");
15512 if (err < 0)
15513 return err;
15514 err = alc861vd_auto_create_extra_out(spec,
15515 spec->autocfg.hp_pins[0],
15516 "Headphone");
15517 if (err < 0)
15518 return err;
15519 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
15520 if (err < 0)
15521 return err;
15523 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15525 if (spec->autocfg.dig_outs)
15526 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15528 if (spec->kctls.list)
15529 add_mixer(spec, spec->kctls.list);
15531 add_verb(spec, alc861vd_volume_init_verbs);
15533 spec->num_mux_defs = 1;
15534 spec->input_mux = &spec->private_imux[0];
15536 err = alc_auto_add_mic_boost(codec);
15537 if (err < 0)
15538 return err;
15540 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15542 return 1;
15545 /* additional initialization for auto-configuration model */
15546 static void alc861vd_auto_init(struct hda_codec *codec)
15548 struct alc_spec *spec = codec->spec;
15549 alc861vd_auto_init_multi_out(codec);
15550 alc861vd_auto_init_hp_out(codec);
15551 alc861vd_auto_init_analog_input(codec);
15552 alc861vd_auto_init_input_src(codec);
15553 if (spec->unsol_event)
15554 alc_inithook(codec);
15557 enum {
15558 ALC660VD_FIX_ASUS_GPIO1
15561 /* reset GPIO1 */
15562 static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
15563 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
15564 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
15565 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
15569 static const struct alc_fixup alc861vd_fixups[] = {
15570 [ALC660VD_FIX_ASUS_GPIO1] = {
15571 .verbs = alc660vd_fix_asus_gpio1_verbs,
15575 static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
15576 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
15580 static int patch_alc861vd(struct hda_codec *codec)
15582 struct alc_spec *spec;
15583 int err, board_config;
15585 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15586 if (spec == NULL)
15587 return -ENOMEM;
15589 codec->spec = spec;
15591 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15592 alc861vd_models,
15593 alc861vd_cfg_tbl);
15595 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
15596 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15597 codec->chip_name);
15598 board_config = ALC861VD_AUTO;
15601 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
15603 if (board_config == ALC861VD_AUTO) {
15604 /* automatic parse from the BIOS config */
15605 err = alc861vd_parse_auto_config(codec);
15606 if (err < 0) {
15607 alc_free(codec);
15608 return err;
15609 } else if (!err) {
15610 printk(KERN_INFO
15611 "hda_codec: Cannot set up configuration "
15612 "from BIOS. Using base mode...\n");
15613 board_config = ALC861VD_3ST;
15617 err = snd_hda_attach_beep_device(codec, 0x23);
15618 if (err < 0) {
15619 alc_free(codec);
15620 return err;
15623 if (board_config != ALC861VD_AUTO)
15624 setup_preset(codec, &alc861vd_presets[board_config]);
15626 if (codec->vendor_id == 0x10ec0660) {
15627 /* always turn on EAPD */
15628 add_verb(spec, alc660vd_eapd_verbs);
15631 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15632 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15634 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15635 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15637 if (!spec->adc_nids) {
15638 spec->adc_nids = alc861vd_adc_nids;
15639 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15641 if (!spec->capsrc_nids)
15642 spec->capsrc_nids = alc861vd_capsrc_nids;
15644 set_capture_mixer(codec);
15645 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
15647 spec->vmaster_nid = 0x02;
15649 codec->patch_ops = alc_patch_ops;
15651 if (board_config == ALC861VD_AUTO)
15652 spec->init_hook = alc861vd_auto_init;
15653 #ifdef CONFIG_SND_HDA_POWER_SAVE
15654 if (!spec->loopback.amplist)
15655 spec->loopback.amplist = alc861vd_loopbacks;
15656 #endif
15657 codec->proc_widget_hook = print_realtek_coef;
15659 return 0;
15663 * ALC662 support
15665 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15666 * configuration. Each pin widget can choose any input DACs and a mixer.
15667 * Each ADC is connected from a mixer of all inputs. This makes possible
15668 * 6-channel independent captures.
15670 * In addition, an independent DAC for the multi-playback (not used in this
15671 * driver yet).
15673 #define ALC662_DIGOUT_NID 0x06
15674 #define ALC662_DIGIN_NID 0x0a
15676 static hda_nid_t alc662_dac_nids[4] = {
15677 /* front, rear, clfe, rear_surr */
15678 0x02, 0x03, 0x04
15681 static hda_nid_t alc272_dac_nids[2] = {
15682 0x02, 0x03
15685 static hda_nid_t alc662_adc_nids[2] = {
15686 /* ADC1-2 */
15687 0x09, 0x08
15690 static hda_nid_t alc272_adc_nids[1] = {
15691 /* ADC1-2 */
15692 0x08,
15695 static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
15696 static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15699 /* input MUX */
15700 /* FIXME: should be a matrix-type input source selection */
15701 static struct hda_input_mux alc662_capture_source = {
15702 .num_items = 4,
15703 .items = {
15704 { "Mic", 0x0 },
15705 { "Front Mic", 0x1 },
15706 { "Line", 0x2 },
15707 { "CD", 0x4 },
15711 static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15712 .num_items = 2,
15713 .items = {
15714 { "Mic", 0x1 },
15715 { "Line", 0x2 },
15719 static struct hda_input_mux alc663_capture_source = {
15720 .num_items = 3,
15721 .items = {
15722 { "Mic", 0x0 },
15723 { "Front Mic", 0x1 },
15724 { "Line", 0x2 },
15728 #if 0 /* set to 1 for testing other input sources below */
15729 static struct hda_input_mux alc272_nc10_capture_source = {
15730 .num_items = 16,
15731 .items = {
15732 { "Autoselect Mic", 0x0 },
15733 { "Internal Mic", 0x1 },
15734 { "In-0x02", 0x2 },
15735 { "In-0x03", 0x3 },
15736 { "In-0x04", 0x4 },
15737 { "In-0x05", 0x5 },
15738 { "In-0x06", 0x6 },
15739 { "In-0x07", 0x7 },
15740 { "In-0x08", 0x8 },
15741 { "In-0x09", 0x9 },
15742 { "In-0x0a", 0x0a },
15743 { "In-0x0b", 0x0b },
15744 { "In-0x0c", 0x0c },
15745 { "In-0x0d", 0x0d },
15746 { "In-0x0e", 0x0e },
15747 { "In-0x0f", 0x0f },
15750 #endif
15753 * 2ch mode
15755 static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15756 { 2, NULL }
15760 * 2ch mode
15762 static struct hda_verb alc662_3ST_ch2_init[] = {
15763 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15764 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15765 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15766 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15767 { } /* end */
15771 * 6ch mode
15773 static struct hda_verb alc662_3ST_ch6_init[] = {
15774 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15775 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15776 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15777 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15778 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15779 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15780 { } /* end */
15783 static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15784 { 2, alc662_3ST_ch2_init },
15785 { 6, alc662_3ST_ch6_init },
15789 * 2ch mode
15791 static struct hda_verb alc662_sixstack_ch6_init[] = {
15792 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15793 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15794 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15795 { } /* end */
15799 * 6ch mode
15801 static struct hda_verb alc662_sixstack_ch8_init[] = {
15802 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15803 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15804 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15805 { } /* end */
15808 static struct hda_channel_mode alc662_5stack_modes[2] = {
15809 { 2, alc662_sixstack_ch6_init },
15810 { 6, alc662_sixstack_ch8_init },
15813 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15814 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15817 static struct snd_kcontrol_new alc662_base_mixer[] = {
15818 /* output mixer control */
15819 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
15820 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15821 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
15822 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
15823 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15824 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15825 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15826 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
15827 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15829 /*Input mixer control */
15830 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15831 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15832 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15833 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15834 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15835 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15836 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15837 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
15838 { } /* end */
15841 static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15842 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15843 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15844 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15845 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15846 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15847 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15848 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15849 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15850 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15851 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15852 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15853 { } /* end */
15856 static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15857 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15858 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
15859 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15860 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
15861 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15862 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15863 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15864 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
15865 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15866 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15867 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15868 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15869 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15870 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15871 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15872 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15873 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15874 { } /* end */
15877 static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15878 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15879 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
15880 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15881 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
15882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15883 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15884 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15885 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15886 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15887 { } /* end */
15890 static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
15891 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15892 ALC262_HIPPO_MASTER_SWITCH,
15894 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15895 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15896 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15898 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15899 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15900 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15901 { } /* end */
15904 static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
15905 ALC262_HIPPO_MASTER_SWITCH,
15906 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15907 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15908 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15909 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15910 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15911 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15912 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15915 { } /* end */
15918 static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15919 .ops = &snd_hda_bind_vol,
15920 .values = {
15921 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15922 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15927 static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15928 .ops = &snd_hda_bind_sw,
15929 .values = {
15930 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15931 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15936 static struct snd_kcontrol_new alc663_m51va_mixer[] = {
15937 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15938 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15939 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15940 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15941 { } /* end */
15944 static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15945 .ops = &snd_hda_bind_sw,
15946 .values = {
15947 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15948 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15949 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15954 static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15955 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15956 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15958 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15959 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15960 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15962 { } /* end */
15965 static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15966 .ops = &snd_hda_bind_sw,
15967 .values = {
15968 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15969 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15970 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15975 static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15976 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15977 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15978 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15979 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15980 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15981 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15982 { } /* end */
15985 static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
15986 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15987 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 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 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15992 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15993 { } /* end */
15996 static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15997 .ops = &snd_hda_bind_vol,
15998 .values = {
15999 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16000 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16005 static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16006 .ops = &snd_hda_bind_sw,
16007 .values = {
16008 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16009 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16014 static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16015 HDA_BIND_VOL("Master Playback Volume",
16016 &alc663_asus_two_bind_master_vol),
16017 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16018 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16022 { } /* end */
16025 static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16026 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16027 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16028 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16032 { } /* end */
16035 static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16036 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16037 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16038 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16039 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16040 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16043 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16044 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16045 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16046 { } /* end */
16049 static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16050 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16051 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16052 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16054 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16055 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16056 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16057 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16058 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16059 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16060 { } /* end */
16063 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16065 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16066 .name = "Channel Mode",
16067 .info = alc_ch_mode_info,
16068 .get = alc_ch_mode_get,
16069 .put = alc_ch_mode_put,
16071 { } /* end */
16074 static struct hda_verb alc662_init_verbs[] = {
16075 /* ADC: mute amp left and right */
16076 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16077 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16078 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16088 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16089 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16090 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16091 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16093 /* Front Pin: output 0 (0x0c) */
16094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16095 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16097 /* Rear Pin: output 1 (0x0d) */
16098 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16099 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16101 /* CLFE Pin: output 2 (0x0e) */
16102 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16103 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16105 /* Mic (rear) pin: input vref at 80% */
16106 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16107 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16108 /* Front Mic pin: input vref at 80% */
16109 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16110 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16111 /* Line In pin: input */
16112 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16113 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16114 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16115 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16116 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16117 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16118 /* CD pin widget for input */
16119 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16121 /* FIXME: use matrix-type input source selection */
16122 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16123 /* Input mixer */
16124 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16125 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16127 /* always trun on EAPD */
16128 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16129 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16134 static struct hda_verb alc662_sue_init_verbs[] = {
16135 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16136 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16140 static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16141 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16142 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16146 /* Set Unsolicited Event*/
16147 static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16148 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16149 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16154 * generic initialization of ADC, input mixers and output mixers
16156 static struct hda_verb alc662_auto_init_verbs[] = {
16158 * Unmute ADC and set the default input to mic-in
16160 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16163 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16164 * mixer widget
16165 * Note: PASD motherboards uses the Line In 2 as the input for front
16166 * panel mic (mic 2)
16168 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
16169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16171 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16172 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16173 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16176 * Set up output mixers (0x0c - 0x0f)
16178 /* set vol=0 to output mixers */
16179 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16180 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16181 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16183 /* set up input amps for analog loopback */
16184 /* Amp Indices: DAC = 0, mixer = 1 */
16185 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16186 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16187 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16188 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16189 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16190 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16193 /* FIXME: use matrix-type input source selection */
16194 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16195 /* Input mixer */
16196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16197 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16201 /* additional verbs for ALC663 */
16202 static struct hda_verb alc663_auto_init_verbs[] = {
16203 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16204 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16208 static struct hda_verb alc663_m51va_init_verbs[] = {
16209 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16210 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16211 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16212 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16213 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16216 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16217 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16221 static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16222 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16223 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16224 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16225 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16226 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16227 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16228 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16232 static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16233 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16234 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16235 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16236 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16239 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16240 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16244 static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16245 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16248 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16250 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16251 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16255 static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16256 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16257 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16258 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16259 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16261 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16262 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16263 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16265 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16266 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16267 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16271 static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16273 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16274 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16275 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16276 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16277 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16278 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16279 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16280 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16281 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16282 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16283 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16287 static struct hda_verb alc663_g71v_init_verbs[] = {
16288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16289 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16290 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16292 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16293 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16294 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16296 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16297 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16298 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16302 static struct hda_verb alc663_g50v_init_verbs[] = {
16303 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16304 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16305 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16307 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16308 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16312 static struct hda_verb alc662_ecs_init_verbs[] = {
16313 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16315 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16316 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16320 static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16321 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16322 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16323 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16324 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16325 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16326 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16327 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16328 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16329 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16330 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16331 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16335 static struct hda_verb alc272_dell_init_verbs[] = {
16336 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16337 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16339 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16340 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16341 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16342 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16343 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16344 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16345 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16346 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16350 static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16351 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16352 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16353 { } /* end */
16356 static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16357 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16358 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16359 { } /* end */
16362 static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16364 unsigned int present;
16365 unsigned char bits;
16367 present = snd_hda_codec_read(codec, 0x14, 0,
16368 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16369 bits = present ? HDA_AMP_MUTE : 0;
16370 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16371 HDA_AMP_MUTE, bits);
16374 static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16376 unsigned int present;
16377 unsigned char bits;
16379 present = snd_hda_codec_read(codec, 0x1b, 0,
16380 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16381 bits = present ? HDA_AMP_MUTE : 0;
16382 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16383 HDA_AMP_MUTE, bits);
16384 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16385 HDA_AMP_MUTE, bits);
16388 static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16389 unsigned int res)
16391 if ((res >> 26) == ALC880_HP_EVENT)
16392 alc662_lenovo_101e_all_automute(codec);
16393 if ((res >> 26) == ALC880_FRONT_EVENT)
16394 alc662_lenovo_101e_ispeaker_automute(codec);
16397 /* unsolicited event for HP jack sensing */
16398 static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16399 unsigned int res)
16401 if ((res >> 26) == ALC880_MIC_EVENT)
16402 alc_mic_automute(codec);
16403 else
16404 alc262_hippo_unsol_event(codec, res);
16407 static void alc662_eeepc_setup(struct hda_codec *codec)
16409 struct alc_spec *spec = codec->spec;
16411 alc262_hippo1_setup(codec);
16412 spec->ext_mic.pin = 0x18;
16413 spec->ext_mic.mux_idx = 0;
16414 spec->int_mic.pin = 0x19;
16415 spec->int_mic.mux_idx = 1;
16416 spec->auto_mic = 1;
16419 static void alc662_eeepc_inithook(struct hda_codec *codec)
16421 alc262_hippo_automute(codec);
16422 alc_mic_automute(codec);
16425 static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
16427 struct alc_spec *spec = codec->spec;
16429 spec->autocfg.hp_pins[0] = 0x14;
16430 spec->autocfg.speaker_pins[0] = 0x1b;
16433 #define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16435 static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16437 unsigned int present;
16438 unsigned char bits;
16440 present = snd_hda_codec_read(codec, 0x21, 0,
16441 AC_VERB_GET_PIN_SENSE, 0)
16442 & AC_PINSENSE_PRESENCE;
16443 bits = present ? HDA_AMP_MUTE : 0;
16444 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16445 AMP_IN_MUTE(0), bits);
16446 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16447 AMP_IN_MUTE(0), bits);
16450 static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16452 unsigned int present;
16453 unsigned char bits;
16455 present = snd_hda_codec_read(codec, 0x21, 0,
16456 AC_VERB_GET_PIN_SENSE, 0)
16457 & AC_PINSENSE_PRESENCE;
16458 bits = present ? HDA_AMP_MUTE : 0;
16459 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16460 AMP_IN_MUTE(0), bits);
16461 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16462 AMP_IN_MUTE(0), bits);
16463 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16464 AMP_IN_MUTE(0), bits);
16465 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16466 AMP_IN_MUTE(0), bits);
16469 static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16471 unsigned int present;
16472 unsigned char bits;
16474 present = snd_hda_codec_read(codec, 0x15, 0,
16475 AC_VERB_GET_PIN_SENSE, 0)
16476 & AC_PINSENSE_PRESENCE;
16477 bits = present ? HDA_AMP_MUTE : 0;
16478 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16479 AMP_IN_MUTE(0), bits);
16480 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16481 AMP_IN_MUTE(0), bits);
16482 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16483 AMP_IN_MUTE(0), bits);
16484 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16485 AMP_IN_MUTE(0), bits);
16488 static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16490 unsigned int present;
16491 unsigned char bits;
16493 present = snd_hda_codec_read(codec, 0x1b, 0,
16494 AC_VERB_GET_PIN_SENSE, 0)
16495 & AC_PINSENSE_PRESENCE;
16496 bits = present ? 0 : PIN_OUT;
16497 snd_hda_codec_write(codec, 0x14, 0,
16498 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16501 static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16503 unsigned int present1, present2;
16505 present1 = snd_hda_codec_read(codec, 0x21, 0,
16506 AC_VERB_GET_PIN_SENSE, 0)
16507 & AC_PINSENSE_PRESENCE;
16508 present2 = snd_hda_codec_read(codec, 0x15, 0,
16509 AC_VERB_GET_PIN_SENSE, 0)
16510 & AC_PINSENSE_PRESENCE;
16512 if (present1 || present2) {
16513 snd_hda_codec_write_cache(codec, 0x14, 0,
16514 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16515 } else {
16516 snd_hda_codec_write_cache(codec, 0x14, 0,
16517 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16521 static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16523 unsigned int present1, present2;
16525 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16526 AC_VERB_GET_PIN_SENSE, 0)
16527 & AC_PINSENSE_PRESENCE;
16528 present2 = snd_hda_codec_read(codec, 0x15, 0,
16529 AC_VERB_GET_PIN_SENSE, 0)
16530 & AC_PINSENSE_PRESENCE;
16532 if (present1 || present2) {
16533 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16534 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16535 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16536 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16537 } else {
16538 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16539 AMP_IN_MUTE(0), 0);
16540 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16541 AMP_IN_MUTE(0), 0);
16545 static void alc663_m51va_unsol_event(struct hda_codec *codec,
16546 unsigned int res)
16548 switch (res >> 26) {
16549 case ALC880_HP_EVENT:
16550 alc663_m51va_speaker_automute(codec);
16551 break;
16552 case ALC880_MIC_EVENT:
16553 alc_mic_automute(codec);
16554 break;
16558 static void alc663_m51va_setup(struct hda_codec *codec)
16560 struct alc_spec *spec = codec->spec;
16561 spec->ext_mic.pin = 0x18;
16562 spec->ext_mic.mux_idx = 0;
16563 spec->int_mic.pin = 0x12;
16564 spec->int_mic.mux_idx = 1;
16565 spec->auto_mic = 1;
16568 static void alc663_m51va_inithook(struct hda_codec *codec)
16570 alc663_m51va_speaker_automute(codec);
16571 alc_mic_automute(codec);
16574 /* ***************** Mode1 ******************************/
16575 #define alc663_mode1_unsol_event alc663_m51va_unsol_event
16576 #define alc663_mode1_setup alc663_m51va_setup
16577 #define alc663_mode1_inithook alc663_m51va_inithook
16579 /* ***************** Mode2 ******************************/
16580 static void alc662_mode2_unsol_event(struct hda_codec *codec,
16581 unsigned int res)
16583 switch (res >> 26) {
16584 case ALC880_HP_EVENT:
16585 alc662_f5z_speaker_automute(codec);
16586 break;
16587 case ALC880_MIC_EVENT:
16588 alc_mic_automute(codec);
16589 break;
16593 #define alc662_mode2_setup alc663_m51va_setup
16595 static void alc662_mode2_inithook(struct hda_codec *codec)
16597 alc662_f5z_speaker_automute(codec);
16598 alc_mic_automute(codec);
16600 /* ***************** Mode3 ******************************/
16601 static void alc663_mode3_unsol_event(struct hda_codec *codec,
16602 unsigned int res)
16604 switch (res >> 26) {
16605 case ALC880_HP_EVENT:
16606 alc663_two_hp_m1_speaker_automute(codec);
16607 break;
16608 case ALC880_MIC_EVENT:
16609 alc_mic_automute(codec);
16610 break;
16614 #define alc663_mode3_setup alc663_m51va_setup
16616 static void alc663_mode3_inithook(struct hda_codec *codec)
16618 alc663_two_hp_m1_speaker_automute(codec);
16619 alc_mic_automute(codec);
16621 /* ***************** Mode4 ******************************/
16622 static void alc663_mode4_unsol_event(struct hda_codec *codec,
16623 unsigned int res)
16625 switch (res >> 26) {
16626 case ALC880_HP_EVENT:
16627 alc663_21jd_two_speaker_automute(codec);
16628 break;
16629 case ALC880_MIC_EVENT:
16630 alc_mic_automute(codec);
16631 break;
16635 #define alc663_mode4_setup alc663_m51va_setup
16637 static void alc663_mode4_inithook(struct hda_codec *codec)
16639 alc663_21jd_two_speaker_automute(codec);
16640 alc_mic_automute(codec);
16642 /* ***************** Mode5 ******************************/
16643 static void alc663_mode5_unsol_event(struct hda_codec *codec,
16644 unsigned int res)
16646 switch (res >> 26) {
16647 case ALC880_HP_EVENT:
16648 alc663_15jd_two_speaker_automute(codec);
16649 break;
16650 case ALC880_MIC_EVENT:
16651 alc_mic_automute(codec);
16652 break;
16656 #define alc663_mode5_setup alc663_m51va_setup
16658 static void alc663_mode5_inithook(struct hda_codec *codec)
16660 alc663_15jd_two_speaker_automute(codec);
16661 alc_mic_automute(codec);
16663 /* ***************** Mode6 ******************************/
16664 static void alc663_mode6_unsol_event(struct hda_codec *codec,
16665 unsigned int res)
16667 switch (res >> 26) {
16668 case ALC880_HP_EVENT:
16669 alc663_two_hp_m2_speaker_automute(codec);
16670 break;
16671 case ALC880_MIC_EVENT:
16672 alc_mic_automute(codec);
16673 break;
16677 #define alc663_mode6_setup alc663_m51va_setup
16679 static void alc663_mode6_inithook(struct hda_codec *codec)
16681 alc663_two_hp_m2_speaker_automute(codec);
16682 alc_mic_automute(codec);
16685 static void alc663_g71v_hp_automute(struct hda_codec *codec)
16687 unsigned int present;
16688 unsigned char bits;
16690 present = snd_hda_codec_read(codec, 0x21, 0,
16691 AC_VERB_GET_PIN_SENSE, 0)
16692 & AC_PINSENSE_PRESENCE;
16693 bits = present ? HDA_AMP_MUTE : 0;
16694 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16695 HDA_AMP_MUTE, bits);
16696 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16697 HDA_AMP_MUTE, bits);
16700 static void alc663_g71v_front_automute(struct hda_codec *codec)
16702 unsigned int present;
16703 unsigned char bits;
16705 present = snd_hda_codec_read(codec, 0x15, 0,
16706 AC_VERB_GET_PIN_SENSE, 0)
16707 & AC_PINSENSE_PRESENCE;
16708 bits = present ? HDA_AMP_MUTE : 0;
16709 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16710 HDA_AMP_MUTE, bits);
16713 static void alc663_g71v_unsol_event(struct hda_codec *codec,
16714 unsigned int res)
16716 switch (res >> 26) {
16717 case ALC880_HP_EVENT:
16718 alc663_g71v_hp_automute(codec);
16719 break;
16720 case ALC880_FRONT_EVENT:
16721 alc663_g71v_front_automute(codec);
16722 break;
16723 case ALC880_MIC_EVENT:
16724 alc_mic_automute(codec);
16725 break;
16729 #define alc663_g71v_setup alc663_m51va_setup
16731 static void alc663_g71v_inithook(struct hda_codec *codec)
16733 alc663_g71v_front_automute(codec);
16734 alc663_g71v_hp_automute(codec);
16735 alc_mic_automute(codec);
16738 static void alc663_g50v_unsol_event(struct hda_codec *codec,
16739 unsigned int res)
16741 switch (res >> 26) {
16742 case ALC880_HP_EVENT:
16743 alc663_m51va_speaker_automute(codec);
16744 break;
16745 case ALC880_MIC_EVENT:
16746 alc_mic_automute(codec);
16747 break;
16751 #define alc663_g50v_setup alc663_m51va_setup
16753 static void alc663_g50v_inithook(struct hda_codec *codec)
16755 alc663_m51va_speaker_automute(codec);
16756 alc_mic_automute(codec);
16759 static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16760 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16761 ALC262_HIPPO_MASTER_SWITCH,
16763 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16764 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16765 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16767 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16768 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16769 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16770 { } /* end */
16773 static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16774 /* Master Playback automatically created from Speaker and Headphone */
16775 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16776 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16777 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16778 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16780 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16781 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16782 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16784 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16785 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16786 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16787 { } /* end */
16790 #ifdef CONFIG_SND_HDA_POWER_SAVE
16791 #define alc662_loopbacks alc880_loopbacks
16792 #endif
16795 /* pcm configuration: identical with ALC880 */
16796 #define alc662_pcm_analog_playback alc880_pcm_analog_playback
16797 #define alc662_pcm_analog_capture alc880_pcm_analog_capture
16798 #define alc662_pcm_digital_playback alc880_pcm_digital_playback
16799 #define alc662_pcm_digital_capture alc880_pcm_digital_capture
16802 * configuration and preset
16804 static const char *alc662_models[ALC662_MODEL_LAST] = {
16805 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16806 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16807 [ALC662_3ST_6ch] = "3stack-6ch",
16808 [ALC662_5ST_DIG] = "6stack-dig",
16809 [ALC662_LENOVO_101E] = "lenovo-101e",
16810 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
16811 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
16812 [ALC662_ECS] = "ecs",
16813 [ALC663_ASUS_M51VA] = "m51va",
16814 [ALC663_ASUS_G71V] = "g71v",
16815 [ALC663_ASUS_H13] = "h13",
16816 [ALC663_ASUS_G50V] = "g50v",
16817 [ALC663_ASUS_MODE1] = "asus-mode1",
16818 [ALC662_ASUS_MODE2] = "asus-mode2",
16819 [ALC663_ASUS_MODE3] = "asus-mode3",
16820 [ALC663_ASUS_MODE4] = "asus-mode4",
16821 [ALC663_ASUS_MODE5] = "asus-mode5",
16822 [ALC663_ASUS_MODE6] = "asus-mode6",
16823 [ALC272_DELL] = "dell",
16824 [ALC272_DELL_ZM1] = "dell-zm1",
16825 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
16826 [ALC662_AUTO] = "auto",
16829 static struct snd_pci_quirk alc662_cfg_tbl[] = {
16830 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16831 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16832 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
16833 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16834 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16835 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16836 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16837 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16838 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16839 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16840 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16841 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16842 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16843 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16844 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16845 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16846 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16847 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
16848 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16849 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16850 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16851 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16852 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
16853 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16854 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16855 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
16856 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16857 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16858 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16859 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16860 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16861 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
16862 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16863 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16864 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16865 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
16866 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16867 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16868 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
16869 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
16870 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
16871 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16872 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16873 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16874 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
16875 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16876 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16877 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
16878 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
16879 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
16880 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
16881 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16882 ALC662_3ST_6ch_DIG),
16883 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB200", ALC663_ASUS_MODE4),
16884 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
16885 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16886 ALC662_3ST_6ch_DIG),
16887 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
16888 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
16889 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
16890 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
16891 ALC662_3ST_6ch_DIG),
16892 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16893 ALC663_ASUS_H13),
16897 static struct alc_config_preset alc662_presets[] = {
16898 [ALC662_3ST_2ch_DIG] = {
16899 .mixers = { alc662_3ST_2ch_mixer },
16900 .init_verbs = { alc662_init_verbs },
16901 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16902 .dac_nids = alc662_dac_nids,
16903 .dig_out_nid = ALC662_DIGOUT_NID,
16904 .dig_in_nid = ALC662_DIGIN_NID,
16905 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16906 .channel_mode = alc662_3ST_2ch_modes,
16907 .input_mux = &alc662_capture_source,
16909 [ALC662_3ST_6ch_DIG] = {
16910 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
16911 .init_verbs = { alc662_init_verbs },
16912 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16913 .dac_nids = alc662_dac_nids,
16914 .dig_out_nid = ALC662_DIGOUT_NID,
16915 .dig_in_nid = ALC662_DIGIN_NID,
16916 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16917 .channel_mode = alc662_3ST_6ch_modes,
16918 .need_dac_fix = 1,
16919 .input_mux = &alc662_capture_source,
16921 [ALC662_3ST_6ch] = {
16922 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
16923 .init_verbs = { alc662_init_verbs },
16924 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16925 .dac_nids = alc662_dac_nids,
16926 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16927 .channel_mode = alc662_3ST_6ch_modes,
16928 .need_dac_fix = 1,
16929 .input_mux = &alc662_capture_source,
16931 [ALC662_5ST_DIG] = {
16932 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
16933 .init_verbs = { alc662_init_verbs },
16934 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16935 .dac_nids = alc662_dac_nids,
16936 .dig_out_nid = ALC662_DIGOUT_NID,
16937 .dig_in_nid = ALC662_DIGIN_NID,
16938 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16939 .channel_mode = alc662_5stack_modes,
16940 .input_mux = &alc662_capture_source,
16942 [ALC662_LENOVO_101E] = {
16943 .mixers = { alc662_lenovo_101e_mixer },
16944 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16945 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16946 .dac_nids = alc662_dac_nids,
16947 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16948 .channel_mode = alc662_3ST_2ch_modes,
16949 .input_mux = &alc662_lenovo_101e_capture_source,
16950 .unsol_event = alc662_lenovo_101e_unsol_event,
16951 .init_hook = alc662_lenovo_101e_all_automute,
16953 [ALC662_ASUS_EEEPC_P701] = {
16954 .mixers = { alc662_eeepc_p701_mixer },
16955 .init_verbs = { alc662_init_verbs,
16956 alc662_eeepc_sue_init_verbs },
16957 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16958 .dac_nids = alc662_dac_nids,
16959 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16960 .channel_mode = alc662_3ST_2ch_modes,
16961 .unsol_event = alc662_eeepc_unsol_event,
16962 .setup = alc662_eeepc_setup,
16963 .init_hook = alc662_eeepc_inithook,
16965 [ALC662_ASUS_EEEPC_EP20] = {
16966 .mixers = { alc662_eeepc_ep20_mixer,
16967 alc662_chmode_mixer },
16968 .init_verbs = { alc662_init_verbs,
16969 alc662_eeepc_ep20_sue_init_verbs },
16970 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16971 .dac_nids = alc662_dac_nids,
16972 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16973 .channel_mode = alc662_3ST_6ch_modes,
16974 .input_mux = &alc662_lenovo_101e_capture_source,
16975 .unsol_event = alc662_eeepc_unsol_event,
16976 .setup = alc662_eeepc_ep20_setup,
16977 .init_hook = alc662_eeepc_ep20_inithook,
16979 [ALC662_ECS] = {
16980 .mixers = { alc662_ecs_mixer },
16981 .init_verbs = { alc662_init_verbs,
16982 alc662_ecs_init_verbs },
16983 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16984 .dac_nids = alc662_dac_nids,
16985 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16986 .channel_mode = alc662_3ST_2ch_modes,
16987 .unsol_event = alc662_eeepc_unsol_event,
16988 .setup = alc662_eeepc_setup,
16989 .init_hook = alc662_eeepc_inithook,
16991 [ALC663_ASUS_M51VA] = {
16992 .mixers = { alc663_m51va_mixer },
16993 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16994 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16995 .dac_nids = alc662_dac_nids,
16996 .dig_out_nid = ALC662_DIGOUT_NID,
16997 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16998 .channel_mode = alc662_3ST_2ch_modes,
16999 .unsol_event = alc663_m51va_unsol_event,
17000 .setup = alc663_m51va_setup,
17001 .init_hook = alc663_m51va_inithook,
17003 [ALC663_ASUS_G71V] = {
17004 .mixers = { alc663_g71v_mixer },
17005 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17006 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17007 .dac_nids = alc662_dac_nids,
17008 .dig_out_nid = ALC662_DIGOUT_NID,
17009 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17010 .channel_mode = alc662_3ST_2ch_modes,
17011 .unsol_event = alc663_g71v_unsol_event,
17012 .setup = alc663_g71v_setup,
17013 .init_hook = alc663_g71v_inithook,
17015 [ALC663_ASUS_H13] = {
17016 .mixers = { alc663_m51va_mixer },
17017 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17018 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17019 .dac_nids = alc662_dac_nids,
17020 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17021 .channel_mode = alc662_3ST_2ch_modes,
17022 .unsol_event = alc663_m51va_unsol_event,
17023 .init_hook = alc663_m51va_inithook,
17025 [ALC663_ASUS_G50V] = {
17026 .mixers = { alc663_g50v_mixer },
17027 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17028 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17029 .dac_nids = alc662_dac_nids,
17030 .dig_out_nid = ALC662_DIGOUT_NID,
17031 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17032 .channel_mode = alc662_3ST_6ch_modes,
17033 .input_mux = &alc663_capture_source,
17034 .unsol_event = alc663_g50v_unsol_event,
17035 .setup = alc663_g50v_setup,
17036 .init_hook = alc663_g50v_inithook,
17038 [ALC663_ASUS_MODE1] = {
17039 .mixers = { alc663_m51va_mixer },
17040 .cap_mixer = alc662_auto_capture_mixer,
17041 .init_verbs = { alc662_init_verbs,
17042 alc663_21jd_amic_init_verbs },
17043 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17044 .hp_nid = 0x03,
17045 .dac_nids = alc662_dac_nids,
17046 .dig_out_nid = ALC662_DIGOUT_NID,
17047 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17048 .channel_mode = alc662_3ST_2ch_modes,
17049 .unsol_event = alc663_mode1_unsol_event,
17050 .setup = alc663_mode1_setup,
17051 .init_hook = alc663_mode1_inithook,
17053 [ALC662_ASUS_MODE2] = {
17054 .mixers = { alc662_1bjd_mixer },
17055 .cap_mixer = alc662_auto_capture_mixer,
17056 .init_verbs = { alc662_init_verbs,
17057 alc662_1bjd_amic_init_verbs },
17058 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17059 .dac_nids = alc662_dac_nids,
17060 .dig_out_nid = ALC662_DIGOUT_NID,
17061 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17062 .channel_mode = alc662_3ST_2ch_modes,
17063 .unsol_event = alc662_mode2_unsol_event,
17064 .setup = alc662_mode2_setup,
17065 .init_hook = alc662_mode2_inithook,
17067 [ALC663_ASUS_MODE3] = {
17068 .mixers = { alc663_two_hp_m1_mixer },
17069 .cap_mixer = alc662_auto_capture_mixer,
17070 .init_verbs = { alc662_init_verbs,
17071 alc663_two_hp_amic_m1_init_verbs },
17072 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17073 .hp_nid = 0x03,
17074 .dac_nids = alc662_dac_nids,
17075 .dig_out_nid = ALC662_DIGOUT_NID,
17076 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17077 .channel_mode = alc662_3ST_2ch_modes,
17078 .unsol_event = alc663_mode3_unsol_event,
17079 .setup = alc663_mode3_setup,
17080 .init_hook = alc663_mode3_inithook,
17082 [ALC663_ASUS_MODE4] = {
17083 .mixers = { alc663_asus_21jd_clfe_mixer },
17084 .cap_mixer = alc662_auto_capture_mixer,
17085 .init_verbs = { alc662_init_verbs,
17086 alc663_21jd_amic_init_verbs},
17087 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17088 .hp_nid = 0x03,
17089 .dac_nids = alc662_dac_nids,
17090 .dig_out_nid = ALC662_DIGOUT_NID,
17091 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17092 .channel_mode = alc662_3ST_2ch_modes,
17093 .unsol_event = alc663_mode4_unsol_event,
17094 .setup = alc663_mode4_setup,
17095 .init_hook = alc663_mode4_inithook,
17097 [ALC663_ASUS_MODE5] = {
17098 .mixers = { alc663_asus_15jd_clfe_mixer },
17099 .cap_mixer = alc662_auto_capture_mixer,
17100 .init_verbs = { alc662_init_verbs,
17101 alc663_15jd_amic_init_verbs },
17102 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17103 .hp_nid = 0x03,
17104 .dac_nids = alc662_dac_nids,
17105 .dig_out_nid = ALC662_DIGOUT_NID,
17106 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17107 .channel_mode = alc662_3ST_2ch_modes,
17108 .unsol_event = alc663_mode5_unsol_event,
17109 .setup = alc663_mode5_setup,
17110 .init_hook = alc663_mode5_inithook,
17112 [ALC663_ASUS_MODE6] = {
17113 .mixers = { alc663_two_hp_m2_mixer },
17114 .cap_mixer = alc662_auto_capture_mixer,
17115 .init_verbs = { alc662_init_verbs,
17116 alc663_two_hp_amic_m2_init_verbs },
17117 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17118 .hp_nid = 0x03,
17119 .dac_nids = alc662_dac_nids,
17120 .dig_out_nid = ALC662_DIGOUT_NID,
17121 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17122 .channel_mode = alc662_3ST_2ch_modes,
17123 .unsol_event = alc663_mode6_unsol_event,
17124 .setup = alc663_mode6_setup,
17125 .init_hook = alc663_mode6_inithook,
17127 [ALC272_DELL] = {
17128 .mixers = { alc663_m51va_mixer },
17129 .cap_mixer = alc272_auto_capture_mixer,
17130 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17131 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17132 .dac_nids = alc662_dac_nids,
17133 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17134 .adc_nids = alc272_adc_nids,
17135 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17136 .capsrc_nids = alc272_capsrc_nids,
17137 .channel_mode = alc662_3ST_2ch_modes,
17138 .unsol_event = alc663_m51va_unsol_event,
17139 .setup = alc663_m51va_setup,
17140 .init_hook = alc663_m51va_inithook,
17142 [ALC272_DELL_ZM1] = {
17143 .mixers = { alc663_m51va_mixer },
17144 .cap_mixer = alc662_auto_capture_mixer,
17145 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17146 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17147 .dac_nids = alc662_dac_nids,
17148 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17149 .adc_nids = alc662_adc_nids,
17150 .num_adc_nids = 1,
17151 .capsrc_nids = alc662_capsrc_nids,
17152 .channel_mode = alc662_3ST_2ch_modes,
17153 .unsol_event = alc663_m51va_unsol_event,
17154 .setup = alc663_m51va_setup,
17155 .init_hook = alc663_m51va_inithook,
17157 [ALC272_SAMSUNG_NC10] = {
17158 .mixers = { alc272_nc10_mixer },
17159 .init_verbs = { alc662_init_verbs,
17160 alc663_21jd_amic_init_verbs },
17161 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17162 .dac_nids = alc272_dac_nids,
17163 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17164 .channel_mode = alc662_3ST_2ch_modes,
17165 /*.input_mux = &alc272_nc10_capture_source,*/
17166 .unsol_event = alc663_mode4_unsol_event,
17167 .setup = alc663_mode4_setup,
17168 .init_hook = alc663_mode4_inithook,
17174 * BIOS auto configuration
17177 /* convert from MIX nid to DAC */
17178 static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17180 if (nid == 0x0f)
17181 return 0x02;
17182 else if (nid >= 0x0c && nid <= 0x0e)
17183 return nid - 0x0c + 0x02;
17184 else
17185 return 0;
17188 /* get MIX nid connected to the given pin targeted to DAC */
17189 static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17190 hda_nid_t dac)
17192 hda_nid_t mix[4];
17193 int i, num;
17195 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17196 for (i = 0; i < num; i++) {
17197 if (alc662_mix_to_dac(mix[i]) == dac)
17198 return mix[i];
17200 return 0;
17203 /* look for an empty DAC slot */
17204 static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
17206 struct alc_spec *spec = codec->spec;
17207 hda_nid_t srcs[5];
17208 int i, j, num;
17210 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
17211 if (num < 0)
17212 return 0;
17213 for (i = 0; i < num; i++) {
17214 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
17215 if (!nid)
17216 continue;
17217 for (j = 0; j < spec->multiout.num_dacs; j++)
17218 if (spec->multiout.dac_nids[j] == nid)
17219 break;
17220 if (j >= spec->multiout.num_dacs)
17221 return nid;
17223 return 0;
17226 /* fill in the dac_nids table from the parsed pin configuration */
17227 static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
17228 const struct auto_pin_cfg *cfg)
17230 struct alc_spec *spec = codec->spec;
17231 int i;
17232 hda_nid_t dac;
17234 spec->multiout.dac_nids = spec->private_dac_nids;
17235 for (i = 0; i < cfg->line_outs; i++) {
17236 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
17237 if (!dac)
17238 continue;
17239 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
17241 return 0;
17244 static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
17245 hda_nid_t nid, unsigned int chs)
17247 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
17248 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
17251 static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
17252 hda_nid_t nid, unsigned int chs)
17254 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
17255 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
17258 #define alc662_add_stereo_vol(spec, pfx, nid) \
17259 alc662_add_vol_ctl(spec, pfx, nid, 3)
17260 #define alc662_add_stereo_sw(spec, pfx, nid) \
17261 alc662_add_sw_ctl(spec, pfx, nid, 3)
17263 /* add playback controls from the parsed DAC table */
17264 static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
17265 const struct auto_pin_cfg *cfg)
17267 struct alc_spec *spec = codec->spec;
17268 static const char *chname[4] = {
17269 "Front", "Surround", NULL /*CLFE*/, "Side"
17271 hda_nid_t nid, mix;
17272 int i, err;
17274 for (i = 0; i < cfg->line_outs; i++) {
17275 nid = spec->multiout.dac_nids[i];
17276 if (!nid)
17277 continue;
17278 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
17279 if (!mix)
17280 continue;
17281 if (i == 2) {
17282 /* Center/LFE */
17283 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
17284 if (err < 0)
17285 return err;
17286 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
17287 if (err < 0)
17288 return err;
17289 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
17290 if (err < 0)
17291 return err;
17292 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
17293 if (err < 0)
17294 return err;
17295 } else {
17296 const char *pfx;
17297 if (cfg->line_outs == 1 &&
17298 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17299 if (cfg->hp_outs)
17300 pfx = "Speaker";
17301 else
17302 pfx = "PCM";
17303 } else
17304 pfx = chname[i];
17305 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17306 if (err < 0)
17307 return err;
17308 if (cfg->line_outs == 1 &&
17309 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17310 pfx = "Speaker";
17311 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17312 if (err < 0)
17313 return err;
17316 return 0;
17319 /* add playback controls for speaker and HP outputs */
17320 /* return DAC nid if any new DAC is assigned */
17321 static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
17322 const char *pfx)
17324 struct alc_spec *spec = codec->spec;
17325 hda_nid_t nid, mix;
17326 int err;
17328 if (!pin)
17329 return 0;
17330 nid = alc662_look_for_dac(codec, pin);
17331 if (!nid) {
17332 /* the corresponding DAC is already occupied */
17333 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
17334 return 0; /* no way */
17335 /* create a switch only */
17336 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
17337 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17340 mix = alc662_dac_to_mix(codec, pin, nid);
17341 if (!mix)
17342 return 0;
17343 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
17344 if (err < 0)
17345 return err;
17346 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
17347 if (err < 0)
17348 return err;
17349 return nid;
17352 /* create playback/capture controls for input pins */
17353 #define alc662_auto_create_input_ctls \
17354 alc880_auto_create_input_ctls
17356 static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17357 hda_nid_t nid, int pin_type,
17358 hda_nid_t dac)
17360 int i, num;
17361 hda_nid_t srcs[4];
17363 alc_set_pin_output(codec, nid, pin_type);
17364 /* need the manual connection? */
17365 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
17366 if (num <= 1)
17367 return;
17368 for (i = 0; i < num; i++) {
17369 if (alc662_mix_to_dac(srcs[i]) != dac)
17370 continue;
17371 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
17372 return;
17376 static void alc662_auto_init_multi_out(struct hda_codec *codec)
17378 struct alc_spec *spec = codec->spec;
17379 int pin_type = get_pin_type(spec->autocfg.line_out_type);
17380 int i;
17382 for (i = 0; i <= HDA_SIDE; i++) {
17383 hda_nid_t nid = spec->autocfg.line_out_pins[i];
17384 if (nid)
17385 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
17386 spec->multiout.dac_nids[i]);
17390 static void alc662_auto_init_hp_out(struct hda_codec *codec)
17392 struct alc_spec *spec = codec->spec;
17393 hda_nid_t pin;
17395 pin = spec->autocfg.hp_pins[0];
17396 if (pin)
17397 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
17398 spec->multiout.hp_nid);
17399 pin = spec->autocfg.speaker_pins[0];
17400 if (pin)
17401 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
17402 spec->multiout.extra_out_nid[0]);
17405 #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17407 static void alc662_auto_init_analog_input(struct hda_codec *codec)
17409 struct alc_spec *spec = codec->spec;
17410 int i;
17412 for (i = 0; i < AUTO_PIN_LAST; i++) {
17413 hda_nid_t nid = spec->autocfg.input_pins[i];
17414 if (alc_is_input_pin(codec, nid)) {
17415 alc_set_input_pin(codec, nid, i);
17416 if (nid != ALC662_PIN_CD_NID &&
17417 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
17418 snd_hda_codec_write(codec, nid, 0,
17419 AC_VERB_SET_AMP_GAIN_MUTE,
17420 AMP_OUT_MUTE);
17425 #define alc662_auto_init_input_src alc882_auto_init_input_src
17427 static int alc662_parse_auto_config(struct hda_codec *codec)
17429 struct alc_spec *spec = codec->spec;
17430 int err;
17431 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17433 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17434 alc662_ignore);
17435 if (err < 0)
17436 return err;
17437 if (!spec->autocfg.line_outs)
17438 return 0; /* can't find valid BIOS pin config */
17440 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
17441 if (err < 0)
17442 return err;
17443 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
17444 if (err < 0)
17445 return err;
17446 err = alc662_auto_create_extra_out(codec,
17447 spec->autocfg.speaker_pins[0],
17448 "Speaker");
17449 if (err < 0)
17450 return err;
17451 if (err)
17452 spec->multiout.extra_out_nid[0] = err;
17453 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
17454 "Headphone");
17455 if (err < 0)
17456 return err;
17457 if (err)
17458 spec->multiout.hp_nid = err;
17459 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
17460 if (err < 0)
17461 return err;
17463 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17465 if (spec->autocfg.dig_outs)
17466 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17468 if (spec->kctls.list)
17469 add_mixer(spec, spec->kctls.list);
17471 spec->num_mux_defs = 1;
17472 spec->input_mux = &spec->private_imux[0];
17474 add_verb(spec, alc662_auto_init_verbs);
17475 if (codec->vendor_id == 0x10ec0663)
17476 add_verb(spec, alc663_auto_init_verbs);
17478 err = alc_auto_add_mic_boost(codec);
17479 if (err < 0)
17480 return err;
17482 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17484 return 1;
17487 /* additional initialization for auto-configuration model */
17488 static void alc662_auto_init(struct hda_codec *codec)
17490 struct alc_spec *spec = codec->spec;
17491 alc662_auto_init_multi_out(codec);
17492 alc662_auto_init_hp_out(codec);
17493 alc662_auto_init_analog_input(codec);
17494 alc662_auto_init_input_src(codec);
17495 if (spec->unsol_event)
17496 alc_inithook(codec);
17499 static int patch_alc662(struct hda_codec *codec)
17501 struct alc_spec *spec;
17502 int err, board_config;
17504 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17505 if (!spec)
17506 return -ENOMEM;
17508 codec->spec = spec;
17510 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17512 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17513 alc662_models,
17514 alc662_cfg_tbl);
17515 if (board_config < 0) {
17516 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17517 codec->chip_name);
17518 board_config = ALC662_AUTO;
17521 if (board_config == ALC662_AUTO) {
17522 /* automatic parse from the BIOS config */
17523 err = alc662_parse_auto_config(codec);
17524 if (err < 0) {
17525 alc_free(codec);
17526 return err;
17527 } else if (!err) {
17528 printk(KERN_INFO
17529 "hda_codec: Cannot set up configuration "
17530 "from BIOS. Using base mode...\n");
17531 board_config = ALC662_3ST_2ch_DIG;
17535 err = snd_hda_attach_beep_device(codec, 0x1);
17536 if (err < 0) {
17537 alc_free(codec);
17538 return err;
17541 if (board_config != ALC662_AUTO)
17542 setup_preset(codec, &alc662_presets[board_config]);
17544 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17545 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17547 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17548 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17550 if (!spec->adc_nids) {
17551 spec->adc_nids = alc662_adc_nids;
17552 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17554 if (!spec->capsrc_nids)
17555 spec->capsrc_nids = alc662_capsrc_nids;
17557 if (!spec->cap_mixer)
17558 set_capture_mixer(codec);
17559 if (codec->vendor_id == 0x10ec0662)
17560 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17561 else
17562 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
17564 spec->vmaster_nid = 0x02;
17566 codec->patch_ops = alc_patch_ops;
17567 if (board_config == ALC662_AUTO)
17568 spec->init_hook = alc662_auto_init;
17569 #ifdef CONFIG_SND_HDA_POWER_SAVE
17570 if (!spec->loopback.amplist)
17571 spec->loopback.amplist = alc662_loopbacks;
17572 #endif
17573 codec->proc_widget_hook = print_realtek_coef;
17575 return 0;
17579 * patch entries
17581 static struct hda_codec_preset snd_hda_preset_realtek[] = {
17582 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
17583 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
17584 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
17585 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
17586 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
17587 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
17588 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
17589 .patch = patch_alc861 },
17590 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17591 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17592 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
17593 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
17594 .patch = patch_alc882 },
17595 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17596 .patch = patch_alc662 },
17597 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
17598 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
17599 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
17600 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
17601 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
17602 .patch = patch_alc882 },
17603 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
17604 .patch = patch_alc882 },
17605 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
17606 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
17607 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
17608 .patch = patch_alc882 },
17609 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17610 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
17611 {} /* terminator */
17614 MODULE_ALIAS("snd-hda-codec-id:10ec*");
17616 MODULE_LICENSE("GPL");
17617 MODULE_DESCRIPTION("Realtek HD-audio codec");
17619 static struct hda_codec_preset_list realtek_list = {
17620 .preset = snd_hda_preset_realtek,
17621 .owner = THIS_MODULE,
17624 static int __init patch_realtek_init(void)
17626 return snd_hda_add_codec_preset(&realtek_list);
17629 static void __exit patch_realtek_exit(void)
17631 snd_hda_delete_codec_preset(&realtek_list);
17634 module_init(patch_realtek_init)
17635 module_exit(patch_realtek_exit)